1 The TSP : NP-Completeness Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell.

Slides:



Advertisements
Similar presentations
Design and Analysis of Algorithms Approximation algorithms for NP-complete problems Haidong Xue Summer 2012, at GSU.
Advertisements

Approximation Algorithms for TSP
1 ©D.Moshkovitz Complexity The Traveling Salesman Problem.
1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell ( )
1 NP-Complete Problems. 2 We discuss some hard problems:  how hard? (computational complexity)  what makes them hard?  any solutions? Definitions 
Complexity ©D Moshkovitz 1 Approximation Algorithms Is Close Enough Good Enough?
Combinatorial Algorithms
CSC5160 Topics in Algorithms Tutorial 2 Introduction to NP-Complete Problems Feb Jerry Le
Computability and Complexity 23-1 Computability and Complexity Andrei Bulatov Search and Optimization.
Complexity 15-1 Complexity Andrei Bulatov Hierarchy Theorem.
1 Discrete Structures & Algorithms Graphs and Trees: II EECE 320.
Introduction to Approximation Algorithms Lecture 12: Mar 1.
Approximation Algorithms
Approximation Algorithms: Combinatorial Approaches Lecture 13: March 2.
1 Optimization problems such as MAXSAT, MIN NODE COVER, MAX INDEPENDENT SET, MAX CLIQUE, MIN SET COVER, TSP, KNAPSACK, BINPACKING do not have a polynomial.
Approximation Algorithms Lecture for CS 302. What is a NP problem? Given an instance of the problem, V, and a ‘certificate’, C, we can verify V is in.
The Theory of NP-Completeness
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2006 Lecture 7 Monday, 4/3/06 Approximation Algorithms.
CSE 421 Algorithms Richard Anderson Lecture 27 NP Completeness.
Complexity ©D.Moshkovitz 1 Paths On the Reasonability of Finding Paths in Graphs.
P, NP, and NP-Complete Suzan Köknar-Tezel.
Approximation Algorithms Motivation and Definitions TSP Vertex Cover Scheduling.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 31.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
1 Approximation Algorithms. 2 Motivation By now we’ve seen many NP-Complete problems. We conjecture none of them has polynomial time algorithm.
Programming & Data Structures
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
The Traveling Salesperson Problem Algorithms and Networks.
The Traveling Salesman Problem Approximation
NP-Completeness: 3D Matching
Complexity Classes (Ch. 34) The class P: class of problems that can be solved in time that is polynomial in the size of the input, n. if input size is.
1 Introduction to Approximation Algorithms. 2 NP-completeness Do your best then.
MCS 312: NP Completeness and Approximation algorithms Instructor Neelima Gupta
Advanced Algorithm Design and Analysis (Lecture 13) SW5 fall 2004 Simonas Šaltenis E1-215b
Tonga Institute of Higher Education Design and Analysis of Algorithms IT 254 Lecture 8: Complexity Theory.
Great Theoretical Ideas in Computer Science.
Approximation Algorithms
Week 10Complexity of Algorithms1 Hard Computational Problems Some computational problems are hard Despite a numerous attempts we do not know any efficient.
CSE 024: Design & Analysis of Algorithms Chapter 9: NP Completeness Sedgewick Chp:40 David Luebke’s Course Notes / University of Virginia, Computer Science.
Princeton University COS 423 Theory of Algorithms Spring 2001 Kevin Wayne Approximation Algorithms These lecture slides are adapted from CLRS.
Techniques for Proving NP-Completeness Show that a special case of the problem you are interested in is NP- complete. For example: The problem of finding.
1 Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
CSE 589 Part VI. Reading Skiena, Sections 5.5 and 6.8 CLR, chapter 37.
Unit 9: Coping with NP-Completeness
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness and course wrap up.
Lecture 6 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
Approximation Algorithms for TSP Tsvi Kopelowitz 1.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 29.
CS6045: Advanced Algorithms NP Completeness. NP-Completeness Some problems are intractable: as they grow large, we are unable to solve them in reasonable.
Lecture 25 NP Class. P = ? NP = ? PSPACE They are central problems in computational complexity.
1 Chapter 8 NP and Computational Intractability Slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved.
NPC.
NP Completeness Piyush Kumar. Today Reductions Proving Lower Bounds revisited Decision and Optimization Problems SAT and 3-SAT P Vs NP Dealing with NP-Complete.
CSC 413/513: Intro to Algorithms
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 32.
1 Ch 10 - NP-completeness Tractable and intractable problems Decision/Optimization problems Deterministic/NonDeterministic algorithms Classes P and NP.
CSE 421 Algorithms Richard Anderson Lecture 27 NP-Completeness Proofs.
The Theory of NP-Completeness 1. Nondeterministic algorithms A nondeterminstic algorithm consists of phase 1: guessing phase 2: checking If the checking.
Approximation Algorithms by bounding the OPT Instructor Neelima Gupta
COSC 3101A - Design and Analysis of Algorithms 14 NP-Completeness.
TU/e Algorithms (2IL15) – Lecture 11 1 Approximation Algorithms.
Approximation Algorithms
More NP-Complete and NP-hard Problems
Richard Anderson Lecture 26 NP-Completeness
Richard Anderson Lecture 26 NP-Completeness
Hamiltonian Cycle and TSP
Hamiltonian Cycle and TSP
Approximation Algorithms for TSP
Richard Anderson Lecture 25 NP-Completeness
Lecture 24 Vertex Cover and Hamiltonian Cycle
Presentation transcript:

