travelling salesman problem - bme kukgkukg.bme.hu/.../uploads/2019/04/12_travelling-salesman.pdf ·...

30
BME FACULTY OF TRANSPORTATION ENGINEERING AND VEHICLE ENGINEERING 32708-2/2017/INTFIN COURSE MATERIAL SUPPORTED BY EMMI Dr. Tibor SIPOS Ph.D . Dr. Árpád TÖRÖK Ph.D . Zsombor SZABÓ 2019 TRAVELLING SALESMAN PROBLEM

Upload: others

Post on 16-Aug-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

BME FACULTY OF TRANSPORTATION ENGINEERING AND VEHICLE ENGINEERING32708-2/2017/INTFIN COURSE MATERIAL SUPPORTED BY EMMI

Dr. Tibor SIPOS Ph.D.Dr. Árpád TÖRÖK Ph.D.Zsombor SZABÓ2019

TRAVELLING SALESMAN PROBLEM

Page 2: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

2

• Main reason to analyse the branch and boundtechnique is to solve the travelling salesmanproblem

• The travelling salesman problem (TSP) is one of the most important optimization problems

• The most famous problem for TSP is the Bridgesof Königsberg

Introduction

Page 3: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

3

• Clay Mathematics Institute – Millenium Problems• Seven most important problems which are unsolved• 𝑃 = 𝑁𝑃 should be proven or negatived• TSP is one of the most famous problem which NP

solution (exponential timed) is known but the P solution (polinomial timed) is researched

• A US $1 million prize being awarded by the institute to the discoverer

• http://www.claymath.org/millennium-problems• http://www.claymath.org/millennium-problems/p-

vs-np-problem

Problem

Page 4: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

4

• In the travelling salesman problem there are 𝑛points of interests (for example cities), and theresistance between them

• The task is to plan the shortest route whichincludes all of the cities for exactly one time

Description

Page 5: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

5

min 𝑍 =

𝑖=1

𝑚

𝑗=1

𝑛

𝑐𝑖𝑗𝑥𝑖𝑗

𝑗=1

𝑛

𝑥𝑖𝑗 = 1 ∀𝑖

𝑖=1

𝑚

𝑥𝑖𝑗 = 1 ∀𝑗

𝑥𝑖𝑗 = ቊ01∀ 𝑖, 𝑗

Description

• Note, that there is another constraintwhich is difficult toformulate

• If the matrix is considered as a graph, then the chosen arcsmust give one, and onlyone circle

Page 6: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

6

• Four steps:

– Matrix reduction: Each element of each row are reduced by the row’s minimum. Then this method is also used for the columns

– On the zero cells the 𝑟 values are counted

– Choose the maximum of the r values

– Then comes the branch and bound method. Thereare two possible ways. The chosen element can be eliminated or can be chosen into the route

Method

Page 7: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

7

Example

D 5 2 6 M

B 1 M 2 7

C 4 8 M 5

A B C D

A M 6 2 4

Page 8: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

8

• Note, that the elements in the matrix’s main diagonal cannot be chosen, so they are signed by‘M’

Table form

Page 9: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

9

Reducted matrix

B

D

C 0 4 M 0

A M 4 0 1

0 M 1 5

A B C D

3 0 4 M

Page 10: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

10

• The second step is the calculating of the 𝑟 valuesfor all of the zeros

𝑟 Ƹ𝑖 Ƹ𝑗 = min𝑗

𝑐 Ƹ𝑖𝑗 +min𝑖𝑐𝑖 Ƹ𝑗

• With this, the next 𝑟 values are occurred𝑟𝐴𝐶 = 1 + 1 = 2𝑟𝐵𝐴 = 0 + 1 = 1𝑟𝐶𝐴 = 0 + 0 = 0𝑟𝐶𝐷 = 0 + 1 = 1𝑟𝐷𝐵 = 3 + 4 = 7

𝒓 values

Page 11: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

11

• The branch and bound method is need an initialbound to solve

• The initial bound for the problem is the sum of therows’ and columns’ minimums during the matrixreduction (𝑍∗ = 10 = 𝑘0)

• In the branching method there are two branches, choosing or eliminating

Branch and Bound

Page 12: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

12

• The branch’s bound will be set𝑘𝑙 = 𝑘𝑙− + 𝑟𝑖𝑗

• The eliminated cell must be signed by ‘M’, and then the matrix reduction will be the next step

