1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock...

24
1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation problem) Layouts on VLSI chips (2D version) Assigning commercials to station breaks (easier) Packing trucks within a given weight limit assic combinatorial optimization problem Research dates back to the 1940s In the mid 80’s labeled “The problem that wouldn’t go a Subject of research on approximations before approximations were cool

Transcript of 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock...

Page 1: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

1

Why is bin packing interesting?

Simplest version of industrial packing problems

Cutting stock allocation problem CD allocation problem (floppy disk allocation

problem) Layouts on VLSI chips (2D version) Assigning commercials to station breaks (easier) Packing trucks within a given weight limit

Classic combinatorial optimization problem

Research dates back to the 1940s

In the mid 80’s labeled “The problem that wouldn’t go away”

Subject of research on approximations before approximations were cool

Page 2: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

2

First Fit Decreasing Sort the items in decreasing order by size Open one bin for each item Si

if there is an open bin where Si will fit

then place Si into the leftmost such bin else open a new bin

place Si into that new bin

.75 .67 .5 .4 .4 .33 .3 .25 .2 .2

.5.67.25

.2.4

.2.4.33

.75

FFD < 11/9 OPT + 4 (i.e. 1.2222…)FFD < 11/9 OPT + 4 (i.e. 1.2222…)

Running Time: O(n log n)Running Time: O(n log n)

[Johnson, Demers, Ullman, Garey, Graham, 1974][Johnson, Demers, Ullman, Garey, Graham, 1974]

Loooooooooong proof (originally 100+ pages)Loooooooooong proof (originally 100+ pages)

.3

Page 3: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

3

More on First Fit Decreasing

Why does FFD have such an improved performance ratio?

Pack the trouble items first (big items) Pack the easier items later (small items)

Can we do better than FFD?Modified First Fit DecreasingModified First Fit Decreasing

[Johnson & Garey, 1985][Johnson & Garey, 1985]

Like FFD, but with special handling for items in (1/6, 1/3]Like FFD, but with special handling for items in (1/6, 1/3]

Competitive ratio: Competitive ratio: 71/60 71/60 = 1.18333…= 1.18333…

Running Time: O(n log n)Running Time: O(n log n)

Page 4: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

4

Summary

Method Competitive Ratio

Any Fit 2Next Fit 2Worst Fit 2First Fit 1.7Best Fit 1.7FFD 1.2222… *Modified FFD 1.18333… * Fully polynomial time

approximation scheme YES *

* = asymptotic competitive ratios (vs absolute competitive ratios)

For all L, A(L) <= Ratio(A)*OPT(L) + KA(L) where KA(L) = o(OPT(L))

Page 5: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

5

Changing the Rules – Fully Dynamic Bin Packing

NOT given the items all at once Instead: given items one at a time – INSERTs (DELETES) Upon an INSERT/DELETE, update the packing

NO apriori limitations on this update – the contents of the bins may be changed at will

.5 .67 .25 .33

Maintain a good packing at all times O(log n) time per INSERT/DELETE (to update)

So, n INSERTs in O(n log n) time

.5 .67

.25

.5.25

.67

.33

Page 6: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

6

Distinct from Off-line, On-Line, Dynamic BP

Off-line bin packing – given all items at once, process & pack (FFD, MFFD, PTAS)

On-line bin packing – given items one at a time (INSERTS), and must pack immediately, but cannot move already packed items

On-line Algorithms

Any Fit, Next Fit 2First Fit, Best Fit 1.7Harmonic++ 1.58889 [Seiden,

2001]

Lower bound 1.54014 [van Vliet, 1992]

Page 7: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

7

Distinct from Off-line, On-Line, Dynamic BP

Variant of On-line bin packing [Gambosi, etal, 1990]– INSERTs

only, each item may be moved a constant number of times

Algorithm A: Competitive ratio: 3/2Running time: O(n)

Algorithm B: Competitive ratio: 4/3Running time: O(n log n)

Dynamic bin packing [Coffman, Garey & Johnson, 1983] – INSERT & DELETE items, but items cannot be moved once packed

2.770 < Dynamic First Fit < 2.898Lower bound: 2.5

Page 8: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

8

Return to Fully Dynamic Bin Packing

NOT given the items all at once

Instead: given items one at a time – INSERTS

Upon an INSERT, update the packingNO apriori limitations on this update – the contents of the bins may be changed at will

Maintain a good packing at all times

O(log n) time per INSERT (to update) So, n INSERTs in O(n log n) time

Page 9: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

9

A first attempt: Fully Dynamic FFD?

Recall FFD Preprocess by sorting items First Fit pack the items

Making FFD fully dynamic

After each INSERT Update the sorting in O(log n) – OK!

Update the packing May need to completely redo the packing

O(n log n) per INSERT – that’s bad!

Page 10: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

10

Another off-line algo: First Fit Grouped

Groups of items: BIG – contains items of size (1/2, 1] LARGE – contains items of size (1/3, 1/2] Small – contains items of size (1/4, 1/3] tiny – contains items of size (0, 1/4]

First Fit Grouped (FFG) Algorithm:

Place each item into its group

Pack the items in BIG using first fit Pack the items in LARGE using first fit Pack the items in Small using first fit Pack the items in tiny using First Fit

Page 11: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

11

FFG – An example

.5 .67 .25 .33 .4 .2 .2 .4 .75 .3

[Johnson, 1974][Johnson, 1974]

Running Time: O(n log n)Running Time: O(n log n)

Competitive RatioCompetitive Ratio of FFG: 4/3 of FFG: 4/3

First Fit: 1.7 FFD: 11/9First Fit: 1.7 FFD: 11/9

.67 .75 .5 .4 .4 .3 .33 .25 .2 .2

BIG LARGE Small tiny

