Packing Rectangles into Bins Nikhil Bansal CMU Joint
Packing Rectangles into Bins Nikhil Bansal (CMU) Joint with Maxim Sviridenko (IBM)
Problem Given: Collection of rectangles (by height, width) Goal : Pack in min # of unit square bins q q Rectangles parallel to bin edges Cannot be rotated 1 3 2 2 Rectangles 5 4 3 1 6 5 6 Bins 4 2/61
Problem Given: Collection of rectangles (by height, width) Goal : Pack in min # of unit square bins q q Rectangles parallel to bin edges Cannot be rotated 1 3 4 2 2 4 3 1 6 Rectangles 5 6 2 -d Bin Packing 5 3/61
Motivation Many Applications: Real World packing of (real world) bins q q q Placing ads in newspapers Cloth cutting: Minimizing sheets to buy Truck Loading Memory allocation in paging systems … 4/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 2 3 4 ! 4 1 3 2 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 (NP-Hard) 1 2 3 4 ! 4 1 3 2 6/61
Approximation algorithms An algorithm is a approximation ( > 1) if q runs in polynomial time q Value of solution · Opt: value of optimum solution Polynomial time approximation scheme (PTAS) is a family of 1+ approximation algorithms for every > 0. E. g. , Running Time 7/61
1 -d bin packing: Inapproximability Cannot get a poly time approximation < 3/2 Partition problem (NP-Hard): Given s 1, …, sn , S= s 1+s 2, …, sn 9 a subset of elements that sums to exactly S/2 ? s 1 s 2 S/2 s 3 s 4 s 5 s 6 S/2 But maybe can get Opt + 1 in poly time ? 8/61
Asymptotic PTAS Alg · (1+ ) Opt + f( ) depends only on e. g. (1/ ) For 1 -d bin packing: Alg · (1+ ) Opt + O(1/ 2) [de la Vega, Lueker 81] 9/61
Outline n n Introduction APTAS for 1 -d packing Results for 2 -d packing Conclusions [de la Vega, Lueker 81] 10/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 2 3 4 ! 4 1 3 2 11/61
Main idea Simplify Original instance I -> I’ q q I’: easy to solve Solutions of I and I’ close (within 1+ ) 12/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 13/61
1 -d: Rounding to a simpler instance I 0 1 Various object sizes 14/61
1 -d: Rounding to a simpler instance Ib : I restricted to bigs. Ib 0 Let b = # of bigs (i. e. ¸ ) 1 Various object sizes 15/61
1 -d: Rounding to a simpler instance Ib : I restricted to bigs. Let b = # of bigs (i. e. ¸ ) Partition big into 1/ 2 groups, each group has b¢ 2 objects Ib 0 1 (here b¢ 2 =3) 16/61
1 -d: Rounding to a simpler instance Ib : I restricted to bigs. Let b = # of bigs (i. e. ¸ ) Partition big into 1/ 2 groups, each group has b¢ 2 objects Ib 0 1 Instance I’b : Ignore largest b ¢ 2 objects. Round up sizes to smallest size in next higher group I’b 0 1 17/61
1 -d: Rounding to a simpler instance Ib : I restricted to bigs. Let b = # of bigs (i. e. ¸ ) Partition big into 1/ 2 groups, each group has b¢ 2 objects Ib 0 1 Instance I’b : Ignore largest b ¢ 2 objects. Round up sizes to smallest size in next higher group I’b 0 1 Alg(I’b) · Alg(Ib) 18/61
1 -d: Rounding to a simpler instance Ib : I restricted to bigs. Let b = # of bigs (i. e. ¸ ) Partition big into 1/ 2 groups, each group has b¢ 2 objects Ib 0 1 Instance I’b : Ignore largest b ¢ 2 objects. Round up sizes to smallest size in next higher group I’b 0 1 Alg(Ib) · Alg(I’b) + b 2 19/61
1 -d: Rounding to a simpler instance Ib : I restricted to bigs. Let b = # of bigs (i. e. ¸ ) Partition big into 1/ 2 groups, each group has b¢ 2 objects Ib 0 1 Instance I’b : Ignore largest b ¢ 2 objects. Round up sizes to smallest size in next higher group I’b 0 1 Alg(I’b) · Alg(I’b) + b 2 20/61
1 -d: Rounding to a simpler instance Ib : I restricted to bigs. Let b = # of bigs (i. e. ¸ ) Partition big into 1/ 2 groups, each group has b¢ 2 objects Ib 0 1 Instance I’b : Ignore largest b ¢ 2 objects. Round up sizes to smallest size in next higher group I’b 0 1 Alg(I’b) · Alg(I’b) + b 2 Opt(Ib) ¸ b ) b 2 · Opt(Ib) 21/61
1 -d: Solving the “few and big” case I’b : 1/ 2 different sizes > . Call these s 1, …, sk. Configuration: A way to pack a bin (Eg: C = [3 s 1, 17 s 3, 5 s 18] ) |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 xi ¸ 0 8 j 2 [1, . . , 1/ 2] 8 i, xi 2 Z IP for I’b 22/61
1 -d: “Few and Big” using LP Minimize i xi i cij xi ¸ nj xi ¸ 0 8 j 2 [1, . . , 1/ 2] (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) 23/61
1 -d: Filling in the smalls So, Alg(Ib) · Opt(I)/(1 - ) + 1/ 2 Packing smalls: q q In each bin, fill as many smalls as possible. If bins not enough, open new bins to fill smalls. Proof: q q 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 24/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. 25/61
Outline n n Introduction APTAS for 1 -d packing Results for 2 -d packing Conclusions [de la Vega, Lueker 81] 26/61
Outline n n n Introduction APTAS for 1 -d packing Results for 2 -d packing q q n [de la Vega, Lueker 81] Square packing problem General rectangle packing problem Conclusions 27/61
Square Packing Problem Given a collection of squares (hypercubes for d>2) Pack into min # of unit bins. 1 2 4 5 6 3 ! 1 5 2 4 6 7 3 7 28/61
Square Packing: Previous Work 2 -dim: 2. 125 [Chung, Garey, Johnson 82] …… 1. 454 d-dim: (3/2)d [Epstein, van Stee 03] [Coppersmith, Raghavan 89] …… 2 -(2/3)d We give an APTAS [Kohayakawa et al 02] (i. e. , Alg(I) · 1+ Opt(I) + f( ) ) 29/61
Outline n n n Introduction APTAS for 1 -d packing Results for 2 -d packing q Square packing problem n n q n [de la Vega, Lueker 81] O(1) Approximation APTAS General rectangle packing problem Conclusions 30/61
O(1) Approximation: Square Packing Opt ¸ Total area of squares in I. If we can use constant fraction of area in each bin ) O(1) approximation. Eg: If use ¸ 1/100 th area in each bin ) 100 approx 31/61
O(1) approximation: Square Packing If big (length ¸ 1/3), put in its own bin. Use ¸ 1/9 th area. Big uses > 1/9 th area Need a way to pack small objects efficiently. 32/61
Shelf Packing Given a rectangular region of size a £ b Goal: Pack squares of length · s a b 33/61
Shelf Packing Given a rectangular region of size a £ b Goal: Pack squares of length · s Algorithm: Decreasing size shelf packing. Take squares in decreasing size • Place sequentially a 1 2 3 b 34/61
Shelf Packing Given a rectangular region of size a £ b Goal: Pack squares of length · s Algorithm: Decreasing size shelf packing. Take squares in decreasing size • Place sequentially • If next does not fit, open a new shelf a 1 2 3 b 35/61
Shelf Packing Given a rectangular region of size a £ b Goal: Pack squares of length · s Algorithm: Decreasing size shelf packing. Take squares in decreasing size a 4 8 1 • Place sequentially • If next does not fit, open a new shelf 3 b 36/61
Shelf Packing Given a rectangular region of size a £ b Goal: Pack squares of length · s Algorithm: Decreasing size shelf packing. Take squares in decreasing size 9 a 16 4 8 1 • Place sequentially • If next does not fit, open a new shelf 3 b 37/61
Shelf Packing Given a rectangular region of size a £ b Goal: Pack squares of length · s Algorithm: Decreasing size shelf packing. Wasted Space · s(a+b) 9 a 16 4 8 1 3 b 38/61
Shelf Packing Given a rectangular region of size a £ b Goal: Pack squares of length · s Algorithm: Decreasing size shelf packing. Wasted Space · s(a+b) 9 a 16 4 Right side: At most s £ a 8 1 3 b 39/61
Shelf Packing Given a rectangular region of size a £ b Goal: Pack squares of length · s Algorithm: Decreasing size shelf packing. Wasted Space · s(a+b) 9 a 16 4 Right side: At most s £ a Top · s 16 b 8 1 3 b 40/61
Shelf Packing Given a rectangular region of size a £ b Goal: Pack squares of length · s Algorithm: Decreasing size shelf packing. Wasted Space · s(a+b) 9 a 16 4 8 1 Right side: At most s £ a Top · s 16 b Shelf 1: (s 1 –s 3) b 3 b 41/61
Shelf Packing Given a rectangular region of size a £ b Goal: Pack squares of length · s Algorithm: Decreasing size shelf packing. Wasted Space · s(a+b) 9 a 16 4 8 1 3 Right side: At most s £ a Top · s 16 b Shelf 1: (s 1 –s 3) b Shelf 2: (s 4 – s 8) b … b 42/61
Shelf Packing Given a rectangular region of size a £ b Goal: Pack squares of length · s Algorithm: Decreasing size shelf packing. Wasted Space · s(a+b) 9 a 16 4 8 1 3 b Right side: At most s £ a Top · s 16 b Shelf 1: (s 1 –s 3) b Shelf 2: (s 4 – s 8) b …. Adding all, at most (s 1 -s 16) b 43/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. 44/61
Outline n n n Introduction APTAS for 1 -d packing Results for 2 -d packing q Square packing problem n n q n [de la Vega, Lueker 81] O(1) Approximation APTAS General rectangle packing problem Conclusions 45/61
Square Packing 0 1 Squares with various lengths 46/61
Square Packing G 1/ -1 0 1/ … Gm m+1 G 1 m … 2 G 0 1 0=1 47/61
Square Packing G 1/ -1 0 1/ … Small Gm m+1 G 1 m Medium … 2 G 0 1 0=1 Big Gm =[ m+1, m) be such that area · (total area) 48/61
Square Packing G 1/ -1 0 1/ … Small Gm m+1 G 1 m Medium … 2 G 0 1 0=1 Big Gm =[ m+1, m) be such that area · (total area) Pack medium in separate bins using O(1) approx Adds at most O( ) to the number of bins. Ignore medium jobs from now on. 49/61
Square Packing G 1/ -1 0 1/ … Small G 1 m+1 m … 2 G 0 1 0=1 Big Gm =[ m+1, m) be such that area · (total area) Pack medium in separate bins using O(1) approx Adds at most O( ) to the number of bins. Ignore medium jobs from now on. 50/61
Square Packing G 1/ -1 0 1/ … G 1 m+1 Small m … 2 G 0 1 0=1 Big Gm =[ m+1, m) be such that area · (total area) Pack medium in separate bins using O(1) approx Adds at most O( ) to the number of bins. Ignore medium jobs from now on. 0= 1 , i = i-12 (1, , 3, 7, …) 51/61
Square Packing G 1/ -1 0 1/ … Small G 1 m+1 m … 2 G 0 1 0=1 Big Packing bigs: Rounding technique similar to 1 -d case, ! O(1) different lengths Opt(Ib’) · Opt(Ib’)/(1 - ) LP to find close to optimum packing of Ib’ 52/61
Square Packing: Filling in the smalls Bigs use ¼ Opt bins What about smalls? 53/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 54/61
Square Packing: Filling in the smalls Small · m+1 , big ¸ m # bigs · 1/ m 2, gaps · 4/ m 2 Recall: Packing · s in a £ b wastes at most s(a+b) a+b · 2, s · m+1 = m 2 Rectangular Gaps Total waste · 2 s ¢ #gaps · 2 m 2 ¢ 4/ m 2 · 8 55/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. 56/61
Square Packing: Technique Summary n n Partition into big, medium, small Ignore mediums Gap between big and small Ideas from 1 -d + packing smalls with low waste 57/61
Outline n n n Introduction APTAS for 1 -d packing Results for 2 -d packing q q n [de la Vega, Lueker 81] Square packing problem General rectangle packing problem Conclusions 58/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 59/61
Results for Rectangle Packing Main Thm: No APTAS exists for 2 -d rectangle packing. Hence for d>2. Proof: Lets skip it. 60/61
Conclusion and Open Problems Impossibility of APTAS for rectangle packing APTAS for square packing 1 -d Case: (1+ ) Opt + O(1/ 2) [de la Vega, Lueker 81] Opt + O(log 2(Opt)) [Karmarkar, Karp 82] Opt + O(1) ? d =2 : d > 2: 1. 691+ 1. 691 d [Caprara 02] [Csirik, Van Vliet 93] (cd) lower bounds for d-dim bin packing ? 61/61
Results for Rectangle Packing Main 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. 62/61
Hardness 2 -d Vector Packing Problem: Given 2 -d vectors (equivalently rectangles). In each bin, widths · 1 , and heights · 1. Valid Invalid 63/61
Hardness of Vector Packing X={x 1, …, xn}, Y={y 1, …, yn}, Z={z 1, …, zn}, T= {t 1, …, tn} Each >b/5 and < b/3 Goal: Max. number of disjoint 4 -tuples that sum to exactly b SNP-Hard: 9 Cannot distinguish if n such tuples or (1 - ) n [ Woeginger’s construction’ 97] Xi’ = (. 2 + xi/5 b, . 3 – xi/5 b) Zi’ = (. 2 + zi/5 b, . 3 – zi/5 b) Yi’ = (. 2 + yi/5 b, . 3 – yi/5 b) Ti’ = (. 2 + ti/5 b, . 3 – ti/5 b) Observation: All these fit in a bin iff xi+yj+zk+tl = b 64/61
Rectangle Packing 2 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 X’i Details to show that other patterns do not work Xi Y’j Yj Z’k Zk T’l Tl 65/61
- Slides: 65