branch and bounding : data structures
DESCRIPTION
Data structures : Branching and boundingTRANSCRIPT
Branch and BoundTravelling 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
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
6 78 9
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.
Ways to select E-Node
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 Cost function: C
^
= g(x) +h(x)
Where,h(x)=the number of misplaced tilesg(x)=the number of moves so far
Assumption: move one tile in any direction cost 1,
Initial State Final State1 2 3
5 6
7 8 4
1 2 3
5 8 6
7 4
1 2 3
5 6
7 8 4
1 2 3
5 6 4
7 8
1 2 3
5 6
7 8 4
1 2
5 6 3
7 8 4
541^C
321^C
541^C
1 2 3
5 8 6
7 41 2 3
5 6
7 8 4
1 3
5 2 6
7 8 4
312^
C
532^C
532^C
1 2 3
5 8 6
7 4
1 2 3
5 8 6
7 4
523^C
303^C
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
3
30
10
20
6
5
4
1 2
4
State space diagram or permutation tree
A
B
DC E
GF H I J K
L M N O P Q
1
23
4
3 4 2 4 2 3
4 3 4 2 3 2
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
EXAMPLELet the following cost matrix be for n=5 in graph G(V,E):
State space tree
Vertex = 3 Vertex = 5
6 7 8
10
4 535 53 25
Vertex = 2 Vertex = 5Vertex = 3
3
Vertex = 2 Vertex = 5Vertex = 4Vertex = 3
28 50 36
52 28
251
2 31
9
11 28
Vertex = 3
Reduction by row: 1
02
23
4
Reduction by column:
1 3
The reduced cost=(10+2+2+3+4)+(1+3) =25Cost 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->2o3: cost(3) = 53, path: 1->3o4: cost(4) = 25, path: 1->4o5: cost(5) = 31, path: 1->5
Explore the node with the lowest cost: Node 4 has a cost of 25Vertices to be explored from node 4: 2, 3, and 5Now 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:
o 2: cost(2) = 35, path: 1->2o 3: cost(3) = 53, path: 1->3o 5: cost(5) = 31, path: 1->5o 6: cost(6) = 28, path: 1->4->2o 7: cost(7) = 50, path: 1->4->3o 8: 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:
o 2: cost(2) = 35, path: 1->2o 3: cost(3) = 53, path: 1->3o 5: cost(5) = 31, path: 1->5o 7: cost(7) = 50, path: 1->4->3o 8: cost(8) = 36, path: 1->4->5o 9: cost(9) = 52, path: 1->4->2->3o 10: 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