knapsack problem

Can anyone explain how the writer rewrite the objective function in (7) to be written as (8)?

  • 1
    $\begingroup$ I deleted my "answer" (which was supposed to be a comment to Rob Pratt's answer). Please accept his answer rather than mine. $\endgroup$
    – prubin
    Feb 17 at 17:29

1 Answer 1


Just consider the two cases:

  • If $z_i=0$, the LHS and RHS are both $0$.
  • If $z_i=1$, the LHS and RHS are both $p_i$.

Explicit calculations for the RHS: \begin{align} \theta_i \left(1 - \left(\frac{\theta_i-p_i}{\theta_i}\right)^0 \right) &= \theta_i \left(1 - 1\right) = 0 \\ \theta_i \left(1 - \left(\frac{\theta_i-p_i}{\theta_i}\right)^1 \right) &= \theta_i \left(1 - 1 + \frac{p_i}{\theta_i}\right) = \theta_i \cdot \frac{p_i}{\theta_i} = p_i \end{align}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.