KEMBAR78
Branch and bounding : Data structures | PPTX
Branch and Bound 
Travelling Salesman Problem
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.
Least Cost or max profit 
This scheme associates a cost or profit with each node. If 
we are searching for a solution with least cost, then the 
list of live nodes can be set up as a min heap. The next E-node 
is the live node with least cost. If we want a solution 
with maximum profit, the live node list can be set up as a 
max heap. The next E-node is the live node with 
maximum profit.
1 
Ways to select E-Node 
2 3 4 5 
Live Node: 2, 3, 4, and 5 
1 
2 3 4 5 
6 7 8 9 
1 
2 3 4 5 
8 9 6 7 
FIFO Branch & Bound (BFS) 
Children of E-node are inserted in a 
queue. 
LIFO Branch & Bound (D-Search) 
Children of E-node are inserted in 
a stack.
Requirements 
• Branching: A set of solutions, which is represented 
by a node, can be partitioned into mutually 
exclusive sets. Each subset in the partition is 
represented by a child of the original node. 
• Lower bounding: An algorithm is available for 
calculating a lower bound on the cost of any 
solution in a given subset.
 Searching: Least-cost search (LC) 
• Cost and approximation 
• Each node, X, in the search tree 
is associated with a cost: C(X) 
• C(X) = cost of reaching the 
current node, X (E-node), from the 
root + the cost of reaching an 
answer node from X. 
C(X) = g(X) + h(X)
 Example: 8-puzzle 
^ 
= g(x) +h(x) 
Cost function: C 
Where, 
h(x)=the number of misplaced tiles 
g(x)=the number of moves so far 
Assumption: move one tile in any direction cost 1, 
Initial State Final State 
1 2 3 
5 6 
7 8 4 
1 2 3 
5 8 6 
7 4
1 2 3 
5 6 
7 8 4 
^ 
C    
1 2 3 
5 6 4 
7 8 
^ 
C    
1 2 3 
5 6 
7 8 4 
^ 
C    
1 2 
5 6 3 
7 8 4 
1 4 5 
1 2 3 
1 4 5 
^ 
C    
1 2 3 
5 8 6 
7 4 
^ 
C    
1 2 3 
5 6 
7 8 4 
^ 
C    
1 3 
5 2 6 
7 8 4 
2 1 3 
2 3 5 
2 3 5 
^ 
C    
1 2 3 
5 8 6 
7 4 
^ 
C    
1 2 3 
5 8 6 
7 4 
3 2 5 
3 0 3
Travelling salesman problem 
In this problem we are given an n vertex network 
(either directed or undirected) and are to find a 
cycle of minimum cost that includes all n vertices. 
Any cycle that includes all n vertices of a 
network is called a tour. In the traveling-salesperson 
problem, we are to find a least-cost 
tour.
Four-Vertex network 
1 2 
3 
30 
10 
20 
6 
5 
4 
4
State space diagram or permutation tree 
A 
B 
1 
2 
3 
4 
C D E 
3 4 2 4 2 3 
F G H I J K 
4 3 4 2 3 2 
L M N O P Q
formulas 
• S={1,p,1|p=Permutation of (2,3,…,n)} 
Size of S=(n-1)! 
oT(S)=T(R)+A(i,j)+r 
where, 
R=parent node 
A=reduced cost matrix for node R 
S=child of R such that <R,S>=<i,j> belongs to E 
r=reduced constant
EXAMPLE 
Let the following cost matrix be for n=5 in graph 
G(V,E):
State space tree 
1 25 
Vertex = 2 Vertex = 5 
35 53 4 25 5 
2 31 
Vertex = 2 Vertex = 5 
6 7 8 
Vertex = 3 Vertex = 5 
10 
Vertex = 3 
3 
Vertex = 3 Vertex = 4 
28 50 36 
52 28 
9 
Vertex = 3 
11 28
Reduction by row: 
10 
2 
2 
3 
4 
Reduction by column: 
1 3
The reduced cost=(10+2+2+3+4)+(1+3) 
=25 
Cost of node1=Lower Bound=25 
Reduced Matrix:
Cost (2): 
•The resulting cost matrix is: 
T(2)=T(1)+A(1,2)+r 
=25+10+0 
=35
Cost (3): 
•The resulting cost matrix is: 
T(3)=T(1)+A(1,3)+r 
=25+17+11 
=53
Cost (4): 
•The resulting cost matrix is: 
T(4)=T(1)+A(1,4)+r 
=25+0+0 
=25
• In summary: 
So the live nodes we have so far are: 
o2: cost(2) = 35, path: 1->2 
o3: cost(3) = 53, path: 1->3 
o4: cost(4) = 25, path: 1->4 
o5: cost(5) = 31, path: 1->5 
Explore the node with the lowest cost: Node 4 has a cost of 25 
Vertices to be explored from node 4: 2, 3, and 5 
Now we are starting from the cost matrix at node 4 is: 
Cost(4):
•Choose to go to vertex 2: Node 6 (path is 1->4->2) 
The resulting cost matrix is: 
T(6)=T(4)+A(4,2)+r 
=25+3+0 
=28
•In summary: 
So the live nodes we have so far are: 
o2: cost(2) = 35, path: 1->2 
o3: cost(3) = 53, path: 1->3 
o5: cost(5) = 31, path: 1->5 
o6: cost(6) = 28, path: 1->4->2 
o7: cost(7) = 50, path: 1->4->3 
o8: cost(8) = 36, path: 1->4->5 
Explore the node with the lowest 
cost: Node 6 has a cost of 28 
Vertices to be explored from node 6: 
3 and 5 
Now we are starting from the cost 
matrix at node 6 is: 
Cost(6)=28
•Choose to go to vertex 3: Node 9 ( path is 1->4->2->3 ) 
The resulting cost matrix is: 
T(9)=T(6)+A(2,3)+r 
=28+11+13 
=52
•Choose to go to vertex 3: Node 10 ( path is 1->4->2- 
>5) 
The resulting cost matrix is: 
T(10)=T(6)+A(2,5)+r 
=28+0+0 
=28
• In summary: 
So the live nodes we have so far are: 
o2: cost(2) = 35, path: 1->2 
o3: cost(3) = 53, path: 1->3 
o5: cost(5) = 31, path: 1->5 
o7: cost(7) = 50, path: 1->4->3 
o8: cost(8) = 36, path: 1->4->5 
o9: cost(9) = 52, path: 1->4->2->3 
o10: cost(2) = 28, path: 1->4->2- 
>5 
Explore the node with the lowest 
cost: Node 10 has a cost of 28 
Vertices to be explored from node 10: 
3 
Now we are starting from the cost 
matrix at node 10 is:
•Choose to go to vertex 3: Node 11( path is 1->4->2->5->3 ) 
The resulting cost matrix is: 
T(11)=T(10)+A(5,3)+r 
=28+0+0 
=28

