65
Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

Embed Size (px)

Citation preview

Page 1: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

Packing Rectangles into Bins

Nikhil Bansal (CMU)Joint with Maxim Sviridenko (IBM)

Page 2: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

2/61

ProblemGiven: Collection of rectangles (by height, width)Goal : Pack in min # of unit square bins

Rectangles parallel to bin edges Cannot be rotated

1

4

6

53 2

Rectangles

Bins

12 3

4 56

123

45

6

Page 3: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

3/61

ProblemGiven: Collection of rectangles (by height, width)Goal : Pack in min # of unit square bins

Rectangles parallel to bin edges Cannot be rotated

1

4

6

5

32 2-d Bin Packing

Rectangles

12 3

4 56

12

3

4 5

6

Page 4: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

4/61

Motivation

Many Applications: Real World packing of (real world) bins

Placing ads in newspapers Cloth cutting: Minimizing sheets to buy Truck Loading Memory allocation in paging systems …

Page 5: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

5/61

1-d Bin Packing

Special case of 2-d packing

1-dim bin packing:Collection of intervals with length in [0,1], Pack into min # of unit bins

!1

42

31

43

2

Page 6: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

6/61

1-d Bin Packing

Special case of 2-d packing

1-dim bin packing:Collection of intervals with length in [0,1], Pack into min # of unit bins (NP-Hard)

!1

42

31

43

2

Page 7: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

7/61

Approximation algorithms

An algorithm is a approximation ( > 1) if runs in polynomial time Value of solution · Opt Opt: value of optimum solution

Polynomial time approximation scheme (PTAS) is a

family of 1+ approximation algorithms for every > 0.

E.g., Running Time

Page 8: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

8/61

1-d bin packing: InapproximabilityCannot get a poly time approximation < 3/2

Partition problem (NP-Hard): Given s1,…,sn , S= s1+s2,…,sn

9 a subset of elements that sums to exactly S/2 ?

S/2

s1 s6s2 s5s3 s4

S/2

But maybe can get Opt + 1 in poly time ?

Page 9: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

9/61

Asymptotic PTAS

Alg · (1+) Opt + f()

f() depends only on e.g. (1/)(1/)

For 1-d bin packing:Alg · (1+) Opt + O(1/2) [de la Vega, Lueker 81]

Page 10: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

10/61

Outline

Introduction APTAS for 1-d packing [de la Vega, Lueker 81]

Results for 2-d packing Conclusions

Page 11: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

11/61

APTAS for 1-d bin packing

Theorem: [de la Vega, Lueker 81] Alg(I) · Opt(I)/(1-) + 1/2

¼ Opt(I) (1+) + f()

!1

42

31

43

2

Page 12: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

12/61

Main idea

Simplify Original instance I -> I’

I’: easy to solve Solutions of I and I’ close (within 1+)

Page 13: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

13/61

Ideas applied to 1-d packing

· : Small ¸ : Big

1) I ! I’ with 1/2 different big sizes & solns. within 1+

2) I’ easy: If k= O(1) different big sizes, can get Opt

+ k

Page 14: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

14/61

1-d: Rounding to a simpler instance

0 1I

Various object sizes

Page 15: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

15/61

1-d: Rounding to a simpler instance Ib : I restricted to bigs. Let b = # of bigs (i.e. ¸ )

0 1Ib

1

Various object sizes

Page 16: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

16/61

1-d: Rounding to a simpler instance

Partition big into 1/2 groups, each group has b¢ 2 objects

0 1Ib

Ib : I restricted to bigs. Let b = # of bigs (i.e. ¸

)

(here b¢2 =3)

Page 17: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

17/61

1-d: Rounding to a simpler instance

Partition big into 1/2 groups, each group has b¢ 2 objects

Instance I’b : Ignore largest b ¢ 2 objects. Round up sizes to smallest size in next higher group

0 1

0 1I’b

Ib

Ib : I restricted to bigs. Let b = # of bigs (i.e. ¸ )

Page 18: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

18/61

1-d: Rounding to a simpler instance

Partition big into 1/2 groups, each group has b¢ 2 objects

Instance I’b : Ignore largest b ¢ 2 objects. Round up sizes to smallest size in next higher group

Alg(I’b) · Alg(Ib)

0 1

0 1I’b

Ib

Ib : I restricted to bigs. Let b = # of bigs (i.e. ¸

)

Page 19: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

19/61

1-d: Rounding to a simpler instance

Partition big into 1/2 groups, each group has b¢ 2 objects

