the traveling salesman problem in theory & practice

34
The Traveling Salesman Problem in Theory & Practice Lecture 13: The Maximum TSP Problem 22 April 2014 David S. Johnson [email protected] http:// davidsjohnson.net Seeley Mudd 523, Tuesdays and Fridays

Upload: fadhila

Post on 23-Feb-2016

54 views

Category:

Documents


1 download

DESCRIPTION

The Traveling Salesman Problem in Theory & Practice. Lecture 13: The Maximum TSP Problem 22 April 2014 David S. Johnson [email protected] http:// davidsjohnson.net Seeley Mudd 523, Tuesdays and Fridays. Outline. The Maximum Traveling Salesman Problem - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The Traveling Salesman Problem in Theory & Practice

The Traveling Salesman Problem in Theory & Practice

Lecture 13: The Maximum TSP Problem22 April 2014

David S. [email protected]

http://davidsjohnson.net

Seeley Mudd 523, Tuesdays and Fridays

Page 2: The Traveling Salesman Problem in Theory & Practice

Outline1. The Maximum Traveling Salesman Problem

1. Heuristics for the symmetric case2. Polynomial-time solvable symmetric special cases3. The Asymmetric Maximum TSP

2. Student Presentation by Jeffrey Scholz on“The Traveling Salesman Problem with Distances 1 and 2,” by Papadimitriou and Yannakakis.

Page 3: The Traveling Salesman Problem in Theory & Practice

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 that

maximizes)c,d(c)c,d(c π(1)π(N)

1N

1i1)π(iπ(i)

N}{1,2,...,N}{1,2,...,:π

Page 4: The Traveling Salesman Problem in Theory & Practice

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

betrayald(y,x) = 6 betrayal alphabet

Page 5: The Traveling Salesman Problem in Theory & Practice

First Observations, Symmetric CaseNP-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...

Page 6: The Traveling Salesman Problem in Theory & Practice

Sketch of the ¾ AlgorithmSuppose 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.

Page 7: The Traveling Salesman Problem in Theory & Practice

Geometry: Norms

Lp Norm:

p = 2 Standard Euclidean Metric p = 1 Rectilinear or “Manhattan” Metric p = “∞”

“Sup” norm, d(x,y) = max{|xi – yi|: 1 ≤ i ≤ d}

Page 8: The Traveling Salesman Problem in Theory & Practice

Polyhedral NormsDefined in terms a “unit ball” which is a centrally symmetric polyhedron P with the origin as its center.

Page 9: The Traveling Salesman Problem in Theory & Practice

Polyhedral NormsDefined in terms a “unit ball” which is a centrally symmetric polyhedron P with the origin as its center.

Page 10: The Traveling Salesman Problem in Theory & Practice

Polyhedral NormsDefined in terms a “unit ball” which is a centrally symmetric polyhedron P with the origin as its center.

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.

x

y

x

y

Page 11: The Traveling Salesman Problem in Theory & Practice

Rectilinear Metric

Sup Norm

Very Approximate Euclidean

x

y

x

y

(0,1)

(1,0)

(1,0)

(0,1)

y

x

Page 12: The Traveling Salesman Problem in Theory & Practice

Alternate DefinitionNote 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 haved(x,y) = max {|(x-y)•hi|: 1 ≤ i ≤ f}.

Page 13: The Traveling Salesman Problem in Theory & Practice

All Polyhedral Norms are MetricsWe 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)

Page 14: The Traveling Salesman Problem in Theory & Practice

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.

Page 15: The Traveling Salesman Problem in Theory & Practice

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 backo 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 beo 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.

Page 16: The Traveling Salesman Problem in Theory & Practice

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. t4

t3

t2

t1

F(c,t1) B(c,t1)

F(c,t4) B(c,t4)

F(c,t2) B(c,t2)

F(c,t3) B(c,t3)

c

Page 17: The Traveling Salesman Problem in Theory & Practice

• 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 by entering through the back and leaving through the front.

o cost = B(c,t) + F(c’,t).

t4

t3

t2

t1

F(c,t1) B(c,t1)

B(c,t4)

F(c,t2) B(c,t2)

F(c,t3) B(c,t3)

The Tunneling TSP

F(c’,t4)

B(c’,t4)

c

c’

F(c’,t3) B(c’,t3)

F(c’,t2) B(c’,t2)

F(c,t4)

F(c’,t1) B(c’,t1)

Page 18: The Traveling Salesman Problem in Theory & Practice

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.

Page 19: The Traveling Salesman Problem in Theory & Practice

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.

Page 20: The Traveling Salesman Problem in Theory & Practice

Tours vs. Sets for Tunnel SystemsLemma: 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).

e1,F(c1,t1)

e1,B(c2,t1)

e1,B(c2,t1)t2

t1

c1

c2

c3

c4

e1,F(c3,t1)

e1,F(c3,t2)

e1,B(c4,t2)

e1,B(c4,t1)e2,F(c1,t1)

Page 21: The Traveling Salesman Problem in Theory & Practice

New GoalFind a maximum-weight subset E’ ⊆ E satisfying (1) – (3).Approach: Divide into cases:a) 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).

b) Pick a spanning tree for the p ≤ k tunnels with nonzero degree in (a).• Total number of possibilities is pp-2 [Cayley, 1889].

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’}.• Total number of possibilities over all p-1 edges is O(Np-1) = O(Nk-1).

d) 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.

Page 22: The Traveling Salesman Problem in Theory & Practice

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.

Page 23: The Traveling Salesman Problem in Theory & Practice

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.)

c1

c2

c3

c4

c5

t1,F

t2,F

t1,B

t2,B

t3,F

t3,B

t1

t2 t3

c2 c3

A choice of spanning tree

An assignment of cities to spanning tree edges

The remaining cities each have two edges to each of the ti,F and ti,B tunnel vertices.

Page 24: The Traveling Salesman Problem in Theory & Practice

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.

Page 25: The Traveling Salesman Problem in Theory & Practice

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).

Page 26: The Traveling Salesman Problem in Theory & Practice

Asymptotic Optimality, Much Quicker

An algorithm is “asymptotically optimal” iflimit|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))fOPT(C).

Page 27: The Traveling Salesman Problem in Theory & Practice

y

v

x

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).

t

u

F(x,t)

F(u,t)

B(y,t)

B(v,t)

Page 28: The Traveling Salesman Problem in Theory & Practice

• 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

Page 29: The Traveling Salesman Problem in Theory & Practice

2. Constructing the Hamilton Cycle

– 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 ≥ (mc(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.

x

ya2

a1

a3

a4

a5

C0 C1

Page 30: The Traveling Salesman Problem in Theory & Practice

– 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)fOPT(C),

– as claimed.

2. Constructing the Hamilton Cycle

f

N

2 2d Rect2d Sup

3 3d Rect3d Sup

4 4d Rect4d Sup

10 100

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

Page 31: The Traveling Salesman Problem in Theory & Practice

Euclidean Metric, Revisited

r = Rcos(Θ/2)h = R - r

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.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

From 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

Page 32: The Traveling Salesman Problem in Theory & Practice

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.

Page 33: The Traveling Salesman Problem in Theory & Practice

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 haveTheorem [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.

Page 34: The Traveling Salesman Problem in Theory & Practice