week5-chap3-recursion-branch-and-bound-cvrp
week5-chap3-recursion-branch-and-bound-cvrp
CONTENTS
3 4
GENERAL DIAGRAM OF BACKTRACKING, BRANCHING AND BOUND GENERAL DIAGRAM OF BACKTRACKING, BRANCHING AND BOUND
try(1) Enumeration problem
• The backtracking algorithm allows us to solve combinatorial enumeration problems and 1
combinatorial optimization problems try(k){ //Try out the possible values assigned to Xk
• The alternative is modeled by a sequence of decision variables X1, X2, . . ., Xn try(2)
try(2) try(2) for v in Ak do {
• Need to find for each variable Xi a value selected from a given discrete set Ai such that 2 3 . . . if check(v,k){
5 6
GENERAL DIAGRAM OF BACKTRACKING, BRANCHING AND BOUND GENERAL DIAGRAM OF BACKTRACKING, BRANCHING AND BOUND
try(1) Minimize optimization problem (Denote f* : optimal value) try(1) Minimize optimization problem (Denote f* : optimal value)
1 1
try(k){//Try out the possible values assigned to Xk try(k){//Try out the possible values assigned to Xk
try(2) try(2) for v in Ak do { try(2) try(2) for v in Ak do {
try(2) try(2)
2 3 if check(v,k){ 2 3 if check(v,k){
. . . . . .
Xk = v; Xk = v;
. . . . . . . . . . . . . . . . . . [Update a data structure D] . . . . . . . . . . . . . . . . . . [Update a data structure D]
7 8
DELIVERY TRUCK ROUTE PROBLEM DELIVERY TRUCK ROUTE PROBLEM
• A fleet of K identical trucks needs to be assigned to transport pepsi boxes from the central • Example N = 3, K = 2, Q = 10, d[1] = 3, d[2] = 2, d[3] = 1
warehouse (point 0) to delivery points 1,2,...,N and back to the warehouse. The travel distance from There are 6 shipping options as below:
point i to point j is c(i,j)
• Each truck has a load capacity of Q (each trip can only transport a maximum of Q boxes)
Route[1] = 0 – 1 – 0 Route[1] = 0 – 1 – 2 – 0
• Each delivery point i has a required quantity of d[i] boxes, i = 1,…, N. Route[2] = 0 – 2 – 3 – 0 Route[2] = 0 – 3 – 0
• It is necessary to develop a transportation plan so that: Route[1] = 0 – 1 – 3 – 0 Route[1] = 0 – 2 – 0
• Each vehicle must be assigned Route[2] = 0 – 2 – 0 Route[2] = 0 – 3 – 1 – 0
• Each delivery point can only be delivered by exactly one vehicle and only once. Route[1] = 0 – 1 – 0 Route[1] = 0 – 2 – 1 – 0
• The total amount of boxes on the vehicle must not exceed the vehicle's load. Route[2] = 0 – 3 – 2 – 0 Route[2] = 0 – 3 – 0
• The total route length of the vehicles is the smallest
• Note: do not need to use all K vehicles.
9 10
6 8 7
11 12
DELIVERY TRUCK ROUTE PROBLEM DELIVERY TRUCK ROUTE PROBLEM
• Strategy to traverse • K = 2, N= 6
– Start by traversing values for the tuple (y[1],. . ., y[K])
– For each complete values of tuple (y[1],. . ., y[K]), start traversing values for the x[1,...,N] derived f
rom x[y[1]] 0
– Each time: try to assign x[v] = u for the kth vehicle:
• If u > 0 (not the starting point): try continuing to browse the value for x[u] still on the kth vehicle
• If u = 0 (starting point) then
(y[1], y[2]) 1
– If k = K (all routes for K vehicles are complete) and all delivery points are visited, then obtain
a solution to the problem
– otherwise, try continuing to assign the values for the route of vehicle (k+1)th, derived from
x[y[k+1]]
– Variable nbR: the number of vehicles that has been used to deliver 1 2 5
– Variable segments
• The number of segments (segment: connection between 2 0 4 3 0
consecutive delivery points on the route)
• when segments = N+nbR then obtain a solution to the problem
6 8 7
13 14
0 0
15 16
DELIVERY TRUCK ROUTE PROBLEM DELIVERY TRUCK ROUTE PROBLEM
• K = 2, N= 6 • K = 2, N= 6
0 0
5 5
4 4
17 18
0 0
5 3 5 3
4 4 6
0 0
19 20
DELIVERY TRUCK ROUTE PROBLEM DELIVERY TRUCK ROUTE PROBLEM
• K = 2, N= 6 • K = 2, N= 6
0 0
5 3 5 6
4 6 4
0 0 0
21 22
0 0
5 6 5 6
4 3 4 3
0 0 0
23 24
DELIVERY TRUCK ROUTE PROBLEM DELIVERY TRUCK ROUTE PROBLEM
• K = 2, N= 6 • K = 2, N= 6
0 0
5 3
4 6
0 0 0 0
25 26
27 28
DELIVERY TRUCK ROUTE PROBLEM
checkY(v, k){ TRY_Y(k){ // thử giá trị cho y[k]
if v = 0 then return true; s = 0;
if load[k] + d[v] > Q then if y[k-1] > 0 then s = y[k-1] + 1;
return false; for v = s to n do {
if visited[v] = true then if checkY(v,k) then {
return false; y[k] = v;
THANK YOU !
return true; if v > 0 then segments = segments + 1;
} visited[v] = true; f = f + c[0,v]; load[k] = load[k] + d[v];
TRY_Y(1); }
output(f*); }
} }
29 30