Traveling Salesman - KITalgo2.iti.kit.edu/appol/tsp.pdf · Steiner Trees [C. F. Gauss 18??] Given G...
Transcript of Traveling Salesman - KITalgo2.iti.kit.edu/appol/tsp.pdf · Steiner Trees [C. F. Gauss 18??] Given G...
Sanders/van Stee: Approximations- und Online-Algorithmen 1
Traveling Salesman
Given G = (V,V ×V ), find simple cycle C = (v1,v2, . . . ,vn,v1)
such that n = |V | and ∑(u,v)∈C d(u,v) is minimized.
Sanders/van Stee: Approximations- und Online-Algorithmen 2
Theorem 1. It is NP-hard to approximate the general TSP
within any factor α.
Proof. Reduction from Hamilton Cycle . . .
Hamilton Cycle Problem:
Given a graph decide whether it contains a simple cycle visiting
all nodes
Sanders/van Stee: Approximations- und Online-Algorithmen 3
Proof. We want to find a Hamilton Cycle in G = (V,E).Consider G′ = (V,V ×V ) and the weight function
d(u,v) =
1 if (u,v) ∈ E
αn else
If G has a Hamilton cycle, there is a cycle of weight n in G′
→ an α-approx. algorithm delivers one with weight ≤ αn
If no Hamilton cycle exists, every Hamilton Cycle has weight≥ αn+n−1> αn.Decision algorithm: Run α-approx TSP on G′
solution has weight ≤ αn → Hamilton path existselse Hamilton path does not exist
e.g. [Vazirani Theorem 3.6]
Sanders/van Stee: Approximations- und Online-Algorithmen 4
Metric TSP
G is undirected and obeys the triangle inequality
∀u,v,w ∈V : d(u,w) ≤ d(u,v)+d(v,w)
u w
v
Metric completion
Consider any connected undirected graph G = (V,E) with
weight function c : E → R+. Define
d(u,v) := shortest path distance from u to v
Example: (undirected) street graphs → distance table
Sanders/van Stee: Approximations- und Online-Algorithmen 5
2-Approximation by MST
Lemma 2.The total weight of an MST ≤
The total weight of any TSP tour
Algorithm:
T := MST(G) // weight(T ) ≤opt
T ′:= T with every edge doubled // weight(T ′) ≤2opt
T ′′:= EulerTour(T ′) // weight(T ′′) ≤ 2opt
output removeDuplicates(T ′′) // shortcutting
Exercise: Implementation in time O(m+n logn) where m is
number of edges before metric completion
Sanders/van Stee: Approximations- und Online-Algorithmen 6
Example
1
2
3
4
5 61
2
3
4
5 6
MST Euler tour12131415161
1
2
3
4
5 6
input weight: 1 2 doubled MST output
weight10
optimal weight: 6
Sanders/van Stee: Approximations- und Online-Algorithmen 7
Proof of Lemma 2
Let C denote the optimal TSP tour
remove one edge from T makes T lighter
now T is a spanning tree
which in no lighter than the
MST
General Technique: Relaxation
here: a TSP path is a special case of a spanning tree
Sanders/van Stee: Approximations- und Online-Algorithmen 8
More on TSP
� Practically better 2-approximations, e.g. lightest edge first
� Relatively simple yet unpractical 3/2-approximation
� PTAS for Euclidean TSP
� Guinea pig for just about any optimization heuristics
� Optimal solutions for practical instances. Rule of thumb:
If it fits in memory it can be solved.
[Concorde system] lines of code is six digit number
� TSP like applications are usually more complicated
Sanders/van Stee: Approximations- und Online-Algorithmen 9
Steiner Trees[C. F. Gauss 18??]
Given G = (V,E), with positive edge weights cost : E → R+
V = R∪F , i.e., Required vertices and Steiner vertices
find a minimum cost tree T ⊆ E that connects all required
vertices
∀u,v ∈ R : T contains a u-v path
THE network design problem
weight: 1 2
Sanders/van Stee: Approximations- und Online-Algorithmen 10
Metric Steiner Trees
Find Steiner tree in complete graph with triangle inequality
∀u,v,w ∈V : d(u,w) ≤ d(u,v)+d(v,w)
u w
v
Sanders/van Stee: Approximations- und Online-Algorithmen 11
Approximation Factor Preserving Reduction
Steiner Tree of G? Metric Steiner Tree of G′?
∀u,v ∈V : cost(u,v) :=
shortest path distance between u and v
weight: 1 2
we only add edges. Hence, opt(G′) ≤ opt(G).
Now consider any Steiner tree I ′ ⊆ G′.
We construct a Steiner tree I ⊆ G of the cost no larger:
replace edges → paths
remove edges from cycles
Sanders/vanStee:A
pproximations-
undO
nline-Algorithm
en12
Exam
ples
weight: 1
2w
eight: 12
Sanders/van Stee: Approximations- und Online-Algorithmen 13
2 Approximation by MST
Given metric graph G = (R∪F,E)
Find MST T of subgraph GR induced by R
Theorem 3. cost(T ) ≤ 2opt
Proof:
consider optimal solution T ∗ (cost(T ) = opt))
double edges of T ∗
find Euler tour B (cost(B) = 2opt)
use shortcuts to obtain Hamilton path H
(cost(H) ≤ cost(B) = 2opt).
H is a spanning tree of GR, i.e,
cost(MST) ≤ cost(H) ≤ cost(B) = 2opt
weight: 1 2weight: 1 2G
2
1
1
3 24
3
T*
B
H
Sanders/van Stee: Approximations- und Online-Algorithmen 14
Tight Example
weight: 1weight: 1 1.9999
T*G MSTMore general:
|R| = n → cost(T ∗) = n, cost(MST) = (2− ε)(n−1)
Sanders/van Stee: Approximations- und Online-Algorithmen 15
Fast Implementation
Theorem 4. MST(GR) can be computed in time O(m+n logn)
where
m, n refer to the input graph.
[K. Mehlhorn, A Faster Approximation Algorithm for the
Steiner Problem in Graphs, Information Processing Letters
27(1988) 125–128.]
Sanders/van Stee: Approximations- und Online-Algorithmen 16
The “Graph Voronoi Diagram”
Voronoi diagram of a set of points R in the plane:
Assign each point in the plane to its closest point in R.
Here, assign each node v ∈V
to its closest required node s(v) ∈ R. Use shortest path distance
d.
break ties arbitrarily
weight: 1 2
Sanders/van Stee: Approximations- und Online-Algorithmen 17
Computing the Graph Voronoi Diagram
Solve single source shortest path problem from s0 in
G0:= ({s0}∪R∪F,E ∪{(s0,v) : v ∈ R})
where the new edges have zero weight.
s0
Time O(m+n logn)
(Dijkstra’s Algorihm using Fibonacci heaps)
Sanders/van Stee: Approximations- und Online-Algorithmen 18
(Yet another) Auxiliary Graph
G′1:= (R,E ′
1) where (u,v) ∈ E ′1 if
∃(u′,v′) ∈ E such that
u′ is assigned to u and
v′ is assigned to v in the graph Voronoi diagram of G.
cost′(u,v):= d(u′,u)+ cost(u,v)+d(v,v′).
Can be computed in linear time from shortest path tree in G0
Sanders/van Stee: Approximations- und Online-Algorithmen 19
Finishing Up
build G′1 from G // O(m+n logn)
G2:= MST(G′1) // O(m+n logn)
G3:= G2 with edges replaced by shortest paths in G // O(m+n)
G4:= MST(G3) // omittable
while ∃v ∈ F :v is a leaf of G4 do // [Floren 91]
remove the edge leading to v in G4
return G4
Sanders/van Stee: Approximations- und Online-Algorithmen 20
Lemma 5. MST(G′1) = MST(GR)
Why this is not obvious:
3
We assume wlog that all the MSTs are unique
(no equal edge weights)
Sanders/van Stee: Approximations- und Online-Algorithmen 21
Lemma: MST(G′1) = MST(GR)
Proof:
Assume G2 = MST(G′1) 6= MST(GR)
Case A: ∃(s, t) ∈ E2 but (s, t) 6∈ E ′1
Case B: ∃(s, t) ∈ E2 with cost′(s, t) > d(s, t) 3
Sanders/van Stee: Approximations- und Online-Algorithmen 22
Proof
Let 〈s = v0, . . .vi,vi+1, . . . ,vk = t〉 denote shortest s–t path. If
s(vi) 6= s(vi+1) we have (s(vi),s(vi+1)) ∈ E ′1.
d(s(vi),s(vi+1)) ≤ cost′(s(vi),s(vi+1))
≤ d(s(vi),vi)+ cost(vi,vi+1)+d(vi+1,s(vi+1))
≤ d(s,vi)+ cost(vi,vi+1)+d(vi+1, t) = d(s, t)
< cost′(s, t) (case B only)
remove (s, t) from E2 G2 gets disconnected
∃i : s(vi),s(vi+1) are in different components.
E2 \{(s, t)}∪{(s(vi),s(vi+1))} different MST
s(v )i s(v )i+1
ts
Sanders/van Stee: Approximations- und Online-Algorithmen 23
More on Steiner trees
� Complicated Approximation down to 1.55 [Robins and
Zelikovsky 00]
� Optimal solutions for large practical instances. [PhD
Polzin,Daneshmand, 2003, Dortmund, Mannheim,
MPII-SB]
� Many applications: multicasting in networks, VLSI
design(?), phylogeny reconstruction