Management Science 461
Lecture 7 – Routing (TSP)
October 28, 2008
2
Facility Location Models
AssumesShipments are not combinedEach truck serves one client at a timeShortest path between facility and client
Can we relax this assumption?Combine shipmentsRespect truck capacityRespect trip time limit
3
Problem Description
Given a set of nodes and a cost metric (distance matrix, network, time network, etc)
Find a route of minimum total length that visits each node exactly once
This is called the Travelling Salesman Problem. Sounds easy….
4
Applications
Business: delivery routes, facility layout Manufacturing: Job scheduling, job
execution order, robotic function ordering State of art: Concorde
http://www.tsp.gatech.edu/concorde.html Largest TSP solved: 49 in 1954; 532 in
1987; 7,397 in 1994; 24,978 in 2004 (took 8 years of computation time)
Modelling TSP
Minimize total cost travelled, making sure each node is visited
Have full distance matrix D for all O-D pairs
Binary variable Xij is 1 if node j visited after node i in the tour
Constraint: ensure all cities visited.
5
Formulation
6
}1,0{
2subject to
minimize
ij
j j jiij
i j ijij
X
iXX
cx
Formulation Problem – Nothing prohibits a subtour Need one constraint for every possible
tour, which is 2N-1
7
4
1
2
3
65
8
Heuristics for the TSP
Trade-off between finding good solutions and time spent coding
Simple heuristics in this class:Construction Heuristics: Nearest Neighbor,
Nearest Insertion, Cheapest Insertion, Farthest Insertion
Improvement Heuristics: 2-opt and k-optOthers – See Concorde
9
Nearest Neighbor (NN)
Start with a random node nFind the nearest node to n not already
selectedSelect the node, travel thereRepeat until all nodes selected; reconnect to
n
10
4
1
2
3
65
From To Dist.
1 2 8
1 3 3
1 4 7
1 5 2
1 6 10
1
11
4
1
2
3
655
From To Dist.
5 2 4
5 3 3
5 4 6
5 6 4
12
4
1
2
3
65
3
From To Dist.
3 2 5
3 4 9
3 6 6
13
2 From To Dist.
2 4 6
2 6 74
1
2
3
65
14
Nearest Insertion (NI)
Choose a starting node Choose a node to enter the path by
considering minimum distance Consider where on the tour is the least-
cost location for adding the node Repeat until all nodes are part of the tour.
15
4
1
2
3
655
From To Dist.
1 2 8
1 3 3
1 4 7
1 5 2
1 6 10
16
24
1
2
3
65
3
From To Dist.
1 2 8
1 3 3
1 4 7
1 6 10
5 2 4
5 3 3
5 4 6
5 6 4
1-5-1(4)
1-3-5-11-5-3-1
: 8: 8
17
33
4
1
2
3
65 6
1-5-3-1(8)
1-6-5-3-1 : 20: 15
From To Dist.
1 2 8
1 4 7
1 6 10
5 2 4
5 4 6
5 6 4
3 2 5
3 4 9
3 6 6
1-5-6-3-1: 211-5-3-6-1
2
3
18
6
2
1-5-6-3-1(15)
1-2-5-6-3-1 : 25: 221-5-2-6-3-1: 211-5-6-2-3-1
2
4
3
From To Dist.
1 2 8
1 4 7
3 2 5
3 4 9
5 2 4
5 4 6
6 2 7
6 4 6: 251-5-6-3-2-1
6
4
1
2
3
65
2
19
77
2
1-5-6-2-3-1(21)
1-4-5-6-2-3-1 : 32: 291-5-4-6-2-3-1: 261-5-6-4-2-3-1
2
4
3
From To Dist.
1 4 7
2 4 6
3 4 9
5 4 6
6 4 6
: 311-5-6-2-4-3-1
5
: 341-5-6-2-3-4-1
4
1
2
3
65
4
20
2-opt Heuristic
Start with a completed tour Repeat until no improvements possible:
Repeat for all pairs of links on the tour: Consider deleting the pair and reconstructing a
valid tour Keep the modification that most improves tour
length
21
2-Opt Heuristic
k+1j+1
k
j
k+1j+1
k
jBefore
After: alternate linkspart of pathreversed
Repeat for all pairs of links until no improvement possible
22
4
1
2
3
65
2-opt example
23
4
1
2
3
65
Another 2-opt example
24
4
1
2
3
65
Not a tour!
Another example
25
Comparison Between HeuristicsHeuristic avg. % above opt.Nearest neighbor (100 runs) 15.3Nearest insertion (100 runs) 17.6Cheapest insertion (100 runs) 13.9Farthest insertion (100 runs) 4.9Arbitrary insertion (100 runs) 3.8Clarke-Wright (100 runs) 3.62-Opt (25 runs) 2.22-Opt (50 runs) + 3-Opt 0.9NN + 2-Opt + 3-Opt 1.2AI + 3-Opt (10 runs) 1.0FI + 3-Opt (10 runs) 0.8Four composite heur. above 0.5