From theory to practice in k-OPT heuristic for Travelling Salesman - - PowerPoint PPT Presentation

from theory to practice in k opt heuristic for travelling
SMART_READER_LITE
LIVE PREVIEW

From theory to practice in k-OPT heuristic for Travelling Salesman - - PowerPoint PPT Presentation

From theory to practice in k-OPT heuristic for Travelling Salesman Problem Lukasz Kowalik la and Kamil (joint work with Marek Cygan, Arkadiusz Soca Zy la) Lukasz Kowalik From theory to practice in k-OPT heuristic for TSP


slide-1
SLIDE 1

From theory to practice in k-OPT heuristic for Travelling Salesman Problem

  • Lukasz Kowalik

(joint work with Marek Cygan, Arkadiusz Soca la and Kamil ˙ Zy la)

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-2
SLIDE 2

Traveling Salesman Problem (TSP)

Input

complete undirected graph G = (V , E) and a weight function w : E → N.

Problem

Find a tour (Hamiltonian cycle) of minimum weight.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-3
SLIDE 3

Traveling Salesman Problem (TSP)

Input

complete undirected graph G = (V , E) and a weight function w : E → N.

Problem

Find a tour (Hamiltonian cycle) of minimum weight.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-4
SLIDE 4

The shortest tour catching all San Francisco pokemons

