1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea...

37
1 The TSP : Approximation and Hardness of Approximation xact science is dominated by the idea of approximation. Bertrand Russell (1872 - 1970) * *TSP = Traveling Salesman Proble Based upon slides of Dana Moshkovitz

Transcript of 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea...

Page 1: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

1

The TSP : Approximation and Hardness of Approximation

All exact science is dominated by the idea of approximation.-- Bertrand Russell (1872 - 1970)

*

*TSP = Traveling Salesman Problem

Based upon slides of Dana Moshkovitz

Page 2: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

2

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?

Lets look at the Traveling Salesman Problem.

Page 3: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

3

The Mission: A Tour Around the World

Page 4: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

4

The Problem: Traveling Costs Money

1795$

Page 5: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

5

Introduction

Objectives:To explore the Traveling Salesman

Problem. Overview:

TSP: Formal definition & Examples TSP is NP-hard Approximation algorithm for special cases Hardness of Approximation in general.

Page 6: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

6

TSP

Given a weighted graph G=(V,E)

V = Vertices = Cities

E = Edges = Distances between cities

Find the shortest tour that visits all cities

Page 7: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

7

TSP

Instance: A complete weighted undirected graph G=(V,E)

(all weights are non-negative).

Problem: To find a Hamiltonian cycle of minimal cost.

3

432

5

1 10

Page 8: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

8

Naïve Solution

Try all possible tours and pick the minimum

Dynamic Programming

))!1(( nO

)2( nO

Definitely we need something better

Page 9: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

9

What can we do?

Give up on polynomial time algorithms?

Try Heuristics by giving up on optimality?

Try approximation algorithms?

Page 10: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

10

Polynomial Algorithm for TSP?

What about the greedy strategy:

At any point, choose the closest vertex not explored

yet?

Page 11: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

11

The Greedy Strategy Fails

5

0

3

1

12

10

2

Page 12: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

12

The Greedy Strategy Fails

5

0

3

1

12

10

2

Page 13: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

13

Another ExampleGreedy strategy fails

0 1-1 3 7-5-11

Even monkeys can do better than this !!!

Page 14: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

14

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.

Page 15: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

15

TSP is NP-hard

Theorem: HAM-CYCLE p TSP.

Proof: By the straightforward efficient reduction illustrated below:

HAM-CYCLE TSP

1 cn1

1

1

n = k = |V|

verify!

cn

Page 16: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

16

What Next?

We will see what are approximation algorithms.

We’ll show an approximation algorithm for TSP,

with approximation factor 2

for cost functions that satisfy a certain property.

Page 17: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

17

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

)(

)(

xOPT

xA c

For all inputs x.OPT(x) here denotes the optimal value of the minimization problem

Page 18: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

18

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

)(

)(

xOPT

xA c

For all inputs x.OPT(x) here denotes the optimal value of the maximization problem

Page 19: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

19

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

Page 20: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

20

TSP

Is a minimization problem. We want a 2-approximation algorithm But only for the case when the

cost function

satisfies the triangle inequality.

Page 21: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

21

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.

Page 22: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

22

The Triangle Inequality

Definition: We’ll say the cost function c satisfies the triangle inequality, if

x,y,zV : c(x,z)+c(z,y)c(x,y)

x

yz

Page 23: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

23

Approximation Algorithm

1. Grow a Minimum Spanning Tree (MST) for G.

2. Return the cycle resulting from a preorder walk on that tree.

Page 24: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

24

Demonstration and Analysis

The cost of a minimal

Hamiltonian cycle the cost of a

MST

Page 25: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

25

Demonstration and Analysis

The cost of a preorder walk is twice the cost of

the tree

Page 26: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

26

Demonstration and Analysis

Due to the triangle inequality, the

Hamiltonian cycle is not worse.

Page 27: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

27

The Bottom Line

optimal HAM cycle

MSTpreorder

walk

our HAM cycle

= ½· ½·

Page 28: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

28

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.

Page 29: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

29

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

Page 30: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

30

Instances

min cost

|V| |V|

1

1

1

0+1

0

0

1

Page 31: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

31

What Should an Algorithm for gap-TSP Return?

|V| |V|

YES! NO!

min cost

gap

DON’T-CARE...

Page 32: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

32

gap-TSP & Approximation

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

Page 33: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

33

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.

Page 34: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

34

The Reduction Illustrated

HAM-CYCLE gap-TSP

1 |V|+11

1

1

|V|+1

Verify (a) correctness (b)

efficiency

Page 35: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

35

Approximating TSP is NP-hard

gap-TSP[] is NP-hard

Approximating TSP within factor is NP-hard

Page 36: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

36

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.

Page 37: 1 The TSP : Approximation and Hardness of Approximation All exact science is dominated by the idea of approximation. -- Bertrand Russell (1872 - 1970)

37

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.