Branch Bound 6

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Branch & Bound Technique

 BFS and D-search strategies are used to explore the nodes

 DFS is used in backtracking.

 BFS strategy is called FIFO branch & bound and D-search is a LIFO branch &
bound.

 FIFO branch & bound uses a queue and LIFO uses a stack.

 Solution can be expressed as a n-tuple (x1, x2, …, xn).

 Like backtrack there is a use of bounding function to check a criteria for branching.
Let us see how a FIFO branch-and-bound algorithm would search the state space tree for
the 4-queens problem.
X1=1

X1=1 4
2 3

X2=2 4
3
X1=1

2 3

Oiuy8

Fig. 1: Portion of 4-queens state space tree generated by FIFO branch & bound.
Note 1: Numbers outside the node give the order in which the nodes are generated by FIFO
branch-and-bound.

Fig. 2: Portion of the generated during backtrack


Note 2: At the time the answer node, node 31, is reached the only live nodes remaining are
nodes 38 and 54.
The 15-puzzle problem:

 Invented by Sam Loyd in 1878

 It consists of 15 numbered tiles on a square frame with a capacity of 16 tiles.

 We are given an initial arrangement of the tiles.

 The objective is to transform this arrangement into the goal arrangement

Fig. 3: An initial (state) arrangement Fig. 4: The Goal (state) arrangement

Legal moves: are ones in which a tile adjacent to the empty spot (ES) is moved to ES. In
Fig. 3, four legal moves are possible.

Note: There are 16! (16! ≈ 20.9 x 10 12) different arrangements of the tiles on the frame. Of
these only one half are reachable from any given initial state.
Let POSITION(i) be the position number in the initial state of the tile numbered i and
LESS(i) be the number of tiles j such that
j < i and POSITION(j) > POSITION(i).

For examples, LESS(4) = 1 and LESS{12) = 6.

Let X = 1 if in the initial state, the empty spot is at one of the shaded positions of Fig. 5 and
X = 0 if it is at one of the remaining positions.

Fig. 5: Empty spots in shaded position


Theorem: The goal state of Figure 8.2(b) is reachable from the initial State iff
16

 LESS (i)  x
i 1
is even.
State Space Tree:
 Order of legal moves (ES rather than tiles): Up, Right, Down or Left
 No node p has a child that is same as p’s parent.

Fig. 6: Tree generation up to level 3.

Result of DFS:
Intelligent Search Method:
 Let c(X) be the length of a path from the root to a nearest goal node (if any) in the
subtree with root X.

 Thus, in Fig. 6, c(l) = c(4) = c(10) = c(23) = 3.

 This will simplify search and quickly finds the answer node.

 This is an impractical strategy as it is not possible to easily compute c( · ).


Least Cost Search:
 We can replace c(X) with c^(X) = f(X) + g(X)

 f (X): 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 of g(X) = no. of nonblank tiles not in their goal position

Begin with Node 1. All its children 2, 3, 4 and 5 are generated,


Now c^(2) = 1 + 4, c^(3) = 1 + 4, c^(4) = 1 + 2 and c^(5) = 1 + 4. So Node 4 becomes E-node.

The live nodes at this time are 2, 3, 5, 10, 11 and 12.


c^(10) = 2 + 1, c^(11) = 2 + 3, c^(12) = 2 + 3. So Node 10 becomes E-node having least cost.

Nodes 22 and 23 are next generated. Node 23 is determined to be a goal node and the search
terminates.
Alorithm:
Task 1: Consider the following sum of subsets problem: (w1, w2, w3, w4) = (11, 13, 24, 7).

Draw the state space tree (variable size) and apply the FIFO branch and bound technique to
obtain the solution. Show the generated tree during the FIFO search and Compare it to that
generated by the backtracking method and make your comment with detailed analysis.

Task 2: Verify whether the initial arrangement can be reachable to the goal arrangement
given below:

6 2
4
3

Fig. 3: An initial (state) arrangement Fig. 4: The Goal (state) arrangement


Hints Task 1:

16
Hints Task 2: Check whether  LESS (i)  x
i 1
is even or not.

You might also like