0% found this document useful (0 votes)
6 views

week5-chap3-recursion-branch-and-bound-cvrp

The document discusses applied algorithms focusing on backtracking and branch-and-bound techniques for solving combinatorial problems. It specifically addresses the delivery truck route problem, detailing the constraints and requirements for optimizing routes for a fleet of trucks. The document includes examples and diagrams to illustrate the algorithms' processes and strategies for traversing delivery routes.

Uploaded by

Bình An
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)
6 views

week5-chap3-recursion-branch-and-bound-cvrp

The document discusses applied algorithms focusing on backtracking and branch-and-bound techniques for solving combinatorial problems. It specifically addresses the delivery truck route problem, detailing the constraints and requirements for optimizing routes for a fleet of trucks. The document includes examples and diagrams to illustrate the algorithms' processes and strategies for traversing delivery routes.

Uploaded by

Bình An
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/ 8

APPLIED ALGORITHMS

CONTENTS

• General diagram of backtracking, branch and bound


• The problem of bus routes picking up and dropping off passengers
• Delivery truck route problem
APPLIED ALGORITHMS
BACKTRACKING, BRANCH AND BOUND

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){

• The constraints of the problem are satisfied Xk = v;


. . . . . . . . . . . . . . .
• Optimize a given objective function . . . [Update a data structure D]

• Backtracking algorithm try(k) if k = n then solution();


else {
• Traverse through all variables (e.g. order from X1, X2, . . ., Xn), for each variable Xk : . . .
try(k+1);
• Traverse through all possible values that could be assigned to Xk, for each value v:
}
• Check constraints . . . . . . . . . . . . . . .
[Recover the data structure D]
• Assign Xk = v
}
• If k = n then record a solution to the problem
}
• Otherwise, consider the variable Xk+1
}

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]

try(k) if k = n then updateBest(); try(k) if k = n then updateBest();


else { else {
. . . . . .
if g(X1, X2, …, Xk) < f* then if g(X1, X2, …, Xk) < f* then
try(k+1); try(k+1);
. . . . . . . . . . . . . . . Calculate the lower . . . . . . . . . . . . . . . Do not further build
} }
bound the solution if
g(X1, X2, …, Xk) of [Recover the data structure D] [Recover the data structure D]
the objective
g(X1, X2, …, Xk)
} ≥ f* }
function for
solutions that are } }
being continued to } }
be built from here

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

DELIVERY TRUCK ROUTE PROBLEM DELIVERY TRUCK ROUTE PROBLEM

• Example N = 3, K = 2, Q = 4, d[1] = 3, d[2] = 2, d[3] = 1 • Design data


– y[k] first delivery point of the kth vehicle (y[k] {0, 1, 2,..., N}, where k = 1, 2,…, K)
 There are 4 shipping options as below:
• y[k] = 0 means the vehicle k will not be used for route planning
– x[i] is the next point of the delivery point i on the route (x[i] {0,1,2,…,N}, với i = 1, 2,..., N)
Route[1] = 0 – 1 – 0 Route[1] = 0 – 1 – 2 – 0
Route[2] = 0 – 2 – 3 – 0 Route[2] = 0 – 3 – 0 – Since the vehilces are identical, we can assume y[k] ≤ y[k+1], k = 1, 2,…, K-1
Route[1] = 0 – 1 – 3 – 0 Route[1] = 0 – 2 – 0 • If y[k] > 0 then y[k+1] > y[k]
Route[2] = 0 – 2 – 0 Route[2] = 0 – 3 – 1 – 0 – Variables associated with the partial solution:
Route[1] = 0 – 1 – 0 Route[1] = 0 – 2 – 1 – 0 • visited[v] = true if v has been visited by a vehicle
Route[2] = 0 – 3 – 2 – 0 Route[2] = 0 – 3 – 0 • load[k]: total amount of boxes on the vehicle k 1 2 5

• f: total length of the current partial solution


• f*: best distance that has been found 0 4 3 0

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

DELIVERY TRUCK ROUTE PROBLEM DELIVERY TRUCK ROUTE PROBLEM


• K = 2, N= 6 • K = 2, N= 6

0 0

(y[1], y[2]) 1 2 (y[1], y[2]) 1 2

15 16
DELIVERY TRUCK ROUTE PROBLEM DELIVERY TRUCK ROUTE PROBLEM
• K = 2, N= 6 • K = 2, N= 6

0 0

(y[1], y[2]) 1 2 (y[1], y[2]) 1 2

5 5

4 4

17 18

DELIVERY TRUCK ROUTE PROBLEM DELIVERY TRUCK ROUTE PROBLEM


• K = 2, N= 6 • K = 2, N= 6

0 0

(y[1], y[2]) 1 2 (y[1], y[2]) 1 2

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

(y[1], y[2]) 1 2 (y[1], y[2]) 1 2

5 3 5 6

4 6 4

0 0 0

21 22

DELIVERY TRUCK ROUTE PROBLEM DELIVERY TRUCK ROUTE PROBLEM


• K = 2, N= 6 • K = 2, N= 6

0 0

(y[1], y[2]) 1 2 (y[1], y[2]) 1 2

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

(y[1], y[2]) 1 2 1 (y[1], y[2]) 1 2 1 3

5 3

4 6

0 0 0 0

25 26

DELIVERY TRUCK ROUTE PROBLEM DELIVERY TRUCK ROUTE PROBLEM


• K = 2, N= 6 TRY_X(s, k){// thử giá trị cho x[s] for v = 0 to n do {
if(s = 0) then{ if checkX(v,k) then {
if k < K then x[s] = v; visited[v] = true; f = f + c[s,v];
TRY_X(y[k+1],k+1);
0 load[k] = load[k] + d[v]; segments = segments + 1;
return if v > 0 then { if f + (n + nbR – segments)*Cmin < f* then TRY_X(v,k); }
} else{
[. . .] if k = K then {
(y[1], y[2]) 1 2 1 3 . . .
} if segments = n + nbR then updateBest();

checkX(v, k){ }else{

4 if v > 0 and visited[v] if f + (n + nbR – segments)*Cmin < f* then TRY_X(y[k+1],k+1);

then return false; }


. if load[k] + d[v] > Q }
. visited[v] = false; f = f – c[s,v];
then return false;
.
return true; load[k] = load[k] – d[v]; segments = segments – 1;
0 0 } }
}

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];

solve(){ if k < K then TRY_Y(k+1);

f = 0; f* = +; y[0] = 0; else { nbR = segments; TRY_X(y[1],1); }

for v = 1 to n do load[k] = load[k] – d[v]; visited[v] = false; f = f – c[0,v];

visited[v] = false; if v > 0 then segments = segments – 1;

TRY_Y(1); }

output(f*); }

} }

29 30

You might also like