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
32
Embed
TSP.1 9.4 Travelling Salesperson Problem (TSP) Very famous problem Many practical applications Very easy to describe Very difficult to solve (Curse of.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
TSP.1
9.4Travelling 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)
x =
0 1 0 0
0 0 1 0
0 0 0 1
1 0 0 0
⎡
⎣
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
TSP.7
Objective function
• d(i,j) = (direct) distance between city i and city j.
z = x ( i , j ) d ( i , j )
j = 1
n
∑i = 1
n
∑
TSP.8
Constraints
• Each city must be “exited” exactly once
• Each city must be “entered” exactly once
x ( i , j )
j = 1
n
∑ = 1 , i = 1 , 2 , ..., n
x ( i , j )
i = 1
n
∑ = 1 , j = 1 , 2 , ..., n
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
x =
0 1 0 0
1 0 0 0
0 0 0 1
0 0 1 0
⎡
⎣
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
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 !!!!!!!
x ( i , j ) ≤ S
i , j ∈ S
∑ − 1 , ∀ S ⊂ { 1 , 2 , ..., n }
TSP.14
Example
• Consider S={1,2}, |S|=2
x =
0 1 0 0
1 0 0 0
0 0 0 1
0 0 1 0
⎡
⎣
⎢
⎢
⎢
⎤
⎦
⎥
⎥
⎥
x ( i , j ) = 2
i , j ∈ S
∑
• Hence the sub-tour elimination constraint is not satisfied.
• Indeed, thee are two subtours in this solution
TSP.15
Thus, LP Version
minx
x ( i , j ) d ( i , j )
j = 1
n
∑i = 1
n
∑
s . t .
x ( i , j ) = 1 , i = 1 , 2 , ..., n
j = 1
n
∑
x ( i , j ) = 1 , j = 1 , 2 , ..., n
i = 1
n
∑
x ( i , j ) ≤ S − 1 , ∀ S ⊂ { 1 , 2 , ..., n }
i , j ∈ S
n
∑
x ( i , j ) ∈ { 0 , 1 }
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
z = d ( 0 , x1) + d ( x
j
j = 1
n − 1
∑ , xj + 1
) + d ( xn
, 0 )
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.
x1, ..., x
n{ } = { 1 , 2 , 3 , ..., n }
TSP.20
LP-Free Formulation
• There are n! feasible solutions
x1, ..., x
n{ } = { 1 , 2 , 3 , ..., n }
min
x
d ( 0 , x1) + d ( x
j
j = 1
n − 1
∑ , xj + 1
) + d ( xn
, 0 )
⎧
⎨
⎩
⎫
⎬
⎭
TSP.21
Which one do you prefer?
TSP.22
LP Version
minx
x ( i , j ) d ( i , j )
j = 1
n
∑i = 1
n
∑
s . t .
x ( i , j ) = 1 , i = 1 , 2 , ..., n
j = 1
n
∑
x ( i , j ) = 1 , j = 1 , 2 , ..., n
i = 1
n
∑
x ( i , j ) ≤ S − 1 , ∀ S ⊂ { 1 , 2 , ..., n }
i , j ∈ S
n
∑
x ( i , j ) ∈ { 0 , 1 }
TSP.23
LP Free Version
x1, ..., x
n{ } = { 1 , 2 , 3 , ..., n }
min
x
d ( 0 , x1) + d ( x
j
j = 1
n − 1
∑ , xj + 1
) + d ( xn
, 0 )
⎧
⎨
⎩
⎫
⎬
⎭
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,
f (i,φ)=d(i,0), φ=empty set
f (i,s) =minj∈S
d(i, j)+f (j,s \ {j}){ }, s≠φ
s \ A:={k∈s,k∉A}.
TSP.25
Explanation
• Then clearly, …..
(i,s)
We are at city iand still have tovisit the cities
in s
Suppose we decidethat 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}
f (i,φ)=d(i,0), φ=empty set
f (i,s) =minj∈S
d(i, j)+f (j,s \ {j}){ }, s≠φ
s \ A:={k∈s,k∉A}.
TSP.26
Example (Winston, p. 751)
• Distance (miles)
• Cities: New York, Miami, Dallas, Chicago
d=
− 1334 1559 809
1334 − 1343 1397
1559 1343 − 921
809 1397 921 −
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
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}