knapsack with multiple constraints and some negative weights

859 Views Asked by At

I'm trying to solve an integer linear programming problem of the following form

$max$ $\sum_{i=1}^n v_i \cdot x_i$
$s.t. \sum_{i=1}^n w_{i1} \cdot x_i \leq 0$ and $\sum_{i=1}^n w_{i2} \cdot x_i \leq 0$

where the $x_i \in \{0,1\}$, and the $w_{ij}$ and $v_{i}$ are integers (without a sign restriction). Now my question is whether this problem is a knapsack.

I have done some research into the problem and found for example this source Algorithms for Knapsack Problems quite helpful. He seems to suggest in chapter 1.3.1 that one can merge the constraints and replace them with

$ \sum_{i=1}^{n} (w_{i1} + \lambda w_{i2}) x_{ij} \leq 0$

where $\lambda>0$ is chosen sufficiently large so that one constraint cannot "interfere" with the other. This is also nicely explained in this StackOverflow post Multiple constraint knapsack problem.

I have an extra issue however, since my weights are not constrained to be nonnegative. Normally, one would get rid of these negative weights, using the standard trick of introducing pseudo $x_i$ which are already in your knapsack and then adjusting your knapsack capacity. (For more information about this trick, see e.g. page 15 in Knapsack Problems: Algorithms and Computer Implementations.)

In my case, since I have two constraints, with the $w_{i1}$ potentially of a different sign then $w_{i2}$ I cannot apply this trick, because one of the weights will still be negative. So even though the first link that I gave seems to suggest on page 16 that "Negative coefficients in the Knapsack model are easily handled", I don't think this still holds in my situation. Am I right? Or can my problem still be reformulated?

Any help is appreciated!