List of knapsack problems

From HandWiki
Revision as of 21:43, 6 February 2024 by NBrush (talk | contribs) (add)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The knapsack problem is one of the most studied problems in combinatorial optimization, with many real-life applications. For this reason, many special cases and generalizations have been examined.[1][2]

Common to all versions are a set of n items, with each item [math]\displaystyle{ 1 \leq j \leq n }[/math] having an associated profit pj and weight wj. The binary decision variable xj is used to select the item. The objective is to pick some of the items, with maximal total profit, while obeying that the maximum total weight of the chosen items must not exceed W. Generally, these coefficients are scaled to become integers, and they are almost always assumed to be positive.

The knapsack problem in its most basic form:

maximize [math]\displaystyle{ \sum_{j=1}^n p_j x_j }[/math]
subject to [math]\displaystyle{ \sum_{j=1}^n w_j x_j \leq W, }[/math]
[math]\displaystyle{ x_j \in \{0,1\} }[/math] [math]\displaystyle{ \forall j \in \{1,\ldots, n\} }[/math]

Direct generalizations

One common variant is that each item can be chosen multiple times. The bounded knapsack problem specifies, for each item j, an upper bound uj (which may be a positive integer, or infinity) on the number of times item j can be selected:

maximize [math]\displaystyle{ \sum_{j=1}^n p_j x_j }[/math]
subject to [math]\displaystyle{ \sum_{j=1}^n w_j x_j \leq W, }[/math]
[math]\displaystyle{ 0 \leq x_j \leq u_j, x_j }[/math] integral for all j

The unbounded knapsack problem (sometimes called the integer knapsack problem) does not put any upper bounds on the number of times an item may be selected:

maximize [math]\displaystyle{ \sum_{j=1}^n p_j x_j }[/math]
subject to [math]\displaystyle{ \sum_{j=1}^n w_j x_j \leq W, }[/math]
[math]\displaystyle{ x_j \geq 0, x_j }[/math] integral for all j

The unbounded variant was shown to be NP-complete in 1975 by Lueker.[3] Both the bounded and unbounded variants admit an FPTAS (essentially the same as the one used in the 0-1 knapsack problem).

If the items are subdivided into k classes denoted [math]\displaystyle{ N_i }[/math], and exactly one item must be taken from each class, we get the multiple-choice knapsack problem:

maximize [math]\displaystyle{ \sum_{i=1}^k\sum_{j\in N_i} p_{ij} x_{ij} }[/math]
subject to [math]\displaystyle{ \sum_{i=1}^k\sum_{j\in N_i} w_{ij} x_{ij} \leq W, }[/math]
[math]\displaystyle{ \sum_{j \in N_i}x_{ij} = 1, }[/math] for all [math]\displaystyle{ 1 \leq i \leq k }[/math]
[math]\displaystyle{ x_{ij} \in \{0,1\} }[/math] for all [math]\displaystyle{ 1 \leq i \leq k }[/math] and all [math]\displaystyle{ j \in N_i }[/math]

If for each item the profit and weight are equal, we get the subset sum problem (often the corresponding decision problem is given instead):

maximize [math]\displaystyle{ \sum_{j=1}^n p_j x_j }[/math]
subject to [math]\displaystyle{ \sum_{j=1}^n p_j x_j \leq W, }[/math]
[math]\displaystyle{ x_j \in \{0,1\} }[/math]

If we have n items and m knapsacks with capacities [math]\displaystyle{ W_i }[/math], we get the multiple knapsack problem:

maximize [math]\displaystyle{ \sum_{i=1}^m\sum_{j=1}^n p_j x_{ij} }[/math]
subject to [math]\displaystyle{ \sum_{j=1}^n w_j x_{ij} \leq W_i, }[/math] for all [math]\displaystyle{ 1 \leq i \leq m }[/math]
[math]\displaystyle{ \sum_{i=1}^m x_{ij} \leq 1, }[/math] for all [math]\displaystyle{ 1 \leq j \leq n }[/math]
[math]\displaystyle{ x_{ij} \in \{0,1\} }[/math] for all [math]\displaystyle{ 1 \leq j \leq n }[/math] and all [math]\displaystyle{ 1 \leq i \leq m }[/math]

