1 / 32

Branch and bound

Pasi Fränti. Branch and bound. 30.9.2014. General search strategies Backtracking. Explore all alternatives Solution constructed by stepwise choices Decision tree Guarantees optimal solution Exponential time (slow) Depth-first search Implement as stack ( push , pop , isempty )

Download Presentation

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. Pasi Fränti Branch and bound 30.9.2014

  2. General search strategiesBacktracking Explore all alternatives • Solution constructed by stepwise choices • Decision tree • Guarantees optimal solution • Exponential time (slow) Depth-first search • Implement as stack (push, pop, isempty) • Linear time memory Breadth-first search • Implemented by queue (enqueue, dequeue, isempty)

  3. Traveling salesman problem Input: graph (V,E) Problem: Find shortest path via all nodes and returning to start node.

  4. Traveling salesman problem Input: graph (V,E) Output: path (p1, p2, ..., pn, pn+1) Solution = A-B-C-F-H-E-D-G-A Length = 22

  5. Traveling salesman problem Exercise task

  6. Knapsack problemProblem definition Input: Weight of N items {w1, w2, ..., wn} Cost of N items {c1, c2, ..., cn} Knapsack limit S Output: Selection for knapsack: {x1,x2,…xn} where xi{0,1}. Sample input: wi={1,1,2,4,12} ci ={1,2,2,10,4} S=15 Real example?

  7. Max 15 Knapsack problemSimplified Input: Weight of N items {w1, w2, ..., wn} Knapsack limit S Output: Selection for knapsack: {x1,x2,…xn} where xi{0,1}. 5 3 7 Sample input: wi={2,3,5,7,11} S=15 2 11

  8. Max 15 Knapsack problemBranch-and-bound wi={2,3,5,7,11} 0 2 2 0 3 3 5 2 3 0 5 5 5 5 12 5 9 2 10 3 7 0 7 7 7 7 12 5 9 2 3 0 10 11 11 11 11 13 2 14 3 11 0

  9. Something hereWhen time To be done... Plus the same for sorting decreasing order wi={2,3,5,7,11} S=15

  10. Graph algorithms

  11. 117 216 110 246 199 182 170 121 231 315 142 79 242 136 191 148 78 120 191 126 178 149 89 116 234 170 112 51 79 131 109 86 73 163 143 72 90 63 53 105 59 27 58 135 116

  12. C A B

  13. Empty space for notes

  14. Branch and Bound Algorithm: Scheduling Problem Material by A.Mirhashemi Input of the problem: A B C • A number of resources • A number of tasks Output of the problem: 1 • A sequence of feeding the tasks to resources to minimize the required processing time 2 3 4

  15. Application 1 Digital processing: Each resource is a processor. All tasks need to pass trough all processors in the fix sequence A,B,C but depending on the task it takes different time for each processor to process them. For example : Processor A: Scanning Processor B: Making a PDF Processor C: Exporting a PDF Task 1: A one page plain text document Task 2: A 10 page document with pictures Task 3: A 5 page html document. Task 4: …

  16. Application 2 Production line: Each product (task) need to pass trough all machines (resources) in the production line but, the time depends on what kind of customization the customer has ordered for that production. For example: Machine A: Solding Machine B: Painting Machine C: Packaging Task 1: A black car with airbag Task 2: A red car without airbag with CD player Task 3: A white car with leather seats Task 4: …

  17. Different tasks take different time to be processed in each resource A B C 1 2 3 4

  18. NP 3 4 2 1 Tasks can be done in any order 3 1 4 2 N! Possible different sequences 3 4 1 2

  19. Decision tree (Brute force)

  20. Greedy Algorithm A possible greedy algorithm might start with selecting the fastest tasks for processor A. A B C 1 2 3 : A 4 2 3 1 4

  21. Greedy solution T(4,2,3,1) = 34 A B C 1 4 2 3 1 2 2 1 4 3 3 4 2 1 3 4

  22. Optimal solution T(4,1,2,3) = 26 A B C 1 1 3 4 2 2 1 4 2 3 3 4 1 2 3 4

  23. Branch and bound Algorithm Define a bounding criteria for a minimum time required by each branch of the decision tree For level 1: For level 2:

  24. Minimum This next Level 1 A B C b(1)= 7+(6+5+4+4)+1=27 b(2)= 5+(6+5+4+4)+1=25 b(3)= 6+(6+5+4+4)+2=27 b(4)= 3+(6+5+4+4)+1=23 1 2 3 4 Bounds: T ≥27 T ≥25 T ≥27 T ≥23

  25. Minimum This next Level 2 b(4,1)= (3+7)+(6+5+4)+1=26 b(4,2)= (3+5)+(6+5+4)+1=24 b(4,3)= (3+6)+(6+5+4)+2=26 A B C 1 2 3 4 T ≥26 T ≥24 T ≥26 Bounds:

  26. Solve the branch 4-2-x-x A B C 1 Bounds: T ≥24 T ≥26 T ≥26 2 Tmin(4,2,x,x)= 29 3 T(4,2,1,3) = 29 T(4,2,3,1) = 34 4 Actual:

  27. Solve the branch 4-2-x-x A B C Bounds: 1 T ≥26 T ≥24 T ≥26 Tmin(4,2,x,x)= 29 2 Tmin(4,1,x,x)= 26 Tmin(4,3,x,x)= 29 3 4 T(4,1,2,3) = 26 T(4,1,3,2) = 28 T(4,3,1,2) = 29 T(4,3,2,1) = 34 Actual: Actual:

  28. T ≥27 T ≥25 T ≥27 T ≥23 Must besolved Solve the other branches A B C Can be skipped 1 2 3 Bounds: T = 26 Actual Time: 4

  29. b(2,1)= (5+7)+(6+4+4)+1=27 b(2,3)= (5+6)+(6+4+4)+3=28 b(2,4)= (5+3)+(6+4+4)+1=23 A B C The only candidate that can outperform T(4,1,2,3) is T(2,4,…) so we calculate it: 1 Actual T(2,4,1,3) = 29 Actual T(2,4,3,1) = 34 2 3 4

  30. T ≥27 T ≥25 T ≥27 T ≥23 T = 29 T = 26 Bounds greater than 26! So the best time is T(4,1,2,3) and we don’t need to solve the problem for any other branch because we now their minimum time, already. A B C 1 2 3 Bounds: Actual Time: 4

  31. Summary • Using only the first level criteria we reduce the problem by 50% (omitting 2 main branches). • Using the second level criteria we can reduce even more.

  32. Empty space for notes

More Related