Euclidean TSP: the Idea of Arora's PTAS
Metric TSP is APX-hard: unless P = NP no polynomial algorithm comes within a factor of the optimum (Christofides' Algorithm). For points in the plane with Euclidean distances, Arora (1996, journal version 1998) and, independently, Mitchell (1999) found something much stronger: for every fixed a -approximation in polynomial time, a PTAS. The two shared the 2010 Gödel Prize. The full proof is long and technical; this lesson explains the four ideas behind Arora's scheme, checks the two quantitative steps with programs, and states the result precisely. Treat it as a guided sketch, not a proof.
The four ideas
- Snap to a grid. Rescale so the bounding box has side and move every point to the nearest grid point. Every tour changes by only a small fraction of OPT, and coordinates become small integers.
- Randomly shifted quadtree. Recursively split the (shifted) bounding box into four squares until each square holds at most one point. The tree has depth .
- Portals. On each side of each square place equally spaced portals, and only allow the tour to cross a square's boundary at a portal. Bending the tour to the nearest portals costs little in expectation over the random shift.
- Few crossings and dynamic programming. A patching lemma shows that a tour can be modified, at small extra cost, to cross each side of each square at most times. A tour that is both portal-respecting and -light can be found by dynamic programming over the quadtree: for each square, try every way the tour can enter and leave through its portals, and combine the four children.
Step 1: snapping loses little
Moving every point by at most changes the length of any tour by at most , since each of the edges has two endpoints. The optimal tour of points with bounding box side has length at least . Snapping to a grid of spacing moves each point by at most ; with , the loss is at most , and the grid has only lines in each direction.
The program snaps random points to coarser and coarser grids, finds the optimal tour of the snapped points with the Held-Karp dynamic program, and measures that tour on the original points.
import random
from math import dist, inf, sqrt
def held_karp(pts):
n = len(pts)
D = [[inf] * n for _ in range(1 << n)]
P = [[-1] * n for _ in range(1 << n)]
D[1][0] = 0.0
for S in range(1, 1 << n, 2):
for j in range(n):
if D[S][j] < inf:
for k in range(1, n):
if not S >> k & 1 and D[S][j] + dist(pts[j], pts[k]) < D[S | 1 << k][k]:
D[S | 1 << k][k] = D[S][j] + dist(pts[j], pts[k])
P[S | 1 << k][k] = j
full = (1 << n) - 1
j = min(range(1, n), key=lambda j: D[full][j] + dist(pts[j], pts[0]))
tour, S = [], full
while j >= 0:
tour.append(j)
S, j = S & ~(1 << j), P[S][j]
return tour
length = lambda pts, t: sum(dist(pts[t[i]], pts[t[i - 1]]) for i in range(len(t)))
rng = random.Random(31)
n, L = 9, 100.0
pts = [(rng.uniform(0, L), rng.uniform(0, L)) for _ in range(n)]
opt = length(pts, held_karp(pts))
print(f"OPT on the original points: {opt:.2f}")
for eps in [0.05, 0.2, 0.5, 1.0, 2.0]:
delta = eps * L / (sqrt(2) * n)
snapped = [(round(x / delta) * delta, round(y / delta) * delta) for x, y in pts]
t = held_karp(snapped)
print(f"eps = {eps:4}: grid spacing {delta:5.2f}, {int(L / delta) + 1:3} lines per axis, "
f"tour from snapped points costs {length(pts, t):.2f} ({round(length(pts, t) / opt - 1, 6) + 0.0:+.2%}), bound +{eps / 2:.0%}")OPT on the original points: 270.24
eps = 0.05: grid spacing 0.39, 255 lines per axis, tour from snapped points costs 270.24 (+0.00%), bound +2%
eps = 0.2: grid spacing 1.57, 64 lines per axis, tour from snapped points costs 270.24 (+0.00%), bound +10%
eps = 0.5: grid spacing 3.93, 26 lines per axis, tour from snapped points costs 270.24 (+0.00%), bound +25%
eps = 1.0: grid spacing 7.86, 13 lines per axis, tour from snapped points costs 270.24 (+0.00%), bound +50%
eps = 2.0: grid spacing 15.71, 7 lines per axis, tour from snapped points costs 276.31 (+2.25%), bound +100%
Only very coarse grids change the answer at all, and always by far less than the bound .
Step 3: portals cost little on average
A tour edge that crosses a dissection line at level (a line that first appears when squares of side are created) must be bent to a portal, at most away, which costs at most extra. Deep lines are cheap, but lines near the top of the tree are expensive. The random shift makes the expensive case rare: a given grid line becomes a level- line with probability about , so the expected cost of one crossing is at most
A tour of length crosses the unit grid lines times, so the total expected detour is , which is at most with . Without the random shift an adversary could place many crossings on the middle line, where every detour is large.
The program takes a good tour, applies many random shifts and computes the exact portal detour of every crossing, for several numbers of portals .
import random
from math import dist
rng = random.Random(8)
L = 64 # bounding box after snapping; points at half-integers
pts = [(rng.randrange(L) + 0.5, rng.randrange(L) + 0.5) for _ in range(30)]
def two_opt(pts):
t = list(range(len(pts)))
improved = True
while improved:
improved = False
for i in range(1, len(t) - 1):
for j in range(i + 1, len(t)):
a, b, c, d = pts[t[i - 1]], pts[t[i]], pts[t[j]], pts[t[(j + 1) % len(t)]]
if dist(a, c) + dist(b, d) < dist(a, b) + dist(c, d) - 1e-9:
t[i:j + 1] = reversed(t[i:j + 1])
improved = True
return t
def level_size(c):
"""Side of the squares created when the line at (shifted) coordinate c appears; box side 2L."""
s = 2 * L
while c % s:
s //= 2
return s
def detour(tour, shift, m):
total = 0.0
for i in range(len(tour)):
p, q = pts[tour[i - 1]], pts[tour[i]]
for axis in (0, 1):
a, b = sorted((p[axis] + shift[axis], q[axis] + shift[axis]))
for c in range(int(a) + 1, int(b) + 1): # crossings with integer lines
s = level_size(c)
tpar = (c - shift[axis] - p[axis]) / (q[axis] - p[axis])
y = p[1 - axis] + tpar * (q[1 - axis] - p[1 - axis]) + shift[1 - axis]
gap = s / m
total += 2 * abs(y - round(y / gap) * gap)
return total
tour = two_opt(pts)
T = sum(dist(pts[tour[i]], pts[tour[i - 1]]) for i in range(len(tour)))
shifts = [(rng.randrange(L), rng.randrange(L)) for _ in range(40)]
print(f"tour length {T:.1f}")
for m in [4, 8, 16, 32, 64]:
d = [detour(tour, s, m) for s in shifts]
print(f"m = {m:2} portals per side: average detour {sum(d) / len(d) / T:6.1%} of the tour, worst shift {max(d) / T:6.1%}")tour length 291.4
m = 4 portals per side: average detour 63.6% of the tour, worst shift 75.3%
m = 8 portals per side: average detour 30.8% of the tour, worst shift 37.5%
m = 16 portals per side: average detour 14.8% of the tour, worst shift 19.5%
m = 32 portals per side: average detour 7.0% of the tour, worst shift 9.5%
m = 64 portals per side: average detour 3.4% of the tour, worst shift 4.5%
The average detour falls roughly in proportion to , as the calculation predicts. The worst of the 40 shifts is noticeably worse than the average: the guarantee is a statement about the random shift, and derandomizing means trying all shifts.
Step 4: the dynamic program, and the result
The patching lemma says that if a tour crosses a line segment of length more than twice, the crossings can be reduced to at most two by adding segments of total length along it. Charging these additions to the crossings, again in expectation over the shift, makes the tour -light with at a cost of . For a square of the quadtree, an "interface" lists which of its portals are used (at most ) and how the entry and exit portals are paired up by the pieces of tour inside. There are interfaces per square, squares, and the best solution for each interface is assembled from the four children.
Theorem (Arora, 1998; Mitchell, 1999). For every fixed , a tour of length at most for points in the plane can be found in time (Arora's randomized version; it can be derandomized at a polynomial cost).
- Rao and Smith (1998) reduced the time to for fixed , using spanners.
- In the running time is : still a PTAS for fixed dimension, but when grows like no PTAS exists unless P = NP (Trevisan, 2000).
- The same framework gives PTASs for Euclidean Steiner tree, -median, and many other geometric problems.
Note: No implementation of the full scheme is competitive in practice: the constants hidden in are enormous. Its importance is structural. It shows exactly what geometry buys over general metrics, and the idea of a randomly shifted hierarchical decomposition reappears in metric embeddings into trees (Bartal, 1996; Fakcharoenphol, Rao and Talwar, 2003).
Test yourself
Why does snapping points to a grid of spacing about cost at most a small fraction of OPT?
- Because the grid is fine enough to contain the optimal tour
- Each point moves at most about , so any tour changes by at most about , while OPT is at least
- Because snapping never increases distances
- Because is small
What is the purpose of the random shift of the quadtree?
- To make the quadtree balanced
- To make every line unlikely to be a high-level line, so the expected portal detour per crossing is only
- To randomize the order of the points
- To avoid points on the boundary
Why does Arora's scheme not contradict the APX-hardness of metric TSP?
- It is not polynomial
- Hardness concerns general metrics; the scheme uses the geometry of the plane (or of a fixed-dimensional space)
- It only works on random inputs
- Metric TSP is not APX-hard