Lecture 13, 22 April 2014

advertisement
The Traveling Salesman Problem
in Theory & Practice
Lecture 13: The Maximum TSP Problem
22 April 2014
David S. Johnson
dstiflerj@gmail.com
http://davidsjohnson.net
Seeley Mudd 523, Tuesdays and Fridays
Outline
1. The Maximum Traveling Salesman Problem
1.
Heuristics for the symmetric case
2. Polynomial-time solvable symmetric special cases
3. The Asymmetric Maximum TSP
2. Student Presentation by Jeffrey Scholz on
“The Traveling Salesman Problem with Distances 1 and 2,”
by Papadimitriou and Yannakakis.
The MaximumTraveling Salesman
Problem (MaxTSP)
Given:
Set of cities {c1,c2,…,cN }.
For each pair of cities {ci,cj}, a distance d(ci,cj).
Find:
Permutation π : {1,2,..., N}  {1,2,..., N} that maximizes
N 1
 d(c
i1
π(i)
, cπ(i1) )  d(cπ(N) , cπ(1) )
Applications
• The “Taxicab Ripoff Problem”
• The “Frequent Flyer Miles Accumulation Problem”
• The “Shortest Superstring Problem”
– Given: Finite set of S strings over some alphabet.
– Find: Shortest string that contains all strings in S as substrings.
– Cities: Strings in S.
– Distances: d(x,y) = |y| - maximum overlap between a suffix of x
and a prefix of y.
X = “alphabet”, y =“ betrayal”
d(x,y) = 5 alphabet
betrayal
d(y,x) = 6 betrayal
alphabet
First Observations, Symmetric Case
NP-hard in general.
But we do not need the triangle inequality to get good approximation bounds.
– To guarantee a solution or weight at least (1/2)Optimal, simply
construct a maximum weight matching and connect the resulting N/2
edges into a tour arbitrarily.
– To guarantee a solution of weight at least (2/3)Optimal, construct a
maximum weight cycle cover, delete the shortest edge from each
cycle (each must contain at least three edges), and connect the
resulting paths into a tour arbitrarily.
– In a 1984 paper (in Russian), Serdyukov presented an algorithm that
uses both a maximum weight matching and a maximum weight cycle
cover, and guarantees a solution of weight at least (3/4)Optimal.
– Current record [Paluch, Mucha, Madry, 2009] is an O(N3) algorithm
that guarantees a solution of weight at least (7/9)Optimal.
History: 0.5 ➟ 0.6666... ➟ 0.71428 ➟ 0.75 ➟ 0.75308... ➟ 0.7777...
Sketch of the ¾ Algorithm
Suppose N is even (odd case is a bit more complicated).
•
Construct a maximum weight matching M (Length ≥ OPT/2).
•
Construct a maximum weight cycle cover C (Length ≥ OPT).
•
Note that every vertex has degree 3 in the combined graph M∪C.
•
We will move edges from C to M so as to turn each into a union of paths.
•
Process the cycles of C in order. For each,
– Pick an arbitrary vertex v in the cycle.
– Vertex v has degree 2 in C and so is the end of a path in M. At least one of the
two edges incident on v in C does not create a cycle in M. Transfer it to M.
•
Turn the collections of paths in M and C into tours (TM and TC) by connecting the
paths arbitrarily.
•
The longer tour must have weight at least (3/4)OPT.
Geometry: Norms
Lp Norm:
p=2
p=1
Standard Euclidean Metric
Rectilinear or “Manhattan” Metric
p = “∞”
“Sup” norm, d(x,y) = max{|xi – yi|: 1 ≤ i ≤ d}
Polyhedral Norms
Defined in terms a “unit ball” which is a centrally symmetric
polyhedron P with the origin as its center.
Polyhedral Norms
Defined in terms a “unit ball” which is a centrally symmetric
polyhedron P with the origin as its center.
Polyhedral Norms
Defined in terms a “unit ball” which is a centrally symmetric
polyhedron P with the origin as its center.
x
x
y
y
To compute the distance from x to y,
Transpose x and y so that one is at the origin,
Then expand or contract the unit square so that the other point is on the
border of the unit square.
The distance is the factor by which the unit square was
expanded/contracted.
(0,1)
x
y
(0,1)
(1,0)
Sup Norm
x
y
(1,0)
Rectilinear Metric
x
y
Very Approximate
Euclidean
Alternate Definition
Note that a centally symmetric polytope P with 2f facets (the
number of facets must be even since P is symmetric) can be
specified by a set HP = {h1, h2, …, hf} of points in Rd such that P is
the intersection of the following collection of 2f half-spaces:
For the Sup Norm we can take Hp = {(1,0),(0,1)}.
For the Rectilinear Norm we can take Hp = {(1,1),(-1,1)}.
Then we have
d(x,y) = max {|(x-y)•hi|: 1 ≤ i ≤ f}.
All Polyhedral Norms are Metrics
We clearly have, for all polyhedral norms and all points x,y in the relevant
space Rd, that d(x,y) ≥ 0, d(x,y) = 0 if and only if y = x, and d(x,y) = d(y,x).
To complete the proof, we need to show that the triangle inequality holds.
Suppose we are given a polynomial norm for Rd specified by the set of
points HP = {h1, h2, …, hf}, and any three points x, y, z in Rd.
We must show d(x,y) ≤ d(x,z) + d(z,y).
Choose i such that d(x,y) = |(x-y)•hi|. Then
d(x,z) + d(z,y) ≥ |(x-z)•hi| + |(z-y)•hi|
≥ |(x-z)•hi + (z-y)•hi|
= |(x-y)•hi|
= d(x,y)
Theorem
[Barvinok, Fekete, Johnson, Tamir, Woeginger, and Woodroofe, “The Geometric
Maximum Traveling Salesman Problem,” J.ACM 30 (2003), 641-664.]
For any fixed polyhedral norm whose “unit ball” has 2f faces, the
MaxTSP problem can be solved in time O(N2f-2logN) time in the real
number RAM model.
(If all the numbers in the input are integers with maximum absolute
value U, the running time under the standard logarithmic cost RAM
model increases only by a factor of log(NU).
Proof: We convert the problem to a non-geometric special case of
MaxTSP, the “Tunneling TSP”, and design an algorithm for that.
The Tunneling TSP
•
We are given a set C of cities and a set T = {t1, t2, …, tk}, k ≥ 2, of “tunnels”.
•
Each tunnel is viewed as a bidirectional passage with a front and back end.
•
For each pair (c,t) of a city and a tunnel, we are given real-valued “access
distances” F(c,t) and B(c,t) from city c to the front and back ends of the
tunnel t, respectively.
•
Each tour edge (c,c’) must pass through some tunnel, either be entering
through the front and leaving through the back
o cost = F(c,t) + B(c’,t),
•
or be entering through the back and leaving through the front.
o cost = B(c,t) + F(c’,t).
•
Since we are concerned with the maximum tour length, we thus can take the
distance between c and c’ to be
o d(c,c’) = max {F(c,ti) + B(c’,ti), B(c,ti) + F(c’,ti): 1 ≤ i ≤ k}.
•
Note that this is symmetric, like the distance under a polyhedral norm.
The Tunneling TSP
c
•
•
•
We are given a set C of cities and
a set T = {t1, t2, …, tk}, k ≥ 2, of
“tunnels”.
F(c,t1)
F(c,t2)
Each tunnel is viewed as a
bidirectional passage with a front
and back end.
For each pair (c,t) of a city and a
tunnel, we are given real-valued
“access distances” F(c,t) and
B(c,t) from city c to the front and
back ends of the tunnel t,
respectively.
B(c,t1)
t1
B(c,t2)
t2
F(c,t3)
B(c,t3)
t3
F(c,t4)
t4
B(c,t4)
The Tunneling TSP
c
•
Each tour edge (c,c’) must pass
through some tunnel, either be
entering through the front and
leaving through the back
F(c,t1)
t1
F(c,t2)
B(c,t2)
B(c’,t1)
F(c’,t1)
o cost = F(c,t) + B(c’,t),
•
B(c,t1)
t2
or by entering through the back and
F(c,t3)
leaving through the front.
o cost = B(c,t) + F(c’,t).
B(c,t3)
F(c’,t2)
B(c’,t2
)
t3
F(c,t4)
t4
B(c,t4)
F(c’,t3)
B(c’,t3
)
F(c’,t4)
c’
B(c’,t4)
Polyhedral Norm TSP ➟ The Tunneling TSP
Lemma: Suppose we are given a dimension-d polyhedral norm
||•||determined by the set HP = {h1, h2, …, hf}. Then for any set C of
points in d-dimensional space, we can, in time O(df|C|), construct a
tunnel system T with k tunnels that yields d(c,c’) = ||c-c’|| for all c,c’ ∈
C.
Proof: By definition, we have
||c-c’|| = max {|(c-c’)•hi|: 1 ≤ i ≤ k}
= max {(c-c’)•hi, (c’-c)•hi: 1 ≤ i ≤ k}.
If we set T = HP, with F(c,h) = c•h and B(c,h) = -c•h for all cities c and
tunnels h, we get
d(c,c’) = max {F(c,hi) + B(c’,hi), B(c,hi) + F(c’,hi): 1 ≤ i ≤ k
= max {c•hi – c’•hi, -c•hi + c’•hi: 1 ≤ i ≤ k}
= max {(c-c’)•hi, (c’-c)•hi: 1 ≤ i ≤ k}
= max {|(c-c’)•hi|: 1 ≤ i ≤ k} = ||c-c’||.
QED.
Tours vs. Sets for Tunnel Systems
• Consider a multigraph G = (C∪T,E), with four weighted edges
between each (city,tunnel) pair:
– e1,F(c,t), w(e1,F(c,t)) = F(c,t)
– e2,F(c,t), w(e2,F(c,t)) = F(c,t)
– e1,B(c,t), w(e1,B(c,t)) = B(c,t)
– e2,B(c,t), w(e2,B(c,t)) = B(c,t)
• For notational convenience, let
– E[t,F] = {ei,F(c,t): c ∈ C, i ∈ {1,2}}, for all t ∈ T.
– E[t,B] = {ei,B(c,t): c ∈ C, i ∈ {1,2}}, for all t ∈ T.
Tours vs. Sets for Tunnel Systems
Lemma: Every tour of a tunnel system corresponds to a subset E’ ⊆ E that has
∑e∈E’ w(e) equal to the tour length, and satisfies:
1.
Every city is incident on exactly two edges in E’.
2.
For each tunnel t ∈ T, |E’ ∩ E[t,F]| = |E’ ∩ E[t,B]|.
3.
The set E’ is connected.
Example: Suppose we have a 4-city instance with tour (c1,c2,c3,c4).
c1
e2,F(c1,t1)
e1,F(c1,t1)
e1,B(c4,t1)
c3
t1
e1,B(c4,t2)
e1,B(c2,t1)
e1,B(c2,t1)
c2
e1,F(c3,t1)
t2
e1,F(c3,t2)
c4
New Goal
Find a maximum-weight subset E’ ⊆ E satisfying (1) – (3).
Approach: Divide into cases:
a)
b)
Pick a degree sequence deg(t1), …, deg(tk), for the tunnels.
•
Choices are even numbers between 0 and 2N.
•
Total number of possiblities is O(Nk-1).
Pick a spanning tree for the p ≤ k tunnels with nonzero degree in (a).
•
c)
Pick the cities c that will be used to realize each of the (p-1) spanning tree edges
from (b), replacing {t,t’} by the pair of edges {t,c} and {c,t’}.
•
a)
Total number of possibilities is pp-2 [Cayley, 1889].
Total number of possibilities over all p-1 edges is O(Np-1) = O(Nk-1).
For each triple (t,c,t’) generated in (c), choose one of the four edges linking c to
t and one of the four edges linking c to t’.
•
Total number of possibilities per triple is 16.
Total number of cases is O(16kk-2N2k-2), which for fixed k is O(N2k-2).
Each can be handled by a bipartite b-matching computation.
The b-matching problem
• Left side vertices: The cities in C.
• Right side vertices: Two representatives tF and tB for each tunnel
t ∈ T with positive degree from (a).
• For each vertex c in a triple (t,c,t’) from (c):
– The chosen edge from c to tF or tB, with the appropriate label from
{ei,F(c,t), ei,B(c,t): i ∈ {1,2}}, and the corresponding weight, F(c,t) or B(c,t).
– The chosen edge from c to t’F or t’B, with the appropriate label from
{ei,F(c,t’), ei,B(c,t’): i ∈ {1,2}}, and the corresponding weight, F(c,t’) or B(c,t’).
• For each vertex c not in a triple from (c), and each tunnel t with
positive degree:
– Two edges from c to tF, with labels ei,F(c,t), i ∈ {1,2}, and weight F(c,t).
– Two edges from c to tB, with labels ei,B(c,t), i ∈ {1,2}, and weight B(c,t).
• Target degrees: 2 for each city c, deg(t)/2 for each tunnel t.
t1,F
A choice of spanning tree
t1
c2
t2
c1
c3
c2
t3
An assignment of cities to
spanning tree edges
t1,B
t2,F
c3
c4
c5
The remaining
cities each have
two edges to
each of the ti,F
and ti,B tunnel
vertices.
t2,B
t3,F
t3,B
Total Running Time
•
•
•
•
•
Constructing tunnel system: O(N2k).
Constructing the tunnel graph: O(Nk).
Number of cases generated and time to construct them: O(N2k-2).
Constructing a maximum b-matching for a single case: O(N3).
TOTAL TIME = O(N2k+1).
(To reduce this to the claimed O(N2k-2logN) = O(N2f-2logN) requires a bit more work and results
from [Megiddo & Tamir (1996] about fast solutions for the duals of transportation problems.)
Is this practical?
• Rectilinear and Sup Norms have 2d faces in Rd, hence running
times O(N2d-2logN).
– O(N2logN) for R2
– O(N4logN) for R3
– etc.
• Practical at least for planar instances.
• But unnecessary:
Theorem [Fekete, 1999]: The maximum TSP for points in the plane
can be solved in linear time for any 4-face polyhedral norm.
What about the Euclidean Metric?
Theorem [Fekete, 1999]: The Maximum TSP for points in Rd under
the Euclidean metric is NP-hard for all d ≥ 3.
This results extends to all Lp norms except for p = 1 and p = ∞.
The problems remain open for all such p’s when the points are in R2.
Note that we get Polynomial Time Approximation Schemes (PTAS’s)
for the MaxTSP under the Euclidean metric in Rd for all d ≥ 2, by
using polyhedral norms whose Unit Balls have more and more faces,
so as to better approximate a circle (sphere).
Asymptotic Optimality, Much Quicker
An algorithm is “asymptotically optimal” if
limit|C|→∞ALG(C)/OPT(C) → 1.
If we are willing to settle for this, we can, for a d-dimensional
polyhedral metric with 2f faces, find asymptotically optimal
maximum TSP solutions in time O(N3+dfN) [Serdyukov, 1995].
Proof: Start by constructing a maximum-cost cycle cover in time O(N3).
We then proceed in two steps.
1. We post-process the cycle cover in time O(dfN) to obtain one that
contains at most f cycles.
2. Given this cover, we construct in time O(N2) a Hamilton Cycle with
length at least (1-(1/N))fOPT(C).
1. Post-Processing the Cycle Cover
•
In time O(dfN), construct the tunnel system corresponding to our
norm.
•
While there are more than f cycles in our cover,
– Pick two cycles that contain edges using the same tunnel. (That is,
their weight is determined by F(c,t) + B(c’,t) for the same tunnel t.)
– Let {x,y} be the edge using tunnel t in the first cycle, and {u,v} be
the edge using tunnel t in the second cycle, with the vertices named
so that
c(x,y) = F(x,t) + B(y,t) and c(u,v) = F(u,t) + B(v,t).
– Replace these two edges by {x,v} and {u,y}. This will connect the
two cycles, and the weight of the replacement edges will be at least
c(x,v) + c(u,y) ≥ F(x,t) + B(v,t) + F(u,t) + B(y,t) = c(x,y) + c(u,v).
x
F(x,t)
u
F(u,t)
t
B(y,t)
y
B(v,t)
v
2. Constructing the Hamilton Cycle
•
Suppose we have a maximum weight cycle cover containing at most k ≤ f
cycles. We will merge them, one by one, until there is a single cycle.
•
Here’s how:
•
While there is more than one cycle, do the following:
– Let C0 be the cycle with minimum average edge weight.
– Let C1 be another cycle.
– Let c(C0) and c(C1) be the total weights of edges in C0 and C1,
respectively.
– Let the edges in C0 be {a1,a2}, {a2,a3}, …, {am,a1}.
– Note that we have must have m < N since there is at least one other
cycle.
2. Constructing the Hamilton Cycle
a5
a4
a1
C0
a3
x
C1
a2
y
– Choose an edge {x,y} to delete from C1.
– Consider the m ways of merging the two cycles, in which we delete
{x,y} from C1 and {ai,ai+1(mod m)} from C0, and add the edges {x,ai} and
{y,ai+1(mod m)}.
– Perform the swap of this type that results in the smallest decrease
in overall weight.
– The average, over these m swaps, of the amount by which the total
edge weight decreases, is c(x,y) + (c(C0) - ∑c(ai,x) - ∑c(ai,y))/m.
– By the Δ-Inequality, we have c(x,y) ≤ c(ai,x) + c(ai,y), for 1 ≤ i ≤ m.
– Therefore, (∑c(ai,x) + ∑c(ai,y))/m ≥ (mc(x,y))/m = c(x,y).
– So the average decrease is no more than c(C0)/m and the decrease
for our choice must be at least the small.
2. Constructing the Hamilton Cycle
– But c(C0)/m is the average edge weight of C0, and all the other
cycles have average edge weight at least as large.
– Thus, c(C0)/m can be no more than the average edge weight over all,
which is OPT/N.
– Thus the weight of the new cycle cover is at least (1 – 1/N)OPT.
– Repeating this k ≤ f times, we get a Hamilton Cycle of weight at
most
(1 – 1/N)fOPT(C),
– as claimed.
f
3
3d Rect
3d Sup
4
4d Rect
4d Sup
10
100
N
2
2d Rect
2d Sup
100
0.9801
0.9703
0.9606
0.9044
0.3360
1,000
0.9980
0.9970
0.9960
0.9900
0.9047
10,000
0.9998
0.9997
0.9996
0.9990
0.9900
Euclidean Metric, Revisited
Maximum error for a polyhedral norm based on
a regular polygon with K vertices, all on the
circle, is h, from the Wolfram Figure, with
•
Θ = 2π/k
•
R=1
•
% Error = 100h = 100(1 – cos(π/k))
Polyhedral length of Maximum tour is at least
the Euclidean length, since its unit ball is
contained in the Euclidean unit ball.
r = Rcos(Θ/2)
h=R-r
From
So Maximum polyhedral norm tour has
polyhedral length at least OPT, and Euclidean
length at least (1-h)OPT.
Asymptotic Opt Error = 1 - r(1-1/N)f
K
10
20
50
100
200
% Error for Opt
4.89
1.23
0.20
0.05
0.01
N = 1,000 % Err.
5.84
3.19
5.06
9.57
18.14
N = 10,000 % Err.
4.99
1.43
0.70
1.04
1.92
What about “in practice”?
Why not use Concorde?
•
Let M = max{d(x,y): x,y in C}.
•
Set d’(x,y) = M – d(x,y) and minimize.
•
OptMax = NM - OptMin.
Quick Test (this morning):
• N = 100.
• Points uniform in the 1,000,000 x 1,000,000 square.
• 1,415,000 as a surrogate for M.
• Running time: 3515.60 seconds (2.4 Ghz Core i5 iMac)
• Versus an average of about 20 seconds for standard Euclidean
instances with N = 500.
What about non-symmetric unit balls?
These yield “quasi-norms” (triangle inequality but no symmetry)
and our results carry over, although now the faces do not pair up
and we need a tunnel for each face. So we have
Theorem [BFJTWW, 2003]: Suppose we are given a
polyhedral quasi-norm for Rd, d ≥ 2, whose unit ball has f faces.
Then the Maximum TSP for a set of N points in Rd can be solved
in time O(N2f-2logN) on a real number RAM.
(A polynomial-time algorithm for the special case of R2 with a
triangle for the unit ball was presented in [Serdyukov, 1995].)
A modified version of Serdukov’s “asymptotically optimal”
algorithm may still apply.
More on this and related problems next time.
Download