0% found this document useful (0 votes)
2 views19 pages

Traveling Salesman Problem

The Traveling Salesman Problem (TSP) seeks to find the shortest possible route for a salesman to visit a set of cities and return to the origin, ensuring each city is visited exactly once. The document discusses the integer programming formulation of TSP, including constraints and the use of the Branch and Bound approach to solve it, exemplified with a distance matrix for five cities. The optimal tour identified is 1-3-4-2-5-1 with a total distance of 16.

Uploaded by

Akankshaa padhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views19 pages

Traveling Salesman Problem

The Traveling Salesman Problem (TSP) seeks to find the shortest possible route for a salesman to visit a set of cities and return to the origin, ensuring each city is visited exactly once. The document discusses the integer programming formulation of TSP, including constraints and the use of the Branch and Bound approach to solve it, exemplified with a distance matrix for five cities. The optimal tour identified is 1-3-4-2-5-1 with a total distance of 16.

Uploaded by

Akankshaa padhi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Traveling Salesman Problem (TSP)

Traveling Salesman Problem (TSP) deals with finding a minimum cost (or distance
or time) tour for a salesman visiting n cities where
 each city is visited exactly once
 and the salesman returns to the starting city

Tour: A tour is a complete route through the n cities where no city is visited more
than once
Subtour: A subtour is a round trip that does not pass through all cities

Network representation
of the TSP

1
Traveling Salesman Problem (TSP) (Contd…)
Integer programming formulation of TSP
Suppose TSP consists of n cities i = j = 1,2,…, n.
cij = distance (time or cost) from city i to city j, for i  j
cij = M (a large positive number), for i  j
1 if the salesman goes from city i to city j
xij  
n n 0 otherwise
Min Z   cij xij
i 1 j 1

n
s.t. x
i 1
ij 1 for j  1,2, , n (the salesman must arrive at each city once)

x
j 1
ij 1 for i  1,2,, n (the salesman must leave each city once)

ui  u j  nxij  n  1 for i  j; i  2,3,, n; j  2,3,, n (subtour elimination constraint)

xij {0,1} for i  1,2,, n; j  1,2,, n

uj  0 for j  1, 2, ,n 2
Traveling Salesman Problem (TSP) (Contd…)
Cycle Total Distance (in miles)
1. 1-2-3-4-5-1 79
3
2. 1-2-3-5-4-1 108
29
3. 1-2-4-3-5-1 80 11
4. 1-2-4-5-3-1 105 30
20
2
5. 1-2-5-3-4-1 78
6. 1-2-5-4-3-1 74 8 4
7. 1-3-4-2-5-1 67 => Shortest Tour
13
8. 1-3-2-4-5-1 97 22
9. 1-3-5-2-4-1 96 20

10. 1-3-2-5-4-1 95 16

11. 1-4-2-3-5-1 101 1

12. 1-4-3-2-5-1 70 6 5

A problem with n nodes (locations) has (n-1)! possible tours.


For symmetric problems, this number is divided by 2. 3
Traveling Salesman Problem (TSP) (Contd…)

• Here, there are 5 nodes, n = 5, therefore there are (5-1)! / 2= 4! / 2


= 12 possible tour for this problem.

• The optimal tour is 1-3-4-2-5-1 of length 67 Miles.

• Of course, This trial approach can only be used for small problems.

• For example, the number of possible tours is 181440 for a problem


with 10 nodes.

• For a problem with 15 nodes, it is 43589145600.

4
Branch and Bound approach for TSP

Observations for developing the solution procedure:

 Deletion of subtour elimination constraint from TSP results


into a Assignment Problem (Subproblem)

 The subproblem (assignment problem) can be solved using


Hungarian Algorithm.

 If the optimal solution to the assignment problem is feasible


to the TSP (i.e., if the optimal solution of the assignment
problem yields a tour), then it is also optimal for the TSP.

5
Branch and Bound approach for TSP
Solution Procedure
Step 0: Ignore the subtour elimination constraint from TSP. The resulting problem is an
assignment problem.
Step 1: Solve the associated assignment problem using Hungarian Algorithm.
Step 2: If the optimal solution to the assignment problem provides a tour (i.e. no subtour), then it
is the optimal solution to the TSP and STOP. OTHERWISE (the optimal solution to the
assignment problem yields subtours), go to Step 3 (restrictions are imposed to remove the
subtours).
Step 3: Select a subtour with the smallest number of cities (because it creates the smallest number
of subproblems). Let k be the number of cities in the selected subtour (i1 - i2 -…- ik - i1).
Step 4: Branch into k subproblems (branches). Then for the subproblems P1, P2,…,Pk , set
c i1i2  M
c i2i3  M

c ik i1  M, respectively
Step 5: Solve one of the subproblem. If the solution of the resulting assignment problem provides
a tour it provides an upper bound (minimum tour length). Otherwise, Go to Step 3.
Step 6: Continue the process until all the unexplored subproblems have been fathomed (better
upper bound or subproblem cannot produce a better solution).
Step 7: The optimum tour is the one associated with the best upper bound.
6
Branch and Bound approach for TSP

Example Problem: 5 City with the following distance matrix

City 1 City 2 City 3 City 4 City 5

City 1 0 10 3 6 9

City 2 5 0 5 4 2

