200 likes | 218 Views
Explore the strategies of Hamilton Paths, solving TSP problems, and simple and approximate algorithms for optimal touring. Includes an example of a tour of five cities and a tour of ten cities.
E N D
6 The Mathematics of Touring 6.1 Hamilton Paths and Hamilton Circuits 6.2 Complete Graphs? 6.3 Traveling Salesman Problems 6.4 Simple Strategies for Solving TSPs 6.5 The Brute-Force and Nearest-Neighbor Algorithms 6.6 Approximate Algorithms 6.7 The Repetitive Nearest-Neighbor Algorithm 6.8 The Cheapest-Link Algorithm
Example 6.7 A Tour of Five Cities: Part 2 In Example 6.4 we met Willy the traveling salesman pondering his upcomingsales trip, dollar signs running through his head. (The one-way airfares between any two cities are shown again in Fig.6-10.) Imagine now that Willy, unwilling or unable to work out the problem for himself, decides to offer areward of $50 to anyone who can find an optimal tour. Would it be worth $50to you to work out this problem? (Yes.) So how would you do it?
Example 6.7 A Tour of Five Cities: Part 2 In Example 6.4 we met Willy the traveling salesman pondering his upcomingsales trip, dollar signs running through his head. The one-way airfares between any two cities are shown.
Example 6.7 A Tour of Five Cities: Part 2 Imagine now that Willy, unwilling or unable to work out the problem for himself, decides to offer areward of $50 to anyone who can find an optimal tour. Would it be worth $50to you to work out this problem? (Yes.) So how would you do it?
Traveling Salesman Problems We will explore two strategies for solving traveling salesman problems: 1. Exhaustive Search 2. Go Cheap
STRATEGY 1(EXHAUSTIVE SEARCH) Make a list of all possible Hamilton circuits. For each circuit in the list, calculate the weight of the circuit. From all the circuits, choose a circuit with leasttotal weight. This is your optimal tour.
Example 6.7 A Tour of Five Cities: Part 2 - STRATEGY 1 The table on the next slide shows a detailed implementation of this strategy. The 24 Hamiltoncircuits are split into two columns consisting of circuits and their mirror images.The total costs for the circuits are shown in themiddle column of the table. There are two optimal tours, with a total cost of $676 – A,D, B, C ,E, A and its mirror image A, E, C, B, D, A.
Example 6.7 A Tour of Five Cities: Part 2 - STRATEGY 1 The first group of 12 Hamilton circuits:
Example 6.7 A Tour of Five Cities: Part 2 - STRATEGY 1 The second group of 12 Hamilton circuits:
Example 6.7 A Tour of Five Cities: Part 2 - STRATEGY 1 There are always going to be at least two optimal tours, since the mirror imageof an optimal tour is also optimal. Either one of them can be used for a solution.
STRATEGY 2(GO CHEAP) • Start from the home city. From there go to the city that is the cheapest to get to. From each new city go to the next new city that is cheapest to get to. When there are no more new cities to go to, go back home.
Example 6.7 A Tour of Five Cities: Part 2 - Strategy 2 In Willy’s case, this strategy works like this: Start at A. From A Willygoes to C (the cheapest place he can fly to from A). From C C to E,E to D, and fromD the last new city to go to is B. From B Willy has toreturn home to A. The total cost of this tour is $773.
Example 6.7 A Tour of Five Cities: Part 2 - Strategy 2 The “go cheap” strategy takes a lot less work than the “exhaustive search”strategy, but there is a hitch – the cost of the tour we get is $773, which is $97more than the optimal tour found under the exhaustive search strategy. Willysays this is not a solution and refuses to pay the $50. The “go cheap” strategylooks like a bust, but be patient –there is more to come.
Example 6.8 A Tour of (Gasp!) 10 Cities Let’s imagine now that Willy, who has done very well with his business, hasexpanded his sales territory to 10 cities (let’s call them A through K). Willy wantsus to help him once again find an optimal tour of his sales territory. Flush withsuccess and generosity, he is offering a whopping $200 as a reward for a solutionto this problem. Should we accept the challenge?
Example 6.8 A Tour of (Gasp!) 10 Cities The graph represents the 10 cities. With this many edges the graph would get prettycluttered if we tried to show the weights (one-way fares between cities) on the graph itself. It is better to putthem in a table, which is on the next slide.
Example 6.8 A Tour of (Gasp!) 10 Cities The table shows theone-way fares between the pairs of cities.
Example 6.8 A Tour of (Gasp!) 10 Cities We now know that a foolproof method for tackling this problemis the “exhaustive search” strategy. But let’s think ofwhat we are getting into. With 10 cities we have 9! = 362,880 Hamilton circuits.Assuming we could compute the cost of a new circuit every 30 seconds–andthat’s working fast–it would take about 3000 hours to do all 362,880 possible circuits. Shortcuts? Say you cut the work in half by skipping the mirror-image circuits. That’s 1500 hours of work. If you worked nonstop, 24 hours a day, 7 days aweek it would still take a couple of months!
Example 6.8 A Tour of (Gasp!) 10 Cities Let’s now try the “go cheap” strategy. The trip would start at A, go to C (119), to E (120), to D (199), to B (150), to J (379), to G (241), to K (235), to F (222), to H (211), and back to A (277).
Example 6.8 A Tour of (Gasp!) 10 Cities The final resultis the tour A, C, E, D, B, J, G, K, F, H, A, with a total cost of $2153.So we now have a tour, but is it the optimal tour? If it isn’t–is it at least close?Willy refuses to pay the $200 unless these questions can be answered to his satisfaction. We will settle this issue later in the chapter.