Branch and bounding : Data structures

  • 1.
    Branch and Bound Travelling Salesman Problem
  • 2.
    Branch and Boundis a state space search method in which all the children of a node are generated before expanding any of its children.
  • 3.
    Least Cost ormax profit This scheme associates a cost or profit with each node. If we are searching for a solution with least cost, then the list of live nodes can be set up as a min heap. The next E-node is the live node with least cost. If we want a solution with maximum profit, the live node list can be set up as a max heap. The next E-node is the live node with maximum profit.
  • 4.
    1 Ways toselect E-Node 2 3 4 5 Live Node: 2, 3, 4, and 5 1 2 3 4 5 6 7 8 9 1 2 3 4 5 8 9 6 7 FIFO Branch & Bound (BFS) Children of E-node are inserted in a queue. LIFO Branch & Bound (D-Search) Children of E-node are inserted in a stack.
  • 5.
    Requirements • Branching:A set of solutions, which is represented by a node, can be partitioned into mutually exclusive sets. Each subset in the partition is represented by a child of the original node. • Lower bounding: An algorithm is available for calculating a lower bound on the cost of any solution in a given subset.
  • 6.
     Searching: Least-costsearch (LC) • Cost and approximation • Each node, X, in the search tree is associated with a cost: C(X) • C(X) = cost of reaching the current node, X (E-node), from the root + the cost of reaching an answer node from X. C(X) = g(X) + h(X)
  • 7.
     Example: 8-puzzle ^ = g(x) +h(x) Cost function: C Where, h(x)=the number of misplaced tiles g(x)=the number of moves so far Assumption: move one tile in any direction cost 1, Initial State Final State 1 2 3 5 6 7 8 4 1 2 3 5 8 6 7 4
  • 8.
    1 2 3 5 6 7 8 4 ^ C    1 2 3 5 6 4 7 8 ^ C    1 2 3 5 6 7 8 4 ^ C    1 2 5 6 3 7 8 4 1 4 5 1 2 3 1 4 5 ^ C    1 2 3 5 8 6 7 4 ^ C    1 2 3 5 6 7 8 4 ^ C    1 3 5 2 6 7 8 4 2 1 3 2 3 5 2 3 5 ^ C    1 2 3 5 8 6 7 4 ^ C    1 2 3 5 8 6 7 4 3 2 5 3 0 3
  • 9.
    Travelling salesman problem In this problem we are given an n vertex network (either directed or undirected) and are to find a cycle of minimum cost that includes all n vertices. Any cycle that includes all n vertices of a network is called a tour. In the traveling-salesperson problem, we are to find a least-cost tour.
  • 10.
    Four-Vertex network 12 3 30 10 20 6 5 4 4
  • 11.
    State space diagramor permutation tree A B 1 2 3 4 C D E 3 4 2 4 2 3 F G H I J K 4 3 4 2 3 2 L M N O P Q
  • 12.
    formulas • S={1,p,1|p=Permutationof (2,3,…,n)} Size of S=(n-1)! oT(S)=T(R)+A(i,j)+r where, R=parent node A=reduced cost matrix for node R S=child of R such that <R,S>=<i,j> belongs to E r=reduced constant
  • 13.
    EXAMPLE Let thefollowing cost matrix be for n=5 in graph G(V,E):
  • 14.
    State space tree 1 25 Vertex = 2 Vertex = 5 35 53 4 25 5 2 31 Vertex = 2 Vertex = 5 6 7 8 Vertex = 3 Vertex = 5 10 Vertex = 3 3 Vertex = 3 Vertex = 4 28 50 36 52 28 9 Vertex = 3 11 28
  • 15.
    Reduction by row: 10 2 2 3 4 Reduction by column: 1 3
  • 16.
    The reduced cost=(10+2+2+3+4)+(1+3) =25 Cost of node1=Lower Bound=25 Reduced Matrix:
  • 17.
    Cost (2): •Theresulting cost matrix is: T(2)=T(1)+A(1,2)+r =25+10+0 =35
  • 18.
    Cost (3): •Theresulting cost matrix is: T(3)=T(1)+A(1,3)+r =25+17+11 =53
  • 19.
    Cost (4): •Theresulting cost matrix is: T(4)=T(1)+A(1,4)+r =25+0+0 =25
  • 20.
    • In summary: So the live nodes we have so far are: o2: cost(2) = 35, path: 1->2 o3: cost(3) = 53, path: 1->3 o4: cost(4) = 25, path: 1->4 o5: cost(5) = 31, path: 1->5 Explore the node with the lowest cost: Node 4 has a cost of 25 Vertices to be explored from node 4: 2, 3, and 5 Now we are starting from the cost matrix at node 4 is: Cost(4):
  • 21.
    •Choose to goto vertex 2: Node 6 (path is 1->4->2) The resulting cost matrix is: T(6)=T(4)+A(4,2)+r =25+3+0 =28
  • 22.
    •In summary: Sothe live nodes we have so far are: o2: cost(2) = 35, path: 1->2 o3: cost(3) = 53, path: 1->3 o5: cost(5) = 31, path: 1->5 o6: cost(6) = 28, path: 1->4->2 o7: cost(7) = 50, path: 1->4->3 o8: cost(8) = 36, path: 1->4->5 Explore the node with the lowest cost: Node 6 has a cost of 28 Vertices to be explored from node 6: 3 and 5 Now we are starting from the cost matrix at node 6 is: Cost(6)=28
  • 23.
    •Choose to goto vertex 3: Node 9 ( path is 1->4->2->3 ) The resulting cost matrix is: T(9)=T(6)+A(2,3)+r =28+11+13 =52
  • 24.
    •Choose to goto vertex 3: Node 10 ( path is 1->4->2- >5) The resulting cost matrix is: T(10)=T(6)+A(2,5)+r =28+0+0 =28
  • 25.
    • In summary: So the live nodes we have so far are: o2: cost(2) = 35, path: 1->2 o3: cost(3) = 53, path: 1->3 o5: cost(5) = 31, path: 1->5 o7: cost(7) = 50, path: 1->4->3 o8: cost(8) = 36, path: 1->4->5 o9: cost(9) = 52, path: 1->4->2->3 o10: cost(2) = 28, path: 1->4->2- >5 Explore the node with the lowest cost: Node 10 has a cost of 28 Vertices to be explored from node 10: 3 Now we are starting from the cost matrix at node 10 is:
  • 26.
    •Choose to goto vertex 3: Node 11( path is 1->4->2->5->3 ) The resulting cost matrix is: T(11)=T(10)+A(5,3)+r =28+0+0 =28