introduction to the hamiltonian circuit problem and …gej/publ/nizhny_novgorod.pdf · introduction...

62
Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J¨ ager Christian Albrechts University Kiel Computer Science Institute Germany Mail: [email protected] May 6, 2010 Gerold J¨ ager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 1 / 62

Upload: lydieu

Post on 18-Sep-2018

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Introduction to theHamiltonian Circuit Problem

and the Traveling Salesman Problem

Gerold Jager

Christian Albrechts University KielComputer Science Institute

GermanyMail: [email protected]

May 6, 2010

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 1 / 62

Page 2: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Overview

1 Notations and DefinitionsBasicsNeighbor and DegreePath, Circuit and CycleConnected ComponentsBridgeArticulation Point

2 Eulerian Cycle ProblemDefinition and Elementary ResultsApplication: 7 Bridges of Konigsberg

3 Hamiltonian Circuit ProblemDefinition and ResultsExamples and Necessary ConditionsTheorem of DiracApplication I: Problem of Knight’s TourApplication II: Problem of Mr. No

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 2 / 62

Page 3: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Overview

4 Traveling Salesman ProblemDefinitionImportanceHelsgaun’s Heuristic

5 Own Research: Pseudo Backbone Contraction AlgorithmDescription of the AlgorithmExperimental Results

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 3 / 62

Page 4: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Basics

Graph G = (V ,E ) consists of

vertex set Vedge set E ⊆

(V2

)n := |V |, m := |E |.Let G be finite, i.e., |V | < +∞.

a b

cd

e

f

g h i

Example graph with n = 9 and m = 10

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 4 / 62

Page 5: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Neighbor and Degree

u, v ∈ V neighboring, if {u, v} ∈ E .

Degree of v ∈ V : Number of neighbors of v .Notation: deg(v).

a b

cd

e

f

g h i

deg(c) = 5deg(a) = deg(g) = 3

deg(b) = deg(d) = deg(e) = deg(f ) = 2deg(h) = 1deg(i) = 0

Minimum degree of G : minimum degree over all vertices of G .Notation: δ(G ).

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 5 / 62

Page 6: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Path, Circuit and Cycle

v1, v2, . . . , vk ∈ V , k ≤ n,vi pairwise distinct.P := (v1, v2, . . . , vk): Path.(Notation: Successive vertices are connected by an edge.)

v1, v2, . . . , vk ∈ V , k ≤ n,vi pairwise distinct.C := (v1, v2, . . . , vk , v1): Circuit.

v1, v2, . . . , vk ∈ V ,D := (v1, v2, . . . , vk , v1): Cycle.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 6 / 62

Page 7: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Exercise 1

Task: Find a

a) pathb) circuitc) cycle

with maximum number of vertices in the graph

a b

cd

e

f

g h i

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 7 / 62

Page 8: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Solution:

a b

cd

e

f

g h i

Path (b,a,d,c,e,g,h)

a b

cd

e

f

g h i

Circuit (a,b,c,d,a)

a b

cd

e

f

g h i

Cycle (a,b,c,e,g,f,c,d,a)

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 8 / 62

Page 9: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Connected Components

G is called connected, if a path from v to w exists for each twodifferent vertices v ,w ∈ V .

Remark:Each graph decomposes in k disjoint connected components V1,V2,. . . ,Vk ⊆ V with V = V1 ∪ V2 ∪ · · · ∪ Vk .

For two vertices a connecting path exists, if and only if they arecontained in the same connected component.

In the case k = 1 the graph is connected.

a b

cd

e

f

g h i

j k

2 connected components

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 9 / 62

Page 10: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Bridge

e ∈ E is called bridge, if omitting e increases the number ofconnected components by one.

Exercise 2

Task: How many bridges are contained in the graph

a b

cd

e

f

g h i

j k

Solution:6 bridges: (c , e), (c , f ), (g , h), (h, j), (h, i), (i , k).E.g., without bridge (c , e): 3 connected components.

a b

cd

e

f

g h i

j k

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 10 / 62

Page 11: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Articulation Point

v ∈ V is called articulation point, if omitting v with all edges toneighboring vertices increases the number of connected components.

