0% found this document useful (0 votes)
24 views23 pages

Branch and Bound

Uploaded by

21311a1993
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views23 pages

Branch and Bound

Uploaded by

21311a1993
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 23

Branch and Bound

( unit-v)

 Backtracking is effective for subset or permutation


problems.

 Backtracking is not good for optimization problems.

 This drawback is rectified by using Branch And Bound


technique.

 Branch And Bound is applicable for only optimization


problems.

 Branch and Bound also uses bounding function similar to


backtracking.
Terminology of tree organization

Problem state :-
Each node in the tree is a problem state.
State Space :-
All paths from the root to problem states define the state
space of the problem.
Solution States :-
These are those problem states S for which the
path from the root to S define a tuple in the
solution space.

Solution Space :-
All paths from the root to solution states define
the solution space of the problem.
– A node which has been generated and all of whose
children have not yet been generated is called a live
node.

– The live node whose children are currently being


generated is called E-node ( Expanding node ).

– A dead node is a generated node which can not to be


expanded further or all of whose children have been
generated.
Branch And Bound
Nodes will be expanded in three ways.
• FIFO branch and bound-- queue

• Least-Cost (or max priority) branch and bound)—priority


queue.
• Least-cost branch and bound directs the search
to the parts which most likely to contain the answer.
 In this case backtracking method is
superior than branch and bound method.
Least Cost ( LC) search :-
• In both FIFO and LIFO branch and bound the selection
rule for the next E-node does not give any preference to
a node that has a very good chance of getting an answer
node quickly.

• In the above example when node 22 is generated, it


should have become obvious that this node will lead to
an answer node in one move.

• However , the FIFO rule first requires the expansion of


all live nodes generated before node 22 was expanded.
• The search for an answer node can be speeded by using
^
an “intelligent “ ranking function c (.) for live nodes.

• The next E-node is selected on the basis of this ranking


function.

• If we use ranking function that assigns node 22 a better


rank than all other live nodes , then node 22 will become
the E-node following node 29.
• The ideal way to assign ranks will be on the basis of the
additional effort ( cost) needed to reach an answer node
from the live node.

For any node x, this could be


1) The number of nodes in the subtree with root x that need
to be generated before an answer node is generated.
OR more simply
2) The number of levels in the subtree with root x that need
to be generated to get an answer node.

Using cost measure 2,


 In the above fig. the cost of the root is 4 ( node 30 is four
levels from node 1) .
 The difficulty with cost functions is that computing the
cost of the node usually involves a search of the subtree
x for an answer node.

 Hence , by the time the cost of a node is determined ,


that subtree has been searched and there is no need to
explore x again. For this reason , search algorithms
usually rank nodes only on the basis of an estimated
^
cost g( . ) .
^
 Let g(x) be an estimate of the additional cost needed to
reach an answer node from x.
^
 Then , node x is assigned a rank using a function c(.) such
that

^ ^
c(.) = h(x) + g(x)

where
h(x) is the cost of reaching x from the root
Actual cost function c(.) is defined as follows:

 if x is an answer node , then c(x) is the cost of reaching


x from the root .

 if x is not an answer node , then c(x)=∞, it means that


subtree with root x contains no answer node.

 otherwise c(x) equal to the cost of a minimum cost


node in the subtree with root x.

^
 c(.) is an approximation to c(.)
 A FIFO or LIFO search always generates the state space tree by
levels.

 What we need is more “intelligent” search method .


 We can associate a cost c(x) with each node x in the state space
tree.
 The cost c(x) is the length of a path from the root to a nearest goal
node( if any ) in the subtree with root x.
Thus in the above fig c(1)=c(4)=c(10)=c(23)=3.

 When such a cost function is available, a very efficient search can


be carried out.

 In this search strategy , the only nodes to become E-nodes are


nodes on the path from the root to a nearest goal node.
 Unfortunately, this is an impractical.

^
We can only compute estimate c(x) of c(x). we can write
^ ^
c(x)=f(x) +g(x), where f(x) is the length of the path from
^
the root to node x and g(x) is an estimate of the
length of a shortest path from x to a goal node in the
subtree with root x.

^
one possible choice for g( x ) is

^
g( x ) = number of nonblank tiles not in their goal
position.
Control Abstraction of LC-Search:-
Algorithm LCSearch( t )
// search tree t for answer node
{
if *t is an answer node then output *t and return;
E=t // E-node

repeat
{
for each child x of E do
{
if x is an answer node then output the
path from x to t and return;

Add( x ); // x is a new live node


( x ->parent )=E // pointer for path to
root
}
if there are no more live nodes then
{
write(“ No answer node “);
return;
}
E=Least();
} until ( false )
}

• ( x ->parent )=E is to print answer path.


Bounding:-
 The bounding functions are used to avoid the generation of sub
trees that do not contain the answer nodes. In bounding upper and
lower bounds are generated at each node.

^
 A cost function c(.) such that ^c (x)<=c(x) is used to provide the lower
bounds on solutions obtainable from any node x.

 If upper is an upper bound on the cost of a minimum cost solution,


then all live nodes x with c^ (x) >upper can be killed.

 upper is updated whenever a child is generated.


0/1 Knapsack Problem
 Generally Branch and Bound will minimize the objective
function.

 The 0/1 knapsack problem is a maximization problem.

 This difficulty can be avoided by replacing the objective


function ∑ pixi by - ∑ pixi .
Note:
1. All live nodes with c(x) > upper can
^

be killed when they are about to become


E-nodes .

^
^
Upper number = c
LC Branch and Bound Solution
Lower number = u

EX:- n=4, ( p1,p2,p3,p4 )= (10,10,12,18 ) -38


( w1,w2,w3,w4 ) = ( 2,4,6,9 ), m=15 1 -32

^ -38 -32
Process: The calculation of U and C is as -32 2 3 -22
follows.
U(1) - Scan through the objects from left to -38
right and put into the knapsack until -32 4 5 -36
the first object that does not fit is -22
encontered.
-38
^ -32 6 7
-38
C(1) – Similar to U(1) except that it also -38
considers a fraction of the first object that
does not fit the knapsack.
-38 8 9 -20
-38 -20
Answer node k
Continue this process until an answer node is
found.
FIFO Branch and Bound
^
Upper number = c
-38
-32 Lower number = u
1

-38
-32 2 -32
3 -27
-38
-32 -36
4 5 -22 6 -32 7 -28
-27 -28
k
-38
-32 8 9
-38
-38

10 11 12 -38 13 -20
-38 -20
Answer node
Home Work :-
1. Draw the portion of the state space tree generated by
LCBB and FIFIBB for the following knapsack problem.

a) n=5, ( p1,p2,p3,p4,p5 ) = ( 10,15,6,8,4 ),


( w1,w2,w3,w4,w5 )= ( 4,6,3,4,2 ) and
m=12

b) n=5, ( p1,p2,p3,p4,p5 )=
( w1,w2,w3,w4,w5 )=
( 4,4,5,8,9 ) and m=15.

You might also like