0
$\begingroup$

In the standard Knapsack problem, the objective is to maximize $\sum c_i x_i$. I encounter a variant where the objective is to minimize $\sum c_i a^{x_i}$ where $a\in(0,1)$ is a constant. I am looking for an algorithm (possibly DP-based) with pseudo-polynomial time complexity to solve this problem. My question is whether this is feasible.

$\endgroup$
4
  • $\begingroup$ Is $x_i$ a nonnegative integer variable or a binary variable? $\endgroup$ Commented Dec 27, 2024 at 17:17
  • $\begingroup$ Which ones are variables, which ones are givens, and what are the constraints? $\endgroup$ Commented Dec 27, 2024 at 20:07
  • $\begingroup$ $x_i$ is a nonnegative integer. $\endgroup$ Commented Dec 28, 2024 at 10:14
  • $\begingroup$ $x_i$ are variables. $c_i$ are given constants. Constraints are standard Knapsack constraints: $\sum a_ix_i\le A$ where $a_i$ and $A$ are constants. $\endgroup$ Commented Dec 28, 2024 at 10:16

1 Answer 1

0
$\begingroup$

You want to minimize $\sum_{i=1}^n c_i a^{x_i}$ subject to $\sum_{i=1}^n a_i x_i \le A$ and $x_i \in \mathbb{Z}^+$.

Define value function $$v(k,B) = \min\left\{\sum_{i=1}^k c_i a^{x_i}: \sum_{i=1}^k a_i x_i \le B \land x_i \in \mathbb{Z}^+\right\}$$ so that the original problem is to calculate $v(n,A)$. The usual dynamic programming approach conditions on the value $y$ of $x_k$ to obtain recursion $$v(k,B) = \min_{y\in \{0,\dots,\lfloor B/a_k \rfloor\}} \left\{c_k a^y + v(k-1,B-a_k y) \right\}.$$


Alternatively, you can linearize the problem by introducing binary decision variables $z_{ij}$ to indicate whether $x_i=j$. The problem is then to minimize the linear objective function $$\sum_{i=1}^n c_i \sum_{j=0}^{\lfloor B/a_i \rfloor} a^j z_{ij}$$ subject to linear constraints \begin{align} \sum_{i=1}^n a_i x_i &\le A \\ \sum_{j=0}^{\lfloor B/a_i \rfloor} j z_{ij} &= x_i &&\text{for $i\in\{1,\dots,n\}$} \\ \sum_{j=0}^{\lfloor B/a_i \rfloor} z_{ij} &= 1 &&\text{for $i\in\{1,\dots,n\}$} \end{align} Now call an integer linear programming solver.

$\endgroup$
1
  • $\begingroup$ Thank you very much for your insightful solution. $\endgroup$ Commented Dec 30, 2024 at 1:45

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.