Traveling Salesman Problem

Similar documents
Hamiltonian Cycle. Hamiltonian Cycle

Applied Integer Programming: Modeling and Solution

Integer Linear Programming (ILP)

Bounds on the Traveling Salesman Problem

The Traveling Salesman Problem: An Overview. David P. Williamson, Cornell University Ebay Research January 21, 2014

ABHELSINKI UNIVERSITY OF TECHNOLOGY

The traveling salesman problem

A Survey on Travelling Salesman Problem

Problem Complexity Classes

Node Edge Arc Routing Problems (NEARP)

2 Notation and Preliminaries

Who Has Heard of This Problem? Courtesy: Jeremy Kun

EXACT ALGORITHMS FOR THE ATSP

Improved Approximations for Cubic Bipartite and Cubic TSP

Network Flows. CTU FEE Department of control engineering. March 28, 2017

Lecture 6 January 21, 2013

Chapter 3: Discrete Optimization Integer Programming

NP and Computational Intractability

Chapter 3: Discrete Optimization Integer Programming

CS/COE

Combinatorial Optimization

Lecture 4: NP and computational intractability

LECTURE 1: INTRODUCTION

Part III: Traveling salesman problems

ACO Comprehensive Exam October 14 and 15, 2013

Decision Problems TSP. Instance: A complete graph G with non-negative edge costs, and an integer

NP-Complete Problems. More reductions

Data Structures in Java

Algorithms Design & Analysis. Approximation Algorithm

Hamiltonian Graphs Graphs

July 18, Approximation Algorithms (Travelling Salesman Problem)

Easy Problems vs. Hard Problems. CSE 421 Introduction to Algorithms Winter Is P a good definition of efficient? The class P

Edge Elimination for the Hamiltonian Cycle problem

Week Cuts, Branch & Bound, and Lagrangean Relaxation

CHAPTER 3 FUNDAMENTALS OF COMPUTATIONAL COMPLEXITY. E. Amaldi Foundations of Operations Research Politecnico di Milano 1

NP-Completeness. NP-Completeness 1

More on NP and Reductions

3.4 Relaxations and bounds

ECS122A Handout on NP-Completeness March 12, 2018

NP-Complete Problems and Approximation Algorithms

Limits to Approximability: When Algorithms Won't Help You. Note: Contents of today s lecture won t be on the exam

NP-complete problems. CSE 101: Design and Analysis of Algorithms Lecture 20

Asymmetric Traveling Salesman Problem (ATSP): Models

SAT, Coloring, Hamiltonian Cycle, TSP

8.5 Sequencing Problems

Data Structures and Algorithms (CSCI 340)

NP-Completeness. Andreas Klappenecker. [based on slides by Prof. Welch]

CS 583: Algorithms. NP Completeness Ch 34. Intractability

CS 350 Algorithms and Complexity

Algorithm Design Strategies V

CS 350 Algorithms and Complexity

1 Heuristics for the Traveling Salesman Problem

15.083J/6.859J Integer Optimization. Lecture 2: Efficient Algorithms and Computational Complexity

ON COST MATRICES WITH TWO AND THREE DISTINCT VALUES OF HAMILTONIAN PATHS AND CYCLES

AM 121: Intro to Optimization Models and Methods Fall 2018

How hard is it to find a good solution?

Unit 1A: Computational Complexity

Part III: Traveling salesman problems

Exercises NP-completeness

Combinatorial optimization problems

Discrete Optimization 2010 Lecture 12 TSP, SAT & Outlook

NP-COMPLETE PROBLEMS. 1. Characterizing NP. Proof

Limitations of Algorithm Power

Approximation Algorithms for Asymmetric TSP by Decomposing Directed Regular Multigraphs

CSC 8301 Design & Analysis of Algorithms: Lower Bounds

8.3 Hamiltonian Paths and Circuits

Design and Analysis of Algorithms

CS 301: Complexity of Algorithms (Term I 2008) Alex Tiskin Harald Räcke. Hamiltonian Cycle. 8.5 Sequencing Problems. Directed Hamiltonian Cycle

NP Complete Problems. COMP 215 Lecture 20

Algorithms. NP -Complete Problems. Dong Kyue Kim Hanyang University

NP-problems continued

CS 320, Fall Dr. Geri Georg, Instructor 320 NP 1

Scheduling and Optimization Course (MPRI)

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

Algorithms: COMP3121/3821/9101/9801

History, Analysis, and Implementation of Traveling Salesman Problem (TSP) and Related Problems

NP-completeness. Chapter 34. Sergey Bereg

CSCI3390-Lecture 18: Why is the P =?NP Problem Such a Big Deal?