Instance I’b : Ignore largest b ¢ 2 objects. Round up sizes to smallest size in next higher group

Alg(Ib) · Alg(I’b) + b 2

0 1

0 1I’b

Ib

Ib : I restricted to bigs. Let b = # of bigs (i.e. ¸

)

Page 20: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

20/61

1-d: Rounding to a simpler instance

Partition big into 1/2 groups, each group has b¢ 2 objects

Instance I’b : Ignore largest b ¢ 2 objects. Round up sizes to smallest size in next higher group

Alg(I’b) · Alg(Ib) · Alg(I’b) + b 2

0 1

0 1I’b

Ib

Ib : I restricted to bigs. Let b = # of bigs (i.e. ¸

)

Page 21: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

21/61

1-d: Rounding to a simpler instance

Partition big into 1/2 groups, each group has b¢ 2 objects

Instance I’b : Ignore largest b ¢ 2 objects. Round up sizes to smallest size in next higher group

Alg(I’b) · Alg(Ib) · Alg(I’b) + b 2

Opt(Ib) ¸ b ) b 2 · Opt(Ib)

0 1

0 1I’b

Ib

Ib : I restricted to bigs. Let b = # of bigs (i.e. ¸

)

Page 22: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

22/61

1-d: Solving the “few and big” caseI’b : 1/2 different sizes > . Call these s1,…,sk .

Configuration: A way to pack a bin (Eg: C = [3 s1, 17 s3, 5 s18] )

|Configurations| · (1/2)1/ = O(1)

xi : # of bins with configuration i

nj : # of objects of size sj in instance

cij: # of objects of size sj in configuration i.

Minimize i xi

i cij xi ¸ nj 8 j 2 [1,..,1/2]

xi ¸ 0 8 i, xi 2 Z

IP for I’b

Page 23: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

23/61

1-d: “Few and Big” using LP

Minimize i xi

i cij xi ¸ nj 8 j 2 [1,..,1/2]

xi ¸ 0 (Relaxed to be fractional)

Clearly, LP (Ib’) · OPT(Ib’)

xi could be fractional.Round up to next integer ( Eg: 17.34 -> 18)

Adds · # configurations = (1/2)1/ = O(1)In fact, adds · 1/2 (non-zero xi’s in basic soln)

Page 24: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

24/61

1-d: Filling in the smalls

So, Alg(Ib) · Opt(I)/(1-) + 1/2

Packing smalls: In each bin, fill as many smalls as possible. If bins not enough, open new bins to fill smalls.

Proof: If no new bins opened, done. If new bins opened, all bins (except maybe last) filled 1-

So, Alg(I) · Area(I)/(1-) + 1 · Opt(I)/(1-) + 1

Page 25: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

25/61

1-d: Overview

0) Partition into small and big 1) Pack small objects later 2) Round large objects to O(1) sizes. Solve the “few and big” case almost optimally.

Page 26: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

26/61

Outline

Introduction APTAS for 1-d packing [de la Vega, Lueker 81]

Results for 2-d packing Conclusions

Page 27: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

27/61

Outline

Introduction APTAS for 1-d packing [de la Vega, Lueker 81]

Results for 2-d packing Square packing problem General rectangle packing problem

Conclusions

Page 28: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

28/61

Square Packing Problem

Given a collection of squares (hypercubes for d>2)Pack into min # of unit bins.

1

3

2 5

7

6

41

3

2

5 764!

1

3

2

5 764

Page 29: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

29/61

Square Packing: Previous Work2-dim: 2.125 [Chung, Garey, Johnson 82]

……

1.454 [Epstein, van Stee 03]

d-dim: (3/2)d [Coppersmith, Raghavan 89]

……

2-(2/3)d [Kohayakawa et al 02]

We give an APTAS (i.e., Alg(I) · 1+ Opt(I) + f() )

Page 30: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

30/61

Outline

Introduction APTAS for 1-d packing [de la Vega, Lueker 81]

Results for 2-d packing Square packing problem

O(1) Approximation APTAS

General rectangle packing problem Conclusions

Page 31: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

31/61

O(1) Approximation: Square PackingOpt ¸ Total area of squares in I.

If we can use constant fraction of area in each bin ) O(1) approximation.

Eg: If use ¸ 1/100th area in each bin ) 100 approx

Page 32: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

32/61

O(1) approximation: Square PackingIf big (length ¸ 1/3), put in its own bin.Use ¸ 1/9th area.

Big uses > 1/9th area

Need a way to pack small objects efficiently.

Page 33: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

33/61

Shelf Packing

