13
The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof: Dr Gautam Das

The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof:

Embed Size (px)

Citation preview

Page 1: The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof:

The Traveling Salesman Problem Approximation

Rachit Shah

March 3 Class NotesCSE Department

UTA Arlington

CSE 6311 Adv Comp Models and AlgorithmsProf: Dr Gautam Das

Page 2: The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof:

Traveling Salesman Problem

• Traveling Salesman Problem (TSP): Given a complete graph with nonnegative edge costs, Find a minimum cost cycle visiting every vertex exactly once.

• Application (Example): Given a number of cities and the costs of traveling from any city to any other city, what is the cheapest round-trip route that visits each city exactly once and then returns to the starting city

Page 3: The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof:

Triangle Inequality

a + b ≥ c

• For example, cost of an edge as the euclidian distance between two points.

• Metric Traveling Salesman Problem (metric TSP): Given a complete graph with edge costs satisfying triangle inequalities, Find a minimum cost cycle visiting every vertex exactly once.

a

c

b

Page 4: The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof:

Metric TSP approximation

• The cost function satisfies the triangle inequality for all vertices u, v, w in V– c(u,w) <= c(u,v) + c(v,w)

• Eulerian graphs and Eulerian circuits:– Eulerian circuit: cycle that uses each edge exactly

once– Eulerian graph: graph with a Eulerian circuit– An undirected graph is Eulerian iff each vertex has

even degree

Page 5: The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof:

Approximate-TSP-tour (G)

1. Find MST T of G2. Double every edge of the MST to get a

Eulerian graph G’Idea: Get a tour from Minimum spanning tree without increasing its cost too much (at most twice).

3. Find an Eulerian circuit E on G’4. Output the vertices of G in order of

appearance in E

Page 6: The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof:

First let’s compare the optimal solutions of MST and TSP for any problem instance G=(V,E)

Cost (Opt. TSP sol-n) Cost (of this tree) Cost (Opt. MST sol-n)≥ ≥

Optimal TSP sol-n Optimal MST sol-nA tree obtained from the tour

(*)

Page 7: The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof:

1

2

3

4

5

6

TSP)alcost(optim2cost(MST)2

c(e)2c(e) cost

MST e - TSP

earcs

inequality Triangle

e arcs dashed

What is the cost of the tour compared to the cost of MST?

Page 8: The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof:

Analysis

• This is a 2 approximation algorithm• MST < Euler Cycle = 2 * MST <= 2.0 TSP

• Can we improve this?– The previous algorithm was a factor 2 algorithm.

• Recall Step 2:

Double every edge of the MST to get a Eulerian graph G’

– If we can work avoid this, we could possibly have a better solution !

Page 9: The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof:

Perfect Matching

• Matching: a matching is a subset M of E such that for all vertices v in V, at most one edge is incident on v.

• Perfect Matching: is a matching M such that for all vertices v in V exactly one edge of M is incident on v.

Page 10: The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof:

Minimum Weight Matching

• Perfect matching with minimum sum of weights

• Input: Complete weighted graph s, |v| is even

• Output: A pair of values (vi, vj) such that the sum of weights is smallest.

Page 11: The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof:

1.5 approximation algorithm

(Known as Christofides Heuristics)

1. Find a MST T of G

2. Find a minimum weight (perfect) matching M on the set of odd degree vertices in T.

3. Add M to T to get the Eulerian graph G’

4. Find an Eulerian circuit E on G’ by skipping vertices already seen (shortcutting)

5. Output the vertices of G in order of appearance in E

Page 12: The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof:

Step 2: Even nodes with odd degree??

• How can I know that I always have even number of nodes, which have odd degree, for me to do the MATCHING?

• Let Sum(d) = 2m, where m= number of edges. Therefore Sum(d) is even.

• Let SumEven(d) to be the sum of degrees of the vertices which have even degree, SumEven(d) is also even.

• Therefore SumOdd(d)=Sum(d)-SumEven(d) = 2k, k=1,2,…, which means that the sum of degrees of the vertices which have odd degree each is also an even number. Thus there are even numbers of vertices which have odd number of degree.

Page 13: The Traveling Salesman Problem Approximation Rachit Shah March 3 Class Notes CSE Department UTA Arlington CSE 6311 Adv Comp Models and Algorithms Prof:

AnalysisTSP = match1 + match2 (we can divide TSP in two mutually

exclusive matchings)MWM <= min{ match1, match2}

Match1 + match 2 = TSP MWM + MWM <= TSP (MWM <= match1 and MWM <=

match2) MWM <= .5 TSP

MWM <= .5 TSP

MST < Euler Cycle = MST + MWM <= TSP + .5 TSP = 1.5 TSP