Sei sulla pagina 1di 34

Branch and Bound

Definitions:
Branch and Bound is a state space search method in which

all the children of a node are generated before expanding any of its children.
Live-node: A node that has not been expanded. It is similar to backtracking technique but uses BF !like

search.

"i4e 5ode: ,6 -6 .6 and /

FIF( Branch 7 Bound $BF % #hildren of '!node are inserted in a queue.

"IF( Branch 7 Bound $D! earch% #hildren of '!node are inserted in a stack.

Dead!node: A node that has been expanded olution!node "#! earch $"east #ost earch%: &he selection rule for the next '!node in FIF( or "IF( branch!and!bound is sometimes )blind*. i.e. the selection

rule does not gi4e any preference to a node that has a 4ery good chance of getting the search to an answer node quickly. &he search for an answer node can often be speeded by using an )intelligent* ranking function6 also called an approximate cost function

# #
8

'xpanded!node $'!node%: is the li4e node with the best 4alue 9equirements

Branching: A set of solutions6 which is represented by a

node6 can be partitioned into mutually exclusi4e sets. 'ach subset in the partition is represented by a child of the original node.
"ower bounding: An algorithm is a4ailable for calculating

a lower bound on the cost of any solution in a gi4en subset. earching: "east!cost search $"#%
#ost and approximation

'ach node6 :6 in the search tree is associated with a cost: #$:%

#$:% ; cost of reaching the current node6 : $'! node%6 from the root + the cost of reaching an answer node from :. #$:% ; g$:% < h$:% =et an approximation of #$x%6

# #
8

# $x% such that

$x% #$x%6 and $x% ; #$x% if x is a solution!node.

&he approximation part of

# $x% is

h$x%;the cost of reaching a solution!node from :6 not known.


"east!cost search:

&he next '!node is the one with least

'xample: 2!pu>>le
#ost function:

; g$x% <h$x%

where h$x% ; the number of misplaced tiles and g$x% ; the number of mo4es so far

Assumption: mo4e one tile in any direction cost +.

Initial State
12356784

inal State
12358674

12356784

8 # =++ . = /
12356478

8 # =++ , = 12356784

8 # =++ . = /
12563784

8 # = , ++= 12358674

8 #= ,+-=/
12356784 13526784

8 #= ,+-=/

8 #=-+ ,=/
12358674 12358674

8 #=-+ ?=-

5ote: In case of tie6 choose the leftmost node.

Algorithm: @A li4eBnodeBset: set to hold the li4e nodes at any time A@ @A lowcost: 4ariable to hold the cost of the best cost at any gi4en node A@ Begin "owcost ; C Dhile li4eBnodeBset do ! choose a branching node6 k6 such that k li4eBnodeBsetC @A k is a '!node A@ - li4eBnodeBset; li4eBnodeBset ! EkFC - =enerate the children of node k and the corresponding lower boundsC k;E$i6>i%: i is child of k and >i its lower boundF - For each element $i6>i% in k do - If >i G H - then - Iill child iC @A i is a child node A@ - 'lse If child i is a solution &hen H ;>iC current best ; child iC 'lse Add child i to li4eBnodeBsetC 'ndifC 'ndifC ! 'ndforC 'ndwhileC

&ra4elling alesman Jroblem: ! "ranc# and "ound al$orit#m


Definition: Find a tour of minimum cost starting from a

node going through other nodes only once and returning to the starting point .
Definitions:

A row$column% is said to be reduced iff it contains at least one >ero and all remaining entries are non! negati4e. A matrix is reduced iff e4ery row and column is reduced.
"ranc#in$:

'ach node splits the remaining solutions into two groups: those that include a particular edge and those that exclude that edge 'ach node has a lower bound. 'xample: =i4en a graph =;$K6'%6 let Li6MG '6
" !ll Solutions

"+ Solutions %it# &i'()

", Solutions %it#out &i'()

"oundin$: Now to compute the cost of each nodeO

ubtract of a constant from any row and any column does not change the optimal solution $&he path%. &he cost of the path changes but not the path itself. "et A be the cost matrix of a =;$K6'%. &he cost of each node in the search tree is computed as follows: "et 9 be a node in the tree and A$9% its reduced matrix &he cost of the child $9%6 : et row i and column M to infinity et A$M6+% to infinity 9educed and let 9#" be the reduced cost. #$ % ; #$9% < 9#"<A$i6M% =et the reduced matrix AP of A and let " be the 4alue subtracted from A. ": represents the lower bound of the path solution &he cost of the path is exactly reduced by ".

Dhat to determine the branching edgeO