Given a rectangular region of size a £ bGoal: Pack squares of length · s

a

b

Page 34: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

34/61

Shelf Packing

Given a rectangular region of size a £ bGoal: Pack squares of length · s Algorithm: Decreasing size shelf packing.

1 3

a

b

2

Take squares in decreasing size

• Place sequentially

Page 35: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

35/61

Shelf Packing

Given a rectangular region of size a £ bGoal: Pack squares of length · s Algorithm: Decreasing size shelf packing.

1 3

a

b

2

Take squares in decreasing size

• Place sequentially• If next does not fit, open a new shelf

Page 36: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

36/61

Shelf Packing

Given a rectangular region of size a £ bGoal: Pack squares of length · s Algorithm: Decreasing size shelf packing.

1 3

48a

b

Take squares in decreasing size

• Place sequentially• If next does not fit, open a new shelf

Page 37: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

37/61

Shelf Packing

Given a rectangular region of size a £ bGoal: Pack squares of length · sAlgorithm: Decreasing size shelf packing.

1 3

48

9 16

a

b

Take squares in decreasing size

• Place sequentially• If next does not fit, open a new shelf

Page 38: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

38/61

Shelf Packing

Given a rectangular region of size a £ bGoal: Pack squares of length · sAlgorithm: Decreasing size shelf packing.

Wasted Space · s(a+b)

1 3

48

9 16

a

b

Page 39: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

39/61

Shelf Packing

Given a rectangular region of size a £ bGoal: Pack squares of length · sAlgorithm: Decreasing size shelf packing.

Wasted Space · s(a+b)

Right side: At most s £ a

1 3

48

9 16

a

b

Page 40: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

40/61

Shelf Packing

Given a rectangular region of size a £ bGoal: Pack squares of length · sAlgorithm: Decreasing size shelf packing.

Wasted Space · s(a+b)

Right side: At most s £ aTop · s16 b

1 3

48

9 16

a

b

Page 41: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

41/61

Shelf Packing

Given a rectangular region of size a £ bGoal: Pack squares of length · sAlgorithm: Decreasing size shelf packing.

Wasted Space · s(a+b)

Right side: At most s £ aTop · s16 b

Shelf 1: (s1 –s3) b

1 3

48

9 16

a

b

Page 42: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

42/61

Shelf Packing

Given a rectangular region of size a £ bGoal: Pack squares of length · sAlgorithm: Decreasing size shelf packing.

Wasted Space · s(a+b)

Right side: At most s £ aTop · s16 b

Shelf 1: (s1 –s3) bShelf 2: (s4 – s8) b …

1 3

48

9 16

a

b

Page 43: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

43/61

Shelf Packing

Given a rectangular region of size a £ bGoal: Pack squares of length · sAlgorithm: Decreasing size shelf packing.

Wasted Space · s(a+b)

Right side: At most s £ aTop · s16 b

Shelf 1: (s1 –s3) bShelf 2: (s4 – s8) b ….Adding all, at most (s1-s16) b

1 3

48

9 16

a

b

Page 44: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

44/61

Square Packing: Packing Smalls

If all squares · s, waste in a £ b region · s(a+b)

If a=b=1, s · 1/3 ) Waste · 2/3

O(1) approximation follows.

Page 45: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

45/61

Outline

Introduction APTAS for 1-d packing [de la Vega, Lueker 81]

Results for 2-d packing Square packing problem

O(1) Approximation APTAS

General rectangle packing problem Conclusions

Page 46: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

46/61

Square Packing

0 1

Squares with various lengths

Page 47: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

47/61

Square Packing

0=10 1m1/m+1 2……

G0G1GmG1/ -1

Page 48: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

48/61

Square Packing

0=10 1m1/m+1 2……

G0G1GmG1/ -1

Gm =[ m+1,m) be such that area · (total area)

Small BigMedium

Page 49: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

49/61

Square Packing

0=10 1m1/m+1 2……

G0G1GmG1/ -1

Pack medium in separate bins using O(1) approx

Adds at most O() to the number of bins. Ignore medium jobs from now on.

Small BigMedium

Gm =[ m+1,m) be such that area · (total area)

Page 50: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

50/61

Square Packing

0=10 1m1/m+1 2……

G0G1G1/ -1

Pack medium in separate bins using O(1) approx

Adds at most O() to the number of bins. Ignore medium jobs from now on.

Small Big

Gm =[ m+1,m) be such that area · (total area)

Page 51: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

51/61

Square Packing

0=10 1m1/m+1 2……

G0G1G1/ -1

