Ads & Aa Unit 4 Part 2
Ads & Aa Unit 4 Part 2
Introduction:
Branch and Bound refers to all state space search methods in which all children of the E-
Node are generated before any other live node becomes the E-Node.
Branch and Bound is the generalization of both graph search strategies, BFS and D-search.
A BFS like state space search is called as FIFO (First in first out) search as the list of
live nodes in a first in first out.
A D-search like state space search is called as LIFO (last in first out) search as the list of
live nodes in a last in first out list.
Live node is a node that has been generated but whose children have not yet been generated.
E-node is a live node whose children are currently being explored. In other words, an E-node is
a node currently being expanded.
Dead node is a generated anode that is not be expanded or explored any further. All children of a
dead node have already been expanded.
Here we will use 3 types of search strategies:
1. FIFO (First In First Out)
2. LIFO (Last In First Out)
3. LC (Least Cost) Search
FIFO Branch and Bound Search:
For this we will use a data structure called Queue. Initially Queue is empty.
Example:
Now we will delete an element from queue, i.e. node 2, next generate children of node 2
and place in this queue.
Page 1
UNIT-IV BRANCH AND BOUND
Next, delete an element from queue and take it as E-node, generate the children of node
3, 7, 8 are children of 3 and these live nodes are killed by bounding functions. So we will not
include in the queue.
Again delete an element an from queue. Take it as E-node, generate the children of 4.
Node 9 is generated and killed by boundary function.
Next, delete an element from queue. Generate children of nodes 5, i.e., nodes 10 and 11
are generated and by boundary function, last node in queue is 6. The child of node 6 is 12 and it
satisfies the conditions of the problem, which is the answer node, so search terminates.
LIFO Branch and Bound Search
For this we will use a data structure called stack. Initially stack is empty.
Example:
Generate children of node 1 and place these live nodes into stack.
Remove element from stack and generate the children of it, place those nodes into stack.
2 is removed from stack. The children of 2 are 5, 6. The content of stack is,
Page 2
UNIT-IV BRANCH AND BOUND
Again remove an element from stack, i.,e node 5 is removed and nodes generated by 5
are 10, 11 which are killed by bounded function, so we will not place 10, 11 into stack.
Delete an element from stack, i.,e node 6. Generate child of node 6, i.,e 12, which is the
answer node, so search process terminates.
LC (Least Cost) Branch and Bound Search
In both FIFO and LIFO Branch and Bound the selection rules for the next E-node in rigid
and blind. The selection rule for the next E-node does not give any preferences to a node that has
a very good chance of getting the search to an answer node quickly.
In this we will use ranking function or cost function. We generate the children of E-node, among
these live nodes; we select a node which has minimum cost. By using ranking function we will
calculate the cost of each node.
Initially we will take node 1 as E-node. Generate children of node 1, the children are 2, 3,
4. By using ranking function we will calculate the cost of 2, 3, 4 nodes is ĉ =2, ĉ =3, ĉ =4
respectively. Now we will select a node which has minimum cost i.,e node 2. For node 2, the
children are 5, 6. Between 5 and 6 we will select the node 6 since its cost minimum. Generate
children of node 6 i.,e 12 and 13. We will select node 12 since its cost (ĉ =1) is minimum. More
over 12 is the answer node. So, we terminate search process.
Control Abstraction for LC-search
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 sub tree with root x. Thus, c(t) is the cost of a
minimum-cost answer node in t.
LC search uses ĉ to find an answer node. The algorithm uses two functions
Page 3
UNIT-IV BRANCH AND BOUND
1. Least-cost()
2. Add_node().
Least-cost() finds a live node with least c(). This node is deleted from the list of live nodes and
returned.
Add_node() to delete and add a live node from or to the list of live nodes.
Add_node(x)adds the new live node x to the list of live nodes. The list of live nodes be
implemented as a min-heap.
BOUNDING
A branch and bound method searches a state space tree using any search mechanism in
which all the children of the E-node are generated before another node becomes the E-
node.
A good bounding helps to prune (reduce) efficiently the tree, leading to a faster
exploration of the solution space. Each time a new answer node is found, the value of
upper can be updated.
Branch and bound algorithms are used for optimization problem where we deal directly
only with minimization problems. A maximization problem is easily converted to a
minimization problem by changing the sign of the objective function.
Page 4
UNIT-IV BRANCH AND BOUND
Page 5
UNIT-IV BRANCH AND BOUND
For node 2, x1=1, means we should place first item in the knapsack.
U=10+10+12=32, make it as -32
L=10+10+12+ (3/9*18) = 32+6=38, we make it as -38
For node 3, x1=0, means we should not place first item in the knapsack.
U=10+12=22, make it as -22
L=10+12+ (5/9*18) = 10+12+10=32, we make it as -32
Next we will calculate difference of upper bound and lower bound for nodes 2, 3
For node 2, U-L=-32+38=6
For node 3, U-L=-22+32=10
Choose node 2, since it has minimum difference value of 6.
Now we will calculate lower bound and upper bound of node 4 and 5. Calculate difference of
lower and upper bound of nodes 4 and 5.
For node 4, U-L=-32+38=6
For node 5, U-L=-22+36=14
Choose node 4, since it has minimum difference value of 6
Page 6
UNIT-IV BRANCH AND BOUND
Now we will calculate lower bound and upper bound of node 6 and 7. Calculate difference of
lower and upper bound of nodes 6 and 7.
For node 6, U-L=-32+38=6
For node 7, U-L=-38+38=0
Choose node 7, since it has minimum difference value of 0.
Page 7
UNIT-IV BRANCH AND BOUND
Now we will calculate lower bound and upper bound of node 8 and 9. Calculate difference of
lower and upper bound of nodes 8 and 9.
For node 8, U-L=-38+38=0
For node 9, U-L=-20+20=0
Here, the difference is same, so compare upper bounds of nodes 8 and 9. Discard the
node, which has maximum upper bound. Choose node 8, discard node 9 since, it has maximum
upper bound.
Consider the path from 12478
X1=1
X2=1
X3=0
X4=1
The solution for 0/1 knapsack problem is ( x1, x2, x3, x4)=(1, 1, 0, 1)
Maximum profit is:
∑pixi=10*1+10*1+12*0+18*1
10+10+18=38.
Page 8
UNIT-IV BRANCH AND BOUND
Page 9
UNIT-IV BRANCH AND BOUND
Associate the cumulative reduced sum to the starting state as lower bound and α as upper
bound.
Page
10
UNIT-IV BRANCH AND BOUND
Page
11
UNIT-IV BRANCH AND BOUND
Step 2:
Now consider the path (1, 2)
Change all entries of row 1 and column 2 of A to ∞ and also set A (2, 1) to ∞.
∞ ∞ ∞ ∞ ∞
∞ ∞ 11 2 0
0 ∞ ∞ 0 2
15 ∞ 12 ∞ 0
11 ∞ 0 12 ∞
Apply row and column reduction for the rows and columns whose rows and column are not
completely ∞. Then the resultant matrix is
Apply row and column reduction for the rows and columns whose rows and column are not
completely ∞
∞ ∞ ∞ ∞ ∞
1 ∞ ∞ 2 0
Then the resultant matrix is = ∞ 3 ∞ 0 2
4 3 ∞ ∞ 0
0 0 ∞ 12 ∞
Page
12
UNIT-IV BRANCH AND BOUND
Change all entries of row 1 and column 4 of A to ∞ and also set A(4,1) to ∞.
∞ ∞ ∞ ∞ ∞
12 ∞ 11 ∞ 0
0 3 ∞ ∞ 2
∞ 3 12 ∞ 0
11 0 0 ∞ ∞
Apply row and column reduction for the rows and columns whose rows and column are not
completely ∞
∞ ∞ ∞ ∞ ∞
12 ∞ 11 ∞ 0
Then the resultant matrix is = 0 3 ∞ ∞ 2
∞ 3 12 ∞ 0
11 0 0 ∞ ∞
Row reduction sum = 0
Column reduction sum = 0
Cumulative reduction(r) = 0 +0=0
Therefore, as ĉ(S)= ĉ(R)+A(1,4)+r
ĉ(S)= 25 + 0 +0 = 25.
Now Consider the path (1, 5)
Change all entries of row 1 and column 5 of A to ∞ and also set A(5,1) to ∞.
∞ ∞ ∞ ∞ ∞
12 ∞ 11 2 ∞
0 3 ∞ 0 ∞
15 3 12 ∞ ∞
∞ 0 0 12 ∞
Apply row and column reduction for the rows and columns whose rows and column are not
completely ∞
∞ ∞ ∞ ∞ ∞
10 ∞ 9 0 ∞
Then the resultant matrix is = 0 3 ∞ 0 ∞
12 0 9 ∞ ∞
∞ 0 0 12 ∞
Row reduction sum = 5
Column reduction sum = 0
Cumulative reduction(r) = 5 +0=0
Therefore, as ĉ(S)= ĉ(R)+A(1,5)+r
ĉ(S)= 25 + 1 +5 = 31.
The tree organization up to this as follows:
Page
13
UNIT-IV BRANCH AND BOUND
The cost of the between (1, 2) = 35, (1, 3) = 53, ( 1, 4) = 25, (1, 5) = 31. The cost of the
path between (1, 4) is minimum. Hence the matrix obtained for path (1, 4) is considered as
reduced cost matrix.
∞ ∞ ∞ ∞ ∞
12 ∞ 11 ∞ 0
A= 0 3 ∞ ∞ 2
∞ 3 12 ∞ 0
11 0 0 ∞ ∞
The new possible paths are (4, 2), (4, 3) and (4, 5).
Now consider the path (4, 2)
Change all entries of row 4 and column 2 of A to ∞ and also set A(2,1) to ∞.
∞ ∞ ∞ ∞ ∞
∞ ∞ 11 ∞ 0
0 ∞ ∞ ∞ 2
∞ ∞ ∞ ∞ ∞
11 ∞ 0 ∞ ∞
Apply row and column reduction for the rows and columns whose rows and column are not
completely ∞
∞ ∞ ∞ ∞ ∞
∞ ∞ 11 ∞ 0
Then the resultant matrix is = 0 ∞ ∞ ∞ 2
∞ ∞ ∞ ∞ ∞
11 ∞ 0 ∞ ∞
Row reduction sum = 0
Column reduction sum = 0
Cumulative reduction(r) = 0 +0=0
Therefore, as ĉ(S)= ĉ(R)+A(4,2)+r
ĉ(S)= 25 + 3 +0 = 28.
Page
14
UNIT-IV BRANCH AND BOUND
The cost of the between (4, 2) = 28, (4, 3) = 50, ( 4, 5) = 36. The cost of the path between
(4, 2) is minimum. Hence the matrix obtained for path (4, 2) is considered as reduced cost
matrix.
∞ ∞ ∞ ∞ ∞
∞ ∞ 11 ∞ 0
A= 0 ∞ ∞ ∞ 2
∞ ∞ ∞ ∞ ∞
11 ∞ 0 ∞ ∞
The new possible paths are (2, 3) and (2, 5).
Page
15
UNIT-IV BRANCH AND BOUND
Page
16
UNIT-IV BRANCH AND BOUND
The cost of the between (2, 3) = 52 and (2, 5) = 28. The cost of the path between (2, 5) is
minimum. Hence the matrix obtained for path (2, 5) is considered as reduced cost matrix.
∞ ∞ ∞ ∞ ∞
∞ ∞ ∞ ∞ ∞
A= 0 ∞ ∞ ∞ ∞
∞ ∞ ∞ ∞ ∞
∞ ∞ 0 ∞ ∞
The new possible path is (5, 3).
Page
17
UNIT-IV BRANCH AND BOUND
Page
18