Exercise 3

Task: How many articulation points are contained in the graph

a b

cd

e

f

g h i

j k

Solution:3 articulation points: c , h, i .E.g., without articulation point c : 4 connected components.

a b

d

e

f

g h i

j k

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 11 / 62

Page 12: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Eulerian Cycle Problem (ECP)

Eulerian Cycle: Cycle traversing all edges.

Eulerian Cycle Problem:

Input.: Connected graph G = (V ,E ).Question: Does in G a Eulerian cycle exist?

Theorem 1: Let G be a graph.G contains a Eulerian cycle.

⇔ G ist connected andeach vertex has even degree.

Theorem 2: Let G = (V ,E ) be a graph.Then in time O(m) a Eulerian cycle can be found in G ,if one exists.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 12 / 62

Page 13: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Leonhard Euler (1736): 7 bridges of Konigsberg in 18-th century.Attention: In graph theoretic sense this is not a bridge!

Question: Does a circular route exist in Konigsberg traversing all bridgesexactly once?

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 13 / 62

Page 14: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

a

b c

d

e f

g

h

Br1

Br1

Br2

Br2

Br3

Br3

Br4

Br4

Br5

Br6

Br7

Model graph of the 7-bridges problem of Konigsberg

Exercise 4

Task: Find a Eulerian cycle in this graph or disprove its existence.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 14 / 62

Page 15: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

a

b c

d

e f

g

h

Solution:

No Eulerian cycle.

Reason: Degree of vertices a, d , g and h is odd.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 15 / 62

Page 16: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Hamiltonian Circuit Problem (HCP)

Hamiltonian Circuit: Circuit containing all n vertices.

Hamiltonian Circuit Problem:

Input.: Graph G = (V ,E ).Question: Does in G a Hamiltonian circuit exist?

Comparison:ECP: Cycle traversing all edges.

Theorem 3: HCP is NP-hart.

Proof: Polynomial reduction from 3-SAT to HCP.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 16 / 62

Page 17: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Exercise 5

Task: Find a Hamiltonian circuit or disprove its existence in the graph

i j

m

olk

p qr

n

gd

b

a

h

ts

e f

c

Sir William Rowan Hamilton (1857): DodecahedronGerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 17 / 62

Page 18: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Solution:

i j

m

olk

p qr

n

gd

b

a

h

ts

e f

c

Hamiltonian circuit: (a,b,d,g,n,r,q,p,k,l,o,m,j,i,c,f,e,s,t,h,a)

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 18 / 62

Page 19: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Exercise 6

Task: Find a

a) Eulerian cycleb) Hamiltonian circuit

or disprove its existence in the graph

a

b c

d

e

Solution:

a) Hamiltonian circuit (a, b, e, c , d , a).b) No Eulerian cycle.

Reason: Degree of vertices a and d is odd.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 19 / 62

Page 20: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Exercise 7

Task: Find a

a) Eulerian cycleb) Hamiltonian circuit

or disprove its existence in the graph

a

b

c

d

e

f

g

Solution:a) No Hamiltonian circuit.

Reason: Vertex c is an articulation point of the graph.⇒ Vertex c has to be traversed twice.

b) Eulerian cycle (a, b, c , e, f , g , c , d , a).

Proposition 1: If a graph G contains an articulation point, then Gcontains no Hamiltonian circuit.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 20 / 62

Page 21: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Exercise 8

Task: Find a Hamiltonian circuit or disprove its existence in the graph

a b

cd

e

f

g h

Solution:

No Hamiltonian circuit.

Reason I: Vertex h has degree 0.

Reason II: Graph is not connected.

Proposition 2: If a graph G contains a vertex of degree 0, then Gcontains no Hamiltonian circuit.

Proposition 3: If a graph G is not connected, then G contains noHamiltonian circuit.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 21 / 62

Page 22: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Exercise 9

Task: Find a Hamiltonian circuit or disprove its existence in the graph

a b

cd

e

f

g

Solution:

No Hamiltonian circuit.

Reason: Vertex g has degree 1.

Proposition 4: If a graph G contains a vertex of degree 1, then Gcontains no Hamiltonian circuit.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 22 / 62

