Week04 - Branch and Bound
Week04 - Branch and Bound
STRUCTURES AND
ALGORITHMS
CONTENT
3 4
GENERAL DIAGRAM GENERAL DIAGRAM
• Branch and Bound: One of the methods to solve combinatorial optimization problems • Consider the problem of finding the
minimum of the objective function in
• Use the backtracking technique to list all options, thereby retaining the best option
which the solution is represented by a set
• Use bound evaluation (upper bound for the problem of finding max and lower bound for the
of variables X = (X1, X2, . . ., Xn).
problem of finding min) to cut down the search space during the listing process.
• The Try(k) function is used to try the
value for variable Xk during the listing
process Evaluate a lower bound
of the objective
function of the solution
• Symbol f*: objective function, the value evolving from this point
5 6
objective function of the development A itinerary (journey) is a way to start from city 1, go through all the remaining
cities, each city exactly once, and then return to starting city 1.
options continuing from point 13.
Know that c(i, j) is the cost of traveling from city i to city j (i, j = 1, 2,..., n)
• If g is greater than or equal to f*, do not
Find the itinerary with the smallest total cost.
continue developing the solution from
Some comments:
point 13 Evaluate a lower bound
of the objective • The number of traveler's itineraries is (n-1)!
function of the solution Sir William Rowan Hamilton [1]
developing from this • We have a one-to-one correspondence between a tourist's itinerary: (1805 – 1865)
point
• 1 ->x[2] -> x[3] ->...-> x[n]-> 1 with a permutation x = (x[2], x[3],..., x[n]) of n -1
Skip
natural number 2, 3,..., n.
• Journey cost: f(x) = c(1, x[2]) + c(x[2], x[3]) +... + c(x[n-1],x[n] ) + c(x[n] ,1)
7 8
THE TRAVELING SALESMAN PROBLEM THE TRAVELING SALESMAN PROBLEM
Solve using searching in the whole space: Init: Solve using branch and bound
• f* = +∞; f = 0; x[1] = 1;
Itinerary : x = (1, x[2], x[3],..., x[n], 1) • for (int v = 2; v<=n; v++) visited[v]=0; Calculate bound:
• Let cmin = min { c(i, j) , i, j = 1, 2, ..., n, i j } be the minimum traveling cost between cites
void Try(int k) {
try(k){//try values assignable to x[k]
for (int v = 2; v<=n; v++) { • Need to estimate the itinerary cost for the current branch corresponding to the part (1, u2, . . .,
for v in candidates(k) do { if (!visited[v]) {
x[k] = v; uk) passing through: 1 u2 . . . uk-1 uk
if (check(v,k)) then {
visited[v] = 1;
x[k] = v; f = f + c(x[k-1],x[k]); • If the lower bound g(1, u2, . . ., uk) ≥ f* then skip (1, u2, . . ., uk)
Determine:
if (k == n) { //Update record
[Update the data structure D] 1) candidates(k)
ftemp = f + c(x[n],x[1]);
2) check(v, k)
if (k == n) then solution(); if (ftemp < f*) f∗ = ftemp;
}
else try(k+1); else Try(k + 1);
[Recover the data structure D] f = f − c(x[k-1],x[k]);
visited[v] = 0;
} }
} }
}
}
9 10
• Need to estimate the itinerary cost for the current branch corresponding to the part (1, u2, . . ., • Function Try(k) finds the optimal solution to
uk) passing through: 1 u2 . . . uk-1 uk the tourist problem using branch and bound Try(k) {
for v = 2 to n do {
• The cost for the partial itinerary (1, u2, ..., uk) is: techniques if not visited[v] {
x[k] = v;
= c(1,u2) + c(u2, u3) + ... + c(uk-1, uk) visited[v] = true;
f = f + c(x[k-1],x[k]);
• For a full itinerary: if k = n then { //Update record
ftemp = f + c(x[n],x[1]);
1 u2 . . . uk-1 uk uk+1 uk+2 ….. un 1 if (ftemp < f*) f∗ = ftemp;
}
• We need n-k+1 more stages, each stage has a cost at least cmin, hence the minimum cost for else {
g = f + (n−k+1)∗cmin;
the remaining itinerary : (n-k+1) cmin Main(){ if g < f∗ then Try(k+1);
//Init: }
• If the partial itinerary is (1, u2, ..., uk) then the full itinerary has the cost at least g(1, u2, ..., uk) = f* = +∞; f = 0; x[1] = 1; f = f − c(x[k-1],x[k]);
for v = 2 to n do visited[v] = false; visited[v] = false;
+ (n-k+1) cmin Try(2); }
print(f*); }
} }
11 12
THANK YOU !
13