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

Week4 Chap3 Recursion Branch and Bound Cbus

Uploaded by

Ha Minh Duc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Week4 Chap3 Recursion Branch and Bound Cbus

Uploaded by

Ha Minh Duc
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

APPLIED ALGORITHMS

APPLIED ALGORITHMS
BACKTRACKING, BRANCH AND BOUND

3
CONTENTS

• General diagram of backtracking, branch and bound


• The problem of bus routes picking up and dropping off passengers
• Delivery truck route problem
• 2D material cutting problem

4
GENERAL DIAGRAM OF BACKTRACKING, BRANCHING AND BOUND

• The backtracking algorithm allows us to solve combinatorial enumeration problems and


combinatorial optimization problems
• The alternative is modeled by a sequence of decision variables X1, X2, . . ., Xn
• Need to find for each variable Xi a value selected from a given discrete set Ai such that
• The constraints of the problem are satisfied
• Optimize a given objective function
• Backtracking algorithm
• Traverse through all variables (e.g. order from X1, X2, . . ., Xn), for each variable Xk :
• Traverse through all possible values that could be assigned to Xk, for each value v:
• Check constraints
• Assign Xk = v
• If k = n then record a solution to the problem
• Otherwise, consider the variable Xk+1

5
GENERAL DIAGRAM OF BACKTRACKING, BRANCHING AND BOUND
try(1) Enumeration problem
1
try(k){ //Try out the possible values assigned to Xk
try(2) try(2) for v in Ak do {
try(2)
2 3 if check(v,k){
. . .
Xk = v;
. . . . . . . . . . . . . . . . . . [Update a data structure D]

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


else {
. . .
try(k+1);
}
. . . . . . . . . . . . . . .
[Recover the data structure D]
}
}
}

6
GENERAL DIAGRAM OF BACKTRACKING, BRANCHING AND BOUND
try(1) Minimize optimization problem (Denote f* : optimal value)
1
try(k){//Try out the possible values assigned to Xk
try(2) try(2) for v in Ak do {
try(2)
2 3 if check(v,k){
. . .
Xk = v;
. . . . . . . . . . . . . . . . . . [Update a data structure D]

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


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

7
GENERAL DIAGRAM OF BACKTRACKING, BRANCHING AND BOUND
try(1) Minimize optimization problem (Denote f* : optimal value)
1
try(k){//Try out the possible values assigned to Xk
try(2) try(2) for v in Ak do {
try(2)
2 3 if check(v,k){
. . .
Xk = v;
. . . . . . . . . . . . . . . . . . [Update a data structure D]

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


else {
. . .
if g(X1, X2, …, Xk) < f* then
try(k+1);
. . . . . . . . . . . . . . . Do not further build }
the solution if
[Recover the data structure D]
g(X1, X2, …, Xk)
≥ f* }
}
}

8
The problem of bus routes picking up and dropping off passengers

• A bus departing from point 0 needs to build a route that could serve n passengers and return to
point 0. Passenger i has: the pick-up point is i and the drop-off point is i + n (i = 1, 2, ... , n). The bus
has K seats to serve passengers. The travel distance from point i to point j is d(i, j), with i, j = 0, 1, 2, .
. , 2n. Calculate the route for the bus so that the total distance traveled is minimal, and the number
of passengers on the bus never exceeds K.

9
The problem of bus routes picking up and dropping off passengers

• A bus departing from point 0 needs to build a route that could serve n passengers and return to
point 0. Passenger i has: the pick-up point is i and the drop-off point is i + n (i = 1, 2, ... , n). The bus
has K seats to serve passengers. The travel distance from point i to point j is d(i, j), with i, j = 0, 1, 2, .
. , 2n. Calculate the route for the bus so that the total distance traveled is minimal, and the number
of passengers on the bus never exceeds K.
• Branch and bound algorithm
• Modelling problem: X1, X2, . . ., X2n is the sequence of pick-up and drop-off points on the bus
route (a permutation of 1, 2, …, 2n).
• Cmin: the smallest distance among the distances between 2 points
• Marker array: visited[v] = true means point v has appeared on the route and visited[v] = false,
otherwise
• load: number of passengers present in the vehicle
• When the route reaches the pick-up point, the load increases by 1, and when it reaches the
drop-off point, the load decreases by 1
• f: length of the partial route
• f*: shortest route length that has been found

10
The problem of bus routes picking up and dropping off passengers

• Analyze the lower bound

X2n X1
• Untraveled route,
including 2n+1-k
segments, each X2
segment has length .
≥ Cmin .
• The length of the . . . .
complete route
The partial route that
developing further
has gone through:
from Xk will be ≥ f + Xk-1
• k segments
Cmin*(2n+1-k) Xk
• Length f
Xk

11
The problem of bus routes picking up and dropping off passengers
try(k){ check(v,k){
for v = 1 to 2n do { if visited[v] = true then return false;
if check(v,k){ if v > n then {
Xk = v; if visited[v-n] = false then return false;
f = f + d(Xk-1,Xk); visited[v] = true; }else{
if v  n then load += 1; else load -= 1; if load + 1 > K then return false;
if k = 2n then updateBest(); }
else { return true;
if f + Cmin*(2n+1-k) < f* then }
try(k+1);
} updateBest(){
if v  n then load -= 1; else load += 1; if f + d(X2n,0) < f* then {
f = f - d(Xk-1,Xk); visited[v] = false; f* = f + d(X2n,0);
} }
} }
}

12
THANK YOU !

13

You might also like