1 The TSP : NP-Completeness Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell ( ) * *TSP = Traveling Salesman Problem Based upon slides of Dana Moshkovitz, Kevin Wayne and others + some old slides

2 A related problem: HC 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.

3 Hamiltonian Cycle HAM-CYCLE: given an undirected graph G = (V, E), does there exist a simple cycle  that contains every node in V ' 3' 2 4 2' 4' NO: bipartite graph with odd number of nodes.

4 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 3n nodes. Each node splits up into an output node, a regular node and an input node.

5 Example c a b G a in a a out b in b b out c in c out c

6 Example c a b G a in a a out b in b b out c in c out c

7 Directed Hamiltonian Cycle Claim. G has a Hamiltonian cycle iff G' does. Pf.  Suppose G has a directed Hamiltonian cycle . Then G' has an undirected Hamiltonian cycle (same order). Pf.  Suppose G' has an undirected Hamiltonian cycle  '.  ' must visit nodes in G' using one of following two orders: …, B, G, R, B, G, R, B, G, R, B, … …, B, R, G, B, R, G, B, R, G, B, … Blue nodes in  ' make up directed Hamiltonian cycle  in G, or reverse of one. ▪

8 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.

9 3-SAT Reduces to Directed Hamiltonian Cycle Construction. Given 3-SAT instance  with n variables x i and k clauses. Construct G to have 2 n Hamiltonian cycles. Intuition: traverse path i from left to right  set variable x i = 1. s t 3k + 3 x1x1 x2x2 x3x3 x i = 1

10 3-SAT Reduces to Directed Hamiltonian Cycle Construction. Given 3-SAT instance  with n variables x i and k clauses. For each clause: add a node and 6 edges. s t clause node x1x1 x2x2 x3x3

11 3-SAT Reduces to Directed Hamiltonian Cycle Claim.  is satisfiable iff G has a Hamiltonian cycle. Pf.  Suppose 3-SAT instance has satisfying assignment x*. 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 C j, there will be at least one row i in which we are going in "correct" direction to splice node C j into tour

12 3-SAT Reduces to Directed Hamiltonian Cycle Claim.  is satisfiable iff G has a Hamiltonian cycle. Pf.  Suppose G has a Hamiltonian cycle . If  enters clause node C j, it must depart on mate edge. thus, nodes immediately before and after C j are connected by an edge e in G removing C j from cycle, and replacing it with edge e yields Hamiltonian cycle on G - { C j } Continuing in this way, we are left with Hamiltonian cycle  ' in G - { C 1, C 2,..., C k }. Set x* i = 1 iff  ' traverses row i left to right. Since  visits each clause node C j, at least one of the paths is traversed in "correct" direction, and each clause is satisfied. ▪