Branch and Bound – Eliminating

Page 13: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

13

Branch and Bound – Eliminating

A

B 0

D 3

MA

C 0 4 M 0

M 4 M

M 1 5

B C D

4 0 1

Page 14: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

14

• If the recent element is chosen for the shortestroute, then the cell itself (𝑐 Ƹ𝑖 Ƹ𝑗), the whole row,

the whole column and 𝑐𝑖= Ƹ𝑗,𝑗= Ƹ𝑖 need to be set to

0

• The bound will not increase, only if a row or a column occur, where there will not be any zeros

• Because there is a 0 in every row and column, the 𝑘 will not change

Branch and Bound – Choosing in

Page 15: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

15

Branch and Bound – Choosing in

A M M 0 1

A

B 0

D

C 0

M M M M

C DB

1 MM

M M 0

Page 16: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

16

• Some special issues are needed

• In these problems the 𝑍∗ will not occur, insteadof this there is a recent 𝑘 value

• The unfeasible subproblem is a remainingcriteria

• During the fathoming step the subproblem withthe lower bound is ought to be chosen

Branch and Bound – Fathoming

Page 17: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

17

First Step – Enumeration Tree

Page 18: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

18

Second Step – Initial Matrix

A M M 0 1

A

B 0

D

C 0

M M M M

C DB

1 MM

M M 0

Page 19: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

19

• No more matrix reduction is needed

• 𝑟 values are ought to be calculated𝑟𝐴𝐶 = 1 + 1 = 2𝑟𝐵𝐴 = 0 + 1 = 1𝑟𝐶𝐴 = 0 + 0 = 0𝑟𝐶𝐷 = 0 + 1 = 1

• AC cell should be used

• L3: AC cell is eliminated (𝑘3 = 12)

• L4: AC cell is used (𝑘4 = 10)

Second Step – 𝒓 values

Page 20: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

20

Second Step – Chosen element

M M 0 1

A B C D

D M M M M

C 0 M M 0

B 0 M 1 M

A

Page 21: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

21

Second Step – Eliminating

M M 1

A B C D

D M M M M

C 0 M M 0

B 0 M 1 M

A M

Page 22: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

22

Second Step – Choosing in

M M

A B C D

D M M M M

C M M M 0

B 0 M M M

A M M

Page 23: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

23

Second Step – Enumeration Tree

Page 24: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

24

Third Step – Initial Matrix

M M

A B C D

D M M M M

C M M M 0

B 0 M M M

A M M

Page 25: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

25

• There are only two feasible cells remained, which are our missing sections

• So the optimal solution is occurred:𝐷 → 𝐵 → 𝐴 → 𝐶 → 𝐷

• Because the new actual optimal solution is𝑘4 = 10 then the higher branches should be fathomed

Third Step – Conclusions

Page 26: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

26

C 4 8 M 5

D 5 2 6 M

A M 6 2 4

B 1 M 2 7

A B C D

Optimal solution: 𝐷 → 𝐵 → 𝐴 → 𝐶 → 𝐷

Page 27: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

27

Optimal solution: 𝐷 → 𝐵 → 𝐴 → 𝐶 → 𝐷

D 5 2 6 M

B 1 M 2 7

C 4 8 M 5

A B C D

A M 6 2 4

Page 28: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

28

Optimal solution: 𝐷 → 𝐵 → 𝐴 → 𝐶 → 𝐷

5

D 5 2 6 M

D

A M 6 2 4

B 1 M 2 7

A B C

C 4 8 M

Page 29: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

29

Optimal solution: 𝐷 → 𝐵 → 𝐴 → 𝐶 → 𝐷

M 5

D 5 2 6 M

C D

A M 6 2 4

B 1 M 2 7

A B

C 4 8

Page 30: TRAVELLING SALESMAN PROBLEM - BME KUKGkukg.bme.hu/.../uploads/2019/04/12_Travelling-salesman.pdf · 2019. 4. 28. · •The travelling salesman problem (TSP) is one of the most important

BME FACULTY OF TRANSPORTATION ENGINEERING AND VEHICLE ENGINEERING32708-2/2017/INTFIN COURSE MATERIAL SUPPORTED BY EMMI

Dr. Tibor SIPOS Ph.D.Dr. Árpád TÖRÖK Ph.D.Zsombor SZABÓ

email: [email protected]

BUDAPEST UNIVERSITY OF TECHNOLOGY AND ECONOMICS