Top | recent changes | Preferences

The KNAPSACK problem is, given a set S={a1,a2,…,an\} of objects, with non-negative integer sizes and profits (e.g. \(size(a1)), and a capacity C, to find a subset of S maximizing profit(S) subject to the constraint that size(S)≤ C.

Here size(S) = a∈ S size(a) and profit(S) = a∈ S profit(a).

The problem is NP-complete. On the other hand, there is an algorithm that works in time polynomial in n and P, where P is the maximum item profit. It uses dynamic programming.

To see how, start with the observation that the maximum total profit is surely bounded by nP.

Define A(i,p) to be the minimum size of any subset with total profit p using just the first i items.
Then A(i,p) satisfies the following recurrence:

A(i,p) = min { A(i-1,p), size(a_i) + A(i, p - profit(a_i)) }.
Since there are n items, the number of distinct pairs (i,p) to consider is at most n2P.
Thus, the problem can be solved by dynamic programming in time polynomial in n and P.

In general, P is not bounded by a polynomial in n. Given a general instance I of the problem (where P is large), we will try to find an approximate solution.

Fix ε > 0.

We want a solution of profit at least OPT - ε OPT.

Note that the maximum obtainable profit is at least P.

Thus, it suffices to find a solution of profit at least OPT - ε P.

Consider rounding each profit profit(a) down to the nearest multiple of δ = ε P / n.

That is, profit'(a) = δ ⌊ profit(a) / δ⌋.

This decreases the profit of any item by at most δ, and so decreases the profit of any set of items by at most nδ = ε P.

Thus, the optimal solution to the modified problem will approximate the optimal solution to the original problem within 1-ε factor. (Exercise.)

Thus, it suffices to find an optimal solution to the modified problem.

In the modified problem, every profit is a multiple of δ, and the profits are between 0 and P.

If we further modify the problem by multiplying each profit by 1/δ, we get an equivalent problem where the profits are integers between 0 and P/δ = n/ε.

We can solve this problem optimally using the first algorithm we discussed. The optimal set of items for this problem gives us a solution to the original problem whose size is at most C and whose profit is within a 1-ε factor of optimal.

thm: For any ε>0, there exists a (1-ε)-approximation algorithm that runs in time polynomial in n and ε.

Note that this means we can approximate the problem to any desired degree of accuracy.

We can think of the algorithm a single algorithm that takes ε as input, or we can think of it as a family of algorithms, one for each ε, and each running in time polynomial in n (with the constant depending on ε. This is called a polynomial-time approximation scheme, or PTAS.

Because the dependence of the running time on 1/ε is polynomial, this is also called a fully polynomial-time approximation scheme, or FPTAS.


Top | recent changes | Preferences
This page is read-only | View other revisions
Last edited January 24, 2004 2:57 pm by NealYoung (diff)