algorithms theory 13 bin packing
play

Algorithms Theory 13 Bin Packing Prof. Dr. S. Albers Winter term - PowerPoint PPT Presentation

Algorithms Theory 13 Bin Packing Prof. Dr. S. Albers Winter term 07/08 Bin packing 1. Problem definition and general observations 2. Approximation algorithms for the online bin packing problem 3. Approximation algorithms for the offline


  1. Algorithms Theory 13 – Bin Packing Prof. Dr. S. Albers Winter term 07/08

  2. Bin packing 1. Problem definition and general observations 2. Approximation algorithms for the online bin packing problem 3. Approximation algorithms for the offline bin packing problem Winter term 07/08 2

  3. Problem definition Given: n items with sizes s 1 , ... , s n where 0 < s i ≤ 1 for 1 ≤ i ≤ n . Goal: Pack items into a minimum number of unit-capacity bins. Example: 7 items with sizes 0.2, 0.5, 0.4, 0.7, 0.1, 0.3, 0.8 Winter term 07/08 3

  4. Problem definition Online bin packing: Items arrive one by one. Each item must be assigned immediately to a bin, without knowledge of any future items. Reassignment is not allowed. Offline bin packing: All n items are known in advance, i.e. before they have to be packed. Winter term 07/08 4

  5. Observations • Bin packing is provably hard. (Offline bin packing is NP-hard. Decision problem is NP-complete.) • There exists no online bin packing algorithm that always finds an optimal solution. Winter term 07/08 5

  6. Online bin packing Theorem 1: There are inputs that force each online bin packing algorithm to use at least 4/3 OPT bins where OPT is the minimum number of bins possible. Proof: Assumption: online bin packing algorithm A always uses less than 4/3 OPT bins 1 1/2 ..... .... 0 1 2 m m + 1 m + 2 2 m time Winter term 07/08 6

  7. Online bin packing 1st point of time: OPT = m /2 and #bins( A ) = b by assumption: b < 4/3 ⋅ m /2 = 2/3 m Let b = b 1 + b 2 , with b 1 = #bins containing one item b 2 = #bins containing two items There is: b 1 + 2 b 2 = m , i.e. b 1 = m –2 b 2 Hence: b = b 1 + b 2 = m – b 2 ( ∗ ) Winter term 07/08 7

  8. Online bin packing 2nd point of time: OPT = m #bins( A ) ≥ b + m – b 1 = m + b 2 Assumption: m + b 2 ≤ #bins( A ) < 4/3 m b 2 < m /3 using ( ∗ ): b = m – b 2 > 2/3 m Winter term 07/08 8

  9. Online bin packing Next Fit (NF), First Fit (FF), Best Fit (BF) Next Fit: Assign an arriving item to the same bin as the preceding item. If it does not fit, open a new bin and place it there. Theorem 2: (a) For all input sequences I : NF ( I ) ≤ 2 OPT ( I ). (b) There exist input sequences I such that: NF ( I ) ≥ 2 OPT ( I ) – 2. Winter term 07/08 9

  10. Next Fit Proof: (a) Consider two bins B 2k-1 , B 2k , 2 k ≤ NF ( I ). 1 0 B 1 B 2 B 2k-1 B 2k Winter term 07/08 10

  11. Next Fit Proof: (b) Consider an input sequence I of length n ( n ≡ 0 ( mod 4)): 0.5, 2/ n , 0.5, 2/ n , 0.5, ... , 0.5, 2/ n Optimal packing: 1 2/n 0.5 0.5 0.5 . . . .......... . . 2/n 0.5 0.5 0.5 2/n 0 B 1 B 2 B n/4 B n/4 + 1 Winter term 07/08 11

  12. Next Fit Next Fit yields: 1 2 /n .......... 2 /n 2 /n 0.5 0.5 0.5 0 B 1 B 2 B n/2 NF ( I ) = OPT ( I ) = Winter term 07/08 12

  13. First Fit First Fit: Assign an arriving item to the first bin (i.e. that was opened earliest) in which it fits. If there is no such bin, open a new one and place it there. Observation: At each point in time there is at most one bin that is less than half full. � FF( I ) ≤ 2OPT( I ) Winter term 07/08 13

  14. First Fit Theorem 3: (a) For all input sequences I : 17 FF ( I ) ≤ ⎡ OPT ( I ) ⎤ 10 (b) There exist input sequences I such that: 17 FF ( I ) ≥ ( OPT ( I ) – 1) 10 (b´) There exist input sequences I such that: 10 FF ( I ) = OPT ( I ) 6 Winter term 07/08 14

  15. First Fit Proof (b`): Input sequence of length 3 ⋅ 6 m : + ε + ε + ε + ε K K 1 / 7 , , 1 / 7 , 1 / 3 , , 1 / 3 , 1 4 4 4 2 4 4 4 3 1 4 4 2 4 4 3 6 m 6 m + ε + ε K 1 / 2 , , 1 / 2 1 4 4 4 2 4 4 4 3 6 m Winter term 07/08 15

  16. First Fit First Fit yields: + ε + ε 1 / 7 1 / 7 + ε + ε 1 / 7 1 / 7 + ε + ε 1 / 7 1 / 7 + ε + ε 1 / 3 1 / 3 + ε + ε L L L 1 / 7 1 / 7 + ε + ε 1 / 7 1 / 7 + ε + ε 1 / 3 1 / 3 L L + ε + ε 1 / 7 1 / 7 B B B B 1 4 4 4 2 4 4 4 3 1 m + 1 4 4 4 2 4 4 4 3 m 1 4 m m 6 m / 2 Winter term 07/08 16

  17. First Fit ......... + ε + ε 1 / 2 1 / 2 B B + 1 4 4 4 2 4 4 4 3 4 m 1 10 m 6 m Winter term 07/08 17

  18. Best Fit Best Fit: Assign an arriving item to the bin in which it fits best (i.e. where it leaves the smallest empty space). Performance of BF and FF is similar. Running times on input sequences of length n : NF O( n ) FF O( n 2 ) O( n log n ) BF O( n 2 ) O( n log n ) Winter term 07/08 18

  19. Offline bin packing Prior to the packing, n and s 1 , ..., s n are known in advance. An optimal packing can be found by exhaustive search. Approach to an offline approximation algorithm: Initially sort the items in decreasing order of size and assign the larger items first! First Fit Decreasing (FFD) resp. FFNI Best Fit Decreasing (BFD) Winter term 07/08 19

  20. First Fit Decreasing Lemma 1: Let I be an input sequence of n objects with sizes s 1 ≥ s 2 ≥ ..... ≥ s n and let m = OPT(I). Then, all items placed by FFD into bins B m+1 ,B m+2 , ... , B FFD(I) Are of size at most 1/3. Winter term 07/08 20

  21. First Fit Decreasing Lemma 2: Let I be an input sequence of n objects with sizes s 1 ≥ s 2 ≥ ..... ≥ s n and let m = OPT ( I ). Then the number of items placed by FFD into bins B m+1 ,B m+2 , ... , B FFD(I) is at most m – 1. Winter term 07/08 21

  22. First Fit Decreasing Proof: Assumption: FFD places more than m – 1 items, say x 1 ,...., x m , into extra bins. W 1 W 2 W m B 1 B 2 B m B m+1 Winter term 07/08 22

  23. First Fit Decreasing Theorem: For all input sequences I : FFD ( I ) ≤ (4 OPT ( I ) + 1) / 3. Theorem: 1. For all input sequences I : FFD ( I ) ≤ 11/9 OPT ( I ) + 4. 2. There exist input sequences I such that: FFD ( I ) = 11/9 OPT ( I ). Winter term 07/08 23

  24. First Fit Decreasing Proof (b): Input sequence of length 3 ⋅ 6 m + 12 m : + ε + ε + ε + ε K K 1 / 2 , , 1 / 2 , 1 / 4 2 , , 1 / 4 2 1 4 4 4 2 4 4 4 3 1 4 4 4 2 4 4 4 3 6 m 6 m + ε + ε − ε − ε K K 1 / 4 , , 1 / 4 , 1 / 4 2 , , 1 / 4 2 1 4 4 4 2 4 4 4 3 1 4 4 4 2 4 4 4 3 6 m 12 m Optimal packing: 1/4 + ε 1/4 + ε 1/4 + 2 ε 1/4 + 2 ε 1/4 - 2 ε 1/4 - 2 ε 1/4 + 2 ε 1/4 + 2 ε ......... ............ 1/4 - 2 ε 1/4 - 2 ε 1/2 + ε 1/2 + ε 1/4 - 2 ε 1/4 - 2 ε B B B B + 1 4 4 4 4 2 4 4 4 4 3 1 4 4 4 4 2 4 4 4 4 3 1 6 m 6m 1 9 m 6 m 3 m Winter term 07/08 24

  25. First Fit Decreasing First Fit Decreasing yields: 1/4 - ε 1/4 + 2 ε 1/4 + ε 1/4 - ε .......... ................... .......... 1/4 + ε 1/4 - ε 1/2 + ε 1/4 + ε 1/4 - ε B B B + 1 4 2 4 4 3 4 1 4 4 4 2 4 4 4 3 1 4 2 4 4 3 4 1 6 m 1 8 m 6 m 2 m 3 m OPT ( I ) = 9 m FFD ( I ) = 11 m Winter term 07/08 25

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend