Download presentation
Presentation is loading. Please wait.
Published byElijah Ford Modified over 9 years ago
1
Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms
2
Traveling Salesman Problem Given a complete weighted graph, find a minimum weight Hamilton circuit. A Hamilton circuit visits each vertex exactly once. A complete graph has one edge btwn each pair of vtxs. A weighted graph has a weight (cost) for each edge.
3
Solving a TSP Brute Force Algorithm – exhaustive search Nearest Neighbor Algorithm Repetitive Nearest Neighbor Algorithm Sorted Edges Algorithm
4
Counting Hamilton Circuits The complete graph K N with N vertices has (N – 1)!/2 distinct Hamilton circuits. Here (N – 1)!/2 =(N-1)x(N-2)x···3x2x1. For N=30, the number of HCs is 4,420,880,996,869,850,977,271,808, 000,000. Generating 1 million HCs per second, say, it would take over 10 billion years to generate all of them. The BFA will take a loooong time to finish.
5
Approximate Solutions Number of HCs in even modest sized problems is so large that we cannot examine them all to find exact solutions by brute force. Instead we must rely on fast algorithms that find approximate solutions. NNA, RRN, SEA
6
Go Cheap – NNA Start from the home city. Go to the city that is the cheapest to get to. Repeat this. From each new city go to the next city that is the cheapest to get to. When there are no more new cities to go to, go back home
7
Nearest Neighbor Algorithm From a vertex, go to nearest vertex not already visited. Repeat until no more new vtxs; then go home. An example of a greedy algorithm: – doesn’t look at the “big picture”, – goes for immediate/short-term gains – can paint itself into a corner and be forced to accept a bad solution
8
From Chicago, find shortest route that visits each of Minneapolis, St. Louis, and Cleveland, and returns to Chicago.
9
Repetitive Nearest Neighbor Do NNA with each vertex of the graph as the starting vertex. Of all the circuits obtained, keep the best one. If there is a designated starting vertex, rewrite this best circuit using that vertex as the reference point.
10
From Chicago, find shortest route that visits each of Minneapolis, St. Louis, and Cleveland, and returns to Chicago.
12
Sorted Edges Algorithm Start with minimum cost edge. At each stage, use the cheapest (least cost) edge which is OK. Stop when have an HC. An edge is NOT OK if It closes a circuit that is not an HC, or It meets a vertex that already has 2 edges which have been chosen.
13
Sorted Edges Algorithm Pick the cheapest link (edge with smallest weight) available. Continue picking next cheapest link available that does not close a circuit which is not an HC, nor create three edges coming out of a single vertex. Done when get a Hamilton circuit.
14
Sorted Edges Algorithm Sort edges in order of increasing cost. Select edges in order from this list to subject to these rules: never reuse an edge skip edges that connect to vtx already having two used edges meeting there skip edges that create “premature” loops, (small circuits in graph that don’t include all vtxs). No circuits created until last edge is added!
15
Comparison of Algorithms Both are approximate; typically give different approximate solutions; typically neither is the “real” solution. Neither better than the other. NNA adds edges in order as you would traverse the circuit. SEA adds edges “at random” in the graph. Neither algorithm says what to do in the case of a “tie”.
24
Example Find an approximate solution to the following TSP using the Sorted-Edges Algorithm. A DC 40 B E 90 100 10 20 80 50 30 60 70
25
Example First (smallest) edge: acceptable. A B E 90 100 10 20 80 50 30 60 70 DC 40
26
Example Second (next smallest) edge: acceptable. A B E 90 100 10 20 80 50 30 60 70 D C 40
27
Example Third edge: acceptable. A B E 90 100 80 50 30 60 70 20 10 D C 40
28
Example Fourth edge: reject (creates premature loop; three edges into one vertex) A B E 90 100 80 50 30 60 70 20 10 D C 40
29
Example Fifth edge: reject (creates premature loop) A B E 90 100 80 50 30 60 70 20 10 D C 40
30
Example Sixth edge: reject (three edges at one vtx) A B E 90 100 80 50 30 60 70 20 10 DC 40
31
Example Seventh edge: acceptable A B E 90 100 80 50 30 60 70 20 10 DC 40
32
Example Already added 4 of 5 edges. Only one possible to close up loop. A B E 90 100 10 20 80 50 30 60 70 D C 40
33
Example do NNA from B AB CE D 600 500 800400 700 650950 850550 750
36
TSP – Conclusion How does one find an optimal Hamilton circuit in a complete weighted graph? NNA & SEA are fairly simple strategies for attacking TSPs, which quickly give good HCs. The search for an optimal and efficient general algorithm….
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.