1 / 11

Chapter 6 The Traveling Salesman Problem Hamilton’s Circuit

Chapter 6 The Traveling Salesman Problem Hamilton’s Circuit. Background. Traveling Salesman Problem—visit many cities and return home spending the least amount of money (most cost effective way). 6.1-6.3—Understanding of what a TSP is. 6.4-6.8—Understanding of how to solve them.

suzuki
Télécharger la présentation

Chapter 6 The Traveling Salesman Problem Hamilton’s Circuit

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. Chapter 6The Traveling Salesman ProblemHamilton’s Circuit

  2. Background • Traveling Salesman Problem—visit many cities and return home spending the least amount of money (most cost effective way). • 6.1-6.3—Understanding of what a TSP is. • 6.4-6.8—Understanding of how to solve them

  3. 6.1 Hamilton Circuit and Hamilton Paths • Hamilton Path– a path that visits each vertex of the graph once and only once (unlike an Euler path which you could touch a vertex more than one—you could only travel an edge once and only once). • Hamilton Circuit– a circuit that visits each vertex of the graph once and only once (at the end, of course, the circuit must return to the starting vertex). • Once a graph has a Hamilton circuit, it automatically has a Hamilton path. • Warm-up—”Euler vs. Hamilton” • Errands, Errands, Errands! Worksheet

  4. 6.2 Complete Graphs(special family of graphs) • Completed Graph –a graph with N vertices in which EVERY pair of distinct vertices is joined by an edge. (notation used is KN ; K4 in the figure below) • Every vertex has (N-1) degree. • KN has N(N-1)/2 edges. • Of all graphs with N vertices and no multiple edges or loops, KN has the most edges. • Because KN has a complete set of edges, it also has a complete set of Hamilton circuits—you can travel the vertices in ANY sequence you choose and you will not get stuck.

  5. Hamilton Circuits in KN • There are (N-1)! distinct Hamilton circuits in KN • 6.3—Traveling Salesman Problems (TSPs) involve connected graphs. Examples: routing school buses, package deliveries, running errands around town. • Need to find a “weighted graph” that represents a situation—weights are attributed to each edge—could be cost, distance, or time. • Then, use the weights to determine the most cost effective route to travel. • 6.4—There are two simplified strategies to find the most cost effective route: 1) Exhaustive Search, and 2) Go Cheap. • Exhaustive Search —write down all of the circuits with their total weights and find the least amount. • Go Cheap —start at your home city and travel to the cheapest city next…from there, travel to the next cheapest city until you have returned home. • Classwork/Homework Pg. 221: 1-15 odd

  6. 6.5 The Brute-Force Algorithmfor solving TSPs • Formalized version of “Exhaustive Search” strategy. • Step 1 –Make a list of all possible Hamilton circuits of the graph. • Step 2 –For each Hamilton circuit calculate its total weight (i.e., add the weights of all of the edges in the circuit). • Step 3 –Choose an optimal circuit (there is always more than one optimal one to choose from!).

  7. Pros and Cons of Brute-Force Algorithm

  8. 6.5 The Nearest Neighbor Algorithmfor TSPs • Formalized version of the “Go Cheap” strategy. • Start –Start at the designated vertex (home). If there is no designated vertex, pick one. • First Step –From the starting vertex go to its nearest neighbor (i.e., the vertex for which the corresponding edge has the smallest weight). • Middle Steps –From each vertex go to its nearest neighbor, choosing only among the vertices that haven’t been yet visited. (If there is more than one nearest neighbor, choose among them at random). Keep doing this until all the vertices have been visited. • Last step –From the last vertex, return to the starting vertex.

  9. Pros and Cons of Nearest Neighbor Algorithm

  10. 6.7 The Repetitive Nearest-Neighbor Algorithm • Variation of the Nearest-Neighbor Algorithm • A circuit really has no starting or ending point…it completes a “full circle”. So, you could start at any vertex and travel the same Hamilton circuit. • Step 1 –Find the nearest-neighbor circuit for one vertex along with its weight. • Step 2 –Repeat this process with every other vertex. • Step 3 –Of the nearest-neighbor circuits obtained, keep the best one. If there is a designated starting vertex, rewrite the circuit using that vertex as the reference point. • Classwork/Homework Pg. 225: 37-41 all

  11. 6.8 The Cheapest-Link Algorithm • Step 1 –Pick the cheapest link (edge with the smallest weight) available—in the event of a tie, choose one at random. • Step 2 –Pick the next cheapest link—this edge does NOT have to be adjacent to the 1st edge! • Step 3 –Continue this, each time choosing the cheapest edge available, but you must follow these two rules: 1) Do NOT allow a circuit to form except at the very end, and2) Do NOT allow three edges to come together at the same vertex. • A violation of either of these two rules will prevent forming a Hamilton Circuit. • Last Step –Connect the last two vertices to close the circuit. • Finish the Pink Packet packet can be used on the test. • Homework/Classwork Pg. 225: 43-47 all

More Related