Preliminaries. Graphs. E : set of edges (arcs) (Undirected) Graph : (i, j) = (j, i) (edges) V = {1, 2, 3, 4, 5}, E = {(1, 3), (3, 2), (2, 4)}

Formal definition of P

Computational Complexity

NP-Complete Reductions 1

Approximation Algorithms for Re-optimization

Polynomial-Time Reductions

Graduate Algorithms CS F-21 NP & Approximation Algorithms

The minimum G c cut problem

Theory of Computation Chapter 9

1. Introduction Recap

The Complexity Classes NP-Hard, BPP.

Topics in Complexity Theory

The P versus NP Problem. Ker-I Ko. Stony Brook, New York

NP-problems continued

Polynomial-time Reductions

Outline. 1 NP-Completeness Theory. 2 Limitation of Computation. 3 Examples. 4 Decision Problems. 5 Verification Algorithm

More NP-Complete Problems

NP-Completeness. CptS 223 Advanced Data Structures. Larry Holder School of Electrical Engineering and Computer Science Washington State University

University of Washington March 21, 2013 Department of Computer Science and Engineering CSEP 521, Winter Exam Solution, Monday, March 18, 2013

Theory of Computation Chapter 1: Introduction

Notes for Lecture 21

Optimisation and Operations Research

Transcription:

Traveling Salesman Problem Zdeněk Hanzálek hanzalek@fel.cvut.cz CTU in Prague April 17, 2017 Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 1 / 33

1 Content 2 Solved TSP instances in pictures 3 General TSP and Its Time Complexity Likely Nonexistence of Polynomial r-approximation Algorithm for Genera 4 Metric TSP and Approximation Algorithms Double-tree Algorithm Christofides Algorithm 5 Tour Improvement Heuristics - Local Search k-opt 6 Conclusion Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 2 / 33

Solved TSP instances 1954 George Dantzig, Ray Fulkerson, and Selmer Johnson 49 cities, one city from each of the 48 states in the U.S.A. (Alaska and Hawaii became states only in 1959) plus Washington, D.C. Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 3 / 33

Solved TSP instances 1962 Procter and Gamble s Contest 33 cities Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 4 / 33

Solved TSP instances 1977 Groetschel 120 cities of West Germany Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 5 / 33

Solved TSP instances 1987 Padberg and Rinaldi 532 AT&T switch locations in the USA Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 6 / 33

Solved TSP instances 1987 Groetschel and Holland 666 interesting places in the world Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 7 / 33

Solved TSP instances 1987 Padberg and Rinaldi a layout of 2 392 points obtained from Tektronics Incorporated Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 8 / 33

Solved TSP instances 1994 D.Applegate, R.Bixby, V.Chvatal, W.Cook 7 397 points in a programmable logic array application at AT&T Bell Laboratories Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 9 / 33

Solved TSP instances 1998 D.Applegate, R.Bixby, V.Chvatal, W.Cook 13 509 cities in the USA with populations greater than 500 Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 10 / 33

Solved TSP instances 2001 D.Applegate, R.Bixby, V.Chvatal, W.Cook 15 112 cities in Germany Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 11 / 33

Solved TSP instances 2004 D.Applegate, R.Bixby, V.Chvatal, W.Cook 24 978 cities in Sweden Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 12 / 33

Related Decision Problem Existence of Hamiltonian Circuit (HC, Hamiltonovská kružnice) Instance: Undirected graph G. Goal: Decide if Hamiltonian circuit (circuit visiting every node exactly once) exists in graph G. NP-complete problem The directed version of this problem is: (Hamiltonian cycle) for a directed graph HC belongs to NP problems. For each yes-instance G we take any Hamiltonian circuit of G as a certificate. To check whether a given edge set is in fact a Hamiltonian circuit of a given graph is obviously possible in polynomial time. Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 13 / 33

Hamilton s Puzzle The Hamiltonian circuit is named after William Rowan Hamilton who invented the Icosian game, now also known as Hamilton s puzzle, which involves finding a Hamiltonian circuit in the edge graph of the dodecahedron. (picture can be viewed as a look inside the dodecahedron through one of its twelve faces). Like all platonic solids, the dodecahedron is Hamiltonian. Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 14 / 33

Problem Formulation Traveling Salesman Problem - TSP Instance: A complete undirected graph K n (n 3) and weights c : E(K n ) Q + 0. Goal: Find a Hamiltonian circuit T whose weight e E(T) c(e) is minimum. Nodes correspond to cities and weights to distances or travel costs This problem is called symmetric TSP, since it is given by a complete undirected graph If the distance form city A to city B differs form the one from B to A, we have to use a directed graph and we deal with an asymmetric TSP Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 15 / 33

Number of Circuits Is Not Exclusive Cause of TSP Complexity Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 16 / 33

