Branch - and - Bound - Knapsack

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 25

Branch and Bound

Hello friends, Mita and I


are here again to Yes, we sure do. Some people say that
introduce to you a tutorial we beavers are nature's engineers.
on branch and bound.
But Amit, this branch and bound refers
to something else, namely a clever way
How does it differs from
of enumerating all solutions of an
backtracking?
integer program, to solve it more
efficiently.

Mita
Amit 1
I still don't really understand how to use the Branch and
Bound algorithm. Ella, How would I use Branch and
Bound in order to solve the problem of what are the best Of course I can
items to pick to maximize my utility? help.
Ella BRANCH-and-BOUND is a method in which E-node
remains E-node until it is dead.
Applied for optimization problem
A state space tree for all possible solutions are
generated
Partitioning or branching on a particular node based
on the previously available best solution

x1 = 0 x1 = 1

x2 = 0 x2 = 1 x2 = 0 x2 = 1
If we are able to write Tom, you are right that the method of
down all possible solutions complete enumeration would work. But
in the enumeration tree, as the problems get bigger, complete
then why don't we enumeration would take too long
compute the objective for because the number of possible solutions
each solution, and simply explodes exponentially!
pick the best one? This is a
method so simple that
even a cartoon turkey
could think of it!

A pizza restaurant has several toppings to choose from


Pepperoni Time
Chilli peppers complexity
Pineapple.
Customers may choose any combination of toppings or
none at all for their pizza. Now consider an algorithm that
finds every possible unique combination of toppings
The enumeration tree The trick is to use the LP relaxation to
explodes exponentially? bound the optimal integer solutions
That sounds rather in a subtree of the enumeration tree,
dangerous. What should we which allows us to eliminate many (in
do to prevent this some cases even 99.999999999%) of the
dangerous explosion? enumeration tree.
Systematic enumeration of all candidate
solutions, discarding large subsets of
fruitless candidates by using upper and
lower estimated bounds of quantity
being optimized

It's too late for my dinosaur friends,


99.9999999% of us have been eliminated.
Sigh.
It is much slower.
Indeed, it often leads to exponential time complexities in
the worst case.
The general idea of B&B is a BFS-like search for the optimal
solution, but not all nodes get expanded (i.e., their children
generated). Rather, a carefully selected criterion determines
which node to expand and when, and another criterion tells
the algorithm when an optimal solution has been found.

Branch and Bound could be done in


three ways:
FIFO SEARCH
LIFO SEARCH
LC SEARCH (LEAST-COUNT SEARCH)
A Greedy approach is to pick the items in decreasing order of
value per unit weight.
The Greedy approach works only for fractional knapsack problem
and may not produce correct result for 0/1 knapsack.
use Dynamic Programming (DP) for 0/1 Knapsack problem.
In DP, we use a 2D table of size n x W.
The DP Solution doesn’t work if item weights are not
integers.
Since DP solution doesn’t alway work, a solution is to use Brute
Force.
With n items, there are 2n solutions to be generated, check each
to see if they satisfy the constraint, save maximum solution that
satisfies constraint. This solution can be expressed as tree.
Knapsack problem using branch and bound

I found backtracking works better


than the brute force by ignoring
feasible solutions.
It is better (than backtracking) if we
know a bound on best possible
solution subtree rooted with every
node.
If the best in subtree is worse than
current best, we can simply ignore
this node and its subtrees. So we
compute bound (best solution) for
every node and compare the bound
with current best solution before
exploring the node.
n
maximize PX
i i
i1
n
subject to WiXiM Xi =0or 1, i =1, …, n.
i
1
Theproblemismodified:
n
minimize  PX
i i
i
1
Control Abstraction for Branch and
Bound(LC Method)
LC Method Control Abstraction Explanation

 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
LC Method Control Abstraction Explanation

 The algorithm uses two subalgorithms LEAST(X) and


ADD(X) to respectively delete and add a live node from or
to the list of live nodes.
 LEAST{X) finds a live node with least c( ). This node
is deleted from the list of live nodes and returned in
variable X.
 ADD(X) adds the new live node X to the list of live
nodes.
 Procedure LC outputs the path from the answer node it
finds to the root node T.
How to find the upper bound?

by quickly finding a feasible solution:


starting from the smallest available i, scanning towards the
largest i’s until M is exceeded.
The upper bound can be calculated.
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
i1 n

knapsack problem   Pi be an optimal


i1
and fractional knapsack
solution for Xi problem. Let
n n
Y=   Pi Xi , Y’ =   Pi
i1
 Y’  Y Xi .
i1
How to expand the tree?
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
Shall we solve the 0/1
knapsack problem
And we’re done! Yahoo! Google! Bing!
Thank you Ella.

You’re most welcome


Essential Branch and Bound
Maximization converted to minimization by changing sign of
objective function
Formulate the search for an optimal solution as a search for a
least-cost answer node in a state space search tree

A branch-and-bound method searches a state


space tree using any search mechanism in
which all children of the E-node are generated
before another node becomes the E-node
Each answer node x has a cost c(x) and we
have to find a minimum-cost answer node
Common strategies include LC, FIFO, and LIFO
Although branch and bound looks difficult at first but while solving it
found to be easier.
Disadvantages of Branch & Bound algorithm:
Extremely time-consuming: the number of nodes in a branching tree
can be too large.
The algorithm finds the first complete schedule and then tries to
improve it.
Often developing the “promising” branches may lead to a huge number
of offsprings that finally may not give an improvement.
Thus the size of the tree may grow exponentially without improving
the best solution obtained.
That’s all for branch
and bound. Bye!

15
MIT OpenCourseWare
http://ocw.mit.edu

15.053 Optimization Methods in Management Science


Spring 2013

For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.

You might also like