Presentation is loading. Please wait.

Presentation is loading. Please wait.

Branch and bound Pasi Fränti 30.9.2014. Explore all alternatives Solution constructed by stepwise choices Decision tree Guarantees optimal solution Exponential.

Similar presentations


Presentation on theme: "Branch and bound Pasi Fränti 30.9.2014. Explore all alternatives Solution constructed by stepwise choices Decision tree Guarantees optimal solution Exponential."— Presentation transcript:

1 Branch and bound Pasi Fränti 30.9.2014

2 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) General search strategies Backtracking

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

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

5 Traveling salesman problem Exercise task

6 Input:Weight of N items {w 1, w 2,..., w n } Cost of N items {c 1, c 2,..., c n } Knapsack limit S Output:Selection for knapsack: {x 1,x 2,…x n } where x i  {0,1}. Sample input: w i ={1,1,2,4,12} c i = {1,2,2,10,4} S=15 Knapsack problem Problem definition Real example?

7 Max 15 Input:Weight of N items {w 1, w 2,..., w n } Knapsack limit S Output:Selection for knapsack: {x 1,x 2,…x n } where x i  {0,1}. Sample input: w i ={2,3,5,7,11} S=15 Knapsack problem Simplified 3 5 2 7 11

8 Max 15 0 5 0 12 Knapsack problem Branch-and-bound 2 230 52071039 w i ={2,3,5,7,11} 50 11 3 10 29 2 3 3 5555 7 77 7 132143011

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

10 Graph algorithms

11 136 170 315 14878 231 234 120 89 131109 116 86 246 182 216 110 117 199 121 142 242 79 191 178 191 126 149 170 51 112 90 163 59 143 73 6353 27 135 105 58 116 72 79

12 A B C

13 Empty space for notes

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

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 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:… Application 2

17 Different tasks take different time to be processed in each resource 1 2 3 4 ABC 767 552 641 343

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

19 For part 1 and 2 Start 1 2 3 4 4 3 3 2 4 4 2 4 2 3 3 2 2 1 3 4 4 3 3 1 4 4 1 4 1 3 3 1 3 1 2 4 4 2 2 1 4 4 1 4 1 2 2 1 4 1 2 3 3 2 2 1 3 3 1 3 1 2 2 1 For part 3 and 4 Decision tree (Brute force)

20 Greedy Algorithm A possible greedy algorithm might start with selecting the fastest tasks for processor A. 1 2 3 4 ABC 767 552 641 343 4 2 3 1 A :

21 4 4 4 2 31 2 2 3 3 1 1 Greedy solution T(4,2,3,1) = 34 1 2 3 4 ABC 767 552 641 343

22 4 4 4 1 1 1 2 2 2 3 3 3 1 2 3 4 ABC 767 552 641 343 Optimal solution T(4,1,2,3) = 26

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 1 2 3 4 ABC 767 552 641 343 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 Level 1 Start 1234 T ≥ 23T ≥27 T ≥ 25 Bounds: Minimum This next

25 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 1 2 3 4 ABC 767 552 641 343 Bounds: Level 2 T ≥26T ≥24T ≥26 Minimum This next

26 1 2 3 4 ABC 767 552 641 343 T(4,2,1,3) = 29 T(4,2,3,1) = 34 T min (4,2,x,x)= 29 Solve the branch 4-2-x-x T ≥26 T ≥24T ≥26 Bounds: Actual:

27 1 2 3 4 ABC 767 552 641 343 Bounds: T ≥26T ≥24T ≥26 T min (4,3,x,x)= 29 T min (4,1,x,x)= 26 T min (4,2,x,x)= 29 Solve the branch 4-2-x-x 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:

28 1 2 3 4 ABC 767 552 641 343 Start 1234 Actual Time: T = 26 Bounds:T ≥27T ≥25T ≥23T ≥27 Must be solved Can be skipped Solve the other branches

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 1 2 3 4 ABC 767 552 641 343 The only candidate that can outperform T(4,1,2,3) is T(2,4,…) so we calculate it: Actual T(2,4,1,3) = 29 Actual T(2,4,3,1) = 34

30 1 2 3 4 ABC 767 552 641 343 Start 1234 Actual Time: 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. Bounds: T = 26T = 29 T ≥27T ≥25T ≥23T ≥27 Bounds greater than 26!

31 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. Summary

32 Empty space for notes


Download ppt "Branch and bound Pasi Fränti 30.9.2014. Explore all alternatives Solution constructed by stepwise choices Decision tree Guarantees optimal solution Exponential."

Similar presentations


Ads by Google