Recall that in the Knapsack Problem, we have n items, each with a weight wt and a value vi. We also have a weight bound W, and the problem is to select a set of items S of highest possible value subject to the condition that the total weight does not exceed W—that is,
. Here's one way to look at the approximation algorithm that we designed in this chapter. If we are told there exists a subset O whose total weight is
and whose total value is
for some V, then our approximation algorithm can find a set A with total weight
and total value at least
. Thus the algorithm approximates the best value, while keeping the weights strictly under W. (Of course, returning the set O is always a valid solution, but since the problem is NP-hard, we don't expect to always be able to find O itself; the approximation bound of 1 + e means that other sets A, with slightly less value, can be valid answers as well.)
Now, as is well known, you can always pack a little bit more for a trip just by "sitting on your suitcase"–in other words, by slightly overflowing the allowed weight limit. This too suggests a way of formalizing the approximation question for the Knapsack Problem, but it's the following, different, formalization.
Suppose, as before, that you're given n items with weights and values, as well as parameters W and V; and you're told that there is a subset O whose total weight is
and whose total value is
for some V. For a given fixed ε> 0, design a polynomial-time algorithm that finds a subset of items A such that
In other words, you want A to achieve at least as high a total value as the given bound V, but you're allowed to exceed the weight limit W by a factor of 1 + ε.
Example. Suppose you're given four items, with weights and values as follows:
(W1, v1) = (5,3), (W2, v2) = (4,6)
(W3, v3) = (1,4), (W4, v4) = (6,11)
You're also given W = 10 and V = 13 (since, indeed, the subset consisting of the first three items has total weight at most 10 and has value 13). Finally, you're given ε = .1. This means you need to find (via your approximation algorithm) a subset of weight at most (1 + .1) * 10 = 11 and value at least 13. One valid solution would be the subset consisting of the first and fourth items, with value 14 ≥ 13. (Note that this is a case where you're able to achieve a value strictly greater than V, since you're allowed to slightly overfill the knapsack.)
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.