Page 23: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Exercise 10

Task: Find a Hamiltonian circuit or disprove its existence in the graph

a b

cd

e

f

g

h

Solution:

No Hamiltonian circuit.

Reason: Edge (b, e) is a bridge of the graph.

Proposition 5: If a graph G contains a bridge, then G contains noHamiltonian circuit.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 23 / 62

Page 24: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Theorem 4 (Dirac, 1952): Let G = (V ,E ) be a graph with minimumdegree δ(G ).If δ(G ) ≥ n/2, then G contains a Hamiltonian circuit.

Proof: a) Show: G is connected.

b) Choose a path P1 in G .

c) Construct from P1 a circuit C .

d) Show: C is a Hamiltonian circuit.

a) Assume G is not connected.Then a connected component F exists with |F | ≤ n/2.⇒ ∀v ∈ F : deg(v) < n/2. � to δ(G ) ≥ n/2.⇒ G is connected.

b) Choose

P1 := (v1, v2, . . . , vk)

so that the number of vertices k of the path is maximal.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 24 / 62

Page 25: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

c) Let

M := {v1, v2, . . . , vk−1}M1 := {v ∈ M | v is predecessor (on P1) of a neighbor of v1}M2 := {v ∈ M | v is neighbor of vk}

Example: Path P1 for k = 8

v1

v2

v3

v4 v5

v6

v7

v8

v1

v2

v3

v4 v5

v6

v7

v8

It holds v2 ∈ M1;v5 ∈ M1

v1

v2

v3

v4 v5

v6

v7

v8

It holds v2 ∈ M2;v6 ∈ M2

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 25 / 62

Page 26: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

It holds:

(i) Both, v1 and vk have at least n/2 neighbors on P1.

v1

v2

v3

v4 v5

v6

v7

v8x v1

v2

v3

v4 v5

v6

v7

v8 x

� to maximality of P1.

(ii) |M| = k − 1 ≤ n − 1.

(iii) |M1| ≥ n/2.Follows from (i), as vk can be no predecessor on P1.

(iv) |M2| ≥ n/2.Follows from (i), as vk is no neighbor of itself.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 26 / 62

Page 27: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Assume M1 ∩M2 = ∅It follows:

n = n/2 + n/2 ≤ |M1|+ |M2| = |M1 ∪M2| ≤ |M| ≤ n − 1

We have: n ≤ n − 1 �

⇒ M1 ∩M2 6= ∅.

⇒ ∃vi ∈ M1 ∩M2, 1 ≤ i < k,

i.e., {v1, vi+1} ∈ E and {vk , vi} ∈ E .

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 27 / 62

Page 28: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Then C := (v1, vi+1, vi+2, . . . , vk−1, vk , vi , vi−1, . . . , v2, v1) is a circuitwith k vertices.Example: Path P1 for k = 8, i = 4

v1

v2

v3

v4 v5

v6

v7

v8For convenience, renumber the circuit: C = (w1,w2, . . . ,wk ,w1).Example: Cycle C after renumbering for k = 8

w1

w2

w3

w4 w5

w6

w7

w8

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 28 / 62

Page 29: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

d) Assume C is not Hamiltonian.

Then k < n.As by a), the graph is connected, j ∈ N and x ∈ V \ C exist with{x ,wj} ∈ E . Then

P2 := (u,wj ,wj+1, . . . ,wk ,w1,w2, . . . ,wj−1)

is a path with k + 1 vertices.� to maximality of P1

Example: Circuit C for k = 8

w1

w2

w3

w4 w5

w6

w7

w8

x y z

Path P2 with k + 1 = 9 vertices

⇒ C is Hamiltonian. �Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 29 / 62

Page 30: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Exercise 11

Task: Find out whether Theorem of Dirac is sharp,

i.e., construct a graph

where the minimum degree is maximized,

with the condition that the graph contains no Hamiltonian circuit.Consider n = 8.

Solution:

a b

cd

e

f

g

h

Minimum degree δ(G1) = 3 = n/2− 1.

Can be generalized to arbitrary n.

Proposition 6: The degree bound of Theorem of Dirac is sharp.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 30 / 62

