Title: The TSP : NP-Completeness Approximation and Hardness of Approximation
1The 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
TSP Traveling Salesman Problem
2A related problem HC
- HAM-CYCLE given an undirected graph G (V, E),
does there exist a simple cycle ? that contains
every node in V.
3Hamiltonian 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
NO bipartite graph with odd number of nodes.
4Directed 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.
5Example
ain
a
aout
a
cin
cout
c
c
b
bin
G
b
bout
6Example
ain
a
aout
a
cin
cout
c
c
b
bin
G
b
bout
7Directed 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. ?
83-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 2n
Hamiltonian cycles which correspond in a natural
way to 2n possible truth assignments.
93-SAT Reduces to Directed Hamiltonian Cycle
- Construction. Given 3-SAT instance ? with n
variables xi and k clauses. - Construct G to have 2n Hamiltonian cycles.
- Intuition traverse path i from left to right ?
set variable xi 1.
xi 1
s
x1
x2
x3
t
3k 3
103-SAT Reduces to Directed Hamiltonian Cycle
- Construction. Given 3-SAT instance ? with n
variables xi and k clauses. - For each clause add a node and 6 edges.
clause node
clause node
s
x1
x2
x3
t
113-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 xi 1, traverse row i from left to right
- if xi 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
123-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 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 - Continuing in this way, we are left with
Hamiltonian cycle ?' inG - C1 , C2 , . . . ,
Ck . - Set xi 1 iff ?' traverses row i left to right.
- Since ? visits each clause node Cj , at least one
of the paths is traversed in "correct" direction,
and each clause is satisfied. ?
133-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.
14Traveling 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 500Reference http//www.tsp.gatech.edu
15Traveling 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 http//www.tsp.gatech
.edu
16Traveling 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 http//www.tsp.gatech.edu
17Traveling 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 http//www.tsp.gatech
.edu
18TSP
- Given a weighted graph G(V,E)
- V Vertices Cities
- E Edges Distances between cities
- Find the shortest tour that visits all cities
19TSP
3
2
1
10
4
3
5
- Instance A complete weighted undirected graph
G(V,E) - (all weights are non-negative).
- Problem To find a Hamiltonian cycle of minimal
cost.
20Naïve Solution
- Try all possible tours and pick the minimum
- Dynamic Programming
Definitely we need something better
21Approximation 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?
22c-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)
For all inputs x. OPT(x) here denotes the optimal
value of the minimization problem
23c-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)
For all inputs x. OPT(x) here denotes the optimal
value of the maximization problem
24So 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
25Vertex Cover
- Any guess on how to design approximation
algorithms for vertex cover?
26Vertex Cover Greedy
27Vertex Cover Greedy
28Vertex Cover Greedy
29Vertex Cover Greedy
30Vertex Cover Greedy
31Vertex Cover Greedy
Greedy VC Approx 8 Opt 6 Factor 4/3 HW 2
Problem Example can be extended to O(log n)
approximation
32A 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 ltgt NP, there is no poly-time algorithm that
achieves - an approximation factor better than 1.1666
Has97.
33What Next?
- Well show an approximation algorithm for TSP,
- with approximation factor 2
- for cost functions that satisfy a certain
property.
34Polynomial Algorithm for TSP?
What about the greedy strategy At any point,
choose the closest vertex not explored yet?
35The Greedy Strategy Fails
10
?
?
5
12
2
3
?
0
1
36The Greedy Strategy Fails
10
?
?
5
12
2
3
?
0
1
37Another ExampleGreedy strategy fails
Dont be greedy Always!
0
1
-1
3
7
-5
-11
Even monkeys can do better than this !!!
38TSP 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.
39TSP is NP-hard
- Theorem HAM-CYCLE ?p TSP.
- Proof By the straightforward efficient reduction
illustrated below
1
cn
1
1
cn
1
HAM-CYCLE
TSP
n k V
40TSP
- Is a minimization problem.
- We want a 2-approximation algorithm
- But only for the case when the
- cost function
- satisfies the triangle inequality.
41The 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.
42The Triangle Inequality
- Definition Well say the cost function c
satisfies the triangle inequality, if - ?x,y,z?V c(x,z)c(z,y)?c(x,y)
43Approximation Algorithm
- 1. Grow a Minimum Spanning Tree (MST) for G.
- 2. Return the cycle resulting from a preorder
walk on that tree.
44Demonstration and Analysis
The cost of a minimal Hamiltonian cycle ? the
cost of a MST
?
45Demonstration and Analysis
The cost of a preorder walk is twice the cost of
the tree
46Demonstration and Analysis
Due to the triangle inequality, the Hamiltonian
cycle is not worse.
47The Bottom Line
optimal HAM cycle
our HAM cycle
preorder walk
?
? ½
½
MST
48What About the General Case?
- Well show TSP cannot be approximated within any
constant factor ??1 - By showing the corresponding gap version is
NP-hard.
Inapproximability
49gap-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.
YES
NO
50Instances
min cost
51What Should an Algorithm for gap-TSP Return?
min cost
DONT-CARE...
52gap-TSP Approximation
- Observation Efficient approximation of factor ?
for TSP implies an efficient algorithm for
gap-TSP?.
53gap-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.
54The Reduction Illustrated
1
?V1
1
1
?V1
1
HAM-CYCLE
gap-TSP
Verify (a) correctness (b) efficiency
55Approximating TSP is NP-hard
Approximating TSP within factor ? is NP-hard
56Summary
?
- Weve studied the Traveling Salesman Problem
(TSP). - Weve seen it is NP-hard.
- Nevertheless, when the cost function satisfies
the triangle inequality, there exists an
approximation algorithm with ratio-bound 2.
57Summary
?
- For the general case weve proven there is
probably no efficient approximation algorithm for
TSP. - Moreover, weve demonstrated a generic method for
showing approximation problems are NP-hard.