Professional Documents
Culture Documents
Distribution
Distribution
Supply Chain
Pick up raw materials/ Deliver to customers
(Travelling Salesman Problem)
-- 12 8 16 9
12 -- 18 11 7
2 8 18 -- 10 8
3 16 11 10 -- 9
9 7 8 9 --
1, F
d
i j
ij X ij
From every city visited, the salesman should go to exactly one city. This is given by
X j
ij 1
.
The salesman reached the present city from exactly one city. This is given by
X i
ij 1
Xij = 0,1.
Subject to
4 X24 + X42 ≤ 1
1, F
5 X25 + X52 ≤ 1
X34 + X43 ≤ 1
4
X35 + X53 ≤ 1
5
X45 + X54 ≤ 1
Heuristics
Heuristics are mental shortcuts for solving problems in a quick way that delivers a result that is sufficient
enough to be useful given time constraints
Heuristic technique, is any approach to problem solving or self discovery that employs a practical
method that is not guaranteed to be optimal, perfect, or rational, but is nevertheless sufficient for
reaching an immediate, short-term goal or approximation. Where finding an optimal solution is
impossible or impractical, heuristic methods can be used to speed up the process of finding a
satisfactory solution. Heuristics can be mental shortcuts that ease the cognitive load of making a
decision
Nearest neighbor
Twice around the tree
-- 12 8 16 9
12 -- 18 11 7 Nearest neighbour
8 18 -- 10 8
16 11 10 -- 9 1 – 3 – 5 – 2 – 4 – 1 = 8 + 8 + 7 + 11 + 16 = 50
9 7 8 9 -- 2 – 5 – 3 – 1 – 4 – 2 = 7 + 8 + 8 + 16 + 11 = 50
3 – 5 – 2 – 4 – 1 – 3 = 8 + 7 + 11 + 16 + 8 = 50
4 – 5 – 2 – 1 – 3 – 4 = 9 + 7 + 12 + 8 + 10 = 46
5 – 2 – 4 – 3 – 1 – 5 = 7 + 11 + 10 + 8 + 9 = 45
-- 12 8 16 9 Twice around the tree
12 -- 18 11 7
8 18 -- 10 8 Minimum Spanning Tree
16 11 10 -- 9 7 + 8 + 8 + 9 = 32
9 7 8 9 --
Twice around the tree
1–3–5–2–5–4–5–3-1
2
8 3 Solutions
8 1 – 3 – 5 – 2 – 4 – 1 = 8 + 8 + 7 + 11 + 16 = 50
1, F
7 1 – 5 – 2 – 4 – 3 – 1 = 9 + 7 + 11 + 10 + 8 = 46
1 – 2 – 5 – 4 – 3 – 1 = 12 + 7 + 9 + 10 + 8 = 46
4
5 9
Milk run (Travelling Salesman Path problem)
Milk run is a delivery method used to transport mixed loads from various suppliers to one
customer. It can also be used to describe a transportation route that has many stops. The
term originated in the dairy industry.
Milk run is a delivery approach that involves using one vehicle to pick up goods from various
suppliers and transporting them in a single shipment to one customer.
The Traveling Salesman Problem (TSP) is the challenge of finding the shortest path or
shortest route for a salesperson to take, given a starting point, a number of cities (nodes),
and optionally an ending point.
Path problem between 1 and 4
-- 12 8 16 9 Let Xij = 1 if the salesman visits city j immediately after visiting city i. The first
12 -- 18 11 7 and last cities are 1 and 4 respectively. The objective function is to
8 18 -- 10 8 Minimize 12X12 + 8X13 + 9X15 + 18X23 + 11X24 + 7X25 + 18X32 + 10X34 + 8X35 +
16 11 10 -- 9 7X52 + 8X53 + 9X54
9 7 8 9 -- Subject to
X12 + X13 + X15 = 1
X23 + X24 + X25 = 1
X32 + X34 + X35 = 1
X52 + X53 + X54 = 1
X12 + X32 + X52 = 1
X13 + X23 + X53 = 1
X24 + X34 + X54 = 1
X15 + X25 + X35 = 1
Path problem between 1 and 4
-- 12 8 16 9
12 -- 18 11 7
8 18 -- 10 8 Solver gives the solution X13 = X34 = X25 = X52 = 1 with Z = 32
16 11 10 -- 9
9 7 8 9 -- We add X25 + X52 ≤ 1
Heuristics
1. Nearest neighbour
2. Spanning tree based
Path problem between 1 and 4 - Heuristic
-- 12 8 16 9
12 -- 18 11 7
8 18 -- 10 8 Nearest neighbour
16 11 10 -- 9 1 – 5 – 2 – 3 – 4 = 9 + 7 + 18 + 10 = 44
9 7 8 9 --
Heuristics
1. Nearest neighbour
2. Spanning tree based
Path problem between 1 and 4 - Heuristic
-- 12 8 16 9 Heuristics
2
12 -- 18 11 7 3
Spanning tree based
8
8 18 -- 10 8
8
16 11 10 -- 9 1, F
7
9 7 8 9 --
4 1 – 3 – 5 – 2 – 4 = 8 + 8 + 7 + 11 = 34
5 9 1 – 3 – 2 – 5 – 4 = 8 + 18 + 7 + 9 = 42
Minimize tn+1 – t1 -- 12 8 16 9
Subject to 12 -- 18 11 7
tj – t1 ≥ d1j j = 2,...,n 8 18 -- 10 8
tn+1 – tj ≥ d1j j = 2,...,n 16 11 10 -- 9
9 7 8 9 --
ti t j dij for i = 3,...,n; j < I; tj ≥ 0
Formulation t1 t2 t3 t4 t5 t6
0 29 8 18 36 45
Minimize t6 – t1 t3 - t2 +1000d23<= 982
1 1 0 0 0 0
subject to t2 - t3 -1000d23<= -18 d23 d24 d25 d34 d35 d45
t2 - t1 ≥ 12 t4 - t2 +1000d24<= 989
t 3 - t1 ≥ 8 Solution: 1 – 3 – 4 – 2 – 5 – 1
t2 - t4 - 1000d24<= -11
= 8 + 10 + 11 + 7 + 9 = 45
t4 - t1 ≥ 16 t4 - t3 +1000d34<= 990
t 5 - t1 ≥ 9 t3 - t4 - 1000d34<= -10 Constraints representing the time windows.
t6 - t2 ≥ 12 t5 - t2 + 1000d25<= 993 These are t2 ≤ 20, t3 ≤ 30 and t4 ≥ 50.
t 6 - t3 ≥ 8 t2 - t5 - 1000d25<= -7
Solution: 1 – 2 – 3 – 5 – 4 – 1
t6 - t4 ≥ 16 t5 - t3 + 1000d35<= 992 = 12 + 18 + 8 + 9 + 16 = 63
t 6 - t5 ≥ 9 t3 - t5 - 1000d35<= -8
t5 - t4 + 1000d45<= 991 Solution 0, 12, 30, 50, 38, 66
t4 - t5 - 1000d45<= -9
Pick up and delivery problem (Dial a ride problem)
Pickup and delivery problem where the salesman visits some cities to pickup material
and delivers it in other cities. The salesman may have to visit all the pickup points first
and collect all the material and then deliver them to the delivery points.
If the salesman is a taxi driver, every pickup has to be followed by a delivery because
each pickup may be a passenger who has to be dropped at the destination. This
particular version of the pickup and delivery problem is called the “dial-a-ride
problem”. Sometimes, these problems also have associated time windows.
Formulation
Assume that cities 1 and 4 are pickup points and cities 2 3 and 5 are delivery points.
Assume that the demand in each city (2, 3 and 5) is d. Assume that the salesman picks up
2d from city 1 and d from city 4. Find the sequence that minimizes total distance
travelled.
t2 ≥ t1 + d12 The optimum solution is t1 = 0, t2 = 27, t3 = 45, t4
t3 ≥ t1 + d13 = 16, t5 = 34 and t6 = 53 and objective function
t5 ≥ t1 + d15 value = 53
t2 ≥ t4 + d24
1 – 4 – 2 – 5 – 3 – 1 = 16 + 11 + 7 + 8 + 8 = 50
t3 ≥ t4 + d34
t5 ≥ t4 + d45 (Importance of triangle inequality)
TSP with subsets – Orienteering problem,
1. The salesman collects revenue in each city and returns to the starting city when a
certain amount is collected. The problem is to travel minimum distance to collect
the required amount. This problem is called the orienteering problem. The
salesman can also return to a known destination.
-- 18 11 7 8 8
5
18 -- 10 8 12 6 4
D
11 10 -- 9 11 9
7 8 9 -- 9 12 8 6
6 5
8 12 11 9 -- 10
8 6 9 12 10 -- Distance = 12 + 18 + 8 + 7 = 45; 16 + 11 + 10 + 11 = 48
Total = 93
VRP Formulation (Achuthan and Caccetta,1991)
If there are N customers, we have a graph with
8 1
N+2 nodes, where node N+1 is the depot
(source) and node N+2 is also the depot
7 2
(destination). The objective function is
6 Minimize
3
8,D
Z cij X ij
7,D ( i , j ) A
5
4
6
5
8
6
VRP Formulation (Achuthan and Caccetta,1991)
yi y j L 1 X ij L
𝑁
∑ 𝑋 𝑖𝑗 + 𝑋 𝑁 +1 , 𝑗 =1
¿ 𝑖=1
¿ 𝑖≠ 𝑗
yN 2 yN 1 L 1
𝑁
∑ 𝑋 𝑖𝑗 + 𝑋𝑖 , 𝑁 +2=1 ui u j WX ij W Q j
¿ 𝑗=1
¿ 𝑗≠ 𝑖
u N 2 u N 1 W
𝑁
∑ 𝑋 𝑁 +1 , 𝑗 =𝑉 vi v j cij T X ij T
¿ 𝑗=1
¿
vN 2 vN 1 T
𝑁
∑ 𝑋 𝑖, 𝑁 +2 =𝑉
¿ 𝑖=1
¿
Minimize
8X12+11X13+7X14+8X15+8X16+12X18+18X21+10X23+8X24+12X25+6X26+8X28+11X31+10X32+9X34+11X35+9X36+16X38+7X41+8X42
+9X43+9X45+12X46+9X48+8X51+12X52+11X53+9X54+10X56+10X58+8X61+6X62+9X63+12X64+10X65+11X68+12X71+8X72+16X73+9X
74 +10X75+11X76
X21+X31+X41+X51+X61+X71 = 1; X12+X32+X42+X52+X62+X72 = 1
X13+X23+X43+X53+X63+X73 = 1; X14+X24+X34+X54+X64+X74 = 1
Initial solution is X15 = X26 = X34 = X41 = X58 =
X15+X25+X35+X45+X65+X75 = 1; X16+X26+X36+X46+X56+X76 = 1 X63 = X72 = 1 with Distance = 57. This has a
X12+X13+X14+X15+X16+X18 = 1; X21+X23+X24+X25+X26+X28 = 1 tour 7 – 2 – 6 – 3 – 4 – 1 – 5 – 8
X31+X32+X34+X35+X36+X38 = 1; X41+X42+X43+X45+X46+X48 = 1
X51+X52+X53+X54+X56+X58 = 1; X61+X62+X63+X64+X65+X68 = 1
X71+X72+X73+X74+X75+X76 = 1; X18+X28+X38+X48+X58+X68 = 1
V = 2 and 3 cities for a vehicle
yi – yj + 4Xij ≤ 3 for i = 1, ...7, j = 1,..., 8; i ≠ j. There are 42 constraints. We also add the
constraint y8 – y7 ≤ 4 instead of y8 – y7 ≤ 7. These ensure that each vehicle goes to exactly
three cities.
The optimum solution to the MILP is given by X14 = X23 = X36 = X48 = X51 = X68 = X72 = X75 = 1
with distance = 72. Since the routes start from the depot (city 7), the two routes are d – 2
– 3 – 6 – d and d – 5 – 1 – 4 – d. The two routes end at the depot (city 8). The individual
distances are 38 and 34 with a total of 72.
With demand and capacities
We consider the case where the capacity of the vehicle is 20 and the demands in the six cities are 8, 7, 6, 5,
6 and 8. We remove the three city limit on the two vehicles by removing the set of constraints. We add the
constraints ui – uj + 20Xij ≤ 20 – dj. We write these constraints the same way as the earlier set. We have 42
constraints. For illustration the first constraint is u1-u2+20X12≤ 13. We also add the constraint u8 – u7 = 20
The optimum solution to the MILP is given by X18 = X24 = X35 = X41 = X58 = X63 = X72 = X76 = 1 with distance = 76.
Since the routes start from the depot (city 7), the two routes are d – 2 – 4 – 6 – d and d – 6 – 3 – 5 – d. The
two routes end at the depot (city 8). The individual distances are 35 and 41 with a total of 76. It is to be
noted that each vehicle visits three vehicles due to the number of vehicles considered and due to the
demand. The best solution with three cities for each vehicle (earlier solution with Z = 72) is infeasible to the
demand constraints. It is also to be noted that if we add the three city restriction (another 43 constraints)
along with the demand constraints, we will get the same solution with Z = 76.
Distance restriction (37)
We add the distance restriction of 37 by adding the constraints vi – vj + (37 + dij)Xij ≤ 37. We write
these constraints the same way as the earlier set. We have 42 constraints. For illustration the first
constraint is v1-v2+55X12≤ 37. We also add the constraint v8 – v7 = 37. We do not add the demand
constraints and the three city restriction constraints.
The optimum solution to the MILP is given by X15 = X23 = X34 = X48 = X58 = X61 = X72 = X76 = 1 with
distance = 73. Since the routes start from the depot (city 7), the two routes are d – 2 – 3 – 4 – d
and d – 6 – 1 – 5 – d. The two routes end at the depot (city 8). The individual distances are 36
and 37 with a total of 73. It is to be noted that each vehicle visits three vehicles due to the
number of vehicles considered and due to the demand. The best solution with three cities for
each vehicle (earlier solution with Z = 72) is infeasible to distance limit of 37 for a vehicle. It is
also to be noted that if we add the three city restriction (another 43 constraints) along with the
demand constraints, we will get the same solution with Z = 73.
Heuristics – Savings based – Clarke Wright
• If a vehicle has to go separately to city i and city j from the origin, the total distance
covered will be 2[d0i + d0j].
• If a vehicle leaves the depot goes to i and then j and returns to the depot, the distance
covered will be (d0i + d0j + dij).
• The saving will be the difference between them. The saving Sij = (d0i + d0j - dij).
Example The distance of the cities from the depot is 12, 8,
16, 9, 10 and 11.
-- 18 11 7 8 8
i-j Saving i-j Saving
18 -- 10 8 12 6 2-6 13
3-6 18
11 10 -- 9 11 9 1-3 17 5-6 11
7 8 9 -- 9 12 3-4 16 4-5 10
8 12 11 9 -- 10 1-6 15 2-4 9
3-5 15 4-6 8
8 6 9 12 10 -- 1-4 14 2-5 6
1-5 14 1 -2 2
2-3 14
Solution for 2 vehicles and 3 cities
3 – 6 = 18, 1 – 3 = 17;
4 – 5 = 10; 2 – 4 = 9 6 trips from depot and back = 66 x 2 = 132
D – 6 – 3 – 1 – D = 11 + 9 + 11 + 12 = 43 Savings = 54
D – 2 – 4 – 5 – D = 8 + 8 + 9 + 10 = 35 Distance = 78
Total = 78
Example (new solution) The distance of the cities from the depot is 12, 8,
16, 9, 10 and 11.
-- 18 11 7 8 8
i-j Saving i-j Saving
18 -- 10 8 12 6 2-6 13
3-6 18
11 10 -- 9 11 9 1-3 17 5-6 11
7 8 9 -- 9 12 3-4 16 4-5 10
8 12 11 9 -- 10 1-6 15 2-4 9
3-5 15 4-6 8
8 6 9 12 10 -- 1-4 14 2-5 6
1-5 14 1 -2 2
2-3 14
Solution for 2 vehicles and 3 cities
3 – 6 = 18, 2 – 3 = 14;
1 – 4 = 14; 1 – 5 = 14 6 trips from depot and back = 66 x 2 = 132
Savings = 60 Savings = 60
Distance = 72
Example (TSP) The distance of the cities from the depot is 12, 8,
16, 9, 10 and 11.
-- 18 11 7 8 8
i-j Saving i-j Saving
18 -- 10 8 12 6 2-6 13
3-6 18
11 10 -- 9 11 9 1-3 17 5-6 11
7 8 9 -- 9 12 3-4 16 4-5 10
8 12 11 9 -- 10 1-6 15 2-4 9
3-5 15 4-6 8
8 6 9 12 10 -- 1-4 14 2-5 6
1-5 14 1 -2 2
Solution for 1 vehicle 2-3 14
3 – 6 = 18; 1 – 3 = 17; 6 trips from depot and back = 66 x 2 = 132
1 – 4 = 14; 5 – 6 = 11; Savings = 66; Distance = 66
2–5=6 Nearest neighbour = D – 2 – 6 – 1 – 4 – 3 – 5 – D
D–4-1–3–6–5–2-D Distance = 8 + 6 + 8 + 7 + 9 + 11 + 10 = 59
9 + 7 + 11 + 9 + 10 + 12 + 8 = 66
Example (capacity) The distance of the cities from the depot is 12, 8, 16,
9, 10 and 11. Demand = 8, 7, 6, 5, 6, 8; capacity = 20
-- 18 11 7 8 8
i-j Saving i-j Saving
18 -- 10 8 12 6 2-6 13
3-6 18
11 10 -- 9 11 9 1-3 17 5-6 11
7 8 9 -- 9 12 3-4 16 4-5 10
8 12 11 9 -- 10 1-6 15 2-4 9
3-5 15 4-6 8
8 6 9 12 10 -- 1-4 14 2-5 6
1-5 14 1 -2 2
Solution for 2 vehicles; capacity = 20 2-3 14
3 – 6 = 18, 3 - 5 = 15;
1 – 4 = 14; 2 – 4 = 9
Savings = 56
Distance = 132 – 56 = 76
Point to point delivery (Bin packing)
Nine point to point deliveries each requiring 32, 26, 23, 17, 16, 14, 10, 10 and 2 minutes are to be made.
Each vehicle is available for 50 minutes. Solve the bin packing problem optimally?
The bin packing problem is about finding minimum number of bins (vehicles) required to make these
deliveries. We start with a heuristic solution:
V1 = 32 + 17
V2 = 26 + 23
V3 = 16 + 14 + 10 + 10
V4 = 2
This heuristic is called “First Fit decreasing heuristic”. This gives a solution with 4 vehicles. We should
check if there is a solution with 3 vehicles.
Formulation (for 3 vehicles)
The formulation is to minimize y1 + y2 +y3
Subject to
x11 + x12 + x13 = 1
x21 + x22 + x23 = 1
x31 + x32 + x33 = 1
x41 + x42 + x43 = 1
x51 + x52 + x53 = 1
x61 + x62 + x63 = 1
x71 + x72 + x73 = 1
x81 + x82 + x83 = 1
x91 + x92 + x93 = 1
32x11 + 26x21 + 23x31 + 17x41 + 16x51 + 14x61 + 10x71 + 10x81 + 2x91 -50y1 <= 0
32x12 + 26x22 + 23x32 + 17x42 + 16x52 + 14x62 + 10x72 + 10x82 + 2x92 - 50y2 <= 0
32x13 + 26x23 + 23x33 + 17x43 + 16x53 + 14x63 + 10x73 + 10x83 + 2x93 - 50y3 <= 0
Yj, Xij = 0,1
Solution (3 vehicles)
Nine point to point deliveries each requiring 32, 26, 23, 17, 16, 14, 10, 10 and 2 minutes are to be made.
Each vehicle is available for 50 minutes. Solve the bin packing problem optimally?
The optimum solution to the formulation is given by Y1 = Y2 = Y3 = 1; X12 = X52 = X92 = 1; X21 = X61 = X71 = 1; X33
= X43 = X83 = 1 with Z = 3. This shows that we need three bins. Items 1, 5 and 9 go to one bin, items 2, 6 and
7 to a bin and items 3, 4 and 8 to the third bin.
Bin packing as a series of knapsack problems
Maximize 32Y1 + 26Y2 + 23Y3 + 17Y4 + 16Y5 + 14Y6 + 10Y7 + 10Y8 + 2Y9
Subject to
32Y1 + 26Y2 + 23Y3 + 17Y4 + 16Y5 + 14Y6 + 10Y7 + 10Y8 + 2Y9 ≤ 50
Yj = 0,1.
Y1 = Y5 = Y9 = 1 with Z = 50.
Y2 = Y6 = Y7 = 1 with Z = 50
Y3 = Y4 = Y8 = 1 with Z = 50
4 vehicles – balance loads - Heuristic
Nine point to point deliveries each requiring 32, 26, 23, 17, 16, 14, 10, 10 and 2 minutes are to be made. Each
vehicle is available for 50 minutes. Solve the bin packing problem optimally for 4 vehicles to balance loads
Item 1 goes to V1 – Load = 32; Item 2 goes to V2; Load = 26; Item 3 goes to V3; Load = 23; Item 4 goes to V4; Load = 17
Item 5 goes to V4; Load = 33; Item 6 goes to V3; Load = 37; Item 7 goes to V2; Load = 36; Item 8 goes to V1; Load = 42
Item 9 goes to V4; Load = 35
4 vehicles – balance loads - Formulation
4 9 9 9
∑ 𝑡 𝑖 𝑋 𝑖𝑗 ≤ 50 ∑ 𝑡 𝑖 𝑋 𝑖𝑗 ≤ 𝑢 ∑ 𝑡 𝑖 𝑋 𝑖𝑗 ≥ 𝑣 Minimize u - v
∑ 𝑋 𝑖𝑗= 1
𝑖 =1 𝑖 =1 𝑖 =1
𝑗 =1
Nine point to point deliveries each requiring 32, 26, 23, 17, 16, 14, 10, 10 and 2 minutes are to be made. Each
vehicle is available for 50 minutes. Solve the bin packing problem optimally for 4 vehicles to balance loads
The optimum solution is X12 = X24 = X33 = X43 = X51 = X64 = X71 = X81 = X92 = 1; u = 40 and v = 34
Vehicle 1 gets 5, 7 and 8; Load = 36; Vehicle 2 gets 1 and 9; Load = 34; Vehicle 3 gets 3 and 4; Load = 40;
Vehicle 4 gets 2 and 6; Load = 40
Case study – Distribution (Inventory vs Transportation)
Nine customers – 32, 26, 23, 17, 16, 14, 10, 10, 2
Demand (day 1) – 12, 8, 3, 4, 10, 10, 7, 8, 9
Day 2 – 10, 9, 3, 8, 10, 9, 8, 2, 9
Inventory cost/item 2, 3, 5, 6, 4, 8, 2, 4, 5
Vehicle capacity = 20
Cost/unit time (distance) = 1
Optimum cost?
Formulation
Let Xijk = 1 if item i goes to vehicle j on day k 72 Xijk and 9 Yi variables
Yi = 1 if day 2 demand for item i is picked on day 1
8 + 9 + 9 + 9 + 9 = 44 constraints
Minimize
❑
∑ 𝑑 𝑖 𝑋 𝑖𝑗𝑘 ≤ 𝐵 ∀ 𝑗 , 𝑘
𝑖
❑ ❑
∑ 𝑋 𝑖𝑗 1=1 ∀ 𝑖 ∑ 𝑋 𝑖𝑗 2 ≤ 1 ∀ 𝑖
𝑗 𝑗
❑ ❑
∑ 𝑋 𝑖𝑗 2+ 𝑌 𝑖 =1 ∀ 𝑖 ∑ 𝑏𝑖 1 𝑋 𝑖𝑗 1+ 𝑏𝑖 2 𝑌 𝑖 ≤ 𝐵 ∀ 𝑖
𝑗 𝑗
Solution
Objective function value = 290 (267 + 23)
X121 = X142 = X211 = X232 = X311 = X441 = X412 = X541 = X541 = X641 = X622
= X731 = X732 = X831 = X931 = X912 = Y3 = Y8 = 1
Item 1 – No capacity
Item 2 – Distance = 26; Inventory = 9 x 3 = 27 (not economical)
Item 3 – Distance = 23; Inventory = 3 x 5 = 15 (keep inventory) – Saving = 8
Item 4 – Distance = 17; Inventory = 32
Item 5 – Distance = 16; Inventory = 10 x 4 = 40
Item 6 - Distance = 14; Inventory = 9 x 8 = 72
Item 7 – Distance = 10; Inventory = 8 x 2 = 16
Item 8 – Distance = 10; Inventory = 2 x 4 = 8 (Economical) – Saving = 2
Item 9 – Distance = 2; Inventory = 9 x 5 = 45
Total saving = 10; Total distance (no inventory) = 300; Cost = 290