Pack medium in separate bins using O(1) approx

Adds at most O() to the number of bins. Ignore medium jobs from now on.

Small Big

0= 1 , i = i-12 (1,,3,7,…)

Gm =[ m+1,m) be such that area · (total area)

Page 52: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

52/61

Square Packing

Packing bigs: Rounding technique similar to 1-d case, ! O(1) different lengths

Opt(Ib’) · Opt(Ib) · Opt(Ib’)/(1-)

LP to find close to optimum packing of Ib’

0=10 1m1/m+1 2……

G0G1G1/ -1

Small Big

Page 53: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

53/61

Square Packing: Filling in the smalls

Bigs use ¼ Opt bins

What about smalls?

Page 54: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

54/61

Square Packing: Filling in the smalls

Divide the free space into

rectangular gaps.

Fill smalls in gaps using decreasing size shelf

algorithm

Rectangular Gaps

Page 55: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

55/61

Square Packing: Filling in the smalls

# bigs · 1/m2, gaps · 4/m

2

Recall: Packing · s in a £ b wastes at most s(a+b)

a+b · 2, s · m+1 = m2

Total waste · 2 s ¢ #gaps · 2 m

2 ¢ 4/m2

· 8

Rectangular Gaps

Small · m+1 , big ¸ m

Page 56: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

56/61

Square Packing

If no new bins opened for smalls, done.

If we do, waste in each bin (except maybe last) is O(), hence done by area lower bound.

Thm: ALG(I) · (1+) Opt(I) +

Generalizes to d>2 dimensions with few modifications.

Page 57: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

57/61

Square Packing: Technique Summary

Partition into big, medium, small Ignore mediums Gap between big and small Ideas from 1-d + packing smalls with low waste

Page 58: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

58/61

Outline

Introduction APTAS for 1-d packing [de la Vega, Lueker 81]

Results for 2-d packing Square packing problem General rectangle packing problem

Conclusions

Page 59: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

59/61

Rectangle packing

Problem: Pack rectangles into min # of unit bins. (no rotation)

2.125 approximation [ Chung, Garey, Johnson 82]2+ [ Kenyon, Remila 96]Best known: 1.691… + [Caprara 02]

Prior to our work: APTAS open

Page 60: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

60/61

Results for Rectangle PackingMain Thm: No APTAS exists for 2-d rectangle

packing.

Hence for d>2.

Proof: Lets skip it.

Page 61: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

61/61

Conclusion and Open ProblemsImpossibility of APTAS for rectangle packingAPTAS for square packing

1-d Case: (1+) Opt + O(1/2) [de la Vega, Lueker 81] Opt + O(log2(Opt)) [Karmarkar, Karp 82]

Opt + O(1) ?

d =2 : 1.691+ [Caprara 02]

d > 2: 1.691d [Csirik, Van Vliet 93]

(cd) lower bounds for d-dim bin packing ?

Page 62: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

62/61

Results for Rectangle PackingMain Thm: No APTAS exists for 2-d rectangle packing.

Hence for d>2.

Thm [Kenyon, Correa 04] : APTAS if allow Alg to pack in (1+) £ (1+) size bins Alg*(I) · (1+) Opt(I) + f()

Thm: APTAS if allow Alg to pack in 1 £ (1+) size bins.

Page 63: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

63/61

Hardness

2-d Vector Packing Problem:Given 2-d vectors (equivalently rectangles). In each

bin, widths · 1 , and heights · 1.

Valid Invalid

Page 64: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

64/61

Hardness of Vector Packing

X={x1,…,xn}, Y={y1,…,yn}, Z={z1,…,zn}, T= {t1,…,tn}Each >b/5 and < b/3

Goal: Max. number of disjoint 4-tuples that sum to exactly bSNP-Hard: 9 Cannot distinguish if n such tuples or (1-) n

[ Woeginger’s construction’ 97]

Xi’ = (.2 + xi/5b, .3 – xi/5b) Yi’ = (.2 + yi/5b, .3 – yi/5b)

Zi’ = (.2 + zi/5b, .3 – zi/5b) Ti’ = (.2 + ti/5b, .3 – ti/5b)

Observation: All these fit in a bin iff xi+yj+zk+tl = b

Page 65: Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)

65/61

Rectangle Packing2 rectangles for each object in X,Y,Z,T(Thin, Tall) and (Fat, Short) for each object in

X,Y,Z(Fat, Tall) and (Thin, Short) for each object in T

Yj

Y’j

Zk Tl

Xi

X’i Z’k T’l

Details to show that other patterns do not work