Chapter 5-The-Traveling-Salesman-Problem
Chapter 5-The-Traveling-Salesman-Problem
Optimization problem:
Given a complete weighted graph, find a minimum
weight Hamiltonian cycle
Decision Problem:
polynomial-time 2-approximation
algorithm for the traveling salesman
problem with the triangle inequality.
Proof. Let H* denote an optimal tour for the given set of
vertices. Since we obtain a spanning tree by deleting any
edge from a tour, the weight of the minimum spanning
tree T is a lower bound on the cost of an optimal tour,
that is, w(T) ≤w(H*)-w(e) ≤w(H*)
A full walk of T lists the vertices when they are first
visited and also whenever they are
returned to after a visit to a subtree. Let us call this walk
W . Since the full walk traverses every edge of T exactly
twice, we have
w(W)=2w(T)
w(W)≤2w(H*)
and so the cost of W is within a factor of 2 of the cost of
an optimal tour.
Unfortunately, W is generally not a tour, since it visits
some vertices more than once. By the triangle
inequality, however, we can delete a visit to any vertex
from W and the cost does not increase. By repeatedly
applying this operation, we can remove from W all but
the first visit to each vertex.
Let H be the cycle corresponding to this preorder
walk. It is a hamiltonian cycle, since every vertex
is visited exactly once, and in fact it is the cycle
computed by ApproxMSTTSP(G). Since H is
obtained by deleting vertices from the full walk
W , we have
w(H)≤w(W)
So w(H)≤w(W) ≤2w(H*) .
Other heuristic strategies and Discussion
Nearest neighbor strategy
20 20
a b a b
15 15
35 10 35 10
25 25
d c d c
12 12
NearestNeighbor(G)
1 select an arbitrary vertex s to start the cycle H
2 u← s
3 while there are vertices not yet in H do
4 select an edge (u,v) of minimum weight, where v is
not in H.
5 add edge (u,v) to H
6 u←v
7 Add the edge (u,s) to H
8 return H
H: (a, c), (c, b), (b, d), (d, a)
20 20
a b a b
15 15
35 10 35 10
25 25 H=85
d c d c H*=72
12 12
20 20
a b a b
15 15
35 10 35 10
25 25
d c d c
12 12
1. Like Prim‘s MST algorithm, starts with an arbitrary
vertex u and adds edge (u,v) of minimum weight such
that vertex v is not yet in the cycle.
2. However, it always adds edges from the endpoint of
the cycle constructed so far.
3. Worst case time of O(|V|2) for a graph with |V|
vertices.
Nearest Neighbor heuristic worst-case ratio:
R(|I|) =½ (1+lg|V|)
The ratio grows with |V|.
For (a):
w( H ) 10
R( I ) 1.25.
w( H *) 8
For(b):
w( H ) 4 w
R( I ) .
w( H *) 8
Shortest link strategy
ShortestLinkedHeuristic(G)
1 H←Ø
2 E' ← E
3 while E' ≠ Ø do
4 remove the lightest edge (u,v) from E'
5 if (u,v) does not make a cycle with edges in H
and (u,v) would not be the third edge in H incident on u
or v then
6 H ← H ∪{u, v}
7 Add the edge connecting the endpoints of the path in H
8 return H
H: (b, c), (c, d), (b, a), (d, a)
20 20
a b a b H=77
15 15 H*=72
35 10 35 10
25 25
d c d c
12 12
20 20
a b a b
15 15
35 10 35 10
25 25
d c d c
12 12
Shortest link strategy
1.Like Kruskal's MST algorithm, considers edges in
order of cost, from shortest to longest.
2.Adds edge (u, v) if it does not make a cycle with edges
in the path constructed so far and would not be the third
edge in the path incident on u or v.
3.When |E|-1 edges have been added, connect the
endpoints of the path to form a cycle.
4.Running time O(|E|lg|E|) for a graph with |E| edges.
19
Insertion heuristic
20 20
a b
H=72
a b
15 15 H*=72
35 10 35 10
25 25
d c d c
12 12
20
20 (a, c): 35+12-
a b a b
15=32 15
15 (b, c): 25+12-10=27
35 10
35 10
(a, b): 35+25-20=40 25
25
d d c
c 12
12
Theorem. Any insertion heuristic order gives a R(|I|)=
. lg | V | 1
Given a complete graph G=(V,E) with positive weights
(distances) on its edges,
The minimum traveling salesman problem consists of
minimizing the cost of a Hamiltonian cycle, the cost of
such a cycle being the sum of the weights on its edges.
The maximum traveling salesman problem consists of
maximizing the cost of a Hamiltonian cycle.
Homework
Experiments:
Implement ApproxMSTTSP,NearestNeighbor,
ShortestLinkedHeuristic, NearestInsertion and compare
these algorithms
Consider the vehicle routing problem:
One is given a set of customers with known positive
demands. A fleet of homogeneous vehicles of known
capacity is available at a given depot to perform this
service. The objective is to find a set of closed routes
(or tours) that start and end at the depot, such that the
total cost of performing the service is minimized.
27