solves a 0-1 multiple knapsack problem
[earn,ind] = knapsack(profit,weight,capa,[bck])
integer row vector
integer row vector
integer row vector
integer
integer
integer row vector
The 0-1 multiple knapsack problem with n (n >= 2) items and m knapsacks (m >= 1) is defined as follow:
Maximize the global profit E=profit*sum(X,1)
under the constraints:
X*weight <= capa
sum(X,1) <= 1 ; i=1,...,n
X(j,i)= 0 or 1
Where
is the vector of the "profits" of the n items. The entries must be positive integers.
is the vector of the corresponding "weights". The entries must be positive integers.
is the vector of the (integer) capacities of the m knapsacks.The entries must be positive integers.
is a m
by n
matrix.
est une matrice m
par n
à valeurs dans {0,1}.
[earn,ind] = knapsack(profit,weight,capa)
solves
the problem. It returns in
the value of the criterium E
for
the "optimal" solution if it has been found. In case of error, earn
is assigned to a negative value:
means that a knapsack cannot contain any item.
means that an item cannot fit into any knapsack.
means that a knapsack contains all the items.
the integer vector of the knapsack number where item
i
is inserted and this value is 0 if the
item i is not in the optimal solution. The matrix
X
can be derived from
ind
by
is an optional integer: the maximum number of
backtrackings to be performed if heuristic solution is
required. If the exact solution is required
bck
must be omitted or assigned to a
negative value.
Coppersmith, D. "Knapsack Used in Factoring." §4.6 in Open Problems in Communication and Computation (Ed. T. M. Cover and B. Gopinath). New York: Springer-Verlag, pp. 117-119, 1987.
Honsberger, R. Mathematical Gems III. Washington, DC: Math. Assoc. Amer., pp. 163-166, 1985.