City 3 4 9 0 7 8

City 4 7 1 3 0 4

City 5 3 2 6 5 0

7
Ignoring the subtour elimination constraint from TSP: Solve the
resulting Assignment Problem using Hungarian Algorithm

Subproblem P0

City 1 City 2 City 3 City 4 City 5


City 1 M 10 3 6 9
City 2 5 M 5 4 2
City 3 4 9 M 7 8
City 4 7 1 3 M 4
City 5 3 2 6 5 M

Z* = Bound= M

8
Row Reduction
City 1 City 2 City 3 City 4 City 5
City 1 M 7 0 3 6
City 2 3 M 3 2 0
City 3 0 5 M 3 4
City 4 6 0 2 M 3
City 5 1 0 4 3 M

Column Reduction
City 1 City 2 City 3 City 4 City 5
City 1 M 7 0 1 6
City 2 3 M 3 0 0
City 3 0 5 M 1 4
City 4 6 0 2 M 3
City 5 1 0 4 1 M
9
Optimal Solution: x13  x25  x31  x42  x54  1, all other xij = 0, ZA = 15.

This solution has two subtours: 1 – 3 – 1 and 2 – 5 – 4–2. So, this is not optimal
solution to the TSP. 10
Z* = Bound = M P0: ZA = 15
(1-3-1) (2-5-4-2)
x13 = 0 x31 = 0

P1:

Branch on subproblem P0:


Subproblem P1: Subproblem P0 with constraint x13 = 0, i.e. Set c13 = M
Subproblem P1
City 1 City 2 City 3 City 4 City 5
City 1 M 10 M 6 9
City 2 5 M 5 4 2
City 3 4 9 M 7 8
City 4 7 1 3 M 4
City 5 3 2 6 5 M
11
Optimal Solution: x14  x25  x31  x43  x52  1, all other xij = 0, ZA = 17.
This solution contains two subtours: 1 – 4 – 3 – 1 and 2 – 5 – 2. This is not optimal
solution to the TSP.
Z* = Bound= M
12
P0: ZA = 15
(1-3-1) (2-5-4-2)
x13 = 0 x31 = 0

P1: ZA = 17
(2-5-2)(1-4-3-1)
x25 = 0 x52= 0

P2:
Branch on Subproblem P1:
Subproblem P2: Subproblem P1 with constraint x25 =0, i.e. Set c25 = M)
Subproblem P2 City 1 City 2 City 3 City 4 City 5
City 1 M 10 M 6 9
City 2 5 M 5 4 M
City 3 4 9 M 7 8
City 4 7 1 3 M 4
City 5 3 2 6 5 M
13
Optimal Solution: x14  x23  x31  x45  x52  1, all other xij = 0, ZA = 21
This solution gives a tour: 1 – 4 – 5 – 2 – 3 – 1. So, this is a feasible solution to the
TSP. Fathomed (feasible solution and update the bound)
Z* = Bound= 21
14
Z* = Bound= 21 P0: ZA = 15
(1-3-1) (2-5-4-2)
x13 = 0 x31 = 0

P1: ZA = 17
(2-5-2)(1-4-3-1)
x25 = 0 x52= 0

P2: ZA = 21 P3:
(1-4-5-2-3-1)
Fathomed
Subproblem P3: Subproblem P1 with constraint x52 =0, i.e. Set c52 = M)
City 1 City 2 City 3 City 4 City 5
City 1 M 10 M 6 9
Subproblem P3
City 2 5 M 5 4 2
City 3 4 9 M 7 8
City 4 7 1 3 M 4
City 5 3 M 6 5 M
15
Optimal Solution: x14  x25  x31  x42  x53  1, all other xij = 0, ZA = 19
This solution gives a tour: 1 – 4 – 2 – 5 –3 – 1. So, this is a feasible solution to the TSP.
Fathomed (Update bound since this is better solution) Z* = Bound= 19 16
P0: ZA = 15
Z* = Bound= 19
(1-3-1) (2-5-4-2)
x13 = 0 x31 = 0

P1: ZA = 17 P4:
(2-5-2)(1-4-3-1)
x25 = 0 x52= 0

P2: ZA = 21 P3: ZA = 19
(1-4-5-2-3-1) (1-4-2-5-3-1)
Fathomed Fathomed

Subproblem P4: Subproblem P0 with constraint x31 = 0 i.e. Set c31 = M

Subproblem P4:

17
Optimal Solution: x13  x25  x34  x42  x51  1, all other xij = 0, Z = 16.
This solution gives a tour: 1 – 3 – 4 – 2 –5 – 1. So, this is a feasible solution to the TSP.
Fathomed (Update bound since this is better solution)
Z* = Bound= 16
18
Optimal
Z* = 16 solution to
P0: ZA = 15
(1-3-1) (2-5-4-2) the TSP

x13 = 0 x31 = 0

P1: ZA = 17 P4: ZA = 16
(2-5-2)(1-4-3-1) (1-3-4-2-5-1)
Fathomed
x25 = 0 x52= 0

P2: ZA = 21 P3: ZA = 19
(1-4-5-2-3-1) (1-4-2-5-3-1)
Fathomed Fathomed

Optimal Sequence of visit by Salesman: 1-3-4-2-5-1,


and Total distance: 16
19

You might also like