Discrete optimization of weighted sum under constraint

86 Views Asked by At

Let $\lambda_1, \dots, \lambda_n \geq 0$, $\;\;c_1, \dots, c_n \in \mathbb{R}$ and $\;\;\gamma >0 $.

We are looking for the maximum of function $f$ with $$ f(x) = x_1\lambda_1 + \dots + x_n\lambda_n $$

where $x_i \in \{-1,1\}$ for $1 \leq i \leq n$

under the constraint

$$ x_1c_1 + \dots + x_nc_n \geq \gamma $$

For our problem approximately $n=50$.

Is there an efficient algorithm as trying out all $2^n$ possibilities is not feasible?

EDIT 2015-04-12

I corrected the constraint. Before correction they were

$$ x_1\lambda_1c_1 + \dots + x_n\lambda_nc_n \geq \gamma $$

1

There are 1 best solutions below

0
On

In short, your problem is \begin{align} \max ~&~ \lambda_1 x_1 + \ldots + \lambda_n x_n \\ \mathrm{s.t.} ~&~ c_1 x_1 + \ldots + c_n x_n \geq \gamma \\ &~ x_i \in \{-1, 1\} \end{align} Let $y_i = \frac{x_i + 1}{2}$. Then you can rewrite the problem as \begin{align} \max ~&~ 2 \left(\lambda_1 y_1 + \ldots + \lambda_n y_n\right) - (\lambda_1 + \ldots+ \lambda_n) \\ \mathrm{s.t.} ~&~ (-2 c_1) y_1 + \ldots + (-2 c_n) y_n \leq -(c_1 + \ldots c_n) - \gamma \\ &~ y_i \in \{0, 1\} \end{align} Note that $\lambda_1 + \ldots + \lambda_n$ in the objective function does not depend on the values of the $y_i$. Thus, this formulation is equivalent to \begin{align} \max ~&~ v_1 y_1 + \ldots + v_n y_n \\ \mathrm{s.t.} ~&~ w_1 y_1 + \ldots + w_n y_n \leq W \\ &~ y_i \in \{0, 1\} \end{align} if we set $v_i = 2 \lambda_i$, $w_i = -2 c_i$ and $W = -(c_1 + \ldots + c_n) - \gamma$. This is an ordinary knapsack problem.

Thus, you will (probably) not be able to find an algorithm which solves all instances exactly in polynomial time. However, there are a lot of solution techniques for the knapsack problem which provide optimal solution in reasonable time for most real life instances (see the link to Wikipedia posted by Maarten Hilferink).