Page 31: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Application I: Problem of Knight’s Tour

Possible moves of a knight on a chessboard

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 31 / 62

Page 32: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Question: Does a knight’s tour exist so that the knight

starts at a cell of the chessboard,

traverses each cell of the chessboard exactly once

and finally returns to his starting cell.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 32 / 62

Page 33: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Model graph of the problem of knight’s tour

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 33 / 62

Page 34: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Formal modeling as HCP:

Define G1 = (V ,E1) with |V | = 64

V = {vi ,j | 1 ≤ i , j ≤ 8}

and

E1 ={{vi ,j , vi ′,j ′} | 1 ≤ i , j , i ′, j ′ ≤ 8

∧(|i − i ′| = 2, |j − j ′| = 1

∨ |i − i ′| = 1, |j − j ′| = 2)}

It holds:

A knight’s tour exists.⇔ G1 contains a Hamiltonian circuit.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 34 / 62

Page 35: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Existence of a Hamiltonian circuit?

No vertices of degree 0 or 1.

No bridges.

No articulation points.

Application of Theorem of Dirac not possible: δ(G1) = 2 < 32.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 35 / 62

Page 36: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Solution:

Knight’s tour exists.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 36 / 62

Page 37: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Application II: Problem of Mr. No

Mr. No and Mr. Go are two mystic Japanese detectives.

Mr. No lives in the right lower cell of a chessboard and Mr. Go in theleft upper cell.

Mr. No wants to visit Mr. Go, but before also all different cells of thechessboard.

In each move he may move only one step vertical or one stephorizontal.

Question: Does such a path exist for Mr. No?

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 37 / 62

Page 38: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Possible steps of Mr. No

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 38 / 62

Page 39: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Model graph of the problem of Mr. No

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 39 / 62

Page 40: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Formal modeling as HCP:

Define G2 = (V ,E2) with |V | = 64

V = {vi ,j | 1 ≤ i , j ≤ 8}

and

E2 ={{vi ,j , vi ′,j ′} | 1 ≤ i , j , i ′, j ′ ≤ 8

∧(|i − i ′| = 1, |j − j ′| = 0

∨ |i − i ′| = 0, |j − j ′| = 1

∨ i = 1, j = 8, i ′ = 8, j ′ = 1)}

It holds:

A path exists for Mr. No.⇔ G2 contains a Hamiltonian circuit.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 40 / 62

Page 41: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Existence of a Hamiltonian circuit?

No vertices of degree 0 or 1.

No bridges.

No articulation points.

Application of Theorem of Dirac not possible: δ(G1) = 2 < 32.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 41 / 62

Page 42: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Mr. Go and Mr. No on a chessboardGerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 42 / 62

Page 43: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Trial 1 for a path for Mr. NoGerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 43 / 62

Page 44: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Trial 2 for a path for Mr. NoGerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 44 / 62

Page 45: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Trial 3 for a path for Mr. NoGerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 45 / 62

Page 46: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Exercise 12

Task: Does a path exist for Mr. No?

Solution:

Path does not exist.

Reason:

Each step of Mr. No changes the color of the traversed cell.

When starting on a white cell, he would reach after 63 steps a blackcell.

But the upper left cell is white.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 46 / 62

Page 47: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Traveling Salesman Problem (TSP):

Input: Graph G = (V ,E ), cost function c : E → R.

Find: Hamiltonian circuit or tour (v1, v2, . . . , vn, v1)

with minimum costs

c(vn, v1) +∑n−1

i=1 c(vi , vi+1).

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 47 / 62

Page 48: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Easy to understand.

Hard to solve:

Theorem 5: TSP is NP-hard.

Proof: Polynomial reduction from HCP to TSP.

Many important applications:

public transporttour planningdesign of microchipsgenome sequencing

Gap between

few performance guaranteesphenomenal results

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 48 / 62

Page 49: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Shortest tour through 15.112 cities in Germany

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 49 / 62

Page 50: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

1 Start with an arbitrary vertex.

2 In each step go to the nearest non-traversed vertex.

3 If all vertices are visited, return to the starting point.

4 Use the resulted tour as starting tour for the next steps.

