A note on the Kenyon-Remila strip-packing algorithm Maxim Sviridenko∗ Abstract We show that a modification of the Kenyon-Remila algorithm for the strip-packing problem yields an improved bound on the value of the approximate solution. As a corollary we derive that there √ exists a polynomial-time algorithm that always finds a solution of value OP T + O( OP T log OP T ) where OP T is the optimal value. 1 Introduction In the minimum strip-packing problem (or two-dimensional cutting stock problem) we are given a set of two-dimensional rectangles indexed by R = {1, . . . , n}. We identify a rectangle with its index. For each rectangle i ∈ R, we are given its height hi ∈ (0, 1] and width wi ∈ (0, 1]. A packing of a set S ⊆ R of rectangles into a larger rectangle B of size W × H is feasible if rectangles are packed with edges parallel to the edges of B without overlaps and rotations. The goal is to find a minimal H such that there exists a feasible packing of all rectangles from R into a rectangle of size 1 × H. Since the minimum strip-packing problem is a generalization of the classical bin packing problem we obtain that the problem is strongly NP-hard. Kenyon-Remila [4] proved Theorem 1 For any constant ε > 0, there exists an algorithm with running time O(n log n+ ε−6 log3 n log3 1ε ) that finds a feasible packing of n rectangles from the set R with heights and widths at most one into a strip of width one and height H(R) such that 1 H(R) ≤ (1 + ε)OP T (R) + O ε2 where OP T (R) is the optimal value of the minimum strip-packing problem. By applying the Kenyon-Remila algorithm with ε = OP T (R)−1/3 and noticing that OP T ≤ n we obtain a polynomial-time algorithm that always finds a feasible packing into a strip IBM T. J. Watson Research Center, Yorktown Heights, P.O. Box 218, NY 10598, USA; Email: sviri@us.ibm.com ∗ 1 of height at most OP T (R) + O(OP T (R)2/3). In contrast, for the classical bin packing problem there is an algorithm [3] that always find a solution of value at most OP T (R) + O(log2 OP T (R)). A natural question arises if we can find an algorithm for the minimum strip-packing problem with better asymptotic behavior, ideally matching the polylogarithmic bound of [3]. A possible approach is to find an algorithm with better additive factor than O ε12 . The running time of such an algorithm must have a polynomial dependence on ε since we are going to balance the absolute error of (1 + ε) with the additive error of O ε12 1 . In this note we prove Theorem 2 For any constant ε > 0, there exists an algorithm with running time O(n log n+ ε−6 log3 n log3 1ε ) that finds a feasible packing of n rectangles from the set R with heights and widths at most one into a strip of width one and height H(R) such that log 1/ε H(R) ≤ (1 + ε)OP T (R) + O ε where OP T (R) is the optimal value of the minimum strip-packing problem. q log OP T (R) , OP T (R) we obtain a polynomial-time algorithm that always find a p feasible packing into the strip of height at most OP T (R) + O( OP T (R) log OP T (R)). By choosing ε = 2 Next Fit Decreasing Height (NFDH) Algorithm This idea was first introduced by Coffman et al. [1]. Suppose we are given a collection of rectangles that need to be packed in a 2D bin. The NFDH algorithm orders the rectangles in the non-increasing order of their heights and packs them into sublevels, shown as in Figure 1. The bottom of the first level coincides with the bottom of the strip. Items are taken from the list and packed in the current level with their bottoms coinciding with the bottom of the level, and pushed as far to the left as possible, given the items already packed in the level. This continues until no items remain (in which case the packing is complete) or the current item is wider than the space remaining at the right side of the strip/bin. In this latter case, the level is closed and a new level is created whose bottom coincides with the top of the leftmost (and hence tallest) item in the old level. This is a complete description of the algorithm in the strip-packing case. If we are packing into a bin or fixed rectangle (which is needed to design a APTAS for the strip packing problem), then we stop if the current item does not fit in the new level because it is taller than the gap between the bottom of the new level and the top of the bin (or rectangle). 1 This is why the algorithm of Jansen, Solis-Oba [2] with smallest possible additive error of 1 but exponential dependence of running time on ε would not give us an improvement. 2 shelf 3 shelf 2 shelf 1 Figure 1: NFDH packing Let w and h be the maximum width and height of a set of rectangles. If w and h are relatively small compared to the dimensions of the bin, then the packing produced by NFDH is very efficient. Lemma 3 (Coffman et al. [1]) Given a set of rectangles with width at most w and height at most h, if NFDH is used to pack these items in a bin of width a and height b, then the total used area in that bin is at least (a − w)(b − h) (provided there are enough rectangles that NFDH never runs out of them). An immediate implication of the Lemma 3 is the following corollary. Corollary 1 Given a set of rectangles R with w = maxi∈R wi and h = maxi∈R hi . Then NFDH heuristic applied to the P set of rectangles R packs this set of rectangles into the strip of width one and height h + i∈R hi wi /(1 − w). 3 Sketch of Kenyon-Remila result Let S = {i ∈ R|wi ≤ ε} and B = R \ S be the sets of small and large rectangles, respectively. Let OP T f r (R) be the optimal solution of the relaxation of the minimum strip-packing problem where we allow to cut rectangles horizontally into an arbitrary number of pieces. Note that there always exists a solution to the relaxed problem with at most n cuts per rectangle (by reformulating the problem using linear programming and using properties of the basic feasible solutions, see [4] for details). Kenyon-Remila proof of the Theorem 1 is basically a combination of the following two Lemmas. Lemma 4 It is possible to define a set W̄ of t = O(1/ε2) widths ε < w̄1 ≤ . . . ≤ w̄t ≤ 1 such that if we round the width of each rectangle in B up to the nearest width in W̄ obtaining a new set of rectangles B̄ we have OP T f r (S ∪ B̄) ≤ (1 + ε)OP T f r (R) + O(t). 3 Lemma 5 Given the set of small rectangles S and large rectangles B̄ such that there are at most t distinct widths of rectangles in B̄. There exists an algorithm with running time O(n log n + ε−6 log3 n log3 1ε ) that finds a feasible packing of height H(S ∪ B̄) such that H(S ∪ B̄) ≤ (1 + ε)OP T f r (S ∪ B̄) + O(t). Since all original large rectangles from the set B fit into the spots occupied by the corresponding rectangles in B̄, combining Lemmas 4 and 5 we derive the Theorem 1. 4 Our Result We prove a strengthened version of Lemma 4 that in combination with Lemma 5 implies Theorem 2. Lemma 6 It is possible to define a set W̄ of t = O logε1/ε widths ε < w̄1 ≤ . . . ≤ w̄t ≤ 1 such that if we round the width of each rectangle in B up to the nearest width in W̄ obtaining a new set of rectangles B̄ we have 1 fr fr . OP T (S ∪ B̄) ≤ (1 + 4ε)OP T (R) + O ε Proof: First we partition the set B of large rectangles intoPthe sets Bj for j = 1, . . . , q = ⌈log2 1/ε⌉ where Bj = {i ∈ B|wi ∈ (2−j , 2−j+1]}. Let Hj = i∈Bj hi be the total height of all rectangles in the set Bj . Since the total area of all the rectangles in the instance is a lower bound on the optimal value of the relaxed problem we have q X j=1 2−j Hj ≤ X i∈R wi hi ≤ OP T f r (R). (1) For each set Bj we define 1/ε groups Gτ j where τ = 1, . . . , 1/ε of height εHj . More precisely, assume that we already defined groups Gτ ′ j for τ ′ < τ and Bj′ is the set of remaining pieces of rectangles (initially Bj′ = Bj ) that were not assigned to any group yet. We assign largest width pieces of rectangles from Bj′ into the group Gτ j one by one until the total height of such rectangles reaches εHj . The last piece (or a full rectangle) that we place into the group Gτ j might be cut into two pieces to guarantee that this group has total height exactly εHj . The rectangles that are cut in few pieces and placed into different groups are not rounded. For each j = 1, . . . , q and τ = 1, . . . , 1/ε round widths of remaining rectangles in group Gτ j up to the largest width of a piece in that group. After the rounding we obtain a new set of large rectangles B̄ containing q log 1/ε =O t=O ε ε 4 different widths. Given a solution of the relaxed strip-packing problem for the original set of rectangles of value OP T f r (S ∪ B) we now define a solution for the rounded instance. First we delete all pieces of rectangles from groups G1j from the solution for each j = 1, . . . , q. We also delete all rectangles that were cut in pieces and placed into different groups. Let Cj ⊆ Bj be the set of these rectangles for j = 1, . . . , q. Obviously, |Cj | ≤ 1/ε. After that for each j = 1, . . . , q and τ = 2, . . . , 1/ε we move the remaining rectangles from Gτ j with rounded widths to the spots occupied by the pieces of (not rounded) rectangles from Gτ −1j in the solution for the original instance, possibly by introducing new horizontal cuts. All the pieces from the group G11 can be packed into a rectangle of size εH1 × 1. The total area of the rectangles in the group G1j for j ≥ 2 is at most 2−j+1 εHj and the width of these rectangles is upper bounded by 2−j+1 . By utilizing Corollary 1 we can pack all rectangles from the set G1j for j ≥ 2 into the strip of width one and height X 1 + (1 − 2−j+1 )−1 wi hi ≤ 1 + 2−j+2 εHj . i∈G1j Analogously, all rectangles from C1 can be packed into a rectangle of size 1ε ×1. By Corollary 1 we can pack all rectangles from the set Cj for j ≥ 2 into the strip of width one and height X 1 1 + (1 − 2−j+1)−1 wi hi ≤ 1 + 2−j+2 . ε i∈C j Therefore, applying the inequality (1) we derive fr q X 1 (2 + 2−j+2 + 2−j+2 εHj ) ε j=1 q X 1 fr 2−j Hj + 4ε = OP T (R) + 2q + O ε j=1 1 ≤ (1 + 4ε)OP T f r (R) + O . ε fr OP T (S ∪ B̄) ≤ OP T (R) + References [1] E. G. Coffman, M. R. Garey, D. S. Johnson and R. E. Tarjan. Performance bounds for leveloriented two dimensional packing algorithms. SIAM J. Computing 9 (1980), 808–826. [2] K Jansen and R. Solis-Oba, New Approximability Results for 2-Dimensional Packing Problems, Lecture Notes in Computer Science 2007, Volume 4708/2007, Proceedings of MFCS 2007, pp. 103-114. [3] N. Karmarkar and R. M. Karp. An Efficient Approximation Scheme for the One-Dimensional Bin-Packing Problem. Proceedings of Foundations of Computer Science 1982, 312–320. 5 [4] C. Kenyon and E. Rémila. A Near-Optimal Solution to a Two-Dimensional Cutting Stock Problem. Mathematics of Operations Research 25 (2000), 645–656. 6