Title: Branch and Bound TSP
1Branch and Bound TSP
- Lecture 31 BB TSP
- Review DP Formulation
- A BB Problem Formulation
- State Space
- Cost function
- Bounds
- Lower Bounds
- Upper Bounds
- Example
- Lecture 30 LC Search
- Bounding Methods
- Example 0-1 Knapsack
- Data Structures Priority Queue
- LC Search
2g(1,V-1) as c1kg(k,V-k,1)in Pictures
2
9
Then g(1,1,2,3,4-1) could be c13
g(3,2,4) 8 31 39. To solve the
problem g(1,V-1), need to find g(2,1,3,4) and
g(4,1,2,3) then pick smallest.
9
15
6
12
8
1
3
13
20
16
17
5
10
4
3Building The DP Solution
- Base case is g(i,ø)
- Get g(i,ø) easily.
- Build g(i, j) cijg(j, ø) from g(j, ø).
- What are the dimensions of the DP Table?
4Call Tree for DP TSP
g(1,2,3,4)
c13g(3,2,4)
c14g(4,2,3)
c12g(2,3,4)
c23g(3,4)
c24g(4,3)
c42g(2,3)
c43g(3,2)
c32g(2,4)
c34g(4,2)
5DP Solution Complexity
- Enumerate all tours?
- O(n!) time
- Use this DP solution?
- O(n2 2n) time and O(n 2n) space
6Problem Formulation
- Given graph (V,E), with Vn and cij be the cost
of edge lti,jgt. If edge lti,jgt is not an element
of E, then cij is infinite (999). - Without loss of generality, assume every tour
starts and ends at vertex 1. - A solution is an array s 1, p, 1, where p is
a permutation of (2, 3, , n). - An optimal solution is a solution s with minimum
total cost.
7Problem Formulation
- Need to define
- State Space
- Cost function c(x)
- Bounds on the cost function
- Use bounds to
- Choose most promising direction
- Eliminate obviously bad choices
8Example
1
9
8
2
10
6
5
3
12
7
4
What is a good State Space? Cost Function?
Lower Bound? Upper Bound?
9One State Space Idea
Note that there are only 5 vertices on the graph,
but 65 nodes on the SS tree
2
5
3
4
5
3
2
5
2
5
2
4
4
4
3
3
10One State Space Idea
Note that there are only 5 vertices on the graph,
but 65 nodes on the SS tree
2
5
3
4
5
3
2
5
2
5
2
4
4
4
3
3
Leaves represent all possible tours
11Cost Function
Here x refers to a state on the State Space Tree,
not a vertex of the graph Be careful to keep
these concepts straight since node may refer to
either!
2
5
3
4
5
3
2
5
2
5
2
4
4
4
3
3
12Cost Function
2
5
3
4
5
3
2
5
2
5
2
4
4
4
3
3
If x is not a leaf, then c(x) is the best
possible cost of any tour through x (minimum of
leaf costs in subtree)
13One Lower Bound on Tour Cost
Consider the partial cost on the tour up to the
node x
2
5
3
4
5
3
2
5
2
5
2
4
4
4
3
3
Not very tight. Can we do better?
14Lower Bound on TSP Tour
1
9
8
2
10
6
5
3
12
7
4
Every tour must leave every node and and arrive
at every node.
15Lower Bound on TSP Tour
Lower bound 82361 20
1
9
8
2
10
6
5
3
12
7
4
Whats the cheapest way to leave each node?
16Lower Bound on TSP Tour
Lower bound20 (No tour can beat it)
0
1
0
0
9
0
2
0
6
1
1
Save the sum of those costs. Subtract each cost
from the cost of leaving each individual node.
Why?
Need to keep track of the relative cost for
taking another exit.
17Lower Bound on TSP Tour
1
Lower bound20
0
1
0
0
2
5
9
0
2
0
6
1
3
4
1
Does that edge collection arrive at every node?
In this case, the tour never arrives at node 3.
We can tighten our estimate of the best tour cost
by using the fact that a tour must arrive at node
3 somehow.
18Lower Bound on TSP Tour
Lower bound21
0
1
0
0
9
0
1
0
6
0
1
At best have to get to node 3 along the cheapest
edge Add this cost to our lower bound and assign
relative costs of arrival into node 3.
19Lower Bound on TSP Tour
Algorithms do this using a matrix. Heres the
representation.
20Lower Bound on TSP Tour
8 2 3 6 1
1
9
8
2
10
6
4
3
12
7
4
Find the minimum element in each row. This is
the cheapest way to leave each node.
21Lower Bound on TSP Tour
8 2 3 6 1
1
9
8
2
10
6
4
3
12
7
4
Compute the relative cost of leaving by
subtracting the minimum from each row.
22Lower Bound on TSP Tour
8 2 3 6 1
0
1
0
0
9
0
2
0
6
1
1
Compute the relative cost of leaving by
subtracting the minimum from each row.
23Lower Bound on TSP Tour
8 2 3 6 1
0
1
0
0
9
0
2
0
6
1
1
Does this edge collection arrive at every
node? Check for a zero in each column.
24Lower Bound on TSP Tour
8 2 3 6 1
0
1
0
0
9
0
2
0
6
1
0 0 1 0 0
1
Does this edge collection arrive at every
node? Check for a zero in each column.
25Lower Bound on TSP Tour
8 2 3 6 1
0
1
0
0
9
0
1
0
6
0
0 0 1 0 0
1
Lower Bound 823611 21
Subtract the minimum from each column to compute
relative cost of arrival.
26Lower Bound on TSP Tour
Does it matter if we consider cost of arrival
first, then cost leaving?
1
9
8
2
10
6
5
3
12
7
4
Every tour must leave every node and and arrive
at every node.
27Lower Bound on TSP Tour
1 3 4 4 2
Consider cost of arrival first, then cost of
leaving.
28Lower Bound on TSP Tour
0
6
4
0
6
3
0
0
10
3
1 3 4 4 2
0
Consider cost of arrival first, then cost of
leaving.
29Lower Bound on TSP Tour
4 0 0 3 0
0
6
4
0
6
3
0
0
10
3
1 3 4 4 2
0
Consider cost of arrival first, then cost of
leaving.
30Lower Bound on TSP Tour
4 0 0 3 0
0
2
0
0
6
0
0
0
7
0
1 3 4 4 2
0
Lower Bound 1344243 21
Consider cost of arrival first, then cost of
leaving.
31Lower Bound on TSP Tour
4 0 0 3 0
0
2
0
0
6
0
0
0
7
0
1 3 4 4 2
0
Lower Bound 1344243 21
The lower bound is the same, but the relative
cost matrix is different.
32Problem Formulation
- Need to define
- State Space
- Cost function c(x)
- Bounds on the cost function
- Use bounds to
- Choose most promising direction
- Eliminate obviously bad choices
State Space Tree
Cost of (subtree) tour
- Lower Bounds
- Path cost so far
- Cost of leaving/arrival
Good Upper Bound?
33Example
bound 21
1to2
1to3
1to4
1to5
bound 211
34Chose to go from 1 to 2
bound 21
1to2
0
1
0
1
0
0
0
9
9
0
1
0
1
6
6
0
0
bound 211
1
1
Add extra cost from 1 to 2, exclude edges from 1
or into 2.
35Chose to go from 1 to 2
bound 21
1to2
0
1
0
1
0
0
0
9
9
0
1
0
1
6
6
0
0
bound 2111
1
1
No edges into node 4 w/ 0 reduced cost.
36Chose to go from 1 to 2
bound 21
1to2
0
1
0
8
1
6
0
bound 2111
0
Add cost of reducing edge into node 4.
37Bounds For Other Choices
bound 21
1to3,1to5,1to2,1to4
1to2
1to3
1to4
1to5
bound 23
bound 999
bound 21
bound 999
38Two Possibilities
0
1
0
0
0
0
9
0
1
1
0
6
6
0
0
1
bound 23
bound 21
39Leaving Node 4
0
0
4to2,1to2,4to3
bound 21
0
0
1
0
6
0
4to2
4to3
4to5
bound 22
bound 21
bound 28
40Leaving Node 3
0
bound 21
0
4to2,1to2,3to2
0
0
6
0
3to5
3to2
bound 21
bound 999
41Leaving Node 3
0
bound 21
0
4to2,1to2,3to2
0
0
6
0
3to5
3to2
bound 21
bound 999
42Call Tree For This Example
b21
b23
b999
b21
b999
b22
b21
b28
b21
b999