5 For k ≤ n apply a k-OPT step, i.e.:Replace tour edges by non-tour edges so that

the edges are still a tourthe tour is better than the original one

6 Repeat step 5 as long as improving steps can be found.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 50 / 62

Page 51: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Example of a 2-OPT step

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 51 / 62

Page 52: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Best TSP heuristic: [Helsgaun, 1998, improved: 2007]

Main ideas: [Lin, Kernighan, 1971]

Optimizations:1 Choose k small.2 For each vertex consider only the s best neighboring edges, the

so-called candidate system.Helsgaun’s main improvement:For each vertex do not consider the s shortest neighboring edges, butthe s neighboring edges with a criterion based on so-called tolerancesof the minimum spanning tree.

3 Apply t (nearly) independent runs of the algorithm.

The larger the algorithm parameters k, s and t are, the slower, butmore effective is Helsgaun’s Heuristic.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 52 / 62

Page 53: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Joint work withChangxing Dong, Boris Goldengorin, Paul Molitor, Dirk Richter

1 Using known heuristics, e.g., Helsgaun’s Heuristic, find good startingtours.

a b c

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 53 / 62

Page 54: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

2 Find all common edges in these starting tours.

a b c

d

Such edges are called pseudo backbone edges.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 54 / 62

Page 55: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

3 Contract all edges of paths of pseudo backbone edges to one edge.

d e

���������������

���������������

���

���

���������

���������

������������������������������������������������

������������������������������������������������

���������������

���������������

������������������������������

����

����

��������������

��������������

���������

���������

���������

���������

��������������������������������������������������������������������������������

��������������������������������������������������������������������������������ee

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 55 / 62

Page 56: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

4 Create a new (reduced) instance by omitting the vertices, which lie ona path of pseudo backbone edges:

d e

������������

������������

���

���

������������

����������������������������������

����������������������������������

��������������������

������������������������

��

����

������������

������������

��������

���������

���������

������������������������������������������������������������������������

������������������������������������������������������������������������f

Fix the contracted edges, i.e., force them to be in the final tour.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 56 / 62

Page 57: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

5 Apply Helsgaun’s Heuristic to the new instance.

e

������������

������������

���

���

������������

����������������������������������

����������������������������������

��������������������

������������������������

��

����

������������

������������

��������

���������

���������

������������������������������������������������������������������������

������������������������������������������������������������������������f g

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 57 / 62

Page 58: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

6 Re-contract the tour of the new instance to a tour of the originalinstance.

g h

The last tour is the optimum one.

a b c

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 58 / 62

Page 59: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Two advantages:1 Reduction of the set of vertices.2 Fixing of a part of the edges.⇒ Helsgaun’s Heuristic can be applied with larger algorithm parameters k,

s and t than for the original instance.

The algorithm works rather good, if the starting tours are1 good ones2 not too similar

(as otherwise the search space is restricted too strongly)

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 59 / 62

Page 60: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Competition: TSP homepage

(http://www.tsp.gatech.edu/)

Large TSP datasets from practice:for comparison of exact algorithms and heuristics.

74 unsolved example instances:VLSI and national instances

For 18 of 74 instances we have set a new record.

10 of 18 records are still up to date.

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 60 / 62

Page 61: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Our new records

Date # Vertices Date # Vertices

24.05.2006 6,880 14.07.2008 28,53422.10.2006 19,289 14.07.2008 39,60320.03.2008 17,845 14.07.2008 56,76928.03.2008 13,584 19.07.2008 104,81501.04.2008 19,402 14.08.2008 52,05727.05.2008 38,478 14.08.2008 238,02523.06.2008 21,215 10.11.2008 29,51424.06.2008 28,924 12.12.2008 47,60830.06.2008 34,656 26.08.2009 32,892

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 61 / 62

Page 62: Introduction to the Hamiltonian Circuit Problem and …gej/publ/nizhny_novgorod.pdf · Introduction to the Hamiltonian Circuit Problem and the Traveling Salesman Problem Gerold J

Thanks

for yourattention!

Gerold Jager Hamiltonian Circuit Problem and Traveling Salesman Problem May 6, 2010 62 / 62