Presentation on theme: "Branch & Bound Algorithms"— Presentation transcript:
1 Branch & Bound Algorithms
Briana B. MorrisonWith thanks to Dr. Hung
2 Topics Define branch & bound 0-1 Knapsack problem Assignment Problem
Breadth-First SearchBest-First SearchAssignment ProblemTraveling Salesperson
3 IntroductionThe branch-and-bound design strategy is very similar to backtracking in that a state space tree is used to solve a problem.The differences are that the branch-and-bound method 1) does not limit us to any particular way of traversing the tree, and 2) is used only for optimization problems.A branch-and-bound algorithm computes a number (bound) at a node to determine whether the node is promising.
4 Introduction …The number is a bound on the value of the solution that could be obtained by expanding beyond the node.If that bound is no better than the value of the best solution found so far, the node is nonpromising. Otherwise, it is promising.The backtracking algorithm for the 0-1 Knapsack problem is actually a branch-and-bound algorithm.A backtracking algorithm, however, does not exploit the real advantage of using branch-and-bound.
5 Introduction …Besides using the bound to determine whether a node is promising, we can compare the bounds of promising nodes and visit the children of the one with the best bound.This approach is called best-first search with branch-and-bound pruning. The implementation of this approach is a modification of the breadth-first search with branch-and-bound pruning.
6 Branch and Bound An enhancement of backtracking
Applicable to optimization problemsUses a lower bound for the value of the objective function for each node (partial solution) so as to:guide the search through state-spacerule out certain branches as “unpromising”
7 0-1 KnapsackTo learn about branch-and-bound, first we look at breadth-first search using the knapsack problemThen we will improve it by using best-first search.Remember the default strategy for the 0-1 knapsack problem was to use a depth-first strategy, not expanding nodes that were not an improvement on the previously found solution.
8 BackTracking (depth-first)
9 Breadth-first Search We can implement this search using a queue.
All child nodes are placed in the queue for later processing if they are promising.Calculate an integer value for each node that represents the maximum possible profit if we pick that node.If the maximum possible profit is not greater than the best total so far, don’t expand the branch.
10 Breadth-first SearchThe breadth-first search strategy has no advantage over a depth-first search (backtracking).However, we can improve our search by using our bound to do more than just determine whether a node is promising.
11 Branch and Bound (breadth-first)
12 0-1 Knapsack 0-1 Knapsack using the branch and bound.
Now look at all promising, unexpanded nodes and expand beyond the one with the best bound.We often arrive at an optimal solution more quickly than if we simply proceeded blindly in a predetermined order.
13 Best-first SearchBest-first search expands the node with the best bounds next.How would you implement a best-first search?Depth-first is a stackBreadth-first is a queueBest-first is a ???
14 Branch and Bound (best first)
15 0-1 Knapsack Capacity W is 10
Upper bound is $100 (use fractional value)ItemWeightValueValue / weight14$401027$42635$25$12
16 Computing Upper Bound To compute the upper bound, use
ub = v + (W – w)(vi+1/wi+1)So the maximum upper bound ispick no items, take maximum profit itemub = (10 – 0)*($10) = $100After we pick item 1, we calculate the upper bound asall of item 1 (4, $40) + partial of item 2 (7, $42)$40 + (10-4)*6 = $76If we don’t pick item 1:ub = (10 – 0) * ($6) = $60
17 State Space Tree with 1 without 1 1 2 with 2 without 2 4
with 1without 112with 2without 24inferior to node 83not feasiblewith 3without 356with 4without 4inferior to node 878not feasibleoptimal solution
18 BoundingA bound on a node is a guarantee that any solution obtained from expanding the node will be:Greater than some number (lower bound)Or less than some number (upper bound)If we are looking for a maximal optimal (knapsack), then we need an upper boundFor example, if the best solution we have found so far has a profit of 12 and the upper bound on a node is 10 then there is no point in expanding the nodeThe node cannot lead to anything better than a 10
19 BoundingRecall that we could either perform a depth-first or a breadth-first searchWithout bounding, it didn’t matter which one we used because we had to expand the entire tree to find the optimal solutionDoes it matter with bounding?Hint: think about when you can prune via bounding
20 Bounding We prune (via bounding) when:
(currentBestSolutionCost >= nodeBound)This tells us that we get more pruning if:The currentBestSolution is highAnd the nodeBound is lowSo we want to find a high solution quickly and we want the highest possible upper boundOne has to factor in the extra computation cost of computing higher upper bounds vs. the expected pruning savings
21 Enumeration in a search tree
root nodeLevel 0each node is a partial solution, i.e. a part of the solution spacechild nodesLevel 1...Level 2child nodes...
22 The assignment problem
We want to assign n people to n jobs so that the total cost of the assignment is as small as possible (lower bound)
23 Example: The assignment problem
Select one element in each row of the cost matrix C so that:no two selected elements are in the same column; andthe sum is minimizedFor example:Job 1 Job 2 Job 3 Job 4Person aPerson bPerson cPerson dLower bound: Any solution to this problem will havetotal cost of at least:sum of the smallest element in each row = 10
24 Assignment problem: lower bounds
25 State-space levels 0, 1, 2
26 Complete state-space
27 Traveling Salesman Problem
Can apply branch & bound if we come up with a reasonable lower bound on tour lengths.Simple lower bound = finding smallest element in the intercity distance matrix D and multiplying it by number of cities nAlternate solution:For each city i, find the sum si of the distances from city i to the two nearest cities;compute the sum s of these n numbers;divide the result by 2and if all the distances are integers, round up the result to the nearest integer;
28 Traveling salesman example:
lb = [(1+3)+(3+6)+(1+2)+(3+4)+(2+3)]/2 = 14
29 Summary: Branch and bound
Feasible solutionOptimal solutionBreadth-First SearchBest-First Search (with branch-and-bound pruning)
30 Summary: Branch and bound
Branch and Bound is:a general search method.minimize a function f(x), where x is restricted to some feasible region.To apply branch and bound, one must have:a means of computing a lower bound on an instance of the optimization problem.a means of dividing the feasible region of a problem to create smaller subproblems.a way to compute an upper bound (feasible solution) for at least some instances.
31 Summary: Branch and bound
The method starts by:considering the original problem with the complete feasible region (called the root problem).The lower-bounding and upper-bounding procedures are applied to the root problem.If the bounds match, then an optimal solution has been found. Otherwise, the feasible region is divided into two or more regions, which together cover the whole feasible region.These subproblems become children of the root search node.The algorithm is applied recursively to the subproblems, generating a tree of subproblems.
32 Summary: Branch and bound
If an optimal solution is found to a subproblem,it is a feasible solution to the full problem, but not necessarily globally optimal.Since it is feasible, it can be used to prune the rest of the tree:if the lower bound for a node exceeds the best known feasible solution, no globally optimal solution can exist in the subspace of the feasible region represented by the node.Therefore, the node can be removed from consideration.The search proceeds until all nodes have been solved or pruned, or until some specified threshold is meet between the best solution found and the lower bounds on all unsolved subproblems.
Стратмор оторвался от перил и переложил пистолет в правую руку. Не произнеся ни слова, он шагнул в темноту, Сьюзан изо всех сил держалась за его плечо. Если она потеряет с ним контакт, ей придется его позвать, и тогда Хейл может их услышать.