.5.67.25 .4

.4.33

.75.3 .2

.2

Page 12: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

12

Fully Dynamic First Fit Grouped

Item I puts on glasses & what does it see? if I is tiny , then I sees everything

if I is Small, then I sees only the BIG, LARGE and Small items

if I is LARGE , then I sees only the BIG and LARGE items

if I is BIG , then I sees only the BIG items

These are “myopic” glasses!

Page 13: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

13

What items “see”

Tiny items see:B B B

L

L

L

L

SS

S

S

S

S

S

S

t

tt

Actual packing:

B B B

L

L

L

L

SS

S

S

S

S

S

S

Small items see:

B B B

Big items see:

Page 14: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

14

Fully Dynamic First Fit Grouped

To process INSERT of item I (assume partial packing exists)

I puts on (myopic) glasses

Item I packs itself in the packing it sees(smaller items are evicted from the bin I goes into)

Refill the bin that I goes into using: Smaller evicted items Smaller items in “inferior” bins (ie largest bin item is in

a smaller group than I)

If an inferior bin is disturbed, evict all remaining items

Repack evicted items using recursion

Page 15: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

15

An example of FDFFG

Existing packing:

That item First Fit packs itself into the second bin:

.66.35.3

.35.32 .30

.25

.30.25.25

.25

Unpacked items: .35, .35, .30

.66 .70

.32 .30.25

.30.25.25

.25

Refill the second bin with the .30 item:

Unpacked items: .35, .35

.32

.66 .70 .25.30.30

.25 .25.25.30

.66INSERT item of size .70 – it sees this packing:

Page 16: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

16

FDFFG Example - continued

Unpacked items: .30, .25

It packs into 3rd bin, as does other .35 and then .30 item:

The first .35 item sees this packing:.66 .70

Unpacked items:.35, .35

.32

.66 .70 .25.30.30

.25 .25.25.30

.32

.66 .70 .35.30 .35

.25

.25

.25.30

Page 17: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

17

FDFFG Example – still continued …

The .30 item sees this packing:

Unpacked items:.30, .25

.32

.66 .70 .35.30 .35

.25

.25

.25.30

That .30 item packs into 4th bin & two .25 items refill that bin:

The remaining two .25 items pack themselves into a 5th bin

Unpacked items:.25, .25

.30.32.66 .70 .35

.30 .35.25

.30

.25

Page 18: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

18

Performance of FDFFG

Key elements of FDFFG

Evicted items are smaller than the inserted item “bundle” tiny items and move as a unit*

Thus: Relatively few items/bundles will be evicted (hence, repacked)

* Is this cheating? (no – will say why later)

Competitive Ratio: 4/3 (same as FFG)Running Time: O(log n) per INSERT

Page 19: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

19

Can we do better than 4/3?

Yes: Mostly Myopic Packing (MMP)Key: Avoid bad cases of FDFFG via special handling

MMP Competitive Ratio: 5/4 = 1.25Looong proof

MMP running time: O(log n) per INSERT or DELETE

O(n log n) for sequence of n INSERT/DELETEs

Page 20: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

20

Mostly Myopic Packing

Same general approach as FDFFG

Much more complicated than FDFFG

Introduce: miniscule items: (0, 1/5] tiny items: (1/5, 1/4]

Carry over: myopic glassesbundle miniscule (not tiny) - size

(1/10,1/5]

Introduce: coalitions! Prior to putting on glasses, L & S items try to form

LLS-coalitions

Constant number of items/bundles “touched” per INSERTEach “touch” costs O(log n)

Thus, O(log n) per INSERT (DELETE)

Page 21: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

21

The 5/4 Competitive Ratio (the 2% sketch)

Analyze the structure of the MMP and OPT packings

Focus on 8 types of “front” bins: B-bins, LLS, LSTT

Lower bound the LLS-bins in MMP relative to OPT

MMPLLS ≥ 1/4(OPTLLS – (L7+S7)) + OPTLSTT – max(L8,S8) - 1

Lower bound the L, S and T-items in B-bins in MMP

Allows upper bound on number of items in “back” bins in MMP relative to the number in OPT

The packings

In OPT: B OPTLLS + OPTLSTT OPTBACK

In MMP: B MMPLLS

MMPBACK

put bounds together to yield the 5/4 bound

Page 22: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

22

What about that possible “cheating”?

Theorem: If A is a fully dynamic bin packing algorithmmoving at most a fixed (i.e. constant) number ofitems per INSERT/DELETE

Then the competitive ratio of A is at least 4/3

Implication: “bundling” (or similar), is necessary to do better than 4/3

Page 23: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

23

Partially dynamic bin packing

Partially dynamic bin packing: INSERTs only, packing can be rearranged

For any > 0 there are algorithms with:

Competitive ratio 1 + Running time O(log n) amortized per INSERT (PTAS)

Competitive ratio 1 + Running time O(log2 n) amortized per INSERT (FPTAS)

What about uniform running times for INSERT only?

MMP is the best we know: competitive ratio 5/4 running time O(log n) per INSERT

Page 24: 1 Why is bin packing interesting? Simplest version of industrial packing problems Cutting stock allocation problem CD allocation problem (floppy disk allocation.

24

Related papers

Z. Ivkovich and E.L. Lloyd, "Fully dynamic algorithms for bin packing: Being mostly myopic helps," SIAM Journal on Computing, 28(1998), 574-611.

Z. Ivkovich and E.L. Lloyd, "Partially dynamic bin packing can be solved within 1+ in (amortized) polylogarithmic time", Information Processing Letters 63(1997), 45-50.

Z. Ivkovich and E.L. Lloyd, "A fundamental restriction on fully dynamic maintenance of bin packing," Information Processing Letters, 59(1996), 229-232.