Week4 Chap3 Recursion Branch and Bound Cbus
Week4 Chap3 Recursion Branch and Bound Cbus
APPLIED ALGORITHMS
BACKTRACKING, BRANCH AND BOUND
3
CONTENTS
4
GENERAL DIAGRAM OF BACKTRACKING, BRANCHING AND BOUND
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]
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]
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]
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
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