the travelling salesman problem involves visiting every town (node) on a graph and returning to the...

31
The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show how to find 2 values that the actual journey lies between called the Upper and Lower Bound. The French towns below have to be visited Travelling Salesman Problem

Upload: karin-roberts

Post on 02-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance.The slides will show how to find 2 values that the actual journey lies between called the Upper and Lower Bound.The French towns below have to be visited

Travelling Salesman Problem

Page 2: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

The following slides show how to find an Upper Bound to the travelling Salesman Problem using the Nearest Neighbour Algorithm and a Lower Bound by removing a town and using the Minimum Connector Algorithm

Travelling Salesman Problem

Link to Nearest Neighbour Algorithm to find an Upper Bound

Link to finding a Lower Bound using Kruskals Algorithm

Page 3: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Nearest Neighbour Algorithm

This is will give an Upper Bound to the Travelling Salesman problem.

It may be possible to complete the journey in a smaller distance but the Upper Bound is an upper limit to the required distance and is definitely possible.

The smaller the Upper Bound the better

Page 4: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Nearest Neighbour from a Table

The chart shows the distances between French towns

Page 5: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

1. Choose a starting town2. Find the nearest neighbour3. Repeat step 2 ensuring that you have not already been there.4. When all the towns have been visited return to the starting

town using the shortest route.5. Repeat using a different starting place and the answer giving

the lowest total distance is the Upper Bound

Page 6: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Start at LyonsReading across nearest neighbour is Dijon – 192 milesReading down nearest neighbour is St Etienne – 59 milesChoose St Etienne

Lyons St Etienne

1

2

Page 7: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Carry on from St EtienneReading across nearest neighbour is Dijon – 244 milesReading down nearest neighbour is Toulouse – 528 milesChoose Dijon

Lyons St Etienne

1

2

3

Dijon

Page 8: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Carry on from DijonCannot choose Lyons as this has already been usedReading across nearest neighbour is Calais – 543 milesReading down nearest neighbour is Orleans – 297 milesChoose OrleansLyons St Etienne Dijon

1

2

3

4

Orleans

Page 9: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Carry on from OrleansReading across nearest neighbour is Calais – 421 milesReading down nearest neighbour is Poitiers – 212 milesChoose Poitiers

Lyons St Etienne Dijon Orleans

1

2

3

45

Poitiers

Page 10: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Carry on from PoitiersReading across nearest neighbour is Bordeaux – 247 milesReading down nearest neighbour is Toulouse – 435 milesCannot choose St Etienne as already visitedChoose BordeauxLyons St Etienne Dijon Orleans Poitiers

1

2

3

45

Bordeaux

6

Page 11: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Carry on from BordeauxReading down nearest neighbour is Toulouse – 244 milesCannot read acrossChoose Toulouse

Lyons St Etienne Dijon Orleans Poitiers

1

2

3

45

BordeauxToulouse

6

7

Page 12: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Carry on from ToulouseReading across nearest neighbour is Marseille – 405 milesCannot read downChoose Marseille

Lyons St Etienne Dijon Orleans Poitiers

1

2

3

45

BordeauxToulouse

6

7

Marseille

8

Page 13: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Carry on from Marseille Reading across nearest neighbour is Calais – 1067 miles (Rest have all been visited)Reading down nearest neighbour have all been visitedChoose Calais

Lyons St Etienne Dijon Orleans Poitiers

1

2

3

45

BordeauxToulouse

6

7

Marseille

8

8

Calais

Page 14: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Carry on from CalaisAll towns have been visited so return to Lyons – 751 miles

Lyons St Etienne Dijon Orleans Poitiers

1

2

3

45

BordeauxToulouse

6

7

Marseille

8

8

Calais

Total distance = total of circled values = 3526 miles

Upper Bound = 3526

Page 15: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Now repeat using a different starting valueThe lowest value obtained is the Upper BoundThis means that the shortest route is equal or less than the Upper Bound

Page 16: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Lower BoundThis is the smallest journey that it may be possible to do.

It may not in fact be possible to actually achieve this distance but it is a value to aim for.

The actual journey length lies between the upper and lower bound.

Page 17: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Lower Bound from a Table

The chart shows the distances between French towns

Page 18: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

1. Remove one of the towns2. Find the minimum connector of the remaining towns using

Prim or Kruskal3. Add the town removed back in using the shortest 2 arcs.4. Find the total length of all the arcs used.

Page 19: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Remove MarseilleNow do Kruskals AlgorithmFind the shortest distance : Draw it

1

2

St EtienneLyons

St Etienne to Lyon 59 miles

Page 20: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Find the next shortest distance Draw it

1

2

St EtienneLyonsDijon

3

Dijon to Lyons 192 miles

Page 21: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Find the next shortest distance Draw it

1

2

St EtienneLyonsDijon

3

PoitiersOrleans

4

5

Orleans to Poitiers 212 miles

Page 22: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Find the next shortest distance Ignore Dijon to St Etienne as this makes a cycleDraw it

1

2

St EtienneLyonsDijon

3

PoitiersOrleans

4

ToulouseBordeaux

6

5

7

Bordeaux to Toulouse 244 miles

Page 23: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Find the next shortest distance Draw it

1

2

St EtienneLyonsDijon

3

PoitiersOrleans

4

ToulouseBordeaux

5

7

6

Bordeaux to Poitiers 247 miles

Page 24: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Find the next shortest distance Draw it

1

2

St EtienneLyonsDijon

3

PoitiersOrleans

4

ToulouseBordeaux

6

5

7

Orleans to Dijon 297 miles

Page 25: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Find the next shortest distance Ignore Orleans to St Etienne and Poitiers to St Etienne as these make a cycleDraw it

1

2

St EtienneLyonsDijon

3

PoitiersOrleans

4

ToulouseBordeaux

6

5

7

8

Calais

Calais to Orleans 421 miles

Page 26: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Now all the towns are connected with the minimum connectorFinally join Marseille back in with the shortest 2 arcs

1

2

St EtienneLyonsDijon

3

PoitiersOrleans

4

ToulouseBordeaux

6

5

7

8

Calais

Page 27: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Now all the towns are connected with the minimum connectorFinally join Marseille back in with the shortest 2 arcs

1

2

St EtienneLyonsDijon

3

PoitiersOrleans

4

ToulouseBordeaux

6

5

7

8

Calais

Marseille

Page 28: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Adding up all the circled distances gives a lower bound This can be repeated to find another lower bound by removing a different town

1

2

St EtienneLyonsDijon

3

PoitiersOrleans

4

ToulouseBordeaux

6

5

7

8

Calais

Marseille

Lower Bound = 2297

Page 29: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

The highest lower bound is the best as the actual answer lies between the Lower and Upper bound. If the Lower and Upper bound are the same then that is the answer

1

2

St EtienneLyonsDijon

3

PoitiersOrleans

4

ToulouseBordeaux

6

5

7

8

Calais

Marseille

Lower Bound = 2297

Page 30: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Lyons St Etienne Dijon Orleans Poitiers

1

2

3

45

BordeauxToulouse

6

7

Marseille

8

8

Calais

Total distance = 3526 miles

Upper Bound = 3526

Page 31: The travelling Salesman problem involves visiting every town (node) on a graph and returning to the start in the shortest distance. The slides will show

Upper Bound = 3526Lower Bound = 2297

The actual answer lies between the Lower and Upper bound and can only be found by trial and error.The Upper and Lower Bound give an idea as to what the actual answer lies betweenThe smaller the gap the better.Remember need High Lower Bound and Low Upper Bound.