37
Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

Embed Size (px)

Citation preview

Page 1: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

Spring 2015Mathematics in

Management Science

Traveling Salesman Problem

Approximate solutions for TSPNNA, RNN, SEA

Greedy Heuristic Algorithms

Page 2: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

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.

Page 3: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

Solving a TSP

Brute Force Algorithm – exhaustive search

Nearest Neighbor Algorithm

Repetitive Nearest Neighbor Algorithm

Sorted Edges Algorithm

Page 4: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

Counting Hamilton Circuits

The complete graph KN 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 is4,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.

Page 5: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

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

Page 6: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

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

Page 7: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

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

Page 8: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

From Chicago, find shortest route that visits each of Minneapolis, St. Louis, and Cleveland, and returns to Chicago.

Page 9: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

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.

Page 10: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

From Chicago, find shortest route that visits each of Minneapolis, St. Louis, and Cleveland, and returns to Chicago.

Page 11: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms
Page 12: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

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 ifIt closes a circuit that is not an HC, or

It meets a vertex that already has 2 edges which have been chosen.

Page 13: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

Sorted Edges Algorithm

Pick the cheapest link (edge with smallest weight) available.

Continue picking next cheapest link available that does notclose a circuit which is not an HC, norcreate three edges coming out of a single

vertex.

Done when get a Hamilton circuit.

Page 14: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

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!

Page 15: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

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”.

Page 16: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms
Page 17: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms
Page 18: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms
Page 19: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms
Page 20: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms
Page 21: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms
Page 22: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms
Page 23: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms
Page 24: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

ExampleFind an approximate solution to the following TSP using the Sorted-Edges Algorithm. A

D C40

BE

90100

10 20

8050 30

60 70

Page 25: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

ExampleFirst (smallest) edge: acceptable.

A

BE

90100

10 20

8050 30

60 70

D C40

Page 26: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

ExampleSecond (next smallest) edge: acceptable.

A

BE

90100

10 20

8050 30

60 70

D C40

Page 27: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

ExampleThird edge: acceptable.

A

BE

90100

8050 30

60 70

2010

D C40

Page 28: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

ExampleFourth edge: reject (creates premature loop; three edges into one vertex)

A

BE

90100

8050 30

60 70

2010

D C40

Page 29: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

ExampleFifth edge: reject (creates premature loop)

A

BE

90100

8050 30

60 70

2010

D C40

Page 30: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

ExampleSixth edge: reject (three edges at one vtx)

A

BE

90100

8050 30

60 70

2010

D C40

Page 31: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

ExampleSeventh edge: acceptable

A

BE

90100

8050 30

60 70

2010

D C40

Page 32: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

ExampleAlready added 4 of 5 edges. Only one possible to close up loop.

A

BE

90100

10 20

8050 30

60 70

D C40

Page 33: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

Example do NNA from BA B

CE

D

600

500

800400

700 650950

850550

750

Page 34: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms
Page 35: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms
Page 36: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms

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….

Page 37: Spring 2015 Mathematics in Management Science Traveling Salesman Problem Approximate solutions for TSP NNA, RNN, SEA Greedy Heuristic Algorithms