(from http://www.math.uwaterloo.ca/tsp/poke/)

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-5
SLIDE 5

Solving TSP

◮ Problem is NP-hard ◮ Best exact algorithm in time 2nnO(1). ◮ No approximation possible in general (unless P=NP) ◮ Some nice approximation algorithm under additional assumptions

◮ w is a metric: 1.5-approximation (Christofides 1976) ◮ Euclidean metric: a PTAS (Arora 1996) ◮ Graphic metric: 1.4-approximation (Sebo, Vygen, 2012)

◮ In practice: people use heuristics.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-6
SLIDE 6

k-OPT local search heuristic

  • 1. H0 := arbitrary Hamiltonian cycle.
  • 2. As long as possible, get a better cycle Hi by means of the

k-move operation. → → → · · ·

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-7
SLIDE 7

k-move

For a tour H, a k-move is defined by a pair (E −, E +) such that ◮ |E −| = |E +| = k and ◮ H′ = H \ E − ∪ E + is a Hamiltonian cycle. Example for k = 3: k-move is improving when w(H′) < w(H).

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-8
SLIDE 8

k-move

For a tour H, a k-move is defined by a pair (E −, E +) such that ◮ |E −| = |E +| = k and ◮ H′ = H \ E − ∪ E + is a Hamiltonian cycle. Example for k = 3: k-move is improving when w(H′) < w(H).

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-9
SLIDE 9

k-move

For a tour H, a k-move is defined by a pair (E −, E +) such that ◮ |E −| = |E +| = k and ◮ H′ = H \ E − ∪ E + is a Hamiltonian cycle. Example for k = 3: k-move is improving when w(H′) < w(H).

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-10
SLIDE 10

k-move

For a tour H, a k-move is defined by a pair (E −, E +) such that ◮ |E −| = |E +| = k and ◮ H′ = H \ E − ∪ E + is a Hamiltonian cycle. Example for k = 3: k-move is improving when w(H′) < w(H).

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-11
SLIDE 11

k-move

For a tour H, a k-move is defined by a pair (E −, E +) such that ◮ |E −| = |E +| = k and ◮ H′ = H \ E − ∪ E + is a Hamiltonian cycle. Example for k = 3: k-move is improving when w(H′) < w(H).

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-12
SLIDE 12

k-OPT heuristic

Practice

An implementation of a variant, called Lin-Kernighan heuristic solves 80K-vertex instances optimally (Hellsgaun ’09).

Theory

Interesting results (lower, upper bounds) on ◮ quality of local optima (e.g. Chandra et al, SICOMP’99), ◮ number of steps needed to find local optimum (e.g., Johnson et al, JCSS’88), ◮ smoothed analysis of 2-opt (e.g. K¨ unnemann and B. Manthey, ICALP’15).

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-13
SLIDE 13

Today’s question How fast can we perform a single step, i.e., How fast can we find an improving k-move?

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-14
SLIDE 14

Today’s question

k-opt Optimization

Input: symmetric function w : V 2 → N, a Hamiltonian cycle H Output: a k-move that maximizes improvement over H.

k-opt Detection

Output: Is there a k-move improving over H?

Upper bounds

◮ O(nk) exhaustive search,

Lower bounds

◮ W [1]-hard [Marx ’08] ◮ no no(k/ log k) algorithm under ETH [Guo et al. ’13] ◮ no o(n2) algorithm for k = 2 (folklore),

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-15
SLIDE 15

Today’s question

k-opt Optimization

Input: symmetric function w : V 2 → N, a Hamiltonian cycle H Output: a k-move that maximizes improvement over H.

k-opt Detection

Output: Is there a k-move improving over H?

Upper bounds

◮ O(nk) exhaustive search, ◮ O(n⌊2k/3⌋+1) time, O(n) additional space [de Berg, Buchin, Jansen, Woeginger ’16]

Lower bounds

◮ W [1]-hard [Marx ’08] ◮ no no(k/ log k) algorithm under ETH [Guo et al. ’13] ◮ no o(n2) algorithm for k = 2 (folklore), ◮ if o(n2.99) algorithm for k = 3, then APSP in time o(n2.99) [de Berg et al].

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-16
SLIDE 16

Part I: Theory

(joint work with Marek Cygan and Arkadiusz Soca la)

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-17
SLIDE 17

Our results

Theorem

For every fixed integer k, k-opt Optimization can be solved in time O(n(1/4+ǫk)k) and space O(n(1/8+ǫk)k), where limk→∞ ǫk = 0.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-18
SLIDE 18

Our results

Theorem

For every fixed integer k, k-opt Optimization can be solved in time O(n(1/4+ǫk)k) and space O(n(1/8+ǫk)k), where limk→∞ ǫk = 0.

Values of ǫk (computed by a program)

k 3 4 5 6 7 8 de Berg et al. O(n3) O(n3) O(n4) O(n5) O(n5) O(n6)

  • ur algorithm

O(n3.4) O(n4) O(n4.25) O(n4 2

3 )

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-19
SLIDE 19

Our results

Theorem

For every fixed integer k, k-opt Optimization can be solved in time O(n(1/4+ǫk)k) and space O(n(1/8+ǫk)k), where limk→∞ ǫk = 0.

Values of ǫk (computed by a program)

k 3 4 5 6 7 8 de Berg et al. O(n3) O(n3) O(n4) O(n5) O(n5) O(n6)

  • ur algorithm

O(n3.4) O(n4) O(n4.25) O(n4 2

3 )

Theorem

If there is ǫ > 0 such that 4-opt Detection admits an algorithm in time O(n3−ǫ · polylog(M)), then there is δ > 0 such that All Pairs Shortest Paths admits an algorithm in time O(n3−δ · polylog(M)), assuming integer weights from {−M, . . . , M}.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-20
SLIDE 20

An equivalent representation of k-move

(The most intuitive) representation of k-move

A pair (E −, E +), where E − ⊆ H, E + ⊆ E(G)

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-21
SLIDE 21

An equivalent representation of k-move

(The most intuitive) representation of k-move

A pair (E −, E +), where E − ⊆ H, E + ⊆ E(G) e4 e3 e

1

e10 e8 e

7

e

6

e5 e

2

e9

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-22
SLIDE 22

An equivalent representation of k-move

(The most intuitive) representation of k-move

A pair (E −, E +), where E − ⊆ H, E + ⊆ E(G) e4 e3 e

1

e10 e8 e

7

e

6

e5 e

2

e9 f (1) = 2 f (2) = 5 f (3) = 9

A more useful representation: a pair (f , )

◮ an embedding f : {1, . . . , k} → {1, . . . , n}

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-23
SLIDE 23

An equivalent representation of k-move

(The most intuitive) representation of k-move

A pair (E −, E +), where E − ⊆ H, E + ⊆ E(G)

1 2 3 4 5 6

e4 e3 e

1

e10 e8 e

7

e

6

e5 e

2

e9 f (1) = 2 f (2) = 5 f (3) = 9 M = {13, 25, 46}

A more useful representation: a pair (f , M)

◮ an embedding f : {1, . . . , k} → {1, . . . , n} ◮ connection pattern: a perfect matching M on {1, .., 2k}

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-24
SLIDE 24

de Berg et al.’s idea

1 2 3 4 5 6

f (1) = 2 f (2) = 5 f (3) = 9 M = {13, 25, 46}

Observation 1

Now we can specify a connection pattern M before specifying an embedding f .

Observation 2

There are only O((2k)!) connection patterns, i.e., O(1) for fixed k.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-25
SLIDE 25

de Berg et al.’s idea

1 2 3 4 5 6

f (1) = 2 f (2) = 5 f (3) = 9 M = {13, 25, 46}

Idea

◮ For each of the O((2k)!) connection patterns M, find the embedding fM which maximizes weight improvement. ◮ Fixing M allows for exploiting the structure of the solution. From now on, assume M is fixed.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-26
SLIDE 26

Key notion: the dependence graph DM

V (DM) = [k]. Vertex i corresponds to the i-th deleted edge from the Hamiltonian cycle e1e2 · · · en. E(DM) = O ∪ IM, where O = {12, 23, . . . , (k − 1)k} ◮ Edge j(j + 1) ∈ O represents the property f (j) < f (j + 1). ◮ IM is defined by M. Edge ij ∈ IM means that the cost of embedding i-the edge depends on f (j).

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-27
SLIDE 27

E(DM) = O ∪ IM

◮ O = {12, 23, . . . , (k − 1)k} ◮ Get IM from M by identifying 2i − 1 with 2i for i ∈ [k]: IM = {ij : i′j′ ∈ M, i′ ∈ {2i − 1, 2i}, j′ ∈ {2j − 1, 2j}}

1 2 3 4 5 6 1 2 3 4 5 6

1 2 3 1 2 3 D = ([3], O ∪ IM)

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-28
SLIDE 28

E(DM) = O ∪ IM

◮ O = {12, 23, . . . , (k − 1)k} ◮ Get IM from M by identifying 2i − 1 with 2i for i ∈ [k]: IM = {ij : i′j′ ∈ M, i′ ∈ {2i − 1, 2i}, j′ ∈ {2j − 1, 2j}}

1 2 3 4 5 6 7 8 1 2 3 4 5 6 7 8

1 2 3 4 1 2 3 4 D = ([4], O ∪ IM)

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-29
SLIDE 29

The algorithm of de Berg, Buchin, Jansen and Woeginger

1 2 3 4 D = ([4], O ∪ IM)

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-30
SLIDE 30

The algorithm of de Berg, Buchin, Jansen and Woeginger

1 2 3 4 D = ([4], O ∪ IM)

  • 1. Find a minimum vertex cover A of IM
  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-31
SLIDE 31

The algorithm of de Berg, Buchin, Jansen and Woeginger

1 2 3 4 D = ([4], O ∪ IM)

  • 1. Find a minimum vertex cover A of IM
  • 2. Embed A in all n|A| ways
  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-32
SLIDE 32

The algorithm of de Berg, Buchin, Jansen and Woeginger

1 2 3 4 D = ([4], O ∪ IM)

  • 1. Find a minimum vertex cover A of IM
  • 2. Embed A in all n|A| ways
  • 3. Dependence graph of the rest D′ has only some edges of O.

D′ is a collection of paths so we can find optimal embedding in O(nk) time using dynamic programming. We have |A| ≤ ⌊2/3k⌋ (worst case: IM is a collection of 3-cycles). Hence, time is O(n⌊2/3k⌋+1k) for every connection pattern.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-33
SLIDE 33

Another possible algorithm

1 2 3 4 D = ([4], O ∪ IM)

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-34
SLIDE 34

Another possible algorithm

1 2 3 4 D = ([4], O ∪ IM)

  • 1. Embed 2, 4, . . . , 2⌊k/2⌋ in all n⌊k/2⌋ ways
  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-35
SLIDE 35

Another possible algorithm

1 2 3 4 D = ([4], O ∪ IM)

  • 1. Embed 2, 4, . . . , 2⌊k/2⌋ in all n⌊k/2⌋ ways
  • 2. Dependence graph of the rest D′ has only some edges of IM.

D′ is a collection of cycles and paths so we can find optimal embedding in O(n3) time using dynamic programming. Hence, time is O(n⌊k/2⌋+3) for every connection pattern.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-36
SLIDE 36
  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-37
SLIDE 37

Tree decompositions and treewidth

Graph G = (V , E) Tree decomposition of G c b a f e d i h g bdef defh abde bcf dhg ehfi Tree decomposition is a tree of bags (subsets of V )

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-38
SLIDE 38

Tree decompositions and treewidth

Graph G = (V , E) Tree decomposition of G c b a f e d i h g bdef defh abde bcf dhg ehfi Tree decomposition is a tree of bags (subsets of V ) such that ◮ For every edge uv ∈ E some bag contains u and v

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-39
SLIDE 39

Tree decompositions and treewidth

Graph G = (V , E) Tree decomposition of G c b a f e d i h g bdef defh abde bcf dhg ehfi bdef defh abde dhg Tree decomposition is a tree of bags (subsets of V ) such that ◮ For every edge uv ∈ E some bag contains u and v ◮ For every vertex v ∈ V bags containing v form nonempty subtree (connected!)

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-40
SLIDE 40

Tree decompositions and treewidth

Graph G = (V , E) Tree decomposition of G c b a f e d i h g bdef defh abde bcf dhg ehfi Tree decomposition is a tree of bags (subsets of V ) such that ◮ For every edge uv ∈ E some bag contains u and v ◮ For every vertex v ∈ V bags containing v form nonempty subtree (connected!) Width of the decomposition: maximum bag size −1 (here: 3). Treewidth of G: minimum width of a decomposition of G .

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-41
SLIDE 41

Dynamic programming

For every node t of a tree decomposition of the graph DM: ◮ Xt = the bag at t, ◮ Vt = union of all bags in the subtree rooted at t. Xt Vt For every node t and partial embedding f : Xt → [n], compute Tt[f ] = max

g:Vt→[n] g|Xt =f

gainM(g). in the bottom-up fashion.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-42
SLIDE 42

Dynamic programming: example

1 2 3 4 D = ([4], O ∪ IM) 234 23 123 T123[f ] = w(ef (1)) + w(ef (2)) + w(ef (3)) − w(E +

f ,M)

T23[f ] = max

g:{1,2,3}→[n] g|{2,3}=f

T123[g]. T234[f ] = T23[f |{2,3}] + w(ef (4)) − w(E +

f ,M \ E + f |{2,3},M)

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-43
SLIDE 43

The O(n(1/3+ǫk)k)-time algorithm

Theorem

Given a connection pattern M, the best k-move (f , M) can be found in time ntw(DM)+1k2 + 2k.

Theorem (Fomin et al. 2009)

Treewidth a k-vertex graph of maximum degree 4 is bounded by ( 1

3 + ǫk)k, where limk→∞ ǫk = 0.

Corollary

For every fixed integer k, k-opt Optimization can be solved in time O(n(1/3+ǫk)k), where limk→∞ ǫk = 0.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-44
SLIDE 44

One more idea: bucketing

Divide the n edges of the Hamiltonian cycle into n1/4 buckets of size s = n3/4. e1, e2, . . . , es es+1, . . . , e2s e2s+1, . . . , e3s e3s+1, . . . , en

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-45
SLIDE 45

One more idea: bucketing

Divide the n edges of the Hamiltonian cycle into n1/4 buckets of size s = n3/4. e1, e2, . . . , es es+1, . . . , e2s e2s+1, . . . , e3s e3s+1, . . . , en 1 2 3 4 Go through all assignments b : [k] → [n1/4] of the k edges to buckets.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-46
SLIDE 46

One more idea: bucketing

Divide the n edges of the Hamiltonian cycle into n1/4 buckets of size s = n3/4. e1, e2, . . . , es es+1, . . . , e2s e2s+1, . . . , e3s e3s+1, . . . , en 1 2 3 4 Go through all assignments b : [k] → [n1/4] of the k edges to buckets. ◮ Edges of O in DM between buckets no longer needed: 1 2 3 4 DM,b = ([4], O ∪ IM)

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-47
SLIDE 47

One more idea: bucketing

Divide the n edges of the Hamiltonian cycle into n1/4 buckets of size s = n3/4. e1, e2, . . . , es es+1, . . . , e2s e2s+1, . . . , e3s e3s+1, . . . , en 1 2 3 4 Go through all assignments b : [k] → [n1/4] of the k edges to buckets. ◮ Edges of O in DM between buckets no longer needed: 1 2 3 4 DM,b = ([4], O ∪ IM) ◮ Dynamic programming works faster, in time O(n

3 4 (tw(DM,b)+1))

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-48
SLIDE 48

One more idea: bucketing

Divide the n edges of the Hamiltonian cycle into n1/4 buckets of size s = n3/4. e1, e2, . . . , es es+1, . . . , e2s e2s+1, . . . , e3s e3s+1, . . . , en 1 2 3 4 Go through all assignments b : [k] → [n1/4] of the k edges to buckets. ◮ Edges of O in DM between buckets no longer needed: 1 2 3 4 DM,b = ([4], O ∪ IM) ◮ Dynamic programming works faster, in time O(n

3 4 (tw(DM,b)+1))

◮ Price: many bucket assignments to consider.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-49
SLIDE 49

The O(n(1/4+ǫk)k)-time algorithm

Plugging in the bucketing idea gives our main result (calculations skipped).

Theorem

For every fixed integer k, k-opt Optimization can be solved in time O(n(1/4+ǫk)k), where limk→∞ ǫk = 0.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-50
SLIDE 50

Part II: Practice

(joint work with Marek Cygan and Kamil ˙ Zy la)

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-51
SLIDE 51

A new heuristic based on theory

(k, t)-OPT heuristic

For every connection pattern M, find the best k-move, restricted

  • nly to the k-moves with dependence graph DM of treewidth at

most t.

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-52
SLIDE 52

Some statistics

tw k = 2 3 4 5 6 7 8 9 1 1 1 1 1 2 1 4 11 37 106 334 1004 3 1 11 90 645 4423 29234 4 2 71 1444 22303 5 11

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP

slide-53
SLIDE 53

Some thoughts

Possible goals ◮ (minor:) show an improvement over 2-OPT, 3-OPT, ◮ (major:) add as an element of a state-of-the-art solver, check if it helps. Some ideas ◮ A question to address: How one should control k, t (bound

  • n treewidth) and n (length of a fragment of the tour) during

the whole local search process? (Increase parameters when stuck?) ◮ Make sure space usage is relatively low (embed some edges by brute-force? use bucketing?)

  • Lukasz Kowalik

From theory to practice in k-OPT heuristic for TSP