Theknapsack problem is one of the most studied problems incombinatorial 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 ofn items, with each item having an associated profitpj and weightwj. The binary decision variablexj 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 exceedW. Generally, these coefficients are scaled to become integers, and they are almost always assumed to be positive.
Theknapsack problem in its most basic form:
| maximize | ||
| subject to | ||
One common variant is that each item can be chosen multiple times. Thebounded knapsack problem specifies, for each itemj, an upper bounduj (which may be a positive integer, or infinity) on the number of times itemj can be selected:
| maximize | ||
| subject to | ||
| integral for allj | ||
Theunbounded knapsack problem (sometimes called theinteger knapsack problem) does not put any upper bounds on the number of times an item may be selected:
| maximize | ||
| subject to | ||
| integral for allj | ||
The unbounded variant was shown to beNP-complete in 1975 by Lueker.[3] Both the bounded and unbounded variants admit anFPTAS (essentially the same as the one used in the 0-1 knapsack problem).
If the items are subdivided intok classes denoted, and exactly one item must be taken from each class, we get themultiple-choice knapsack problem:
| maximize | ||
| subject to | ||
| for all | ||
| for all and all | ||
If for each item the profit and weight are equal, we get thesubset sum problem (often the correspondingdecision problem is given instead):
| maximize | ||
| subject to | ||
If we haven items andm knapsacks with capacities, we get themultiple knapsack problem:
| maximize | ||
| subject to | for all | |
| for all | ||
| for all and all | ||
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 havemultiple subset sum problem.
| maximize | |||
| subject to | |||
| for all | |||
Set-Union Knapsack Problem:
SUKP is defined by Kellerer et al[2] (on page 423) as follows:
Given a set of items and a set of so-called elements, each item corresponds to a subset of the element set. The items have non-negative profits,, and the elements have non-negative weights,. 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.
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 themultiple-constrained knapsack problem,multidimensional knapsack problem, orm-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 | ||
| subject to | for all | |
| , integer | for all | |
The 0-1 variant (for any fixed) was shown to beNP-complete around 1980 and more strongly, has no FPTAS unless P=NP.[4][5]
The bounded and unbounded variants (for any fixed) also exhibit the same hardness.[6]
For any fixed, these problems do admit apseudo-polynomial time algorithm (similar to the one for basic knapsack) and aPTAS.[2]
If all the profits are 1, we will try to maximize the number of items which would not exceed the knapsack capacity:
| maximize | ||
| subject to | ||
If we have a number of containers (of the same size), and we wish to pack alln items in as few containers as possible, we get thebin packing problem, which is modelled by having indicator variables containeri is being used:
| minimize | ||
| subject to | ||
Thecutting stock problem is identical to thebin packing problem, but since practical instances usually have far fewer types of items, another formulation is often used. Itemj is neededBj times, each "pattern" of items which fit into a single knapsack have a variable,xi (there arem patterns), and patterni uses itemjbij times:
| minimize | ||
| subject to | for all | |
| for all | ||
If, to the multiple choice knapsack problem, we add the constraint that each subset is of sizen and remove the restriction on total weight, we get theassignment problem, which is also the problem of finding a maximalbipartite matching:
| maximize | ||
| subject to | for all | |
| for all | ||
| for all and all | ||
In theMaximum Density Knapsack variant there is an initial weight, and we maximize the density of selected items which do not violate the capacity constraint:[7]
| maximize | ||
| subject to | ||
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.[2]
{{cite book}}: CS1 maint: multiple names: authors list (link){{cite book}}: CS1 maint: multiple names: authors list (link)