Transcript

§ 6.3-6.4 Traveling-§ 6.3-6.4 Traveling-Salesman Problems; Salesman Problems;

Simple Strategies to Simple Strategies to Solve TSPsSolve TSPs

ExampleExample (D`oh!): We all know that Homer is (D`oh!): We all know that Homer is lazy. However, he has to run errands at the lazy. However, he has to run errands at the Kwik-E-Mart, the Retirement Home and Moe`s. Kwik-E-Mart, the Retirement Home and Moe`s. Assuming that he wants to begin and end his Assuming that he wants to begin and end his day at home find the route that will allow day at home find the route that will allow him to get back to napping as soon as him to get back to napping as soon as possible.possible.

• We might represent this dilemma with the We might represent this dilemma with the following graph:following graph:

12

8

20

1715

20

A

B

C

D

• We might represent this dilemma with the We might represent this dilemma with the following graph:following graph:

12

8

20

1715

27

A

B

C

D

These numbers will represent the number of blocks between each destination.

When we place values like this on the edges of a graph we refer to them as the weights of the edges.

• One solution might begin as follows:One solution might begin as follows:

1212

8

20

1715

20

A

B

C

D

• . . . And continue like so. . . . . . And continue like so. . .

1212

8

2020

1715

20

A

B

C

D

• . . . And so on . . . . . . And so on . . .

1212

8

2020

171715

20

A

B

C

D

• . . . Continuing until he arrives back at . . . Continuing until he arrives back at home. home.

1212

88

2020

171715

20

A

B

C

D

• Following this circuit, we find that Homer has to travel

12 + 8 + 20 + 17 = 57 blocks to finish his errands and get back to napping.

• But is this the most efficient route he can take?

• How might we find this bestroute?

• `Method 1`Make a list of all possible

Hamiltonian circuits.Calculate the `cost` for each

one.Select the circuit with the

least cost.

• `Method 1`Make a list of all possible

Hamiltonian circuits.Calculate the `cost` for each

one.Select the circuit with the

least cost. Circuit Mirror Image

Weight

A, B, C, D, A

A, D, C, B, A

12 + 8 + 20 + 17 = 57

A, B, D, C, A

A, C, D, B, A

12 + 20 + 17 + 15 = 74

A, C, B, D, A

A, D, B, C, A

15 + 20 + 20 + 8 = 63

• `Method 1`Make a list of all possible

Hamiltonian circuits.Calculate the `cost` for each

one.Select the circuit with the

least cost. Circuit Mirror Image

Weight

A, B, C, D, A

A, D, C, B, A

12 + 8 + 20 + 17 = 57

A, B, D, C, A

A, C, D, B, A

12 + 20 + 17 + 15 = 74

A, C, B, D, A

A, D, B, C, A

15 + 20 + 20 + 8 = 63

We can see that the first We can see that the first route was indeed the most route was indeed the most efficient--Homer can get efficient--Homer can get back to his nap after back to his nap after traveling only 57 blocks. traveling only 57 blocks. Woo Hoo!Woo Hoo!

Example: The Galactica needs to survey a set of planets (A, B, C, D, E, F, G) in order to find water for the Fleet. the Commander has asked the helm to chart the course that will use the lowest amount of tylium fuel.

Example: The Galactica needs to survey a set of planets (A, B, C, D, E, F, G) in order to find water for the Fleet. the Commander has asked the helm to chart the course that will use the lowest amount of tylium fuel.

Again, we can model this situation using a graph like the one on the screen to the right.

• this time, however, it is incredibly difficult to list all the possible paths, so the ‘homer’ method (I.e. Method I( is not a good choice here.

• in fact, even listing the weight of each edge on the graph is hard given the number of vertices.

• so, the first thing we will do is list the weights in a table. . .

A

B

C

G

FE

D

75

22

50

13

40

20

40

30 6550

80

35

2915

4835

60

28

30 32

28

A B C D E F G

A 75 50 28 35 15 22

B 75 30 60 80 65 50

C 50 30 40 48 35 28

D 28 60 40 20 30 29

E 35 80 48 20 40 32

F 15 65 35 30 40 13

G 22 50 28 29 32 13

THE FOLLOWING TABLE TELLS US HOW MANY TONS OF TYLIUM IT TAKES TO TRAVEL FROM ONE PLANET TO ANOTHER:

A B C D E F G

A 75 50 28 35 15 22

B 75 30 60 80 65 50

C 50 30 40 48 35 28

D 28 60 40 20 30 29

E 35 80 48 20 40 32

F 15 65 35 30 40 13

G 22 50 28 29 32 13

THE FOLLOWING TABLE TELLS US HOW MANY TONS OF TYLIUM IT TAKES TO TRAVEL FROM ONE PLANET TO ANOTHER:

METHOD I IS IMPRACTICAL HERE (WE HAVE (7-1)!=6!=720 POSSIBLE HAMILTONIAN CIRCUITS!)

SO WHAT CAN WE DO IN THIS CASE?

A B C D E F G

A 75 50 28 35 15 22

B 75 30 60 80 65 50

C 50 30 40 48 35 28

D 28 60 40 20 30 29

E 35 80 48 20 40 32

F 15 65 35 30 40 13

G 22 50 28 29 32 13

THE FOLLOWING TABLE TELLS US HOW MANY TONS OF TYLIUM IT TAKES TO TRAVEL FROM ONE PLANET TO ANOTHER:

LET’S TRY THE FOLLOWING:

METHOD 2START AT VERTEX A. FROM THERE, GO TO THE VERTEX WHICH COSTS THE LEAST TO GET TO.KEEP GOING TO THE ‘CHEAPEST’ VERTEX UNTIL YOU GET BACK TO A.

THIS METHOD MAY NOT GIVE US THE MOST EFFICIENT ROUTE, BUT IN GENERAL IT GETS US CLOSE.

THEREFORE, WE USE IT WHEN COMPUTING THE COST OF ALL THE POSSIBLE CIRCUITS IS IMPRACTICAL.WE WILL FORMALIZE THESE METHODS

AND A VARIATION ON THE SECOND ONE TOMORROW. . .


Top Related