&he rule fa4ors a solution through left subtree rather than right subtree6 i.e.6 the matrix is reduced by a dimension.

5ote that the right subtree only sets the branching edge to infinity. Jick the edge that causes the greatest increase in the lower bound of the right subtree6 i.e.6 the lower bound of the root of the right subtree is greater.

'xample: o &he reduced cost matrix is done as follows: - #hange all entries of row i and column M to infinity et A$M6+% to infinity $assuming the start node is +%

- 9educe all rows first and then column of the resulting matrix

=i4en the following cost matrix:

tate pace &ree:


+ ,/ Kertex ; . . ,/ Kertex ; / / -+

Kertex ; , Kertex ; , -/ /-

Kertex ; , 0 Kertex ; 3 /, ,2 Kertex ; / +?

Kertex ; 1 /?

Kertex ; / 2 -0

,2 Kertex ; -

++

,2

&he & J starts from node +: *ode 1 o 9educed Qatrix: &o get the lower bound of the path starting at node + 9ow R +: reduce by +?

9ow R,: reduce ,

9ow R-: reduce by ,

9ow R .: 9educe by -:

9ow R .: 9educe by .

#olumn +: 9educe by +

#olumn ,: It is reduced. #olumn -: 9educe by -

#olumn .: It is reduced. #olumn /: It is reduced. &he reduced cost is: 9#" ; ,/ o the cost of node + is: #ost$+% ; ,/ &he reduced matrix is: cost+1, ; ,/

#hoose to go to 4ertex ,: *ode 2 - #ost of edge L+6,G is: A$+6,% ; +? et row R+ ; inf since we are choosing edge L+6,G et column R , ; inf since we are choosing edge L+6,G et A$,6+% ; inf

- &he resulting cost matrix is:

- &he matrix is reduced: o 9#" ; ? - &he cost of node , $#onsidering 4ertex , from 4ertex +% is: -ost+2, . cost+1, + !+1'2, . 25 + 1/ . 35

#hoose to go to 4ertex -: *ode 3 - #ost of edge L+6-G is: A$+6-% ; +1 $In the reduced matrix et row R+ ; inf since we are starting from node + et column R - ; inf since we are choosing edge L+6-G et A$-6+% ; inf

- &he resulting cost matrix is:

9educe the matrix: o 9ows are reduced o &he columns are reduced except for column R +: 9educe column + by ++:

&he lower bound is: o 9#" ; ++ &he cost of going through node - is: o cost$-% ; cost$+% < 9#" < A$+6-% ; ,/ < ++ < +1 ; /-

#hoose to go to 4ertex .: *ode 4 o 9emember that the cost matrix is the one that was reduced at the starting 4ertex + o #ost of edge L+6.G is: A$+6.% ; ? o et row R+ ; inf since we are starting from node + o et column R . ; inf since we are choosing edge L+6.G o et A$.6+% ; inf o &he resulting cost matrix is:

o 9educe the matrix: 9ows are reduced #olumns are reduced o &he lower bound is: 9#" ; ? o &he cost of going through node . is:

cost$.% ; cost$+% < 9#" < A$+6.% ; ,/ < ? < ? ; ,/

#hoose to go to 4ertex /: *ode 5 o 9emember that the cost matrix is the one that was reduced at starting 4ertex + o #ost of edge L+6/G is: A$+6/% ; + o et row R+ ; inf since we are starting from node + o et column R / ; inf since we are choosing edge L+6/G o et A$/6+% ; inf o &he resulting cost matrix is:

o 9educe the matrix: 9educe rows: 9educe row R,: 9educe by ,

9educe row R.: 9educe by -

#olumns are reduced o &he lower bound is: 9#" ; , < - ; / o &he cost of going through node / is: cost$/% ; cost$+% < 9#" < A$+6/% ; ,/ < / < + ; -+

In summary: o o the li4e nodes we ha4e so far are: ,: cost$,% ; -/6 path: +!G, -: cost$-% ; /-6 path: +!G .: cost$.% ; ,/6 path: +!G. /: cost$/% ; -+6 path: +!G/ o 'xplore the node with the lowest cost: 5ode . has a cost of ,/ o Kertices to be explored from node .: ,6 -6 and / o 5ow we are starting from the cost matrix at node . is: #ost$.% ; ,/

#hoose to go to 4ertex ,: *ode 6 $path is +!G.!G,% o #ost of edge L.6,G is: A$.6,% ; o et row R. ; inf since we are considering edge L.6,G o et column R , ; inf since we are considering edge L.6,G o et A$,6+% ; inf o &he resulting cost matrix is:

o 9educe the matrix: 9ows are reduced #olumns are reduced o &he lower bound is: 9#" ; ? o &he cost of going through node , is: cost$0% ; cost$.% < 9#" < A$.6,% ; ,/ < ? < - ; ,2

#hoose to go to 4ertex -: *ode 7 $ path is +!G.!G- % o #ost of edge L.6-G is: A$.6-% ; +, o et row R. ; inf since we are considering edge L.6-G o et column R - ; inf since we are considering edge L.6-G o et A$-6+% ; inf o &he resulting cost matrix is:

o 9educe the matrix: 9educe row R-: by ,:

9educe column R +: by ++

o &he lower bound is: 9#" ; +o o the 9#" of node 1 $#onsidering 4ertex - from 4ertex .% is: #ost$1% ; cost$.% < 9#" < A$.6-% ; ,/ < +< +, ; /? #hoose to go to 4ertex /: *ode 8 $ path is +!G.!G/ % o #ost of edge L.6/G is: A$.6/% ; ? o et row R. ; inf since we are considering edge L.6/G o et column R / ; inf since we are considering edge L.6/G o et A$/6+% ; inf o &he resulting cost matrix is:

o 9educe the matrix: 9educed row ,: by ++

#olumns are reduced o &he lower bound is: 9#" ; ++ o o the cost of node 2 $#onsidering 4ertex / from 4ertex .% is: #ost$2% ; cost$.% < 9#" < A$.6/% ; ,/ < ++ < ? ; -0

In summary: o o the li4e nodes we ha4e so far are: ,: cost$,% ; -/6 path: +!G, -: cost$-% ; /-6 path: +!G /: cost$/% ; -+6 path: +!G/ 0: cost$0% ; ,26 path: +!G.!G, 1: cost$1% ; /?6 path: +!G.!G 2: cost$2% ; -06 path: +!G.!G/ o 'xplore the node with the lowest cost: 5ode 0 has a cost of ,2 o Kertices to be explored from node 0: - and / o 5ow we are starting from the cost matrix at node 0 is: #ost$0% ; ,2

#hoose to go to 4ertex -: *ode 0 $ path is +!G.!G,! G- % o #ost of edge L,6-G is: A$,6-% ; ++ o et row R, ; inf since we are considering edge L,6-G o et column R - ; inf since we are considering edge L,6-G o et A$-6+% ; inf o &he resulting cost matrix is:

o 9educe the matrix: 9educe row R-: by ,

9educe column R +: by ++

o &he lower bound is: 9#" ; , <++ ; +o o the cost of node 3 $#onsidering 4ertex - from 4ertex ,% is: #ost$3% ; cost$0% < 9#" < A$,6-% ; ,2 < +< ++ ; /, #hoose to go to 4ertex /: *ode 1/ $ path is +!G.!G,! G/ % o #ost of edge L,6/G is: A$,6/% ; ?

o et row R, ; inf since we are considering edge L,6-G o et column R - ; inf since we are considering edge L,6-G o et A$/6+% ; inf o &he resulting cost matrix is:

o 9educe the matrix: 9ows reduced #olumns reduced o &he lower bound is: 9#" ; ? o o the cost of node +? $#onsidering 4ertex / from 4ertex ,% is: #ost$+?% ; cost$0% < 9#" < A$,6-% ; ,2 < ? < ? ; ,2

In summary: o o the li4e nodes we ha4e so far are: ,: cost$,% ; -/6 path: +!G, -: cost$-% ; /-6 path: +!G /: cost$/% ; -+6 path: +!G/ 1: cost$1% ; /?6 path: +!G.!G 2: cost$2% ; -06 path: +!G.!G/ 3: cost$3% ; /,6 path: +!G.!G,!G +?: cost$,% ; ,26 path: +!G.!G,!G/ o 'xplore the node with the lowest cost: 5ode +? has a cost of ,2 o Kertices to be explored from node +?: o 5ow we are starting from the cost matrix at node +? is:

#hoose to go to 4ertex -: *ode 11 $ path is +!G.!G,! G/!G- % o #ost of edge L/6-G is: A$/6-% ; ? o et row R/ ; inf since we are considering edge L/6-G o et column R - ; inf since we are considering edge L/6-G o et A$-6+% ; inf o &he resulting cost matrix is:

o 9educe the matrix: 9ows reduced #olumns reduced o &he lower bound is: 9#" ; ? o o the cost of node ++ $#onsidering 4ertex / from 4ertex -% is:

#ost$++% ; cost$+?% < 9#" < A$/6-% ; ,2 < ? < ? ; ,2


S

Potrebbero piacerti anche