Branch and Bound
Branch and Bound
Branch and Bound
Updated: 12/27/2010
DFS, BFS, hill climbing and best-first search can be used to solve some searching problem for searching a feasible solution. However, they cannot be used to solve the optimization problems for searching an (the) optimal solution.
This strategy can be used to solve optimization problems without an exhaustive search in the average case.
Branch-and-bound strategy
2 mechanisms:
A mechanism to generate branches when searching the solution space A mechanism to generate a bound so that many braches can be terminated
Branch-and-bound strategy
It is efficient in the average case because many branches can be terminated very early. Although it is usually very efficient, a very large tree may be generated in the worst case. Many NP-hard problem can be solved by B&B efficiently in the average case; however, the worst case time complexity is still exponential. 5
A feasible solution is found whose cost is equal to 5. An upper bound of the optimal solution is first found here. 8
Given a graph, the TSP Optimization problem is to find a tour, starting from any vertex, visiting every other vertex and returning to the starting vertex, with minimal cost. It is NP-hard. We try to avoid n! exhaustive search by the branch-and-bound technique on the average case. (Recall that O(n!)>O(2n).)
11
i 1 2 3 4 5 6 7
1 4 45 39 28 3 44
2 3 17 90 46 88 26
3 93 77 80 88 18 33
4 13 42 36 33 46 27
5 33 21 16 56 92 84
6 9 16 28 7 25 39
7 57 34 25 91 57 7
12
There is a way to split the solution space (branch) There is a way to predict a lower bound for a class of solutions. There is also a way to find a upper bound of an optimal solution. If the lower bound of a solution exceeds the upper bound, this solution cannot be optimal and thus we should terminate the branching associated with this solution.
13
Splitting
One group including a particular arc The other excluding the arc
Each splitting incurs a lower bound and we shall traverse the searching tree with the lower lower bound.
14
to j
from i
4 5 6 7
1 0 29 32 3 0 18
2 0 1 83 21 85 0
3 90 73 73 63 15 7
4 10 38 20 8 43 1
5 30 17 0 49 89 58
6 6 12 12 0 0 13
1 0 29 32 3 0 18
2 0 1 83 21 85 0
3 83 66 66 56 8 0 (-7)
4 9 37 19 7 42 0 (-1)
5 30 17 0 49 89 58
6 6 12 12 0 0 13
7 50 26 5 80 28 0 (-4)
17
Lower bound
The total cost of 84+12=96 is subtracted. Thus, we know the lower bound of feasible solutions to this TSP problem is 96.
18
If we use arc 3-5 to split, the difference on the lower bounds is 17+1 = 18. 19
If an arc of cost 0 (x) is selected, then the lower bound is added by 0 (x) when the arc is included. If an arc <i,j> is not included, then the cost of the second smallest value (y) in row i and the second smallest value (z) in column j is added to the lower bound. Select the arc with the largest (y+z)-x20
Weonlyhavetosetc4-6tobe.
1 0 29 32 3 0 18
2 0 1 83 21 85 0
3 83 66 66 56 8 0
4 9 37 19 7 42 0
5 30 17 0 49 89 58
6 6 12 12
7 50 26 5 80 28 0
0 13
21
23
Upper bound
We follow the best-first search scheme and can obtain a feasible solution with cost C. C serves as an upper bound of the optimal solution and many branches may be terminated if their lower bounds are equal to or larger than C.
24
1 1 1
1 1
Preventing an arc
In general, if paths i1-i2--im and j1-j2--jn have already been included and a path from im to j1 is to be added, then path from jn to i1 must be prevented (by assigning the cost of jn to i1 to be ) For example, if 4-6, 2-1 are included and 1-4 is to be added, we must prevent 6-2 from being used by setting c6-2=. If 6-2 is used, there will be a loop which is forbidden.
26
i= 1 n
i= 1 n
Fig. 6-27 The Branching Mechanism in the Branch-and-Bound Strategy to Solve 0/1 Knapsack Problem.
28
Ans: by quickly finding a feasible solution in a greedy manner: starting from the smallest available i, scanning towards the largest is until M is exceeded. The upper bound can be calculated.
29
E.g. n = 6, M = 34 i Pi Wi 1 6 10 2 10 19 3 4 8 4 5 10 5 6 12 6 4 8
(Pi/Wi Pi+1/Wi+1)
A feasible solution: X5 = 0, X6 = 0
X1 = 1, X2 = 1, X3 = 0, X4 = 0,
-(P1+P2) = -16 (upper bound) Any solution higher than -16 can not be an optimal solution.
30
knapsack problem and Pi X be an optimal i solution for fractional knapsack problem. Let Y= Pi X i ,Y = Pi X . i
i =1
YY
i =1
i =1
31
We can use the greedy method to find an optimal solution for knapsack problem. For example, for the state of X1=1 and X2=1, we have X1 = 1, X2 =1, X3 = (34-6-10)/8=5/8, X4 = 0, X5 = 0, X6 =0 -(P1+P2+5/8P3) = -18.5 (lower bound) -18 is our lower bound. (We only consider integers, since the benefits of a 0/1 knapsack problem will be integers.)
32
By the best-first search scheme That is, by expanding the node with the best lower bound. If two nodes have the same lower bounds, expand the node with the lower upper bound.
33
34
Node 2 is terminated because its lower bound is equal to the upper bound of node 14. Nodes 16, 18 and others are terminated because the local lower bound is equal to the local upper bound. (lower bound optimal solution upper bound)
35
The A * algorithm
Used to solve optimization problems. Using the best-first strategy. If a feasible solution (goal node) is selected to expand, then it is optimal and we can stop. Estimated cost function of a node n : f(n) f(n) = g(n) + h(n) g(n): cost from root to node n. h(n): estimated cost from node n to a goal node. h*(n): real cost from node n to a goal node. f*(n): real cost of node n Estimated further cost should never exceed the real further cost. h(n) h*(n) f(n) = g(n) + h(n) g(n)+h*(n) = f*(n) . (1) 36
Reasoning
Let t be the selected goal node. We have f*(t)=f(t) +h(t)=f(t)+0=f(t)..(2) Assume that t is not the optimal node. There must exist one node, say s, that has been generated but not selected and that will lead to the optimal node. Since we take the best first search strategy, we have f (t) f(s)(3). We have f*(t)=f(t) f(s) f*(s) by Eqs. (1), (2) and (3), which means that s is not the node leading to the optimal node. Contradiction occurs. 37 Therefore, t is the optimal node.
The A * algorithm
Stop when the selected node is also a goal node. It is optimal iff h(n) h*(n)
E.g.: To find a shortest path from node s to node t
38
The A * algorithm
Step 1.
The A * algorithm
Step 2. Expand A
g(D)=2+2=4 g(E)=2+3=5
f(D)=4+1=5 f(E)=5+2=7
40
The A * algorithm
Step 3. Expand C
g(F)=3+2=5 g(G)=3+2=5
h(F)=min{3,1}=1 h(G)=min{5}=5
f(F)=5+1=6 f(G)=5+5=10
41
The A * algorithm
Step 4. Expand D
The A * algorithm
Step 5. Expand B
g(J)= 2= 4+ 6
h(J)= in{5}= m 5
f(J)= 5= 6+ 11
43
The A * algorithm
Step 6. Expand F I is selected to expand. The A* algorithm stops, since I is a goal node.
g )= + + = (K 3 2 1 6 g )= + + = (L 3 2 3 8
h )= in 5 = (K m { } 5 h )= (L 0
f(K 6 5 1 )= + = 1 f(L 8 0 8 )= + =
44
The A* Algorithm
Can be considered as a special type of branch-and-bound algorithm. When the first feasible solution is found, all nodes in the heap (priority queue) are terminated. * stands for real A* algorithm stands for real good algorithm
45
Q&A
46