As a special case of the multiple knapsack problem, when the profits are equal to weights and all bins have the same capacity, we can have multiple subset sum problem.

Quadratic knapsack problem:

maximize [math]\displaystyle{ \sum_{j=1}^n p_j x_j+\sum_{i=1}^{n-1}\sum_{j=i+1}^n p_{ij} x_i x_j }[/math]
subject to [math]\displaystyle{ \sum_{j=1}^n w_j x_j \leq W, }[/math]
[math]\displaystyle{ x_j \in \{0,1\} }[/math] for all [math]\displaystyle{ 1 \leq j \leq n }[/math]

Set-Union Knapsack Problem:

SUKP is defined by Kellerer et al[2] (on page 423) as follows:

Given a set of [math]\displaystyle{ n }[/math] items [math]\displaystyle{ N = \{1, \ldots, n\} }[/math] and a set of [math]\displaystyle{ m }[/math] so-called elements [math]\displaystyle{ P = \{1, \ldots, m\} }[/math], each item [math]\displaystyle{ j }[/math] corresponds to a subset [math]\displaystyle{ P_j }[/math] of the element set [math]\displaystyle{ P }[/math]. The items [math]\displaystyle{ j }[/math] have non-negative profits [math]\displaystyle{ p_j }[/math], [math]\displaystyle{ j = 1, \ldots, n }[/math], and the elements [math]\displaystyle{ i }[/math] have non-negative weights [math]\displaystyle{ w_i }[/math], [math]\displaystyle{ i = 1, \ldots, m }[/math]. The total weight of a set of items is given by the total weight of the elements of the union of the corresponding element sets. The objective is to find a subset of the items with total weight not exceeding the knapsack capacity and maximal profit.

Multiple constraints

If there is more than one constraint (for example, both a volume limit and a weight limit, where the volume and weight of each item are not related), we get the multiple-constrained knapsack problem, multidimensional knapsack problem, or m-dimensional knapsack problem. (Note, "dimension" here does not refer to the shape of any items.) This has 0-1, bounded, and unbounded variants; the unbounded one is shown below.

maximize [math]\displaystyle{ \sum_{j=1}^n p_j x_j }[/math]
subject to [math]\displaystyle{ \sum_{j=1}^n w_{ij} x_j \leq W_i, }[/math] for all [math]\displaystyle{ 1 \leq i \leq m }[/math]
[math]\displaystyle{ x_j \geq 0 }[/math], [math]\displaystyle{ x_j }[/math] integer for all [math]\displaystyle{ 1\leq j \leq n }[/math]

The 0-1 variant (for any fixed [math]\displaystyle{ m \ge 2 }[/math]) was shown to be NP-complete around 1980 and more strongly, has no FPTAS unless P=NP.[4][5]

The bounded and unbounded variants (for any fixed [math]\displaystyle{ m \ge 2 }[/math]) also exhibit the same hardness.[6]

For any fixed [math]\displaystyle{ m \ge 2 }[/math], these problems do admit a pseudo-polynomial time algorithm (similar to the one for basic knapsack) and a PTAS.[2]

Knapsack-like problems

If all the profits are 1, we will try to maximize the number of items which would not exceed the knapsack capacity:

maximize [math]\displaystyle{ \sum_{j=1}^n x_j }[/math]
subject to [math]\displaystyle{ \sum_{j=1}^n w_j x_j \leq W, }[/math]
[math]\displaystyle{ x_j \in \{0,1\}, }[/math] [math]\displaystyle{ \forall j \in \{1,\ldots,n\} }[/math]

If we have a number of containers (of the same size), and we wish to pack all n items in as few containers as possible, we get the bin packing problem, which is modelled by having indicator variables [math]\displaystyle{ y_i=1 \Leftrightarrow }[/math] container i is being used:

minimize [math]\displaystyle{ \sum_{i=1}^n y_i }[/math]
subject to [math]\displaystyle{ \sum_{j=1}^n w_j x_{ij} \leq Wy_i, }[/math] [math]\displaystyle{ \forall i \in \{1,\ldots,n\} }[/math]
[math]\displaystyle{ \sum_{i=1}^n x_{ij} = 1 }[/math] [math]\displaystyle{ \forall j \in \{1,\ldots,n\} }[/math]
[math]\displaystyle{ y_i \in \{0,1\} }[/math] [math]\displaystyle{ \forall i \in \{1,\ldots,n\} }[/math]
[math]\displaystyle{ x_{ij} \in \{0,1\} }[/math] [math]\displaystyle{ \forall i \in \{1,\ldots,n\} \wedge \forall j \in \{1,\ldots,n\} }[/math]

