1 / 19

Chapter 6 Branch-and-Bound

Chapter 6 Branch-and-Bound. 6.1 Illustrating Branch-and-Bound with the 0-1 Knapsack Problem 6.2 The Traveling Salesperson Problem. 1. An improvement on the backtracking algorithm. 2. Similar to backtracking, a state space tree is used .

Download Presentation

Chapter 6 Branch-and-Bound

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 6Branch-and-Bound 6.1 Illustrating Branch-and-Bound with the 0-1Knapsack Problem 6.2 The Traveling Salesperson Problem Branch-and-Bound

  2. 1. An improvement on the backtracking algorithm. 2. Similar to backtracking, a state space tree is used. 3. Does not limit us to any particular way of traversing the tree. 4. It is used only for the optimization problem. 5. Branch-and-Bound algorithm computes a number (bound) at a node to determine whether the node is promising. P.S: the 0-1 Knapsack problem in Section 5.7 is actually a branch-and-bound algorithm. What is Branch-and-Bound? Branch-and-Bound

  3. 1. Best-first search with branch-and-bound pruning: A simple modification of the approach called breadth-first search with branch-and-bound pruning. Branch-and-Bound Pruning voidbreadth_first_tree_search(treeT) { queue_of_nodeQ; nodeu, v ; initialize(Q); v = root of T ; visit v; enqueue(Q, v); while (!empty(Q)) { dequeue(Q, v); for (each child u of v) { visit u; enqueue(Q, u); } } } Branch-and-Bound

  4. 7 1 3 8 6 5 2 13 14 10 12 15 4 11 9 16 Breadth-First Search of a Tree Branch-and-Bound

  5. 1. Breadth-First Search with Branch-and-Bound Pruning for the 0-1 Knapsack problem. 2. Best-First Search with Branch-and-Bound Pruning for the 0-1 Knapsack problem:an improvement of 1. A node is nonpromising if this bound is less than or equal tomaxprofit or weight  W. 6.1 Illustrating Branch-and-Bound with the 0-1Knapsack Problem Branch-and-Bound

  6. (0,0) $0 0 $115 (1,1) $40 2 $115 Example 6.1 Suppose thatn = 4, W=16, and we have the following ipiwipi/wi 1 $40 2 $20 2 $30 5 $6 3 $50 10 $5 4 $10 5 $2 Find the solutions. • Sol: • Setmaxprofit = 0 • Visit node(0,0) • profit = ? • weight = ? • 3. Visit node (1,1) :profit = ? weight = ? bound = ? maxprofit = ? bound = ? Branch-and-Bound

  7. (0,0) $0 0 $115 (1,1) (1,2) $0 0 $82 $40 2 $115 (2,1) (2,2) (2,3) (2,4) $70 7 $115 $40 2 $98 $30 5 $82 $0 0 $60 (3,4) (3,1) (3,2) (3,3) (3,5) (3,6) $120 17 $0 $70 7 $80 $90 12 $98 $40 2 $50 $80 15 $82 $30 5 $40 (4,1) (4,2) (4,3) (4,4) $80 12 $80 $70 7 $70 $100 17 $0 $90 12 $90 Example 6.1 (Cont’d) n = 4, W=16, 4. Visit node(1,2) profit = ? weight = ? 5. Visit node (2,1) maxprofit = ? bound = ? Branch-and-Bound

  8. voidbreadth_first_branch_and_bound(state_space_treeT, number& best) { queue_of_nodeQ; nodeu, v ; initialize(Q); v = root of T ; enqueue(Q, v); best = value(v); while (!empty(Q)) {dequeue(Q, v); for (each child u of v) {if (value(u) is better than best) best = value(u); if (bound(u) is better than best) enqueue(Q, u); }} } Breadth-First Branch-and-Bound Branch-and-Bound

  9. voidknapsack2(intn, const intp[], const intw[], intW, int maxprofit) { queue_of_nodeQ; nodeu, v ; initialize(Q); v.level = 0 ; v.profit = 0 ; v.weight = 0 ; maxprofit = 0; enqueue(Q, v); while (!empty(Q)) {dequeue(Q, v); u.level = v.level+1 ; u.weight = v.weight +w[u.level] ; u.profit = v.profit+p[u.level] ; if (u.weight <=W && u.profit>maxprofit ) maxprofit = u.profit; if (bound(u) > maxprofit) enqueue(Q, u); u.weight = v.weight ; u.profit = v.profit ; if (bound(u) > maxprofi) enqueue(Q, u); } } Algorithm 6.1 Branch-and-Bound

  10. floatbound(nodeu) { indexj, k ; inttotalweight ; floatresult ; if (u.weight >=W) return 0; else {result = u.profit ; j = u.level+1 ; totweight = u.weight ; while (j <=n && totweight+w[j]<=W ) {totweight= totweight+w[j]; result= result+p[j]; j++; } k = j ; if (k <= n) result= result+(Wtotweight)p[k]/w[k]; return result ; } } Algorithm 6.1 (Cont’d) Branch-and-Bound

  11. (0,0) $0 0 $115 (1,1) $40 2 $115 Example 6.2 Suppose thatn = 4, W=16, and we have the following ipiwipi/wi 1 $40 2 $20 2 $30 5 $6 3 $50 10 $5 4 $10 5 $2 Find the solutions. • Sol: • Setmaxprofit = 0 • Visit node(0,0) • profit = ? • weight = ? • 3. Visit node (1,1) :profit = ? weight = ? bound = ? maxprofit = ? bound = ? Branch-and-Bound

  12. (0,0) $0 0 $115 (1,1) (1,2) $0 0 $82 $40 2 $115 (2,1) (2,2) $70 7 $115 $40 2 $98 (3,4) (3,1) (3,2) (3,3) $120 17 $0 $70 7 $80 $90 12 $98 $40 2 $50 (4,1) (4,2) $100 17 $0 $90 12 $90 Example 6.2 (Cont’d) n = 4, W=16, 4. Visit node(1,2) profit = ? weight = ? 5. Visit node (2,1) maxprofit = ? bound = ? Branch-and-Bound

  13. voidbest_first_branch_and_bound(state_space_treeT, number& best) { priority_queue_of_nodePQ; nodeu, v ; initialize(PQ); v = root of T ; insert(PQ, v); best = value(v); while (!empty(PQ)) {remove(PQ, v); if (bound(v) is better than best) for (each child u of v) {if (value(u) is better than best) best = value(u); if (bound(u) is better than best) insert(PQ, u); } } } Best-First Branch-and-Bound Branch-and-Bound

  14. voidknapsack3(intn, const intp[], const intw[], intW, int maxprofit) { priority_queue_of_nodePQ; nodeu, v ; initialize(PQ); v.level = 0 ; v.profit = 0 ; v.weight = 0 ; maxprofit = 0; insert(PQ, v); while (!empty(PQ)) {remove(PQ, v); if (v.bound > maxprofit) { u.level = v.level+1 ; u.weight = v.weight +w[u.level] ; u.profit = v.profit+p[u.level] ; if (u.weight <=W&&u.profit>maxprofit ) maxprofit = u.profit; u.bound = bound(u); if (u.bound > maxprofit) insert(PQ, u); u.weight = v.weight ; u.profit = v.profit ; u.bound = bound(u); if (u.bound > maxprofi) insert(PQ, u); } } } Algorithm 6.2 Branch-and-Bound

  15. How to find the optimal tour more efficient than using backtracking? Branch-and-Bound can be considered for searching the state space tree. Best-First Search:the best bound at present is searched first 6.2 The Traveling Salesperson Problem v1 v2 Optimal tour 10 4 7 v4 v3 7 2 v5 Branch-and-Bound

  16. 1.Starts at v1, the 2nd vertex can be v2, v3, v4, v5. v1:min{14,4,10,20}=4v2:min{14,7,8,7}=7 v3:min{4,5,7,16}=4 v4:min{11,7,9,2}=2 v5 :min{18,7,17,4}=4 The minimum bound is 21. There can be no tour with a shorter length. 2. Suppose we have visited [v1, v2] v1:14 v2:min{7,8,7}=7 v3:min{4,7,16}=4 v4:min{11,9,2}=2 v5 :min{18,17,4}=4 The minimum bound is 31. [1,2] [1] [1,3] [1,4] [1,2,3,5] [1,2,5] [1,2,4] [1,2,3] [1,2,3,4] [1,5] Computation of Bound for a Node Branch-and-Bound

  17. Visit node [1] :bound=21, minlength= Visit node [1,2] : bound=31, Visit node [1,3] : bound=22, Visit node [1,4] : bound=30, Visit node [1,5] : bound=42, Visit node [1,3,2] : bound=22, Visit node [1,3,4] : bound=27, Visit node [1,3,5] : bound=39, Visit node [1,3,2,4] : bound=37, minlength=37 Visit node [1,3,2,5] : bound=31, minlength=31 Best First Search Node Best First Search Node Example 6.3 Branch-and-Bound

  18. [1] Bnd=21 [1,5] Bnd=42 [1,2] Bnd=31 [1,4] Bnd=30 [1,3] Bnd=22 [1,3,2] Bnd=22 [1,3,4] Bnd=27 [1,3,5] Bnd=39 [1,4,2] Bnd=45 [1,4,3] Bnd=38 [1,4,5] Bnd=30 [1,3,4,5] Len=34 [1,3,2,5] Len=31 [1,3,2,4] Len=37 [1,3,4,2] Len=43 [1,4,5,2] Len=30 [1,4,5,3] Len=48 Example 6.3 (Cont’d) Branch-and-Bound

  19. for (all i such that 2i n &&i is not in v.path) {u.path = v.path; put i at the end of u.path; if(u.level== n2) { put index of only vertex not in u.path at the end of u.path ; put 1 at the end of u.path ; if(length(u)<minlength) {minlength=length(u); opttour = u.path ; } } else { u.bound = bound(u); if(u.bound<minlength) insert(PQ, u); } } }}} Algorithm 6.3 voidtravel2(intn, const numberW[][], ordered_set&opttour number&minlength) { priority_queue_of_node PQ; node u, v; initialize(PQ); v.level = 0; v.path = [1]; v.bound = bound(v); minlength = ; insert(PQ, v); while (!empty(PQ )) { remove(PQ, v); if(v.bound <minlength) { v.level = v.level +1; Branch-and-Bound

More Related