Strongly NP-hard Problems Let L be an optimization problem. For a polynomial p let L p be the restriction of L to such instances I that consist of nonnegative integers with largest(i) p(size(i)), i.e. numerical parameters of L p are bounded by a polynomial in the size of the input. L is called strongly NP-hard if there is a polynomial p such that L p is NP-hard. If L is strongly NP-hard, then L cannot be solved by a pseudopolynomial time algorithm unless P = NP. In the following we will study the case, where: L... TSP, L p... TSP with restriction c(e) {1,2}, i.e. largest(i) = 2 n = p(size(i)) On the other hand: L... Knapsack, L p... Knapsack with bounded integer costs for which the Dynamic prog. table has polynomial number (n p(size(i))) of columns, i.e. Knapsack is not strongly NP-hard. Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 17 / 33

TSP Complexity and Likely Nonexistence of Pseudopolynomial Algorithm Proposition TSP is strongly NP-hard. Proof: We show that the TSP is NP-hard even when restricted to instances where all distances are 1 or 2 using polynomial transformation from the HC problem Let G be an undirected graph in which we want to find the Hamiltonian circuit. Create a TSP instance such that every node from G is associated to one node in the complete undirected graph K n. Weight of {i,j} in K n equals: { 1 if {i,j} E(G); c({i,j}) = 2 if {i,j} / E(G). G has a Hamiltonian circuit iff optimal TSP solution is equal to n. Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 18 / 33

Likely Nonexistence of Polynomial r-approximation Algorithm for General TSP Theorem If we believe P NP, than there is no polynomial r-approximation algorithm for TSP for r 1. Proof by contradiction: Assume there exists a polynomial r-approximation algorithm A for TSP. We further show that we can solve the HC problem while using such an inaccurate algorithm A. Since HC is NP-complete, P=NP. In other words: if there exists a polynomial r-approximation algorithm A solving TSP, then the NP-complete HC problem can be solved in polynomial time by A. Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 19 / 33

Likely Nonexistence of Polynomial r-approximation Algorithm for General TSP Every HC instance can be polynomially reduced to a TSP instance inaccurately solved by r-approximation algorithm A: Let G be an undirected graph in which we want to find the Hamiltonian circuit. Create a TSP instance such that every node from G is associated to one node (city) in the complete undirected graph K n. Weight (distance) of {i,j} in K n equals: { 1 if {i,j} E(G); c({i,j}) = 2+(r 1) n if {i,j} / E(G). We use A to solve the instance. if the result is in interval n,r n, then the Hamiltonian circuit exists, otherwise the result is greater or equal to (n 1)+2+(r 1) n = r n+1 and G has no Hamiltonian circuit. Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 20 / 33

Likely Nonexistence of Polynomial r-approximation Algorithm for General TSP - Illustration Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 21 / 33

Metric TSP and Triangle Inequality In most common applications the distances of the TSP satisfies the triangle inequality. Metric TSP Instance: Complete undirected graph K n (n 3) with weights c : E(K n ) R + 0 such that c({i,j})+c({j,k}) c({k,i}) for all i,j,k V(K n ). Goal: Find the Hamiltonian circuit T such that e E(T) c(e) is minimal. The metric TSP is strongly NP-hard. Can be proved in the same way as the complexity of TSP because weights 1 and 2 preserve the triangle inequality. Therefore the psudopolynomial algs do not exist. But approximation algorithms do exist. It is not difficult to make the TSP instance metric simply by adding to same constant h to the cost of every edge (the criterion function is higher by n h). Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 22 / 33

Nearest Neighbor - Heuristic Algorithm Input: An instance (K n,c) of metric TSP. Output: Hamiltonian circuit H. Choose arbitrary node v [1] V(K n ) ; for i := 2 to n do choose v [i] V(K n )\{v [1],,v [i 1] } such that c({v [i 1],v [i] }) is minimal; end Hamiltonian circuit H is defined by the sequence {v [1],,v [n], v [1] } ; The nearest unvisited city is chosen in each step This is not an approximation algorithm Time complexity is O(n 2 ) Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 23 / 33

Double-tree Algorithm Input: An Instance (K n,c) of the metric TSP. Output: Hamiltonian circuit H. 1 Find a minimum weight spanning tree T in K n ; 2 By doubling every edge in T we get multigraph in which we find the Eulerian walk L; 3 Transform the Eulerian walk L to the Hamiltonian circuit H in the complete graph K n : create a sequence of nodes on the Eulerian walk L; we skip nodes that are already in the sequence; the rest creates the Hamiltonian circuit H; Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 24 / 33

Double-tree Algorithm is 2-approximation Algorithm Time complexity is O(n 2 ) It is a 2-approximation algorithm for the metric TSP: 1. due to the triangle inequality, the skipped nodes don t prolong the route, i.e. c(e(l)) c(e(h)) 2. while deleting one edge in the circuit, we create the tree. Therefore, inequality OPT(K n,c) c(e(t)) holds 3. 2c(E(T)) = c(e(l)) holds due to the creation of L by doubling edges in T above points imply 2OPT(K n,c) c(e(h)) since: 2OPT(K n,c) 2. 2c(E(T)) = 3. c(e(l)) 1. c(e(h)) Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 25 / 33

Christofides Algorithm [1976] Input: An instance (K n,c) of metric TSP. Output: Hamiltonian circuit H. 1 Find a minimum weight spanning tree T in K n ; 2 Let W be the set of vertices having an odd degree in T; 3 Find a minimum weight matching M of nodes from W in K n ; 4 Merge of T and M forms a multigraph (V(K n ),E(T) M) in which we find the Eulerian walk L; 5 Transform the Eulerian walk L into the Hamiltonian circuit H in the complete graph K n ; Observation: Each edge connects 2 nodes the sum of the degree of all nodes is 2 E there are an even number of nodes with an odd degree in every graph (and an arbitrary number of nodes with an even degree). With respect to the previous observation and completeness of K n, it follows that it is possible to find the perfect matching. Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 26 / 33

Christofides Algorithm is a 3 2 Approximation Time complexity is O(n 3 ) It is a 3 2 approximation algorithm for the metric TSP: 1. due to the triangle inequality the skipped nodes do not prolong the route, i.e c(e(l)) c(e(h)) 2. while deleting one edge in the circuit, we create the tree. Therefore, inequality OPT(K n,c) c(e(t)) holds 3. since the perfect matching M considers every second edge in the alternating path and being the minimum weight matching it chooses the smaller half, OPT(Kn,c) 2 c(e(m)) holds 4. due to the construction of L it holds c(e(m))+c(e(t)) = c(e(l)) finally while inserting 2. and 3. in 4. and appending 1. we obtain 3 2 OPT(K n,c) c(e(h)) Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 27 / 33

Tour Improvement Heuristics - Local Search k-opt One of the most successful techniques for TSP instances in practice. A simple idea which can be used to solve other optimization problems as well: Find any Hamiltonian circuit by some heuristic Improve it by local modifications (for example: delete 2 edges and reconstruct the circuit by some other edges). Local search is an algorithmic principle based on two decisions: Which modifications are allowed When to modify the solution (one possibility is, to allow improvements only) Example of local search is k-opt algorithm for TSP Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 28 / 33

k-opt algorithm for TSP Input: An instance (K n,c) of TSP, number k 2. Output: Hamiltonian circuit H. 1. Let H be any Hamiltonian circuit; 2. Let S be the family of k-element subsets S of E(H); for all S S do // outer loop deals with removed edges for all Ham.circuits H H such that E(H ) E(H)\S do // inner loop deals with inserted edges if c(e(h )) < c(e(h)) then H := H a go to 2.; end end Note: H is constructed, so that it is Hamiltonian circuit as well. When k=2, the inner loop, which creates the Hamiltonian circuits H from the remaining edges of H, executes only once, since there is just one way to construct the new Hamiltonian circuit H. Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 29 / 33

Examples of 2-opt and 3-opt for TSP 2-opt 3-opt just one way to construct the new Hamiltonian circuit: the gain if the improvement is: c(e(h )) c(e(h)) = (a,d)+(b,c)-(c,d)-(a,b) and path (b,...,d) has changed orientation at least two ways to construct the new Hamiltonian circuit: c(e(h )) c(e(h)) = (a,d)+(e,b)+(c,f)-(a,b)-(c,d)-(e,f) no path has changed orientation c(e(h )) c(e(h)) = (a,d)+(e,c)+(b,f)-(a,b)-(c,d)-(e-f) path (c,...,b) has changed orientation Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 30 / 33

Example of 4-opt for TSP One possible solution called the double bridge - no path has changed orientation: Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 31 / 33

TSP - Summary One of the most popular NP-hard problems 49-120 550-2,392-7,397 19,509-24,978 cities from year 1954 to year 2004 Lot of constraints must be added when solving real life problems CVRP - Capacitated Vehicle routing Problem - limited number of cars and limited load capacity of cars, every customer buys a different amount of the product VRPTW - Time Windows - customers define time windows in which they accept cargo VRPPD - Pick-up and Delivery - customers return some amount of the product (or wrapping) that takes place in the car Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 32 / 33

References David L. Applegate, Robert E. Bixby, Vasek Chvátal, and William J. Cook. The Traveling Salesman Problem: A Computational Study. Princeton University Press, 2007. B. H. Korte and Jens Vygen. Combinatorial Optimization: Theory and Algorithms. Springer, fourth edition, 2008. Z. Hanzálek (CTU) Traveling Salesman Problem April 17, 2017 33 / 33