The cutting stock problem is identical to the bin packing problem, but since practical instances usually have far fewer types of items, another formulation is often used. Item j is needed Bj times, each "pattern" of items which fit into a single knapsack have a variable, xi (there are m patterns), and pattern i uses item j bij times:

minimize [math]\displaystyle{ \sum_{i=1}^m x_i }[/math]
subject to [math]\displaystyle{ \sum_{i=1}^m b_{ij} x_i \geq B_j, }[/math] for all [math]\displaystyle{ 1 \leq j \leq n }[/math]
[math]\displaystyle{ x_i \in \{0,1,\ldots ,n\} }[/math] for all [math]\displaystyle{ 1\leq i \leq m }[/math]

If, to the multiple choice knapsack problem, we add the constraint that each subset is of size n and remove the restriction on total weight, we get the assignment problem, which is also the problem of finding a maximal bipartite matching:

maximize [math]\displaystyle{ \sum_{i=1}^k\sum_{j=1}^n p_{ij} x_{ij} }[/math]
subject to [math]\displaystyle{ \sum_{i=1}^n x_{ij} = 1, }[/math] for all [math]\displaystyle{ 1 \leq j \leq n }[/math]
[math]\displaystyle{ \sum_{j=1}^n x_{ij} = 1, }[/math] for all [math]\displaystyle{ 1 \leq i \leq n }[/math]
[math]\displaystyle{ x_{ij} \in \{0,1\} }[/math] for all [math]\displaystyle{ 1 \leq i \leq k }[/math] and all [math]\displaystyle{ j \in N_i }[/math]

In the Maximum Density Knapsack variant there is an initial weight [math]\displaystyle{ w_0 }[/math], and we maximize the density of selected items which do not violate the capacity constraint: [7]

maximize [math]\displaystyle{ \frac{\sum_{j=1}^n x_j p_j}{w_0 +\sum_{j=1}^n x_j w_j} }[/math]
subject to [math]\displaystyle{ \sum_{j=1}^n w_j x_j \leq W, }[/math]
[math]\displaystyle{ x_j \in \{0,1\}, }[/math] [math]\displaystyle{ \forall j \in \{1,\ldots,n\} }[/math]

Although less common than those above, several other knapsack-like problems exist, including:

  • Nested knapsack problem
  • Collapsing knapsack problem
  • Nonlinear knapsack problem
  • Inverse-parametric knapsack problem

The last three of these are discussed in Kellerer et al's reference work, Knapsack Problems.[2]

References

  1. Martello, Silvano and Toth, Paolo (1990). Knapsack Problems: Algorithms and Computer Implementations. John Wiley & Sons. ISBN 978-0471924203. http://www.or.deis.unibo.it/knapsack.html. 
  2. 2.0 2.1 2.2 2.3 Kellerer, Hans and Pferschy, Ulrich and Pisinger, David (2004). Knapsack Problems. Springer Verlag. ISBN 978-3-540-40286-2. 
  3. Lueker, G.S. (1975). Two NP-complete problems in nonnegative integer programming. Report No. 178, Computer Science Laboratory, Princeton. 
  4. Gens, G. V.; Levner, E. V. (1979). "Complexity and Approximation Algorithms for Combinatorial Problems: A Survey". Central Economic and Mathematical Institute, Academy of Sciences of the USSR, Moscow. 
  5. "On the Existence of Fast Approximation Schemes". Nonlinear Programming 4: 415–437. 1980. 
  6. Magazine, Michael J.; Chern, Maw-Sheng (1984). "A Note on Approximation Schemes for Multidimensional Knapsack Problems". Mathematics of Operations Research 9 (2): 244–247. doi:10.1287/moor.9.2.244. 
  7. Cohen, Reuven; Katzir, Liran (2008). "The Generalized Maximum Coverage Problem". Information Processing Letters 108: 15–22. doi:10.1016/j.ipl.2008.03.017.