1 / 65

TSP: an introduction

TSP: an introduction. Vittorio Maniezzo University of Bologna. Travelling Salesman Problem (TSP). n locations given (home of salesperson and n -1 customers). [ d ij ] distance matrix given, contains distances (Km, time, … ) between each pair of locations.

tovi
Download Presentation

TSP: an introduction

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. TSP: an introduction Vittorio Maniezzo University of Bologna Vittorio Maniezzo - University of Bologna - Transportation Logistics

  2. Travelling Salesman Problem (TSP) • n locations given (home of salesperson and n-1 customers). • [dij] distance matrix given, contains distances (Km, time, … ) between each pair of locations. • The TSP asks for the shortest tour starting home, visiting each customer once and returning home • Symmetric / asymmetric versions. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  3. Introduction • Which is the shortest tour? • Difficult to say … Vittorio Maniezzo - University of Bologna - Transportation Logistics

  4. TSP history • The general form of the TSP appears to have been first studied by mathematicians starting in the 1930s by Karl Menger in Vienna. • Mathematical problems related to the traveling salesman problem were treated in the 1800s by the Irish mathematician Sir William Rowan Hamilton. • The picture shows Hamilton's Icosian Game that requires players to complete tours through the 20 points using only the specified connections. (http://www.math.princeton.edu/tsp/index.html) Vittorio Maniezzo - University of Bologna - Transportation Logistics

  5. Past practice … Vittorio Maniezzo - University of Bologna - Transportation Logistics

  6. Current practice • Actual tours of persons or vehicles (deliveries to customers) • Given:Graph of streets, where some nodes represent customers. • Find: • shortest tour among customers. • Precondition: • Solve shortest path problems  Distance matrix Vittorio Maniezzo - University of Bologna - Transportation Logistics

  7. Application: PCB • Minimization of time for drilling holes in PCBs (printed circuit boards) Vittorio Maniezzo - University of Bologna - Transportation Logistics

  8. Application: setup costs • Minimization of total setup costs (or setup times) when setup costs are sequence dependent • All product types must be produced and the setup must return to initial configuration Vittorio Maniezzo - University of Bologna - Transportation Logistics

  9. Application: paint shop • Minimization of total setup costs (or setup times) when setup costs are sequence dependent • All colors must be processed Vittorio Maniezzo - University of Bologna - Transportation Logistics

  10. Solution Methods • n nodes (n-1)! possible tours • Some possible solution method: • Complete enumeration • IP: Branch and Bound (and Cut, and Price, … ) • Dynamic programming • Approximation algorithms • Heuristics • Metaheuristics n 5 10 15 20 n! 120 3,628.800 1,31*10^12 2,43*10^18 Vittorio Maniezzo - University of Bologna - Transportation Logistics

  11. i \ j • 1 • 2 • 3 • 4 • 5 • 1 •  • 18 • 17 • 20 • 21 • 2 • 18 •  • 21 • 16 • 18 • 3 • 16 • 98 •  • 19 • 20 • 4 • 17 • 16 • 20 •  • 17 • 5 • 18 • 18 • 19 • 16 •  Standard Example • Example with 5 customers (1 home, 4 customers) • Zimmermann, W.,O.R., Oldenbourg, 1990: • e.g. cost of 1-2-3-4-5: 18+21+19+17+18 = 93 • First: simplify by reducing costs Vittorio Maniezzo - University of Bologna - Transportation Logistics

  12. i \ j • 1 • 2 • 3 • 4 • 5 • 1 •  • 1 • 0 • 3 • 3 • 2 • 2 •  • 5 • 0 • 1 • 3 • 0 • 82 •  • 3 • 3 • 4 • 1 • 0 • 4 •  • 0 • 5 • 2 • 2 • 3 • 0 •  Lower bound • Subtract minimum from each row & column • Reduction constant = 17+16+16+16+16 + 1 = 82 • all tours have costs which are 82 greater, • e.g. cost of 1-2-3-4-5:1+5+3+0+2 = 11[= 93 - 82] • Optimal tour does not change (see [Toth, Vigo, 02]). Vittorio Maniezzo - University of Bologna - Transportation Logistics

  13. Complete Enumeration • 5 customers  4! = 234 = 24 tours Vittorio Maniezzo - University of Bologna - Transportation Logistics

  14. A wider scope • A combinatorial optimizationproblem is defined over a set C= {c1, … ,cn}of basic components. • A solution of the problem is a subset S C; • F 2C is thesubset of feasible solutions, (a solution S is feasible iff SF). • z: 2C is the cost function, • the objective isto find a minimum cost feasible solutionS°, i.e., to find S° F such that z(S°) z(S), S  F. • Failing this,the algorithm anyway returns the best feasible solution found, S* F. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  15. TSP as a CO example • TSP is defined over a weighted undirected complete graph G=(V,E,D), where V is the set of vertices, E is the set of edges and D is the set of edge weights. • The component set corresponds to E (C=E), • F corresponds to the set of Hamiltonian cycles in G • z(S) is the sum of the weights associated to the edges belonging to the solution S. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  16. LP-Formulation • LP formulation is a binary LP (IP) which is almost identical to the assignment problem: • plus conditions to avoid short cycles Vittorio Maniezzo - University of Bologna - Transportation Logistics

  17. 1 2 3 4 5 Example for short cycles • Optimal solution of LP without conditions to avoid short cycles = solution of assignment problem • short cycles 1-3-1 and 2-5-4-2 •  conditions to avoid short cycles are needed Vittorio Maniezzo - University of Bologna - Transportation Logistics

  18. Conditions to avoid short cycles • Several formulations in the literature • e.g. Dantzig-Fulkerson-Johnson • exponentially many! Vittorio Maniezzo - University of Bologna - Transportation Logistics

  19. Example: avoid short cycles • Above example with n = 5 cities: • must consider subsets Q: • {1, 2}; {1, 3}; {1, 4}; {1, 5}; {2, 3}; {2, 4}; {2, 4}; {3, 4}; {3, 5}; {4, 5} • constraint for subset Q = {1, 2} and V-Q = {3, 4, 5} x13 + x14 + x15 + x23 + x24 + x25  1 • n = 6  subsets (constraints) • exponentially many! Vittorio Maniezzo - University of Bologna - Transportation Logistics

  20. Heuristics for the TSP Vittorio Maniezzo University of Bologna Vittorio Maniezzo - University of Bologna - Transportation Logistics

  21. Computational issues • The size of the instances met in realworld applications rules out the possibility of solving them to optimality inan acceptable time. • Nevertheless, these instances must be solved. • Thus the needto look forsuboptimal solutions, provided that they are of “acceptablequality” and that they can be found in “acceptable time”. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  22. Heuristic algorithms • How to cope with NP-completeness: • small instances; • polynomial specialcases; • approximationalgorithms guarantee to find asolution within a known gap from optimality; • probabilistic algorithms guarantee that for instancesbig enough, the probability of getting a bad solution is very small; • heuristic algorithms: no guarantee, but historically, on the average, these algorithms have the best quality/time trade off for the problem of interest. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  23. heuristics: focus on solution structure • Simplest heuristics exploit structural properties of feasiblesolutions in order to quickly come to a good one. • Theybelong to one of two main classes: constructive heuristics or localsearch heuristics. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  24. Constructive heuristics • 1. Sort the components in C by increasing costs. • 2. Set S*= and i=1. • 3. Repeat • If (S*  ci is a partial feasible solution) thenS* =S*ci. • i=i+1. • Until S* F. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  25. Constructive heuristics • A constructive approach can yield optimal solutions for certainproblems, eg. the MST. • In other cases itcould be unable to construct a feasible solution. • TSP: order all edges byincreasing edge cost, take the least cost one and add to it increasing costedges, provided they do not close subtours, until a Hamiltonian circuit iscompleted. • More involved constructive strategies give rise to well-known TSPheuristics, like the Farthest Insertion, the Nearest Neighbor, the Best Insertion or the Sweepalgorithms. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  26. Nearest Neighbor Heuristic • 0. Start from any city; e.g. the first one • 1. Find nearest neighbor (to the last city) not already visited • 2. repeat 1 until all cities are visited. • Then connect last city with starting point • Ties can be broken arbitrarily. • Starting from different starting points gives different solutions! Some will be bad some will be good. • GREEDYthe last connections tend to be long and improvement heuristics should be used afterwards Vittorio Maniezzo - University of Bologna - Transportation Logistics

  27. Best Insertion Heuristic • 0. Select 2 cities A, B and start with short cycle A-B-A • 1. Insert next city (not yet inserted) in the best position in the short cycle • 2. Repeat 1. until all cities are visited • Using different starting cycles and different choices of the next city different solutions are obtained • Often when symmetric: starting cycle = 2 cities with maximum distancenext city = maximizes min distance to inserted cities Vittorio Maniezzo - University of Bologna - Transportation Logistics

  28. An approximation algorithm • In some cases, it is possible to construct solutions which are guaranteed to be “not too bad”. • Approximation algorithms provide a guarantee on worst possible value for the ratio (zh – z*)/z*. • TSP hypothesis: it is always cheaper to go straight from a node u to another node v instead of traversing an intermediate node w (triangular inequality). Vittorio Maniezzo - University of Bologna - Transportation Logistics

  29. Approx-TSP • An approx. Algorithm for the TSP with triangular inequality is: • Approx-TSP-Tour(G,w) • 1 select a root vertex rV • 2 construct a MST T for G rooted in r • 3 let L be the list of vertices visited in a preorder tree walk of T • 4 return the hamiltonian cycle H which visits all vertices in the order L Vittorio Maniezzo - University of Bologna - Transportation Logistics

  30. Approx-TSP: example a d e b f g c h Vittorio Maniezzo - University of Bologna - Transportation Logistics

  31. Approx-TSP: example a d e b f g c h Vittorio Maniezzo - University of Bologna - Transportation Logistics

  32. Approx-TSP: example a d e b f g c h Vittorio Maniezzo - University of Bologna - Transportation Logistics

  33. Approx-TSP: example a d e b f g c h Vittorio Maniezzo - University of Bologna - Transportation Logistics

  34. Approx-TSP: performance • Theorem • Approx-TSP-Tour is an approximation algorithm with a ratio bound of 2 for the traveling salesman problem with triangle inequality. • Proof • Because the optimal tour solution must have one more edge than the MST of T, so c(MST)  c(T*). • c(Tour) = 2c(MST) • Because of the assumption of triangle inequality, c(H)  c(Tour). • Therefore, c(H)  2c(T*). • Since the input is a complete graph, so the implementation of Prim’s algorithm runs in O(V2). Therefore the total time complexity of • Approx-TSP-Tour also is O(V2). Vittorio Maniezzo - University of Bologna - Transportation Logistics

  35. Local Search: neighborhoods • The neighborhood of a solution S, N(S), is a subset of 2C defined by a neighborhood functionN: 2C 22c. • Often only feasible solutions considered, thus neighborhood functions N: F  2F. • The specific function used has a deep impact on the algorithm performance and its choice is left to the algorithm designer. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  36. Local search • 1. Generate an initial feasible solution S. • 2. Find S'N(S), such that z(S')=min z(S^), S^ N(S). • 3. If z(S') < z(S) then S=S' • go to step 2. • 4. S* = S. • The update of a solution in step 3 is called a move from S to S'. • It could be made to the first improving solution found. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  37. Local search • There are problems forwhich a local search approach guarantees to find an optimal solution (ex. the simplexalgorithm). • ForTSP, two LS are 2-opt and 3-opt, which take a solution (a list of nvertices) and exhaustively swap the elements of all pairs or triplets ofvertices in it. • More sophisticated neighborhoods give rise to moreeffective heuristics, among which Lin and Kernighan[LK73]. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  38. 2 – opt (arcs): try allinversions of some subsequence if improvement  start again from beginning 3 – opt (arcs): try allshifts of some subsequence to different positions if improvement  start again from beginning Local search heuristics 3-opt (nodes): swap every triplet of nodes in the permutation representing the solution. if improvement  start again from beginning 2-opt (nodes): swap every pair of nodes in the permutation representing the solution. if improvement  start again from beginning Vittorio Maniezzo - University of Bologna - Transportation Logistics

  39. Metaheuristcs for the TSP(some of them) Vittorio Maniezzo University of Bologna, Italy Vittorio Maniezzo - University of Bologna - Transportation Logistics

  40. Metaheuristics: focus on heuristic guidance • Simple heuristics can perform very well, but can get trapped in poor quality solutions (local optima). • Newapproaches have been presented starting from the mid '70ies. • They are algorithms which manage the trade-offbetween search diversification, when search is goingon in bad regions of the search space, and intensification, aimed atfinding the best solutions within the region being analyzed. • These algorithms have been named metaheuristics. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  41. Metaheuristics • Metaheuristics include: • Simulated Annealing • Tabu Search • GRASP • Genetic Algorithms • Variable Neighborhood Search • ACO • Particle Swarm Optimization (PSO) • … Vittorio Maniezzo - University of Bologna - Transportation Logistics

  42. Simulated Annealing • Simulated Annealing (SA) [AK89] modifies local search in order to accept, in probability, worsening moves. • 1. Generate an initial feasible solution S, • initialize S* = S and temperature parameter T. • 2. Generate S’N(S). • 3. If z(S') < z(S) then S=S', if(z(S*) > z(S)) S* = S • else accept to set S=S' with probability p = e-(z(S')-z(S))/kT. • 4. If (annealing condition) decrease T. • 5. If not(end condition) go to step 2. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  43. SA example: ulysses 16 • Simulated annealing trace Vittorio Maniezzo - University of Bologna - Transportation Logistics

  44. Tabu search • Tabu Search (TS) [GL97] escapes from local minima by moving onto the best solution of theneighborhood at each iteration, eventhough it is worse than the current one. • A memory structure called tabu list, TL, forbids to return to already explored solutions. • 1. Generate an initial feasible solution S, • set S* = S and initialize TL=. • 2. Find S' N(S), such that • z(S')=min {z(S^), S^ N(S), S^ TL}. • 3. S=S', TL=TL {S}, if (z(S*) > z(S)) set S* = S. • 4. If not(end condition) go to step 2. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  45. TS example: ulysses 16 • Tabu Search trace Vittorio Maniezzo - University of Bologna - Transportation Logistics

  46. GRASP • GRASP (Greedy Randomized Adaptive Search Procedure) [FR95] restarts search from another promising region of the searchspace as soon as a local optimum is reached. • GRASP consists in amultistart approachwith a suggestion on how toconstruct the initial solutions. • 1. Build a solution S (=S* in the first iteration) by a constructive greedy randomized procedure based on candidate lists. • 2. Apply a local search procedure starting from S and producing S'. • 3. If z(S')<z(S*) then S*=S'. • 4. If not(end condition) go to step 2. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  47. Genetic algorithms • Genetic Algorithms (GA) [G89] do not rely on construction or localsearch but on the parallel update of a set R of solutions. • This is achievedby recombining subsets of 2elements in R, the parent sets, toobtain new solutions. • To be effective on CO problems they are often hybridized with SA, TSor local search. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  48. Genetic algorithms • 1. Initialize a set R of solutions. • 2. Construct a set Rc of solutions by recombining pairs of randomly chosen elements in R. • 3. Construct a set Rmof solutions by randomly modifying elements in Rc. • 4. Construct the new set R by extracting elements from Rm, following a montecarlo strategy with repetitions. • 5. If not(end condition) go to step 2. Vittorio Maniezzo - University of Bologna - Transportation Logistics

  49. Components of a GA • A problem to solve, and ... • Encoding technique (gene, chromosome) • Initialization procedure (creation) • Evaluation function (fitness) • Selection of parents (reproduction) • Genetic operators (mutation, recombination) • Parameter settings (practice and art) Vittorio Maniezzo - University of Bologna - Transportation Logistics

  50. GA jargon • Procedure GA • { initialize population; • evaluate population; • while not(End_condition) • { selectparents for reproduction; • perform recombination and mutation; • evaluate population; • } • } Vittorio Maniezzo - University of Bologna - Transportation Logistics

More Related