Top Banner
Branch and bound Pasi Fränti 1.10.2014
31

Branch and bound

Jan 01, 2016

Download

Documents

igor-jacobson

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 ) - PowerPoint PPT Presentation
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Branch and bound

Branch and bound

Pasi Fränti1.10.2014

Page 2: Branch and bound

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 strategiesBacktracking

Page 3: Branch and bound

Traveling salesman problem

Input: graph (V,E)

Problem: Find shortest path via all nodes and returning to start node.

A

B C

D E F

G H

22

24 4

3 32

23

43 5

Page 4: Branch and bound

A

B C

D E F

G H

22

24 4

3 32

23

43 5

Traveling salesman problem

Solution = A-B-C-F-H-E-D-G-ALength = 22

Input: graph (V,E)

Output: path (p1, p2, ..., pn, pn+1)

Page 5: Branch and bound

Traveling salesman problem

D

C

A

F

F

B

D

C

G

E E

FE

G

D C F

2

4

998

11

1512

F

22

G3 2

6

6

H

11 13

H

G

DA

F G

D

15

17

20

23

14 13

H

G

D A

15

11

17

20

24 27

13

B7

F

H

G

A

17

2022

24

16

6

Page 6: Branch and bound

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

Knapsack problemProblem definition

Real example?

Page 7: Branch and bound

Max 15

Input: Weight of N items {w1, w2, ..., wn}

Knapsack limit SOutput: Selection for knapsack: {x1,x2,…xn}

where xi {0,1}. Sample input:

wi={2,3,5,7,11}

S=15

Knapsack problemSimplified

3

5

2

7

11

Page 8: Branch and bound

Max 15

0

5

0

12

12

Knapsack problemBranch-and-bound

2

2 3 0

5 2 0710 39

wi={2,3,5,7,11}

5 01131029

2

33

5 55 5

7777

13 2 14 3 011

11 11 11

Page 9: Branch and bound

Something hereWhen time

Plus the same for sorting decreasing order

wi={2,3,5,7,11}S=15

To be done...

Page 10: Branch and bound

136

170315

148 78

231

234

12089

131109

116

86

246

182

216110

117

199

121142

24279

191178

191

126149

17051 112

90163

59

14373

63 53

27135

10558

116

72

79

Page 11: Branch and bound

A

B

C

Page 12: Branch and bound

Empty space for notes

Page 13: Branch and bound

Branch and Bound Algorithm:

Scheduling Problem

Input of the problem:

A number of tasks

A number of resources

1

2

3

4

A B C

Output of the problem:

A sequence of feeding the tasks to resources

to minimize the required processing time

Material by A.Mirhashemi

Page 14: Branch and bound

Application 1Digital 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: ScanningProcessor B: Making a PDFProcessor C: Exporting a PDF

Task 1: A one page plain text documentTask 2: A 10 page document with picturesTask 3: A 5 page html document.Task 4: …

Page 15: Branch and bound

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: SoldingMachine B: PaintingMachine C: Packaging

Task 1: A black car with airbagTask 2: A red car without airbag with CD playerTask 3: A white car with leather seatsTask 4: …

Application 2

Page 16: Branch and bound

Different tasks take different timeto be processed in each resource

1

2

3

4

A B C

7 6 75 5 26 4 13 4 3

Page 17: Branch and bound

Tasks can be done in any order

N! Possible different sequences

12

34

3 1 4 2

2 1 4 3

NP

Page 18: Branch and bound

Decision tree (Brute force)

Page 19: Branch and bound

Greedy Algorithm

A possible greedy algorithm might start with selecting the fastest tasks for processor A.

1

2

3

4

A B C

7 6 7

5 5 2

6 4 1

3 4 3

4 2 3 1A :

Page 20: Branch and bound

4

4

4

2 3 1

2

2

3

3

1

1

Greedy solution T(4,2,3,1) = 34 1

2

3

4

A B C

7 6 7

5 5 2

6 4 1

3 4 3

Page 21: Branch and bound

4

4

4

1

1

1

2

2

2

3

3

3

1

2

3

4

A B C

7 6 7

5 5 2

6 4 1

3 4 3

Optimal solutionT(4,1,2,3) = 26

Page 22: Branch and bound

Branch and bound AlgorithmDefine a bounding criteria for a minimum time required by each branch of the decision tree

For level 1:

For level 2:

Page 23: Branch and bound

1

2

3

4

A B C

7 6 7

5 5 2

6 4 1

3 4 3

b(1)= 7+(6+5+4+4)+1=27b(2)= 5+(6+5+4+4)+1=25b(3)= 6+(6+5+4+4)+2=27b(4)= 3+(6+5+4+4)+1=23

Level 1

T ≥23T ≥27 T ≥27T ≥25Bounds:

Minimum

This next

Page 24: Branch and bound

b(4,1)= (3+7)+(6+5+4)+1=26b(4,2)= (3+5)+(6+5+4)+1=24b(4,3)= (3+6)+(6+5+4)+2=26

1

2

3

4

A B C

7 6 7

5 5 2

6 4 1

3 4 3

Bounds:

Level 2

T ≥26 T ≥24 T ≥26

Minimum

This next

Page 25: Branch and bound

1

2

3

4

A B C

7 6 7

5 5 2

6 4 1

3 4 3

T(4,2,1,3) = 29T(4,2,3,1) = 34

Tmin(4,2,x,x)= 29

Solve the branch 4-2-x-x

T ≥26 T ≥24 T ≥26Bounds:

Actual:

Page 26: Branch and bound

1

2

3

4

A B C

7 6 7

5 5 2

6 4 1

3 4 3

Bounds: T ≥26 T ≥24 T ≥26

Tmin(4,3,x,x)= 29Tmin(4,1,x,x)= 26Tmin(4,2,x,x)= 29

Solve the branch 4-2-x-x

T(4,1,2,3) = 26T(4,1,3,2) = 28

T(4,3,1,2) = 29T(4,3,2,1) = 34

Actual: Actual:

Page 27: Branch and bound

1

2

3

4

A B C

7 6 7

5 5 2

6 4 1

3 4 3

Actual Time: T = 26Bounds: T ≥27 T ≥25 T ≥23T ≥27

Must besolved

Can beskipped

Solve the other branches

Page 28: Branch and bound

b(2,1)= (5+7)+(6+4+4)+1=27b(2,3)= (5+6)+(6+4+4)+3=28b(2,4)= (5+3)+(6+4+4)+1=23

1

2

3

4

A B C

7 6 7

5 5 2

6 4 1

3 4 3

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) = 29Actual T(2,4,3,1) = 34

Page 29: Branch and bound

1

2

3

4

A B C

7 6 7

5 5 2

6 4 1

3 4 3

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 ≥27 T ≥25 T ≥23T ≥27

Bounds greater than 26!

Page 30: Branch and bound

• 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

Page 31: Branch and bound

Empty space for notes