SlideShare a Scribd company logo
TSP.1
9.4
Travelling Salesperson Problem
(TSP)
• Very famous problem
• Many practical applications
• Very easy to describe
• Very difficult to solve (Curse of Dimensionality)
• We shall consider the dynamic
programming (DP) approach
• Other approaches: see 620-362
TSP.2
Problem Formulation
• There are many ways to describe this
problem.
• We shall consider the following:
– English version
– Linear Programming oriented version
– Linear Programming Free version
– Dynamic programming version
TSP.3
English Version
• You are given a set of n cities
• You are given the distances between
the cities
• You start and terminate your tour at
your home city
• You must visit each other city exactly
once.
• Your mission is to determine the
shortest tour.
TSP.4
Maths versions
• We shall consider two Maths Version
• The first is LP-based
• The second is LP-free
• The first version dominates the OR
literature
TSP.5
TSP Version 1 (LP)
• Decision variable:
A boolean matrix x interpreted as
follows:
x(i,j):= 1, iff we go from city i to city j.
x(i,j) := 0, otherwise
TSP.6
Example
• This matrix represents the tour (1,2,3,4,1)
TSP.7
Objective function
• d(i,j) = (direct) distance between city i and
city j.
TSP.8
Constraints
• Each city must be “exited” exactly once
• Each city must be “entered” exactly once
TSP.9
Is this enough ?
TSP.10
No!
• The first two constraints allow sub-
tours
• Thus, we have to add a constraint that
will prevent sub-tours
TSP.11
Explanation: sub-tours
• Two subtour: (1,2,1) and (3,4,3)
• This solution is not feasible for the TSP
TSP.12
• If we start at the home city n=1, we will
not visit city 3 and 4.
• We must go from city 2 to either city 3
or city 4.
1
2
3
4
TSP.13
Subtour elimination constraint
• S = subset of cities
• |S| = cardinality of S (# of elements in S)
• There are 2n such sets !!!!!!!
TSP.14
Example
• Consider S={1,2}, |S|=2
• Hence the sub-tour
elimination constraint is
not satisfied.
• Indeed, thee are two
subtours in this solution
TSP.15
Thus, LP Version
TSP.16
LP-Free Version
• Decision variables:
xj := j-th city on the tour, j=1,2,…,n
• Example:
• x=(1,3,2,4,1)
• We start at city 1, then go to city 3,
then go to city 2 then go to city 4 then
return to city 1.
TSP.17
ASSUMPTION
• Assume that 0 is the home city, and
that there are n other cities
TSP.18
Objective function
TSP.19
Constraints
• The constraint basically says that x
is a permutation of the cities
(1,2,3,…,n)
• Make sure that you appreciate the
role of { } in this formulation.
TSP.20
LP-Free Formulation
• There are n! feasible solutions
TSP.21
Which one do you prefer?
TSP.22
LP Version
TSP.23
LP Free Version
TSP.24
DP Solution
• Let,
f(i,s) := shortest sub-tour given that we
are at city i and still have to visit the
cities in s (and return to home city)
Then clearly,
TSP.25
Explanation
• Then clearly, …..
(i,s)
We are at city i
and still have to
visit the cities
in s
Suppose we decide
that from here we
go to city j
Then we shall travel
the Distance d(i,j)
(j,s{j})
We are now at
city j and still
have to visit the
cities in s{j}
TSP.26
Example (Winston, p. 751)
• Distance (miles)
• Cities: New York, Miami, Dallas, Chicago
TSP.27
Initialization (s=)
• f(1, ) = d(1,0) = 1334
• f(2, ) = d(2,0) = 1559
• f(3, ) = d(3,0) = 809
TSP.28
Iteration (on, i and s)
• We shall generate s systematically by its “size”.
• Size = 1: Possible values for s: {1}, {2}, {3}.
• s = {1} : f(2,{1})= ? ; f(3,{1})= ?
• s = {2} : f(1,{2})= ? ; f(3,{2})= ?
• s = {3} : f(1,{3})= ? ; f(2,{3})= ?
TSP.29
|s|=1
f(i,{j}) = d(i,j)+f(j, )
• f(2,{1})= d(2,1) + f(1,) = 1343 + 1334 = 2677
• f(3,{1})= d(3,1) + f(1,) = 1397 + 1334 = 2731
• f(1,{2})= d(1,2) + f(2,) = 1343 + 1559 = 2902
• f(3,{2})= d(3,2) + f(2,) = 921 + 1559 = 2480
• f(1,{3})= d(1,3) + f(3,) = 1397 + 809 = 2206
• f(2,{3})= d(2,3) + f(3,) = 921 + 809 = 1730
TSP.30
|s| = 2
f(i,s)= min{d(i,j)+f(j,s{j}): j in s}
• Size = 2: Possible values for s: {1,2}, {1,3}, {2,3}
Thus, we have to determine the values of
• f(3,{1,2}) = ? ; f(2,{1,3}) = ? ; f(1,{2,3}) = ?
• Eg:
f(3,{1,2}) = min {d(3,j) + f(j,s{j}): j in {1,2} }
= min {d(3,1) + f(1,{2}) , d(3,2) + f(2,{1})}
= min {1397+2902,921+2677}
= min {4299,3598}
= 3598 , N(3,{1,2})={2}
TSP.31
|s| = 3
• In this case there is only one feasible s, namely
s={1,2,3}.
• Thus, there is only one equation to solve, namely
for i=0, s={1,2,3}. The value of f(0,{1,2,3}) is the
shortest tour.
• Note that in this case
• f(0,{1,2,3})=min {d(0,j) + f(j,{1,2,3}{j}: j in {1,2,3}
• = min {d(0,1)+f(1,{2,3}), d(0,2)+ f(2,{1,3}),
d(0,3)+f(3,{1,2})}
• =min {1334+3073, 1559+3549, 809 + 3598}
• = min {4407,5108,4407} = 4407, N(0,{1,2,3})={1,3}
TSP.32
Recovery
• S=(0,{1,2,3}), N(s)={1,3} , c=1
• S={1,{2,3}}, N(s)={2}, c=(1,2)
• S={2,{3}}, N(s)={3}, c=(1,2,3).
• Hence: x*=(0,1,2,3,0), z*=4407

More Related Content

Similar to Travelling sales an problem

time_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdftime_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdf
SrinivasaReddyPolamR
 
Traveling Salesman Problem
Traveling Salesman Problem Traveling Salesman Problem
Traveling Salesman Problem
Indian Institute of Technology, Roorkee
 
Laplace_1.ppt
Laplace_1.pptLaplace_1.ppt
Laplace_1.ppt
cantatebrugyral
 
Lecture11
Lecture11Lecture11
Lecture11
Nv Thejaswini
 
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
Mahbubur Rahman
 
Melaka Trial Paper 1 2010
Melaka Trial Paper 1 2010Melaka Trial Paper 1 2010
Melaka Trial Paper 1 2010
sooklai
 
1_Asymptotic_Notation_pptx.pptx
1_Asymptotic_Notation_pptx.pptx1_Asymptotic_Notation_pptx.pptx
1_Asymptotic_Notation_pptx.pptx
pallavidhade2
 
Optimal Vacation Itinerary Modeling
Optimal Vacation Itinerary ModelingOptimal Vacation Itinerary Modeling
Optimal Vacation Itinerary Modeling
Gerard Trimberger
 
bode_plot By DEV
 bode_plot By DEV bode_plot By DEV
bode_plot By DEV
Devchandra Thakur
 
Optimization algorithms for solving computer vision problems
Optimization algorithms for solving computer vision problemsOptimization algorithms for solving computer vision problems
Optimization algorithms for solving computer vision problems
Krzysztof Wegner
 
LaplaceTransformIIT.pdf
LaplaceTransformIIT.pdfLaplaceTransformIIT.pdf
LaplaceTransformIIT.pdf
jenniecortesmomongan
 
Residues in MATLAB
Residues in MATLABResidues in MATLAB
Residues in MATLAB
Patrick Trivilin Rodrigues
 
Algorithms - Rocksolid Tour 2013
Algorithms  - Rocksolid Tour 2013Algorithms  - Rocksolid Tour 2013
Algorithms - Rocksolid Tour 2013
Gary Short
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Swetha S
 
MATHEMATICS : ARITHMETIC PROGRESSIONS
MATHEMATICS : ARITHMETIC PROGRESSIONSMATHEMATICS : ARITHMETIC PROGRESSIONS
MATHEMATICS : ARITHMETIC PROGRESSIONS
virupapanju
 
Laplace transforms and problems
Laplace transforms and problemsLaplace transforms and problems
Laplace transforms and problems
Vishnu V
 
Laplace transforms
Laplace transformsLaplace transforms
Laplace transforms
Awais Chaudhary
 
Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法
Kai Katsumata
 
Recurrences
RecurrencesRecurrences
Appendix b 2
Appendix b 2Appendix b 2
Appendix b 2
Loc Tran
 

Similar to Travelling sales an problem (20)

time_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdftime_complexity_list_02_04_2024_22_pages.pdf
time_complexity_list_02_04_2024_22_pages.pdf
 
Traveling Salesman Problem
Traveling Salesman Problem Traveling Salesman Problem
Traveling Salesman Problem
 
Laplace_1.ppt
Laplace_1.pptLaplace_1.ppt
Laplace_1.ppt
 
Lecture11
Lecture11Lecture11
Lecture11
 
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
Constraint Satisfaction Problem (CSP) : Cryptarithmetic, Graph Coloring, 4- Q...
 
Melaka Trial Paper 1 2010
Melaka Trial Paper 1 2010Melaka Trial Paper 1 2010
Melaka Trial Paper 1 2010
 
1_Asymptotic_Notation_pptx.pptx
1_Asymptotic_Notation_pptx.pptx1_Asymptotic_Notation_pptx.pptx
1_Asymptotic_Notation_pptx.pptx
 
Optimal Vacation Itinerary Modeling
Optimal Vacation Itinerary ModelingOptimal Vacation Itinerary Modeling
Optimal Vacation Itinerary Modeling
 
bode_plot By DEV
 bode_plot By DEV bode_plot By DEV
bode_plot By DEV
 
Optimization algorithms for solving computer vision problems
Optimization algorithms for solving computer vision problemsOptimization algorithms for solving computer vision problems
Optimization algorithms for solving computer vision problems
 
LaplaceTransformIIT.pdf
LaplaceTransformIIT.pdfLaplaceTransformIIT.pdf
LaplaceTransformIIT.pdf
 
Residues in MATLAB
Residues in MATLABResidues in MATLAB
Residues in MATLAB
 
Algorithms - Rocksolid Tour 2013
Algorithms  - Rocksolid Tour 2013Algorithms  - Rocksolid Tour 2013
Algorithms - Rocksolid Tour 2013
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
MATHEMATICS : ARITHMETIC PROGRESSIONS
MATHEMATICS : ARITHMETIC PROGRESSIONSMATHEMATICS : ARITHMETIC PROGRESSIONS
MATHEMATICS : ARITHMETIC PROGRESSIONS
 
Laplace transforms and problems
Laplace transforms and problemsLaplace transforms and problems
Laplace transforms and problems
 
Laplace transforms
Laplace transformsLaplace transforms
Laplace transforms
 
Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法Linear Cryptanalysis Lecture 線形解読法
Linear Cryptanalysis Lecture 線形解読法
 
Recurrences
RecurrencesRecurrences
Recurrences
 
Appendix b 2
Appendix b 2Appendix b 2
Appendix b 2
 

Recently uploaded

ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
khuleseema60
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
EduSkills OECD
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
melliereed
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
RidwanHassanYusuf
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
Celine George
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
imrankhan141184
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
TechSoup
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
Krassimira Luka
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
David Douglas School District
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
Iris Thiele Isip-Tan
 
How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17
Celine George
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
Celine George
 

Recently uploaded (20)

ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
 
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
Andreas Schleicher presents PISA 2022 Volume III - Creative Thinking - 18 Jun...
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
Nutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour TrainingNutrition Inc FY 2024, 4 - Hour Training
Nutrition Inc FY 2024, 4 - Hour Training
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
 
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptxBIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
BIOLOGY NATIONAL EXAMINATION COUNCIL (NECO) 2024 PRACTICAL MANUAL.pptx
 
How to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 InventoryHow to Setup Warehouse & Location in Odoo 17 Inventory
How to Setup Warehouse & Location in Odoo 17 Inventory
 
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
Traditional Musical Instruments of Arunachal Pradesh and Uttar Pradesh - RAYH...
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
 
Temple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation resultsTemple of Asclepius in Thrace. Excavation results
Temple of Asclepius in Thrace. Excavation results
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
 
Educational Technology in the Health Sciences
Educational Technology in the Health SciencesEducational Technology in the Health Sciences
Educational Technology in the Health Sciences
 
How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17How to Predict Vendor Bill Product in Odoo 17
How to Predict Vendor Bill Product in Odoo 17
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17How Barcodes Can Be Leveraged Within Odoo 17
How Barcodes Can Be Leveraged Within Odoo 17
 

Travelling sales an problem

  • 1. TSP.1 9.4 Travelling Salesperson Problem (TSP) • Very famous problem • Many practical applications • Very easy to describe • Very difficult to solve (Curse of Dimensionality) • We shall consider the dynamic programming (DP) approach • Other approaches: see 620-362
  • 2. TSP.2 Problem Formulation • There are many ways to describe this problem. • We shall consider the following: – English version – Linear Programming oriented version – Linear Programming Free version – Dynamic programming version
  • 3. TSP.3 English Version • You are given a set of n cities • You are given the distances between the cities • You start and terminate your tour at your home city • You must visit each other city exactly once. • Your mission is to determine the shortest tour.
  • 4. TSP.4 Maths versions • We shall consider two Maths Version • The first is LP-based • The second is LP-free • The first version dominates the OR literature
  • 5. TSP.5 TSP Version 1 (LP) • Decision variable: A boolean matrix x interpreted as follows: x(i,j):= 1, iff we go from city i to city j. x(i,j) := 0, otherwise
  • 6. TSP.6 Example • This matrix represents the tour (1,2,3,4,1)
  • 7. TSP.7 Objective function • d(i,j) = (direct) distance between city i and city j.
  • 8. TSP.8 Constraints • Each city must be “exited” exactly once • Each city must be “entered” exactly once
  • 10. TSP.10 No! • The first two constraints allow sub- tours • Thus, we have to add a constraint that will prevent sub-tours
  • 11. TSP.11 Explanation: sub-tours • Two subtour: (1,2,1) and (3,4,3) • This solution is not feasible for the TSP
  • 12. TSP.12 • If we start at the home city n=1, we will not visit city 3 and 4. • We must go from city 2 to either city 3 or city 4. 1 2 3 4
  • 13. TSP.13 Subtour elimination constraint • S = subset of cities • |S| = cardinality of S (# of elements in S) • There are 2n such sets !!!!!!!
  • 14. TSP.14 Example • Consider S={1,2}, |S|=2 • Hence the sub-tour elimination constraint is not satisfied. • Indeed, thee are two subtours in this solution
  • 16. TSP.16 LP-Free Version • Decision variables: xj := j-th city on the tour, j=1,2,…,n • Example: • x=(1,3,2,4,1) • We start at city 1, then go to city 3, then go to city 2 then go to city 4 then return to city 1.
  • 17. TSP.17 ASSUMPTION • Assume that 0 is the home city, and that there are n other cities
  • 19. TSP.19 Constraints • The constraint basically says that x is a permutation of the cities (1,2,3,…,n) • Make sure that you appreciate the role of { } in this formulation.
  • 20. TSP.20 LP-Free Formulation • There are n! feasible solutions
  • 21. TSP.21 Which one do you prefer?
  • 24. TSP.24 DP Solution • Let, f(i,s) := shortest sub-tour given that we are at city i and still have to visit the cities in s (and return to home city) Then clearly,
  • 25. TSP.25 Explanation • Then clearly, ….. (i,s) We are at city i and still have to visit the cities in s Suppose we decide that from here we go to city j Then we shall travel the Distance d(i,j) (j,s{j}) We are now at city j and still have to visit the cities in s{j}
  • 26. TSP.26 Example (Winston, p. 751) • Distance (miles) • Cities: New York, Miami, Dallas, Chicago
  • 27. TSP.27 Initialization (s=) • f(1, ) = d(1,0) = 1334 • f(2, ) = d(2,0) = 1559 • f(3, ) = d(3,0) = 809
  • 28. TSP.28 Iteration (on, i and s) • We shall generate s systematically by its “size”. • Size = 1: Possible values for s: {1}, {2}, {3}. • s = {1} : f(2,{1})= ? ; f(3,{1})= ? • s = {2} : f(1,{2})= ? ; f(3,{2})= ? • s = {3} : f(1,{3})= ? ; f(2,{3})= ?
  • 29. TSP.29 |s|=1 f(i,{j}) = d(i,j)+f(j, ) • f(2,{1})= d(2,1) + f(1,) = 1343 + 1334 = 2677 • f(3,{1})= d(3,1) + f(1,) = 1397 + 1334 = 2731 • f(1,{2})= d(1,2) + f(2,) = 1343 + 1559 = 2902 • f(3,{2})= d(3,2) + f(2,) = 921 + 1559 = 2480 • f(1,{3})= d(1,3) + f(3,) = 1397 + 809 = 2206 • f(2,{3})= d(2,3) + f(3,) = 921 + 809 = 1730
  • 30. TSP.30 |s| = 2 f(i,s)= min{d(i,j)+f(j,s{j}): j in s} • Size = 2: Possible values for s: {1,2}, {1,3}, {2,3} Thus, we have to determine the values of • f(3,{1,2}) = ? ; f(2,{1,3}) = ? ; f(1,{2,3}) = ? • Eg: f(3,{1,2}) = min {d(3,j) + f(j,s{j}): j in {1,2} } = min {d(3,1) + f(1,{2}) , d(3,2) + f(2,{1})} = min {1397+2902,921+2677} = min {4299,3598} = 3598 , N(3,{1,2})={2}
  • 31. TSP.31 |s| = 3 • In this case there is only one feasible s, namely s={1,2,3}. • Thus, there is only one equation to solve, namely for i=0, s={1,2,3}. The value of f(0,{1,2,3}) is the shortest tour. • Note that in this case • f(0,{1,2,3})=min {d(0,j) + f(j,{1,2,3}{j}: j in {1,2,3} • = min {d(0,1)+f(1,{2,3}), d(0,2)+ f(2,{1,3}), d(0,3)+f(3,{1,2})} • =min {1334+3073, 1559+3549, 809 + 3598} • = min {4407,5108,4407} = 4407, N(0,{1,2,3})={1,3}
  • 32. TSP.32 Recovery • S=(0,{1,2,3}), N(s)={1,3} , c=1 • S={1,{2,3}}, N(s)={2}, c=(1,2) • S={2,{3}}, N(s)={3}, c=(1,2,3). • Hence: x*=(0,1,2,3,0), z*=4407