13 3-SAT  P Directed HC  P HC Objectives: To explore the Traveling Salesman Problem. Overview: TSP: Examples and Defn. Is TSP NP-complete? Approximation algorithm for special cases Hardness of Approximation in general.

14 Traveling Salesman Problem A Tour around USA 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:

15 Traveling Salesperson Problem 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:

16 Traveling Salesperson Problem 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:

17 Traveling Salesperson Problem 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:

18 TSP Given a weighted graph G=(V,E) V = Vertices = Cities E = Edges = Distances between cities Find the shortest tour that visits all cities

19 TSP Instance: A complete weighted undirected graph G=(V,E) (all weights are non-negative). Problem: To find a Hamiltonian cycle of minimal cost

20 Naïve Solution Try all possible tours and pick the minimum Dynamic Programming Definitely we need something better

21 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?

22 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 For all inputs x. OPT(x) here denotes the optimal value of the minimization problem (1/c) A(x) ≤ Opt(x) ≤ A(x)

23 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 For all inputs x. OPT(x) here denotes the optimal value of the maximization problem c A(x) ≥ Opt(x) ≥ A(x)

24 So why do we study Approximation Algorithms 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

25 Vertex Cover Any guess on how to design approximation algorithms for vertex cover?

26 Vertex Cover: Greedy

27 Vertex Cover: Greedy

28 Vertex Cover: Greedy

29 Vertex Cover: Greedy

30 Vertex Cover: Greedy

31 Vertex Cover: Greedy Greedy VC Approx = 8 Opt = 6 Factor 4/3 HW 2 Problem : Example can be extended to O(log n) approximation

32 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! Nothing better than 2-factor known. If P <> NP, there is no poly-time algorithm that achieves an approximation factor better than [Has97].

33 What Next? We’ll show an approximation algorithm for TSP, with approximation factor 2 for cost functions that satisfy a certain property.

34 Polynomial Algorithm for TSP? What about the greedy strategy: At any point, choose the closest vertex not explored yet?

35 The Greedy Strategy Fails   

36 The Greedy Strategy Fails   

37 Another Example Greedy strategy fails Even monkeys can do better than this !!! Don’t be greedy Always!

38 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.

39 TSP is NP-hard Theorem: HAM-CYCLE  p TSP. Proof: By the straightforward efficient reduction illustrated below: HAM-CYCLETSP 1 cn n = k = |V| cn

40 TSP Is a minimization problem. We want a 2-approximation algorithm But only for the case when the cost function satisfies the triangle inequality.

41 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.

42 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 y z

43 Approximation Algorithm 1. Grow a Minimum Spanning Tree (MST) for G. 2. Return the cycle resulting from a preorder walk on that tree.

44 Demonstration and Analysis The cost of a minimal Hamiltonian cycle  the cost of a MST 

45 Demonstration and Analysis The cost of a preorder walk is twice the cost of the tree

46 Demonstration and Analysis Due to the triangle inequality, the Hamiltonian cycle is not worse.

47 The Bottom Line optimal HAM cycle MST preorder walk our HAM cycle  = ½·  ½·

48 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

49 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|.

50 Instances min cost |V|  |V|    0  +1  0 0 1

51 What Should an Algorithm for gap-TSP Return? |V|  |V| YES!NO! min cost gap DON’T-CARE...

52 gap-TSP & Approximation Observation: Efficient approximation of factor  for TSP implies an efficient algorithm for gap-TSP[  ].

53 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.

54 The Reduction Illustrated HAM-CYCLEgap-TSP 1  |V| Verify (a) correctness (b) efficiency

55 Approximating TSP is NP- hard gap-TSP[  ] is NP-hard Approximating TSP within factor  is NP-hard

56 Summary 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. 

57 Summary 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. 