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]
Common to all versions are a set of n items, with each item
1\leqj\leqn
The knapsack problem in its most basic form:
maximize
pjxj | ||||||||
subject to |
wjxj\leqW, | |||||||
xj\in\{0,1\} | \forallj\in\{1,\ldots,n\} |
__TOC__
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
pjxj | ||||||||
subject to |
wjxj\leqW, | |||||||
0\leqxj\lequj,xj |
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
pjxj | ||||||||
subject to |
wjxj\leqW, | |||||||
xj\geq0,xj |
The unbounded variant was shown to be NP-complete in 1975 by Lueker.[2] 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
Ni
maximize
pijxij | ||||||||
subject to |
wijxij\leqW, | |||||||
xij=1, | for all 1\leqi\leqk | |||||||
xij\in\{0,1\} | for all 1\leqi\leqk j\inNi |
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
pjxj | ||||||||
subject to |
pjxj\leqW, | |||||||
xj\in\{0,1\} |
If we have n items and m knapsacks with capacities
Wi
maximize
pjxij | ||||||||
subject to |
wjxij\leqWi, | for all 1\leqi\leqm | ||||||
xij\leq1, | for all 1\leqj\leqn | |||||||
xij\in\{0,1\} | for all 1\leqj\leqn 1\leqi\leqm |
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.
maximize
pjxj+\sum
pijxixj | ||||||||||||||||||||
subject to |
wjxj\leqW, | |||||||||||||||||||
xj\in\{0,1\} | for all 1\leqj\leqn |
Set-Union Knapsack Problem:
SUKP is defined by Kellerer et al[3] (on page 423) as follows:
Given a set ofitemsn
and a set ofN=\{1,\ldots,n\}
so-called elementsm
, each itemP=\{1,\ldots,m\}
corresponds to a subsetj
of the element setPj
. The itemsP
have non-negative profitsj
,pj
, and the elementsj=1,\ldots,n
have non-negative weightsi
,wi
. 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.i=1,\ldots,m
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
pjxj | ||||||||
subject to |
wijxj\leqWi, | for all 1\leqi\leqm | ||||||
xj\geq0 xj | for all 1\leqj\leqn |
The 0-1 variant (for any fixed
m\ge2
The bounded and unbounded variants (for any fixed
m\ge2
For any fixed
m\ge2
If all the profits are 1, we will try to maximize the number of items which would not exceed the knapsack capacity:
maximize
xj | ||||||||
subject to |
wjxj\leqW, | |||||||
xj\in\{0,1\}, | \forallj\in\{1,\ldots,n\} |
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
yi=1\Leftrightarrow
minimize
yi | ||||||||
subject to |
wjxij\leqWyi, | \foralli\in\{1,\ldots,n\} | ||||||
xij=1 | \forallj\in\{1,\ldots,n\} | |||||||
yi\in\{0,1\} | \foralli\in\{1,\ldots,n\} | |||||||
xij\in\{0,1\} | \foralli\in\{1,\ldots,n\}\wedge\forallj\in\{1,\ldots,n\} |
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
xi | ||||||||
subject to |
bijxi\geqBj, | for all 1\leqj\leqn | ||||||
xi\in\{0,1,\ldots,n\} | for all 1\leqi\leqm |
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
pijxij | ||||||||
subject to |
xij=1, | for all 1\leqj\leqn | ||||||
xij=1, | for all 1\leqi\leqn | |||||||
xij\in\{0,1\} | for all 1\leqi\leqk j\inNi |
In the Maximum Density Knapsack variant there is an initial weight
w0
maximize
| ||||||||||||||||||||||||||
subject to |
wjxj\leqW, | |||||||||||||||||||||||||
xj\in\{0,1\}, | \forallj\in\{1,\ldots,n\} |
Although less common than those above, several other knapsack-like problems exist, including:
The last three of these are discussed in Kellerer et al's reference work, Knapsack Problems.