Professional Documents
Culture Documents
0/1 Knapsack: Branch and Bound
0/1 Knapsack: Branch and Bound
0/1 Knapsack: Branch and Bound
We have already seen two graph search strategies, BFS and D-search, in
which the exploration of a new node cannot begin until the node currently
being explored is fully explored.
A D-search•like state space search will be called LIFO (Last In First Out)
search as the list of live nodes is a last-in-first-out list (or stack).
The search for an answer node can often be
speeded by using an "intelligent" ranking
function, c(. ), for live nodes.
The next £-node is selected on the basis of
this ranking function.
Let T be a state space tree and c( ) a cost
function for the nodes in T. If X is a node in T then
c(X) is the minimum cost of any answer node in
the subtree with root X. Thus, c(T) is the cost of a
minimum cost answer node
0/1 knapsack problem using
Branch and Bound
The 0/1 knapsack problem
Positive integer P1, P2, …, Pn (profit)
W1, W2, …, Wn (weight)
M (capacity)
n
maximize Pi X i
i1
n
Xi = 0 or 1, i =1, …, n.
subject to Wi X i M
i1
The problem is
n modified:
minimize P X
i i
i1
53
The 0/1 knapsack problem
55
How to find the ranking Function
Ans: by relaxing our restriction from Xi = 0 or 1 to
0 Xi 1 (knapsack problem)
n
be an optimal solution for 0/1
Let Pi Xi
i1 n
Pi be an optimal
knapsack problem i1
and fractional knapsack
solution for Xi problem. Let
n n
Y= Pi Xi , Y’ Pi
=
Xi .
i1
i1
YY’
By the best-first search scheme
That is, by expanding the node with the best
lower bound. If two nodes have the same lower
bounds, expand the node with the lower upper
bound.
57
Example (LCBB)
Consider the knapsack instance:
n = 4;
(pi, p2,
p3, p4) = (10, 10, 12, 18);
(wi. w2, w3, w4) = (2, 4, 6, 9) and
M = 15.