330 likes | 591 Views
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. Problem Formulation.
E N D
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
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
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.
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 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
Example • This matrix represents the tour (1,2,3,4,1)
Objective function • d(i,j) = (direct) distance between city i and city j.
Constraints • Each city must be “exited” exactly once • Each city must be “entered” exactly once
No! • The first two constraints allow sub-tours • Thus, we have to add a constraint that will prevent sub-tours
Explanation: sub-tours • Two subtour: (1,2,1) and (3,4,3) • This solution is not feasible for the TSP
2 1 4 3 • 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.
Subtour elimination constraint • S = subset of cities • |S| = cardinality of S (# of elements in S) • There are 2n such sets !!!!!!!
Example • Consider S={1,2}, |S|=2 • Hence the sub-tour elimination constraint is not satisfied. • Indeed, thee are two subtours in this solution
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.
ASSUMPTION • Assume that 0 is the home city, and that there are n other cities
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.
LP-Free Formulation • There are n! feasible solutions
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,
Explanation (j,s\{j}) We are now at city j and still have to visit the cities in s\{j} (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 clearly, ….. Then we shall travel the Distance d(i,j)
Example (Winston, p. 751) • Distance (miles) • Cities: New York, Miami, Dallas, Chicago
Initialization (s=) • f(1, ) = d(1,0) = 1334 • f(2, ) = d(2,0) = 1559 • f(3, ) = d(3,0) = 809
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})= ?
|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
|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}
|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}
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