The TSP NPCompleteness Approximation and Hardness of Approximation
















































![gap-TSP[ ] ¢ ¢ Instance: a complete weighted undirected graph G=(V, E). Problem: to gap-TSP[ ] ¢ ¢ Instance: a complete weighted undirected graph G=(V, E). Problem: to](https://slidetodoc.com/presentation_image_h/758f5e0791d75bc3e0e9712b016e24b9/image-49.jpg)



![gap-TSP is NP-hard Theorem: For any constant 1, HAM-CYCLE p gap-TSP[ ]. Proof Idea: gap-TSP is NP-hard Theorem: For any constant 1, HAM-CYCLE p gap-TSP[ ]. Proof Idea:](https://slidetodoc.com/presentation_image_h/758f5e0791d75bc3e0e9712b016e24b9/image-53.jpg)

![Approximating TSP is NPhard gap-TSP[ ] is NP-hard Approximating TSP within factor is NP-hard Approximating TSP is NPhard gap-TSP[ ] is NP-hard Approximating TSP within factor is NP-hard](https://slidetodoc.com/presentation_image_h/758f5e0791d75bc3e0e9712b016e24b9/image-55.jpg)


- Slides: 57
* The TSP : NP-Completeness Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970) Based upon slides of Dana Moshkovitz, Kevin Wayne and others + some old slides 1 *TSP = Traveling Salesman Problem
A related problem: HC ¢ 2 HAM-CYCLE: given an undirected graph G = (V, E), does there exist a simple cycle that contains every node in V. YES: vertices and faces of a dodecahedron.
Hamiltonian Cycle ¢ HAM-CYCLE: given an undirected graph G = (V, E), does there exist a simple cycle that contains every node in V. 1 1' 2 2' 3 3' 4 4' 5 3 NO: bipartite graph with odd number of nodes.
Directed Hamiltonian Cycle ¢ DIR-HAM-CYCLE: given a digraph G = (V, E), does there exists a simple directed cycle that contains every node in V? ¢ Claim. DIR-HAM-CYCLE P HAM-CYCLE. ¢ Pf. Given a directed graph G = (V, E), construct an undirected graph G' with 3 n nodes. Each node splits up into an output node, a regular node and an input node. 4
Example ain a aout a cin c b G bin b bout 5 c cout
Example ain a aout a cin c b G bin b bout 6 c cout
Directed Hamiltonian Cycle ¢ Claim. G has a Hamiltonian cycle iff G' does. ¢ Pf. l Suppose G has a directed Hamiltonian cycle . l Then G' has an undirected Hamiltonian cycle (same order). ¢ Pf. l Suppose G' has an undirected Hamiltonian cycle '. l ' must visit nodes in G' using one of following two orders: …, B, G, R, B, … …, B, R, G, B, … l Blue nodes in ' make up directed Hamiltonian cycle in G, or reverse of one. ▪ 7
3 -SAT Reduces to Directed Hamiltonian Cycle ¢ Claim. 3 -SAT P DIR-HAM-CYCLE. ¢ Pf. Given an instance of 3 -SAT, we construct an instance of DIR-HAM-CYCLE that has a Hamiltonian cycle iff is satisfiable. ¢ Construction. First, create graph that has 2 n Hamiltonian cycles which correspond in a natural way to 2 n possible truth assignments. 8
3 -SAT Reduces to Directed Hamiltonian Cycle ¢ Construction. Given 3 -SAT instance with n variables xi and k clauses. l xi = 1 l Construct G to have 2 n Hamiltonian cycles. Intuition: traverse path i from left to right set variable xi = 1. s x 1 x 2 x 3 9 t 3 k + 3
3 -SAT Reduces to Directed Hamiltonian Cycle ¢ Construction. Given 3 -SAT instance with n variables xi and k clauses. l For each clause: add a node and 6 edges. clause node s x 1 x 2 x 3 10 t
3 -SAT Reduces to Directed Hamiltonian Cycle ¢ Claim. is satisfiable iff G has a Hamiltonian cycle. ¢ Pf. l Suppose 3 -SAT instance has satisfying assignment x*. l Then, define Hamiltonian cycle in G as follows: • if x*i = 1, traverse row i from left to right • if x*i = 0, traverse row i from right to left • for each clause Cj , there will be at least one row i in which we are going in "correct" direction to splice node Cj into tour 11
3 -SAT Reduces to Directed Hamiltonian Cycle ¢ Claim. is satisfiable iff G has a Hamiltonian cycle. ¢ Pf. l Suppose G has a Hamiltonian cycle . l If enters clause node Cj , it must depart on mate edge. • thus, nodes immediately before and after Cj are connected by an edge e in G • removing Cj from cycle, and replacing it with edge e yields Hamiltonian cycle on G - { Cj } l Continuing in this way, we are left with Hamiltonian cycle ' in G - { C 1 , C 2 , . . . , Ck }. l Set x*i = 1 iff ' traverses row i left to right. l Since visits each clause node Cj , at least one of the paths is traversed in "correct" direction, and each clause is satisfied. ▪ 12
3 -SAT P Directed HC P HC ¢ Objectives: l ¢ Overview: l l 13 To explore the Traveling Salesman Problem. TSP: Examples and Defn. Is TSP NP-complete? Approximation algorithm for special cases Hardness of Approximation in general.
Traveling Salesman Problem A Tour around USA ¢ 14 TSP. Given a set of n cities and a pairwise distance function d(u, v), is there a tour of length D? All 13, 509 cities in US with a population of at least 500 Reference: http: //www. tsp. gatech. edu
Traveling Salesperson Problem ¢ 15 TSP. Given a set of n cities and a pairwise distance function d(u, v), is there a tour of length D? Optimal TSP tour Reference: http: //www. tsp. gatech. edu
Traveling Salesperson Problem ¢ 16 TSP. Given a set of n cities and a pairwise distance function d(u, v), is there a tour of length D? 11, 849 holes to drill in a programmed logic array Reference: http: //www. tsp. gatech. edu
Traveling Salesperson Problem ¢ 17 TSP. Given a set of n cities and a pairwise distance function d(u, v), is there a tour of length D? Optimal TSP tour Reference: http: //www. tsp. gatech. edu
TSP ¢ Given a weighted graph G=(V, E) V = Vertices = Cities E = Edges = Distances between cities ¢ 18 Find the shortest tour that visits all cities
3 TSP 1 3 4 2 10 5 ¢ Instance: A complete weighted undirected graph G=(V, E) (all weights are non-negative). ¢ Problem: To find a Hamiltonian cycle of minimal cost. 19
Naïve Solution ¢ Try all possible tours and pick the minimum ¢ Dynamic Programming Definitely we need something better 20
Approximation Algorithms A “good” algorithm is one whose running time is polynomial in the size of the input. ¢ Any hope of doing something in polynomial time for NP-Complete problems? ¢ 21
c-approximation algorithm ¢ ¢ The algorithm runs in polynomial time The algorithm always produces a solution which is within a factor of c of the value of the optimal solution c (1/c) A(x) ≤ Opt(x) ≤ A(x) 22 For all inputs x. OPT(x) here denotes the optimal value of the minimization problem
c-approximation algorithm ¢ ¢ The algorithm runs in polynomial time The algorithm always produces a solution which is within a factor of c of the value of the optimal solution c c A(x) ≥ Opt(x) ≥ A(x) 23 For all inputs x. OPT(x) here denotes the optimal value of the maximization problem
So why do we study Approximation Algorithms ¢ ¢ 24 As algorithms to solve problems which need a solution As a mathematically rigorous way of studying heuristics Because they are fun! Because it tells us how hard problems are
Vertex Cover ¢ 25 Any guess on how to design approximation algorithms for vertex cover?
Vertex Cover: Greedy 26
Vertex Cover: Greedy 27
Vertex Cover: Greedy 28
Vertex Cover: Greedy 29
Vertex Cover: Greedy 30
Vertex Cover: Greedy VC Approx = 8 Opt = 6 Factor 4/3 31 HW 2 Problem : Example can be extended to O(log n) approximation
A Simpler Approximation Algorithm Choose an edge e in G ¢ Add both endpoints to the Approximate VC ¢ Remove e from G and all incident edges and repeat. ¢ Cover generated is at most twice the optimal cover! 32 • Nothing better than 2 -factor known. • If P <> NP, there is no poly-time algorithm that achieves an approximation factor better than 1. 1666 [Has 97].
What Next? ¢ We’ll show an approximation algorithm for TSP, with approximation factor 2 for cost functions that satisfy a certain property. 33
Polynomial Algorithm for TSP? What about the greedy strategy: At any point, choose the closest vertex not explored yet? 34
The Greedy Strategy Fails 10 2 5 12 3 1 35 0
The Greedy Strategy Fails 10 2 5 12 3 1 36 0
Don’t be greedy Another Example Always! Greedy strategy fails -11 -5 37 -1 0 1 3 Even monkeys can do better than this !!! 7
TSP is NP-hard The corresponding decision problem: ¢ Instance: a complete weighted undirected graph G=(V, E) and a number k. ¢ Problem: to find a Hamiltonian path whose cost is at most k. 38
TSP is NP-hard Theorem: HAM-CYCLE p TSP. Proof: By the straightforward efficient reduction illustrated below: 1 1 cn 1 HAM-CYCLE 39 TSP n = k = |V|
TSP Is a minimization problem. ¢ We want a 2 -approximation algorithm ¢ But only for the case when the cost function satisfies the triangle inequality. ¢ 40
The Triangle Inequality Cost Function: Let c(x, y) be the cost of going from city x to city y. ¢ Triangle Inequality: In most situations, going from x to y directly is no more expensive than going from x to y via an intermediate place z. ¢ 41
The Triangle Inequality Definition: We’ll say the cost function c satisfies the triangle inequality, if x, y, z V : c(x, z)+c(z, y) c(x, y) x 42 z y
Approximation Algorithm 1. Grow a Minimum Spanning Tree (MST) for G. 2. Return the cycle resulting from a preorder walk on that tree. 43
Demonstration and Analysis The cost of a minimal Hamiltonian cycle the cost of a MST 44
Demonstration and Analysis The cost of a preorder walk is twice the cost of the tree 45
Demonstration and Analysis Due to the triangle inequality, the Hamiltonian cycle is not worse. 46
The Bottom Line optimal HAM cycle 47 MST = ½· preorder walk ½· our HAM cycle
What About the General Case? ¢ ¢ We’ll show TSP cannot be approximated within any constant factor 1 By showing the corresponding gap version is NP-hard. Inapproximability 48
gap-TSP[ ] ¢ ¢ Instance: a complete weighted undirected graph G=(V, E). Problem: to distinguish between the following two cases: There exists a Hamiltonian cycle, whose cost is at most |V|. The cost of every Hamiltonian cycle is more than |V|. 49
Instances 1 1 1 min cost |V| 0 1 0 +1 0 50
What Should an Algorithm for gap-TSP Return? YES! NO! |V| DON’T-CARE. . . gap 51 min cost |V|
gap-TSP & Approximation Observation: Efficient approximation of factor for TSP implies an efficient algorithm for gap-TSP[ ]. 52
gap-TSP is NP-hard Theorem: For any constant 1, HAM-CYCLE p gap-TSP[ ]. Proof Idea: Edges from G cost 1. Other edges cost much more. 53
The Reduction Illustrated 1 1 |V|+1 1 1 HAM-CYCLE Verify (a) correctness (b) efficiency 54 gap-TSP |V|+1
Approximating TSP is NPhard gap-TSP[ ] is NP-hard Approximating TSP within factor is NP-hard 55
Summary ¢ ¢ ¢ 56 We’ve studied the Traveling Salesman Problem (TSP). We’ve seen it is NP-hard. Nevertheless, when the cost function satisfies the triangle inequality, there exists an approximation algorithm with ratio-bound 2.
Summary ¢ ¢ 57 For the general case we’ve proven there is probably no efficient approximation algorithm for TSP. Moreover, we’ve demonstrated a generic method for showing approximation problems are NP-hard.

























































