A Structural Lemma in 2-Dimensional Packing, and its Implications on Approximability∗† Nikhil Bansal‡ Alberto Caprara § Klaus Jansen ¶ Maxim Sviridenko∗∗ Lars Prädel k Abstract We present a new lemma stating that, given an arbitrary packing of a set of rectangles into a larger rectangle, a “structured” packing of nearly the same set of rectangles exists. This lemma has several implications on the approximability of 2-dimensional packing problems. In this paper, we use it to show the existence of a polynomial-time approximation scheme for 2-dimensional geometric knapsack when the range of the profit to area ratios of the rectangles is bounded by a constant. As a corollary, we get an approximation scheme for the problem of packing rectangles into a larger rectangle to occupy the maximum area. The existence of such an approximation scheme was a longstanding open problem, and has already been used in other papers on the absolute approximability of 2-dimensional bin and strip packing. Moreover, we show that our approximation scheme can be used to find an asymptotic polynomial-time approximation scheme for 2-dimensional fractional bin packing, the LP relaxation of the customary set covering formulation of 2-dimensional bin packing. This also has already been used in another paper to improve the best known approximation guarantee for 2-dimensional bin packing itself. The asymptotic approximation scheme is obtained by showing that the set covering LP relaxation can be modified slightly to obtain an almost equivalent LP, by introducing upper bounds on the dual LP variables, so that the dual separation problem reduces to the special case of 2-dimensional geometric knapsack with bounded range of profit to area ratios mentioned above. We believe that this technique is of independent interest and should have other applications. 1 Introduction Due to their practical relevance, 2-dimensional (geometric) packing problems have always received considerable attention in the combinatorial optimization literature. Given that the structure of their solutions can be extremely complicated, after some early approximability results proved in the early ∗ Dedicated to our dear friend and colleague Alberto Caprara, who died in an unfortunate hiking accident during the completion of this work † The extended abstract of this paper was published in Proceedings of the 20th International Symposium on Algorithms and Computation (ISAAC 2009) [2] ‡ Eindhoven University of Technology. e-mail: n.bansal@tue.nl § DEIS, University of Bologna, Viale Risorgimento 2, I-40136 Bologna, Italy ¶ Department of Computer Science, Christian-Albrechts-University to Kiel, Christian-Albrechts-Platz 4, 24098 Kiel, Germany, e-mail: kj@informatik.uni-kiel.de, Work supported by DFG project JA612/12-1, “Design and analysis of approximation algorithms for two- and three-dimensional packing problems” k Department of Computer Science, Christian-Albrechts-University to Kiel, Christian-Albrechts-Platz 4, 24098 Kiel, Germany, e-mail: lap@informatik.uni-kiel.de, Work supported by DFG project JA612/12-1, “Design and analysis of approximation algorithms for two- and three-dimensional packing problems” ∗∗ University of Warwick. e-mail: sviri@dcs.warwick.ac.uk, Work supported by EPSRC grant EP/J021814/1, FP7 Marie Curie Career Integration Grant and Royal Society Wolfson Merit Award. 1 1980s, the study of these problems was limited for a long time to the design of heuristic algorithms that could be useful in practice, without any proof of approximation guarantee. In the last few years, some progress has been made towards the solution of some instances to proven optimality by enumerative methods. Only in the last decade it has been observed that the tools used in the late 1970s and early 1980s to settle the approximability status of the main 1-dimensional packing problems could in fact be used with the same purpose also for their 2-dimensional counterparts. For two of the three basic 2-dimensional packing problems, namely 2-Dim Strip Packing and 2-Dim Bin Packing, the picture of approximability is now pretty clear, due to a series of recent relevant results listed in the state-of-the-art review below. For the third basic problem, namely 2-Dim Geometric Knapsack, the main question, concerning the existence of a polynomial-time approximation scheme, remains open. So far, the best approximation ratio that can be achieved in polynomial time is arbitrarily close to 2. Approximation schemes have been devised only for the variants in which either all items are squares, or the bin (i.e., the space in which the items must be packed) can be slightly enlarged, or the items are much smaller than the bin itself. 1.1 Basic notions In the 2-dimensional packing problems considered in this paper we are given a set I of items, the i-th item corresponding to a rectangle having width wi , height hi , and profit pi , to be packed into bins, corresponding to unit squares. We ∑ will let ai := wi · h∑ item i. For a subset i denote the area of∑ ∑S ⊆ I, we will use the notations w(S) := i∈S wi , h(S) := i∈S hi , p(S) := i∈S pi , a(S) := i∈S ai . A set C of items can be packed into a bin if the items can be placed into the bin without any two overlapping with each other. We only consider the orthogonal packing case, where the items must be placed so that their edges are parallel to the edges of the bin. We address both the classical version without rotations, in which the edges associated with the item heights have to be parallel to each other, and the version with rotations, in which this restriction is not imposed. In the latter case, we will assume without loss of generality wi ≥ hi for i ∈ I. In 2-Dim Geometric Knapsack, only one bin is available and the objective is to pack a subset of the items having maximum profit into the bin. In 2-Dim Strip Packing, a strip of unit width and infinite height is available and the objective is to pack all the items in I minimizing the height of the strip used. Finally, in 2-Dim Bin Packing, an unlimited number of bins is available and the objective is to pack all the items in I into the minimum number of bins. It is well known that 2-Dim Bin Packing can be formulated as the Set Covering problem in which the set I of items has to be covered by configurations from the collection C ⊆ 2I , where each configuration C ∈ C corresponds to a set of items that can be packed into a bin. Letting xC be a binary variable equal to 1 if there exists a bin in the solution containing precisely the items in configuration C, the Set Covering formulation reads: ∑ ∑ min{ xC : xC ≥ 1 (i ∈ I), xC ∈ {0, 1} (C ∈ C)}. (1) C∈C C3i The associated 2-Dim Fractional Bin Packing is the linear program (LP) given by the continuous relaxation of this Set Covering problem. Since the number of configurations is not bounded by a polynomial, the problem of solving this LP relaxation is nontrivial. Given an instance I of a minimization problem, we let opt(I) denote the value of the optimal solution of the problem for I. Given an algorithm for the problem, we say that it has asymptotic approximation guarantee ρ if there exists a constant δ such that the value of the solution found by the algorithm is at most ρ opt(I) + δ for each instance I. If δ = 0, then the algorithm has (absolute) approximation guarantee ρ. An asymptotic polynomial-time approximation scheme (APTAS) is a family 2 of polynomial-time algorithms such that, for each ε > 0, there is a member of the family with asymptotic approximation guarantee 1 + ε. If δ = 0 for every ε, then this is a polynomial-time approximation scheme (PTAS). In case the running time of the algorithms is polynomial in the input size and 1/ε, we obtain an asymptotic fully polynomial-time approximation scheme (AFPTAS) and a fully polynomialtime approximation scheme (FPTAS), respectively. The definitions for a maximization problem are analogous, replacing “at most ρ opt(I) + δ” by “at least ρ opt(I) − δ” and “1 + ε” by “1 − ε”. In the paper, we will let opt2KP (I) denote the optimal solution value of 2-Dim Geometric Knapsack for the given instance I. 1.2 State-of-the-art For 2-Dim Geometric Knapsack, the best known approximation algorithm, due to Jansen and Zhang [21], has approximation guarantee arbitrarily close to 2. On the other hand, no inapproximability result is known (with exception that there is no FPTAS, unless P = N P [25]). PTASs are known only with resource augmentation, i.e., the algorithm can use a bin with both sides slightly enlarged [12], or even with only one side slightly enlarged [18] (but the optimum does not have this privilege). Without resource augmentation, a PTAS is also known in case all items are much smaller than the bin [11] or when all items are squares [19]. For 2-Dim Strip Packing, a basic result of Steinberg [27] yields a polynomial-time algorithm with absolute approximation guarantee 2, which was not improved before this paper. Moreover, Kenyon and Rémila [23] showed the existence of an AFPTAS. This was extended by Jansen and van Stee [20] to the case in which the items can be rotated. Furthermore there is an APTAS by Jansen and Solis-Oba with additive constant 1 [18]. For 2-Dim Bin Packing, Bansal et al. [1] showed that it does not admit an APTAS unless P = N P . For the case without rotations, Caprara [7] presented a polynomial-time algorithm with asymptotic approximation guarantee arbitrarily close to Π∞ , where Π∞ = 1.691 . . . is the so-called harmonic constant in the context of Bin Packing [24]. For the case with rotations, an asymptotic approximation guarantee arbitrarily close to 2 follows from the result of [20]. APTASs are known for the 2-Stage and the Guillotine 2-Dim Bin Packing [5, 8], in which the items must be packed in a certain structured way, as well as for the cases in which one or two sides of the bins can be slightly enlarged [1, 6, 10]. Building upon the results of [7, 23], Bansal et al. derived in [3, 4] an approximation algorithm for 2-Dim Bin Packing, with and without rotations, with asymptotic approximation guarantee arbitrarily close to 1 + ln Π∞ = 1.525 . . .. This latter algorithm runs in polynomial time if there exists an APTAS for 2-Dim Fractional Bin Packing, a question that was open before this paper. Finally, the best-known absolute approximation guarantee for the problem before this paper was equal to 3 and due to Zhang [28]. 1.3 Our contribution and its implications The main result of this paper is a new lemma about the structure of the packings of items into a bin. Very roughly, it says that given any complicated packing of items into a bin, there is a simpler packing with almost the same items. Slightly more precisely, the lemma concerns a packing into a bin of a set of items that can be partitioned into three subsets, namely “fat and tall”, “fat and low”, and “thin and tall”, and for which the number of widths of the “fat and low” items as well as the number of heights of the “thin and tall” items is bounded by a constant (see Figure 1). We show that, regardless of how low and spread around the bin the “fat and low” items may be (and how thin and spread around the bin the “thin and tall” items may be), for each constant δ > 0, there exists an alternative packing in which nearly all the “fat and low” items of width, say, w, are grouped together one on top of the other in larger 3 rectangles of width w and height δ (and nearly all the “thin and tall” items of height, say, h, are grouped together one on the right of the other in larger rectangles of width δ and height h). Figure 1: An example of an “unstructured” packing (left) and the corresponding “structured” packing of the same items (right). Here, there is a unique “fat and tall” item, whereas the “fat and low” items have two distinct widths and the “thin and tall” items have two distinct heights. We apply our structural lemma to derive the first, to the best of our knowledge, nontrivial PTAS for a variant (in fact, restriction) of 2-Dim Geometric Knapsack in which items are rectangles of arbitrary size and the bin cannot be enlarged. The restriction requires the range of profit to area ratios of the items to be bounded from above by a constant. Besides the use of this new lemma in its analysis, the PTAS is a (nontrivial) combination of well-established techniques. As a special case, this implies a PTAS for the case in which the profit of an item is equal to its area, whose existence was a longstanding open problem. This result has applications in 2-Dim Bin Packing and 2-Dim Strip Packing. For example, it has already been used independently by Harren and van Stee [15] and by Jansen et al. [17] to derive polynomial-time algorithms for 2-Dim Bin Packing with absolute approximation guarantee 2 (which is best possible unless P = N P ). For 2-Dim Strip Packing the PTAS has been used to achieve a polynomial-time algorithm with absolute approximation guarantee arbitrarily close to 5/3 = 1.666 . . . by Harren et al. [16]. We also show that our PTAS can be used to derive an APTAS for 2-Dim Fractional Bin Packing, which, as already mentioned, has been used by Bansal et al. [4] to derive a polynomial-time algorithm for 2-Dim Bin Packing with asymptotic approximation guarantee 1.525 . . . This APTAS cannot be obtained by applying the well-established equivalence between approximate separation and optimization in a straightforward way, since the dual-separation problem for 2-Dim Fractional Bin Packing is a general 2-Dim Geometric Knapsack, for which the existence of a PTAS remains open. In this paper we show that 2-Dim Fractional Bin Packing can be modified slightly to obtain an almost equivalent LP, by introducing upper bounds on the dual LP variables, so that the dual-separation problem reduces to the special case of 2-Dim Geometric Knapsack to which our PTAS applies. We believe that this technique is of independent interest and should have other applications. 1.4 Formal statement of our results The (fairly complex) formal statement of our main result is: Lemma 1 (Structural lemma) Consider a set of items (rectangles) that fits into a bin (unit square) of the form L ∪ H ∪ V , where wi ≥ ε for i ∈ L ∪ H; hi ≥ ε for i ∈ L ∪ V ; and the number of distinct widths of the items in H and heights of the items in V is at most d, where ε and d are given constants. Let w1 , w2 . . . be the distinct widths of the items in H; h(wj ) be the total height of the items having width wj ; h1 , h2 . . . be the distinct heights of the items in V ; and w(hj ) be the total width of the items having height hj . 4 Then, there exists a constant f (d, ε) such that, for any δ > 0, the following set of rectangles fits into a unit square: the items in L plus, for j = 1, 2, . . ., a set of rectangles of width wj and height δ for a total height at least h(wj ) − δf (d, ε), and a set of rectangles of height hj and width δ for a total width at least w(hj ) − δf (d, ε). Although its proof is constructive, the lemma is stated in existential form since this suffices for our purposes, as we use it only in the analysis and not in the design of algorithms. This lemma allows us to replace the items in H, that have arbitrary small heights of less than ε, with rectangles of uniform heights of δ. The total height of the new rectangles is almost as large as the total height of the items in H. Furthermore, the items in V are replaced by rectangles of uniform widths of δ, so that the total width of the new rectangles is almost as large as the total width of the items in V . Thus, the resulting packing consists only of a constant number of different types of items and the structure of the packing is therefore much simpler. By using this lemma, we are able to prove the following theorem, that shows that 2-Dim Geometric Knapsack has a PTAS if the range of the profit/area ratios, namely maxi∈I (pi /ai )/ mini∈I (pi /ai ), is bounded from above by a constant. Note that, by possibly scaling the profits, this is equivalent to saying that there exists a constant r such that pi /ai ∈ [1, r] for i ∈ I. Theorem 1 For any fixed r ≥ 1, there exists a PTAS for 2-Dim Geometric Knapsack with and without rotations restricted to instances I for which pi /ai ∈ [1, r] for i ∈ I. As a corollary, we get a PTAS for the problem of maximizing the area occupied in a bin, whose existence was open so far. Corollary 1 There exists a PTAS for the special case of 2-Dim Geometric Knapsack with and without rotations in which pi = ai for i ∈ I. Finally, we show that Theorem 1 suffices to solve near-optimally the dual-separation problem for a closely-related variant of 2-Dim Fractional Bin Packing. By the well known connection between approximate separation and optimization [13, 14, 26], this allows us to prove: Theorem 2 There exists an APTAS for 2-Dim Fractional Bin Packing with and without rotations. 2-Dim Fractional Bin Packing is nontrivial, since the number of configurations in the relaxation of (1) are typically exponentially many. As mentioned above, the results in [3, 4] along with Theorem 2 imply: Corollary 2 ([3, 4]) There exists a polynomial-time approximation algorithm for 2-Dim Bin Packing with and without rotations with approximation guarantee arbitrarily close to 1 + ln Π∞ = 1.525 . . .. For the sake of readability, in the coming sections we present the above results in reverse order, which corresponds to increasing technical difficulty. Namely, in Section 2 we prove Theorem 2 by using Theorem 1, in Section 3 we prove Theorem 1 by using Lemma 1, and in Section 4 we prove Lemma 1. Some of the results in this paper were initially announced in [3]. A preliminary version of the present paper appeared in [2]. 1.5 Next-fit decreasing height Throughout the paper, we will extensively use the next-fit decreasing height (NFDH) procedure introduced by [9]. NFDH considers the items in decreasing order of height and greedily packs them in this order into shelves. A set of items is said to be packed into a shelf if their bottom faces all lie on the 5 same horizontal line. More specifically, starting from the bottom of the first bin, the items are packed left justified into a shelf until the next item does not fit. The shelf is then closed (i.e., no further item will be packed into the shelf), and the next item is used to define a new shelf whose bottom line touches the top face of the tallest (first) item in the shelf below. If the shelf does not fit into the bin, i.e., if the next item does not fit on top of the tallest item in the shelf below, the bin is closed and a new bin is started. The procedure continues until all items are packed. The key properties of NFDH that we need are: Lemma 2 Consider a set of items I and its packing into bins by NFDH, letting m be the number of these bins and S1 and S2 be the subset of items packed into the first and second bin, respectively. The total areas of the items in S1 and S2 satisfy the following: (i) if m > 1 and wi ≥ hi for i ∈ I, then a(S1 ) ≥ 1/4; (ii) if m > 2, then max{a(S1 ), a(S2 )} ≥ 1/4; (iii) if m > 1, then a(S1 ) ≥ (1 − maxi∈I wi ) · (1 − maxi∈I hi ). The proof of the above lemma is based on elementary considerations, mostly applying the telescopic sum principle in [9], but it is not entirely trivial, and we could not find it explicitly in the literature. For this reason, we report it in the appendix. 2 An APTAS for 2-Dim Fractional Bin Packing 1. Find a near-optimal solution of the modified LP (5), by using as approximate dualseparation oracle the PTAS of Theorem 1, as explained in Lemma 4. 2. Transform the near-optimal solution of (5) found in Step 1 into a near-optimal solution of (2), as explained in Lemma 3. Figure 2: Structure of the APTAS for 2-Dim Fractional Bin Packing, namely LP (2). In this section we prove Theorem 2 by using Theorem 1. The (elementary) structure of the method is summarized in Figure 2. The continuous relaxation of (1) reads: ∑ ∑ min{ xC : xC ≥ 1 (i ∈ I), xC ≥ 0 (C ∈ C)} (2) C∈C C3i (noting that the condition xC ≤ 1 (C ∈ C) is redundant), and its LP dual is given by: ∑ ∑ max{ πi : πi ≤ 1 (C ∈ C), πi ≥ 0 (i ∈ I)}. i∈I (3) i∈C The well-known connection between approximate separation and optimization for (2) reads: Theorem 3 ([13, 14, 26]) There exists a PTAS for (2) if, for any ε > 0, there exists a polynomial-time ∑ |I| algorithm∑ that, given π ∗ ∈ R+ such that maxC∈C i∈C πi∗ ≥ 1 + ε, finds a configuration C ∗ ∈ C such that i∈C ∗ πi∗ > 1. 6 We refer to [13, 14, 22, 26] for a much detailed description about the relation between the primal and dual problem and the separation oracle. In other words, the theorem above states that if there is a PTAS for the 2-Dim Geometric Knapsack problem, where the profit of item i is πi∗ , then there is also a PTAS for (2). Since the existence of such a PTAS remains open, we now introduce a variant of (2) that, on the one hand, is almost equivalent to the original problem and, on the other, has a dual-separation problem that fulfils the requirements of Theorem 1. The definition of this variant and its properties is the novelty of this section. The variant is simply obtained by imposing a bound of 4ai on each dual variable πi : ∑ ∑ πi ≤ 1 (C ∈ C), 0 ≤ πi ≤ 4ai (i ∈ I)}, (4) πi : max{ i∈I i∈C which corresponds to the primal problem with the additional variables yi : ∑ ∑ ∑ min{ xC + 4ai yi : xC + yi ≥ 1 (i ∈ I), xC , yi ≥ 0 (C ∈ C, i ∈ I)}. C∈C i∈I (5) C3i Lemma 3 Given any solution of (5) of value z ∗ , one can obtain in polynomial time a solution of (2) of value at most z ∗ + 1 for the case with rotations and z ∗ + 2 for the case without rotations. Proof Consider a solution (x∗C , yi∗ ) of (5). Let I ∗ := {i ∈ I : yi∗ > 0} be the set of items associated with a positive y-component in the solution. We pack the items in I ∗ into bins by NFDH. If at least one of these bins contains a subset of items S ∗ ⊆ I ∗ such that a(S ∗ ) ≥ 1/4, we do the following. We let α := mini∈S ∗ yi∗ , and define a new solution of (5) in which yi∗ is decreased by α for i ∈ S ∗ and xS ∗ is increased by∑ α. It is immediate to verify that the new solution is feasible, and not worse than the previous one since i∈S ∗ 4ai α = 4αa(S ∗ ) ≥ α. We repeat the procedure above until no bin packed by NFDH with the items in I ∗ has area occupied at least 1/4. In this case, by Lemma 2(ii), for the case without rotations we have that NFDH packs the items in I ∗ into at most two bins, associated with, say, subsets S1∗ and S2∗ . At this point, we define another new solution of (5) in which yi∗ is set to 0 for i ∈ S1∗ ∪ S2∗ (i.e., all y-components are zero) and xS1∗ , xS2∗ are set to the value 1. This solution is feasible also for (2) (by neglecting the y variables) and has a value which is larger than the previous one by at most 2. On the other hand, for the case with rotations, by Lemma 2(i) NFDH packs the items in I ∗ into one bin, and the reasoning is analogous, leading to a solution for (2) whose value is larger by at most 1. Note that the number of iterations of the above procedure is at most |I| as, in each iteration, at least one yi∗ is decreased from a positive value to 0. Lemma 4 There exists a PTAS for (5) with and without item rotations. Proof By the counterpart of Theorem 3 for ∑ (5), for any ε > 0 we need a polynomial-time algorithm ∗ ∈ [0, 4a ]|I| such that max ∗ ∗ that, given π i C∈C i∈C πi ≥ 1 + ε, finds a configuration C ∈ C such that ∑ ∗ i∈C ∗ πi > 1. In other words, if the 2-Dim Geometric Knapsack associated with the items in I having ∗ profits πi satisfies opt2KP (I) ≥ 1+ε, we want a solution of the problem of value > 1. Letting σ := ε/3, we first remove all the items i ∈ I such that πi∗ ≤ σai , whose overall contribution to opt2KP (I) is at most σ, since the sum of the areas of the items packed is at most 1. For the items left, the range of the profit/area ratios is [σ, 4], i.e., it becomes [1, 4/σ] after scaling. Then, we apply the PTAS of Theorem 1 with internal precision σ where now r = 4/σ. The solution found by this PTAS, after scaling profits back to their original values, has value at least (1 − σ) (opt2KP (I) − σ) ≥ (1 − σ)(1 + ε − σ) > 1. Lemmas 3 and 4 together immediately imply Theorem 2. 7 1−γ γ γ 1−γ γγ Figure 3: An example of I for which the area of the items is arbitrarily small (left) but still finding a (near-)optimal solution of 2-Dim Geometric Knapsack (right) is nontrivial if rotations are not allowed: |I| = 4, (w1 , h1 ) = (w2 , h2 ) = (1 − γ, γ), (w3 , h3 ) = (w4 , h4 ) = (γ, 1 − γ) for an arbitrarily small γ > 0. 3 A PTAS for Restricted 2-Dim Geometric Knapsack In this section we prove Theorem 1 by using Lemma 1. Recall that we are assuming pi /ai ∈ [1, r] for i ∈ I, where r is a constant. For simplicity, we will assume that r is integer. Note first that items for a total area at least min{a(I), 1}/4 can be packed into the bin. Indeed, following Lemma 2, consider the packing of the items in I into m bins by NFDH. Either m ≤ 2, and therefore a total area at least a(I)/2 > a(I)/4 is packed into one bin, or m > 2 and a total area at least 1/4 is packed into one bin. Together with pi /ai ≥ 1 for i ∈ I this implies opt2KP (I) ≥ min{a(I), 1}/4. Let ε < 1/2 denote the accuracy required. Letting δ < ε2 be a suitable constant threshold specified below, we distinguish the case in which a(I) ≥ δ, for which we apply the algorithm in Section 3.1, from the case in which a(I) < δ. In this second case, if rotations are allowed all the items are packed into the bin by NFDH, by Lemma 2(i). On the other hand, for the case without rotations handling instances in which the overall area a(I) of the items is very small may be tricky, see for instance Figure 3. In fact, for the case in which a(I) < δ, we adopt a completely different method illustrated in Section 3.3. According to Lemma 6 in that section, we can set the threshold δ := (ε/15)2 and have, overall, a PTAS for the two cases a(I) ≥ δ and a(I) < δ. The novelty of this section is the use of Lemma 1 in the definition of the algorithm in Section 3.1 and in its analysis in Section 3.2. Apart from this, the algorithms are based on a (sometimes not entirely trivial) combination of known techniques and easy observations, and their analysis is fairly standard. 3.1 Description of the main algorithm for a(I) ≥ δ We first illustrate the case without rotations, as it is more complex, and then discuss the variations for the case with rotations. The algorithm is outlined in Figure 4. Roughly speaking, in order to apply Lemma 1 for suitable ε and δ, we temporarily put aside the “small” items (having width and height < ε). Moreover, we keep the “large” items (width and height ≥ ε) as they are, we transform the “horizontal” items (width ≥ ε, height < ε) so that they have a constant number of distinct widths and all height δ, and, symmetrically, we transform the “vertical” items (width < ε, height ≥ ε) so that they have a constant number of distinct heights and all width δ. If we do this properly, Lemma 1 guarantees that the optimal solution of the transformed instance is not too far from the one of the original instance. Moreover, by introducing a sufficiently large gap between the sizes of the “small” items and of the other items packed, we can guarantee that the “small” items can be packed separately at the end, still obtaining a near-optimal solution. Formally, let ε > 0 denote an internal accuracy parameter, assuming for simplicity that 1/ε is 8 1. Define ε and εj for j = 0, . . . , 2/ε. 2. For m = 0, . . . , 2ε: a. Define δm , neglect the items having either width or height in (εm+1 , εm ], and partition the remaining items into the sets L, H, V, S of large, horizontal, vertical and small items. b. Allow the items in H to be sliced horizontally, and change their profits and widths so as to partition them into subgroups Hjk` of items having the same profit/height ratio and the same width. Subdivide the items in Hjk` into rectangles of height δm (having the same profit and width). c. Allow the items in V to be sliced vertically, and change their profits and heights so as to partition them into subgroups Vjk` of items having the same profit/width ratio and the same height. Subdivide the items in Vjk` into rectangles of width δm (having the same profit and height). d. Let I 0 be defined by the items in L and the rectangles of height and width δm defined in Steps 2b and 2c. e. For each Q ⊆ I 0 , test if the items in Q can be packed into the bin. If so, pack the items in S in the residual space and the original items in H and V in the rectangles of height and width δm . 3. Return the highest-profit feasible solution among those found in Step 2e. Figure 4: Structure of the PTAS for 2-Dim Knapsack for the case a(I) ≥ δ. integer. We will show how to find in polynomial time a solution of value at least (1−αε) opt2KP (I)− ε, where α > 8 is a suitable constant (independent of ε). Since a(I) > δ it holds opt2KP (I) > δ/4. By setting ε := (εδ)/α, we have (1 − αε) opt2KP (I) − ε = (1 − εδ) opt2KP (I) − εδ/α > (1 − ε/4) opt2KP (I) − 4εopt2KP (I)/α > (1 − ε/4 − 4ε/8) opt2KP (I) > (1 − ε) opt2KP (I) (recalling δ < ε2 < 1/4). Thus, this yields a PTAS for the case in which a(I) > δ. Size classification Let ε0 := 1 and, for j = 0, . . . , 2/ε, let εj+1 be a suitable constant, depending on ε, r, εj , to be specified later, such that εj+1 < ε2 εj . Let Ij ⊆ I denote the subset of items that have width or height in the interval (εj+1 , εj ]. We apply the method that follows for all values m = 0, . . . , 2/ε, and take the best solution produced. We neglect the items in Im (i.e., we find a solution in which none of these items is packed) and partition the rectangles in I \ Im as follows: Let L (large) denote the rectangles having both height and width > εm ; H (horizontal) denote the rectangles having width > εm and height ≤ εm+1 ; V (vertical) denote the rectangles having height > εm and width ≤ εm+1 ; S (small) denote the rectangles having both height and width ≤ εm+1 . 9 Rounding the items in H and V In order to apply Lemma 1, we modify the widths of the items in H (resp., the heights of the items in V ) so that there are only a constant number of distinct widths (resp., heights). In this phase we allow the items in H to be sliced horizontally (resp., the items in V to be sliced vertically) so as to be able to form subsets whose total height (resp., width) is exactly a given value. At the end of the algorithm, we will pack a subset of the items in H and V with their original sizes and without slicing them. We partition the items in H into groups Hjk for which the width and the profit/area ratio is approximately the same, as follows: Hjk := {i ∈ H : wi ∈ ((1 − ε)j , (1 − ε)j−1 ], pi /ai ∈ (r(1 − ε)k , r(1 − ε)k−1 ]}. Note that we have to consider j = 1, . . . , d(log εm )/(log(1 − ε))e, as wi ∈ (εm , 1], and k = 1, . . . , d(log 1/r)/(log(1 − ε))e + 1, as pi /ai ∈ [1, r]. This implies that the total number of groups is at most gm := d(log εm )/(log(1 − ε))e · (d(log 1/r)/(log(1 − ε))e + 1) (6) Note that the profit/height ratio of each item i ∈ Hjk is pi /hi = (pi /ai ) · wi ∈ (r(1 − ε)j+k , r(1 − For simplicity, we redefine (decrease) the profits of the items in each group Hjk so that this ratio is exactly r(1 − ε)j+k , i.e., the profit of any (slice of) item in Hjk having height h is given by r(1 − ε)j+k · h. Given that items in Hjk can be sliced, this implies that it is better to pack the items in Hjk with smallest width. Analogously, we partition the items in V into at most gm groups Vjk as follows: ε)j+k−2 ]. Vjk := {i ∈ V : hi ∈ ((1 − ε)j , (1 − ε)j−1 ], pi /ai ∈ (r(1 − ε)k , r(1 − ε)k−1 ]}. and redefine the profits of the items in each group Vjk so that their profit/width ratio is exactly r(1 − ε)j+k . For each group Hjk , if h(Hjk ) > 1/(1 − ε)j , we keep only the items with the smallest width for a total height equal to 1/(1 − ε)j because we cannot pack more than this height into the bin. Accordingly, in the reminder of this section we will assume h(Hjk ) ≤ 1/(1 − ε)j . Then, we consider the items in increasing order of widths, and define rgm /ε subgroups Hjk1 , Hjk2 , . . . of consecutive items, so that the total height of the items in each subgroup Hjk` is exactly h(Hjk )ε/(rgm ), slicing items where 2 /ε. needed. Note that the overall number of subgroups of items in H is at most rgm For each subgroup Hjk` , we define the increased width wjk` of all items as the largest original width of an item in the subgroup. Finally, for each subgroup Hjk` we merge and slice the items into bh(Hjk )ε/(rgm δm )c identical slices of width wjk` and height δm , where δm ∈ [(εm+1 /ε), εm ] is a suitable constant, depending on ε, r, εm , to be specified later (in these slices we pack the original items of H each of them having a height of at most εm+1 in step 2e of Figure 4). The possible residual slice of height < δm is neglected. The profit loss of this step is later estimated by using Lemma 1. 2 /ε distinct increased The rounding procedure for the items in V is analogous, leading to at most rgm heights and, for each increased height hjk` , to identical slices of height hjk` and width δm . After having defined the slices as above, we consider these slices as single items that cannot be sliced further. Overall, this leaves us with a modified instance I 0 with the items in L and the items corresponding to slices from H and V . Note that |I 0 | ≤ |I| as δm > εm+1 . Enumeration of the solutions for I 0 We enumerate all 2-Dim Geometric Knapsack solutions associated with I 0 as these are polynomially many. Specifically, since the area of each item in I 0 is at least δm εm , only the O(|I|1/(δm εm ) ) subsets 10 with at most 1/(δm εm ) items may be fit into the bin. Moreover, we can test in constant time if each of these subsets indeed fits into the bin, since we can assume that the bottom left corner of each item is placed into the bin at some (x, y) position which is an integer linear combination of the widths and heights of the items in the subset, and therefore we have O(22/(δm εm ) ) possible positions for each item. For each solution for I 0 , and the associated packing into the bin, we pack the small items in S and the original items in H and V by the greedy procedure of the next section. Among the solutions defined in this way, we keep the best one. Converting the solution for I 0 into one for I We use the empty spaces left in the bin by the items in I 0 to pack the items in S, and the space occupied by the slices of items in H and V to pack the original items in H and V . All original items in H, V and S are unpacked at the beginning of this phase. In order to pack the items in S, we draw horizontal and vertical lines through the coordinates of each corner of the items in I 0 , and let the cells be the rectangles that are empty among those defined by these lines. We consider the cells one by one (in an arbitrary order) and, for each cell C, having area aC , we consider the unpacked items in S in decreasing order of profit/area ratios and define a subset R by selecting the first items until condition a(R) ≥ aC − 2εm+1 is satisfied. We pack all the items in R by NFDH into the cell, given that they fit as we now show. Indeed, by Lemma 2(iii), letting wC and hC be the width and height of the cell, after scaling all small item widths by 1/wC and all item heights by 1/hC , we have that the area of any subset of items in S packed by NFDH in the cell, in case some items are unpacked, is at least (1−εm+1 /wC )·(1−εm+1 /hC )·(wC ·hC ) ≥ wC ·hC −2εm+1 = aC −2εm+1 . As to the items in H, for each group Hjk , we consider the slices of width wjk` and height δm in increasing order of widths (i.e., by increasing `). For each such slice, we consider the unpacked original items in Hjk in increasing order of widths, and define a subset R by selecting the first items until condition h(R) ≥ δm − εm+1 is satisfied. We pack all items in R in the slice (noting that they clearly fit). Note that the order in which we consider slices and original items guarantees that we never run out of items. We do the same for the items in V . The case with rotations The case with rotations is actually simpler. Namely, given that wi ≥ hi , we have V = ∅. The rounding of the items in H is exactly the same, leading to slices of width wjk` and height δ in I 0 . The only difference is that, in the enumeration of the solutions for I 0 , we consider the possibility of rotating these slices as well as the items in L in the bin, which leads us to consider O((2|I|)1/(δm εm ) ) subsets of items for which the rotation is specified, rather than O(|I|1/(δm εm ) ). The small items are not rotated. 3.2 Proof of approximation guarantee Lemma 5 By defining ε0 := 1 and, for each j = 0, . . . , 2/ε, δj := ε2 /(2r2 gj2 f (rgj2 /ε, εj )) and εj+1 := ε/(2r(2/(δj εj ) + 1)2 ), the value of the 2-Dim Geometric Knapsack solution produced by the algorithm above is at least (1−13ε) opt2KP (I)−ε, where gm is defined by (6) and f (·, ·) is the constant in the statement of Lemma 1. Proof In this proof, letting T ⊆ I be the set of items packed in a solution, with some abuse we will also refer to T as a solution, i.e., we will not make a distinction between the set of items packed and the packing itself (with its layout). Moreover, we will allow T to contain not only “regular” items but also horizontal slices of items in H and vertical slices of items in V . 11 First of all, note that, given that there are 2/ε subsets Ij and that each item belongs to at most two of these subsets, there exists a value of m for which the total profit of the items in Im in the optimal solution is at most ε opt2KP (I). By removing these items from I we get an instance I 0 := I \ Im such that opt2KP (I 0 ) ≥ (1 − ε) opt2KP (I). From now on, we consider the solution obtained by the algorithm for this value of m and the associated values of εm and δm and sets L, H, V, S. We first address the case without rotations. For the new instance I 0 , consider an optimal solution of the relaxation of 2-Dim Geometric Knapsack in which the items in H can be sliced horizontally and the items in V can be sliced vertically. We let T 1 denote this solution. Clearly, p(T 1 ) ≥ opt2KP (I 0 ). The profits of the (sliced) items in T 1 are the original ones, i.e. the profit of a sliced item is distributed among the slices according to their areas. We let T 2 contain the same items as T 1 but with profits redefined so that the new profit/height ratio of each item in T 2 ∩ Hjk is r(1 − ε)j+k , and the profit/width ratio of each item in T 2 ∩ Vjk is (1 − ε)j+k . In the worst case, an item in Hjk of width (1−ε)j−1 , profit/area ratio r(1−ε)k−1 , and height h, originally having profit r(1−ε)k−1 ·(1−ε)j−1 ·h, has now profit r(1 − ε)j+k · h, i.e., its profit is decreased by a factor (1 − ε)2 . This implies p(T 2 ) ≥ (1 − ε)2 p(T 1 ). Note that the total height of the items in T 2 ∩ Hjk , whose width is at least (1 − ε)j , cannot exceed 1/(1 − ε)j . Accordingly, in case h(Hjk ) > 1/(1 − ε)j , we can keep only the items in Hjk with the smallest widths for a total height 1/(1 − ε)j (discarding the others) and define a new solution T 3 in which all (slices of) items discarded are replaced by (slices of) items kept. The same is done for Vjk . By the above redefinition of the profits, we have p(T 3 ) = p(T 2 ). The widths of the items in T 3 ∩ Hjk are the original ones. We define a new solution T 4 associated with the increased widths by replacing all the (slices of) items in Hjk` with original widths by the (slices of) items in Hjk(`+1) with increased widths wjk(`+1) , for ` < rgm /ε. For the last group Hjk(rgm /ε) , the associated (slices of) items are removed in T 4 . The overall profit of these items is at most p(Hjk(rgm /ε) ) ≤ r(1 − ε)j+k · h(Hjk )ε/(rgm ) ≤ ε min{a(I), 1}/gm , noting that (after possibly keeping only the items with the smallest widths) h(Hjk ) ≤ min{a(I), 1}/(1− ε)j . Recalling that opt2KP (I) ≥ min{a(I), 1}/4, we have that the overall loss over all gm groups Hjk is at most 4ε opt2KP (I), i.e., reasoning analogously for the items in V , p(T 4 ) ≥ p(T 3 ) − 8ε opt2KP (I). We now apply Lemma 1 to the solution T 4 , with δ := δm , defining a new solution T 5 in which slices of items in Hjk` , having width wjk(`+1) , now have height δm . Noting that in the statement of 2 /ε, we have that the decrease in the total Lemma 1 the value of ε is now εm and the value of d is now rgm 2 /ε, ε ), and therefore height packed for the items in Hjk` passing from T 4 to T 5 is at most δm f (rgm m j+k 2 2 the decrease in profit is at most r(1 − ε) · δm f (rgm /ε, εm ) ≤ rδm f (rgm /ε, εm ). Summing over all 2 δ f (rg 2 /ε, ε )/ε ≤ ε/2 by the sets Hjk` , the total profit decrease for the items in H is at most r2 gm m m m above definition of δm . Reasoning analogously for the items in V shows p(T 5 ) ≥ p(T 4 ) − ε. We compare the solution T 5 with the solution A considered by the algorithm, for the value of m as defined above, such that in T 5 and A the set of items in L as well as the number of slices of width wjk` and height δm , and of height hjk` and width δm , coincide (noting that such a solution A is indeed considered by the algorithm in its enumeration part). Note that the number of cells available for the small items in A is at most (2/(δm εm ) + 1)2 , as the number of horizontal and vertical lines defined by the corners of the items in I 0 is at most twice the number of these items, which are at most 1/(δm εm ) (and to these lines we must add the right and top boundary of the bin). Even if the cells in general do not coincide in T 5 and in A, their overall area is the same, say a. Moreover, the procedure used to pack the small items in the algorithm guarantees that the profit/area ratio of each small item unpacked in the end in A is at most equal to the one of each small item packed. In other words, recalling that the empty area in each cell of A is at most 2εm+1 , and 12 letting T 6 be the solution with the same items in L ∪ H ∪ V as T 5 and the same items in S as A, we have p(T 6 ∩ S) ≥ ((a − 2εm+1 (2/(δm εm ) + 1)2 )/a) p(T 5 ∩ S). Letting γ := 2εm+1 (2/(δm εm ) + 1)2 ), and noting that the area 1 − a for the items in L ∪ H ∪ V is entirely occupied in T 5 and T 6 (leading to a profit of at least 1 − a), we have that the following inequalities hold, recalling that the range of profit/area ratios is [1, r]: p(T 6 \S) = p(T 5 \S) ≥ 1−a, p(T 6 ∩S) ≥ ((a−γ)/a) p(T 5 ∩S), p(T 6 ∩S) ≥ 0, p(T 5 ∩S) ≤ ra. A straightforward calculation shows that the value a ∈ [0, 1] for which the ratio p(T 6 )/p(T 5 ) is minimized is γ, which implies p(T 6 ) ≥ (1 − γ)/(1 + (r − 1)γ) p(T 5 ), i.e., p(T 6 ) ≥ (1 − ε) p(T 5 ) by the definition of εm+1 in the statement (which is equivalent to γ = ε/r). Finally, for each slice of width wjk` and height δm in T 6 , as already mentioned the total height of the original items in H packed in A is at least δm − εm+1 . Moreover, the profit/height ratio of the original items is not smaller than the one for T 6 . This implies that, while the profit of the slice in T 6 is equal to r(1 − ε)j+k · δm , the profit in A is at least r(1 − ε)j+k · (δm − εm+1 ). Reasoning analogously for the items in V , this implies p(A) ≥ ((δm − εm+1 )/δm ) p(T 6 ) ≥ (1 − ε) p(T 6 ) (by the above definition of εm+1 ). Summarizing, we have p(A) ≥ (1 − ε)5 p(T ) − 8ε opt2KP (I) − ε ≥ (1 − 13ε)opt2KP (I) − ε, completing the proof. For the case with rotations, the reasoning is analogous, noting that in each set T i the items in L ∪ H may be rotated (recalling that V is empty), and that the algorithm considers a solution A with the same set of items in L and the same number of slices of width wjk` and height δm as T 5 , rotated in the same way. We note that the only part which is responsible of the additive error −ε is the application of the structural lemma, as in all the other parts the profit of the solution is decreased only by a (small) multiplicative factor. 3.3 The case with no rotations and a(I) < δ In this section we illustrate the method for the case a(I) < δ, whose √ general structure is outlined in Figure 5. First of all, we define an internal accuracy parameter ε := δ, assuming for convenience that 1/ε is integer, and partition the items as follows: Let H denote the rectangles having width > 1 − 2ε and height ≤ ε; V denote the rectangles having height > 1 − 2ε and width ≤ ε; S denote the rectangles having both height and width ≤ 1 − 2ε. Note that, since a(I) < ε2 and ε = ε/15 < 1/30, H ∪ V ∪ S defines a partition of I, and the total height h(H) of the items in H and the total width w(V ) of the items in V are smaller than ε. Observation 1 All items in S can be packed into a (1 − ε) × (1 − ε) square in polynomial time. Proof The items in S having width at least ε (and therefore total height smaller than ε) are packed one above the other into a (1 − 2ε) × ε rectangle. Symmetrically, the items in S having height at least ε are packed one besides the other into an ε × (1 − 2ε) rectangle. Finally, the items in S having width and 13 1. Define ε, g, and partition the items into the sets H, V, S of horizontal, vertical and small items. 2. For each subset P ⊆ H ∪ V with at most g/ε2 items: a. Neglect the items in H ∪ V whose profit is larger than the minimum profit in P . b. Allow the remaining items in H to be sliced horizontally, and change their profits and widths so as to partition them into subgroups Hk` of items having the same profit/area ratio and the same width. Treat Hk` as a single (sliceable) item. c. Allow the remaining items in V to be sliced vertically, and change their profits and height so as to partition them into subgroups Vk` of items having the same profit/area ratio and the same height. Treat Vk` as a single (sliceable) item. d. For all possible heights of the slices of the Hk` items and all possible widths of the slices of the Vk` items (after suitable discretization), test if these slices and the items in P can be packed in the bin, according to Observation 2. 3. Pack in the bin the highest-profit feasible combination of items in P and slices of the remaining items found in Step 2d. 4. Pack the items in S into a (1 − ε) × (1 − ε) square in the middle of the bin, as explained in Observation 1, and the original items in (H ∪ V ) \ P in the slices. Figure 5: Structure of the PTAS for 2-Dim Knapsack for the case a(I) < δ. height smaller than ε are packed by NFDH into a (1 − 2ε) × (1 − 2ε) square, noting that they all fit since, if they did not, by Lemma 2(iii) their overall area would be at least (1 − 3ε) · (1 − 3ε) > ε2 = δ. The packing of the items in S is illustrated in Figure 7. The key part of the algorithm is then to pack the items in H ∪ V close to the edges of the bin, leaving an empty (1 − ε) × (1 − ε) square for the items in S, given that the total height of the items in H and width of the items in V are at most ε. The structure of this packing is illustrated in Figure 6 and formalized in the following observation. Observation 2 There exists an optimal solution with the following structure. The set of items in H that are packed can be partitioned into Hdown and Hup , where the items in Hdown are packed one above the other (touching) and by decreasing widths starting from the bottom edge of the bin, and the items in Hup are packed one below the other (touching) and by decreasing widths starting from the top edge of the bin. The symmetric property holds for the set of items in V that are packed, partitioned into Vleft and Vright . Proof Consider a generic solution and remove from the bin the items in S that are packed. Note that since 1 − 2ε > 1/2, the widths of all items in H and the heights of all items in V are all > 1/2. Therefore, the items in H are one on top of the other in the solution (possibly not touching each other). Moreover, no item in H can have both an item in V above it and an item in V below it. Then, every item in H can be shifted vertically either down or up until it touches another item in H or the bottom or top edge of the bin. When no shifting is possible, we have a set Hdown (resp., Hup ) of items one above (resp., below) the other (touching) starting from the bottom (resp., top) edge of the bin. It is easy to see 14 that the items in Hdown (resp., Hup ) can then be permuted so that they appear by decreasing widths from bottom to top (resp., top to bottom). The symmetric thing applies to the items in V . ε ε ε ε Figure 6: Packing the items in H ∪ V “close” to the edges of the bin. Figure 7: Packing the items in S. Packing the items in H ∪ V Roughly speaking, in order to find a near-optimal packing of the items in H ∪ V that leaves the (1 − ε) × (1 − ε) square in the middle, we first enumerate the most profitable items in H ∪ V and then restrict attention to the items in H ∪ V with lower profits, being allowed to slice them appropriately. We let g := d(log 1/r)/(log(1 − ε))e + 1 and enumerate all the subsets of g/ε2 items in H ∪ V , so as to be sure to consider the g/ε2 items with highest profit in the optimal solution. For each subset P , we neglect the items in Q := {i ∈ H ∪ V : pi > minj∈P pj }, having profit larger than some item in P , and modify the widths of the items in H \ (P ∪ Q) and the heights of the items in V \ (P ∪ Q) as follows. As in Section 3.1, we allow the items in H \ (P ∪ Q) to be sliced horizontally and partition them into g groups for which the profit/area ratio is approximately the same: Hk := {i ∈ H \ (P ∪ Q) : pi /ai ∈ (r(1 − ε)k , r(1 − ε)k−1 ]}. For each group Hk , we consider the items in increasing order of widths, and define 1/ε subgroups Hk1 , Hk2 , . . ., of consecutive items, so that the total height of the items in each group is εh(Hk ). For all items in each subgroup Hk` , we let the increased width wk` be the largest original width of an item in the subgroup, and the decreased profit/height ratio to be r(1 − ε)k · (1 − 2ε) (recalling that all items in H have width at least 1 − 2ε). The overall number of subgroups of H \ (P ∪ Q), and hence the overall number of distinct increased widths, is g/ε. We treat the items in each subgroup Hk` as a single item of width wk` , height εh(Hk ), and profit r(1 − ε)k · (1 − 2ε) · εh(Hk ) that can be sliced horizontally. We consider in the solution two slices of this item, one to be packed near the bottom edge of the bin and the other to be packed near the top edge of the bin, recalling Figure 6. Moreover, we consider for these slices only heights that are an integer multiple of ε2 h(Hk ) ( including 0). We enumerate all the possible heights of the 2g/ε slices of the items in H \ (P ∪ Q) in the solution, noting that the number of heights to consider for each slice is 1/ε. We do the symmetric thing for the items in V \ (P ∪ Q), by defining groups Vk and then subgroups Vk` , each treated as a single item of height hk` , width εh(Vk ), and profit r(1 − ε)k · (1 − 2ε) · εw(Vk ) that can be sliced vertically into slices whose width is an integer multiple of ε2 w(Vk ). 15 2 The overall number of sets P enumerated is O(|I|g/ε ) and, for each of them, we enumerate (1/ε)2g/ε heights of the slices packed from the subgroups of the items in H \ (P ∪ Q) and (1/ε)2g/ε widths of the slices packed from the subgroups of the items in V \ (P ∪ Q). For each set of items in P and slices, we can test in constant time if they indeed fit into the bin, considering a packing structured as in Observation 2. In particular, we have a constant number of items; for each item in H we have to decide if it is in Hdown or in Hup , and for each item in V we have to decide if it is in Vleft or in Vright . Furthermore, we have to combine the items of H and V in the corners of the bin. This is done by guessing an order of the items in the lower-left and upper-right corner of the bin and pack the items lower-leftmost and upper-rightmost, respectively. Among the subsets that fit, we keep the one with the largest overall profit. In order to define a solution in which the original items in H \ (P ∪ Q) are packed, we consider, for k = 1, . . . , g, both the packed slices from the subgroups of Hk and the original items in Hk in increasing order of widths. According to this order, we pack the items in each slice one above the other until the first item does not fit, in which case we switch to the next slice. Noting that we never run out of items (see formal proof below), we stop when the current item does not fit into the slice having the largest width. We do the symmetric thing to pack the original items in V \ (P ∪ Q). Proof of approximation guarantee The approximation guarantee is proved in the next lemma, in which a few observations are in common with the proof of Lemma 5. Lemma 6 If a(I) < ε2 , the value of the 2-Dim Geometric Knapsack solution produced by the algorithm above is at least (1 − 15ε) opt2KP (I). Proof As in the proof of Lemma 5, we identify a solution simply by the set of items packed. Note that all items in H can be packed into the bin, implying opt2KP (I) ≥ p(H) (and, symmetrically, opt2KP (I) ≥ p(V )). We consider an optimal solution and the iteration of the algorithm in which the set P considered coincides with the g/ε2 items in H ∪ V in the optimal solution having highest profit. The sets Hk , Hk` , Vk , Vk` considered below are those obtained for this P (and the associated Q). We let T 1 denote the solution obtained from the optimal one by replacing, for ` < 1/ε, all the items in Hk` with original widths and profits by items in Hk(`+1) with increased widths wk(`+1) and reduced profit/height ratio r(1 − ε)k · (1 − 2ε). We allow the items in Hk(`+1) to be also taken from outside the optimal solution, and to be sliced horizontally, so as to ensure that the overall height occupied in the optimal solution by the items in Hk` is occupied by these slices in T 1 . For the last group Hk(1/ε) , the associated items in the optimal solution are removed in T 1 . The symmetric thing is done for the items in V \ (P ∪ Q). The profit reduction before removing the items in Hk(1/ε) and Vk(1/ε) is by a factor at most (1 − ε)(1 − 2ε) ≥ (1 − 3ε), noting that the original profit/height ratio of the items in Hk is at most r(1 − ε)k−1 · 1. As to the items in Hk(1/ε) , their overall profit is at most p(Hk(1/ε) ) ≤ r(1 − k−1 ε) ∑g · 1 · εh(Hk k ) (since they have width at most 1). Since opt2KP (I) ≥ p(H) ≥ p(H \ (P ∪ Q)) ≥ k=1 r(1 − ε) · (1 − 2ε) · h(Hk ), we get g ∑ k=1 p(Hk(1/ε) ) ≤ g ∑ r(1 − ε)k−1 · εh(Hk ) ≤ k=1 ε opt (I) ≤ 2εopt2KP (I). (1 − ε)(1 − 2ε) 2KP Overall, considering also the items in Vk(1/ε) , we have p(T 1 ) ≥ (1 − 7ε)opt2KP (I). 16 1. Define the initial high gap-rectangles in the whole bin. 2. Subdivide the bin into horizontal strips of height ε and width 1, numbering them from 1 to (1/ε) from bottom to top, i.e., Strip 1 is the lowest one. 3. For i = 1, . . . , 1/ε: a. Define the initial wide gap-rectangles in Strip i. b. Suitably change the wide gap-rectangles in Strip i so that their number is bounded by a constant, as explained in Claims 2 and 4. c. Suitably change the high gap-rectangles starting in Strip i so that their number is bounded by a constant, as explained in Claim 6. 4. Obtain rectangles of height δ from the wide gap-rectangles and rectangles of width δ from the high gap-rectangles as explained in Claim 1. Figure 8: Structure of the construction in the proof of Lemma 1. We then consider the solution T 2 obtained from T 1 by first arranging the items in T 1 according to Observation 2, so that the (slices of) items of Hk` appear consecutively in Hdown and can be considered as a unique slice (and the same for Hup ), and then rounding the height of this unique slice down to the nearest multiple of ε2 h(Hk ). The overall profit lost for the slice is at most r(1 − ε)k · (1 − 2ε) · ε2 h(Hk ), i.e., summing over the 2g/ε slices of items in H \ (P ∪ Q) and reasoning as above, at most g ∑ (2/ε) · r(1 − ε)k · (1 − 2ε) · ε2 h(Hk ) ≤ 2εopt2KP (I), k=1 leading to p(T 2 ) ≥ p(T 1 ) − 4εopt2KP (I) if the symmetric thing is done also for the (slices of) items in Vk` . We compare the solution T 2 with the solution A determined by the algorithm when (besides having P as above), the heights of the slices of Hk` as well as the widths of the slices of Vk` are as in T 1 . In this case, the definition of Hk` with increased width ensures that, in the final packing of the original items in Hk , if the current item does not fit into the current slice this is because the residual free height of the latter is not sufficient (and not because the width of the slice is too small). This implies that, for each slice of Hk` , of height say h, the profit in T 1 is exactly r(1 − ε)k · (1 − 2ε) · h, while the final profit in A is at least r(1 − ε)k · (1 − 2ε) · h − pi , where i is the current item that does not fit into the slice in the final packing. Given that the items in P are the g/ε2 with highest profit in the optimal solution, and that we neglect the items in Q in our algorithm, we have pi ≤ minj∈P pj ≤ (ε2 /g)opt2KP (I). Considering the symmetric situation for the slices of Vk` and summing over all 4g/ε slices, we get p(A) ≥ p(T 2 ) − (4g/ε) · (ε2 /g)opt2KP (I) = p(T 2 ) − 4εopt2KP (I), completing the proof. 4 Proof of the Structural Lemma In this section we prove Lemma 1, by transforming the original packing of the items in L ∪ H ∪ V into a packing of the set of rectangles listed at the end of the statement. Again, for simplicity, we will assume 17 that 1/ε is integer. In Figure 8 we provide an outline of the construction we apply. In the remainder of the section, by saying “Step x” we will implicitly refer to this figure. 4.1 Main body Formally, Step 1 does the following. Consider the layout of the packing of the items in L ∪ H ∪ V , take the items in V out of the solution and draw a vertical line through the left and right edge of each item in L ∪ H, expanding it down and up until it hits another item or the bottom or top edge of the bin. The rectangular regions of the bin that do not contain items in L ∪ H defined by these lines are called high gap-rectangles (see Figure 9). By possibly slicing vertically the items in V , all these items fit into one of the high gap-rectangles. Figure 9: Definition of the high gap-rectangles (dark-grey rectangles are the items in L ∪ H and lightgrey rectangles the items in V ; the high gap-rectangles are those delimited by the dashed lines). Figure 10: A high gap-rectangle and the associated (slices of) items in V (left) and the associated three rows associated with the three distinct height combinations (right). Now consider, for each high gap-rectangle g, the associated (sliced) items in V , and shift vertically down each of them as much as possible within g, by possibly slicing it further. This has the effect that for every (sliced) item in V , each point in its bottom edge is either touching the bottom edge of g, or the top edge of another item, see Figure 10, left.) Having done this, the height h of the used area inside g is a combination of the heights of at most 1/ε items in V . Redefine the height of g to be equal to h, and from now on denote it by h(g) (in particular, this removes all high gap-rectangles of height smaller than ε, that contain no item in V ). Note ( that, ) after this redefinition, the number of distinct heights of the high gap-rectangles is at most q := d+1/ε , since the number of distinct heights of the items in V is at d most d. Note that one could do the symmetric thing for the items in H, taking them out of the solution, building wide gap-rectangles by drawing horizontal lines through the bottom and top edge of each item 18 in L ∪ V , and redefining their width w(g) as a combination of the widths of at most 1/ε items in H. In this case, although the number of distinct widths of the wide gap-rectangles and of distinct heights of the high gap-rectangles would be bounded by the constant q after the above redefinition, the number of (wide and high) gap-rectangles would not. The technical part of the proof is to carefully define wide and high gap-rectangles so that their total number is indeed bounded by a constant p, depending on q and ε. In the hope of improving readability, we postpone this part to Section 4.2 and show that, once this is done, the proof of the lemma follows easily. Claim 1 If the number of wide and high gap-rectangles in the bin is bounded by a constant p, then Lemma 1 follows by letting f (d, ε) := pq. Proof We define the packing of the rectangles listed at the end of the statement of the lemma. Recall that all (sliced) items in H and V are contained respectively in the wide and high gap-rectangles. Consider a given high gap-rectangle g, as in Figure 10, left. The (sliced) items in V within g are subdivided in columns of items of the same width one besides the other, each containing different combinations of the d heights (for instance, in Figure 10, left, there are seven columns). Exchange these columns within g so that columns associated with the same combination of the heights appear consecutively from the left to the right. Moreover, order the items in each column from bottom to top (say according to increasing heights) so that, for two consecutive columns associated with the same height combination, items having the same height are vertically aligned. Then, merge consecutive columns associated with the same width combination into a unique column whose width is the sum of the two original ones. This is illustrated in Figure 10, right, where at the end we have only three columns. Finally, round down the width of each column to the nearest integer multiple of δ (the parameter in the statement of the lemma). Do the symmetric thing for each wide gap-rectangle g and the associated rows of (sliced) items in H. In particular, at the end g contains at most q distinct rows, whose height is rounded down to the nearest integer multiple of δ. Before rounding down the widths of the columns within the gap-rectangles, the total width of the columns containing items of height hj is at least w(hj ) (i.e., all items in V , possibly sliced, are packed). After rounding, the total width of these is at least w(hj ) − pqδ, since, in the worst case, each rounding of the width of a column reduces this total width by δ, and the overall number of columns is at most pq, i.e., one for each height combination and high gap-rectangle. As this applies to all heights hj and the symmetric counterpart to all widths in wj , the proof of Lemma 1 follows, letting f (d, ε) := pq. 4.2 Reducing the number of wide and high gap-rectangles to a constant According to the discussion in the previous section, what we still have to provide is a packing in which the number of wide and high gap-rectangles is bounded by a constant. In order to achieve this, not only it is necessary to apply some transformation to the wide and high gap-rectangles defined initially, but it also appears to be necessary to treat wide gap-rectangles in an asymmetric way with respect to high gap-rectangles, which looks strange at first sight. In the remainder, we say that an item in L or a (wide or high) gap-rectangle starts in some position if its bottom-left corner is in this position. It ends in some position if its top-right corner is in this position. As mentioned in Figure 8, we subdivide the bin into 1/ε horizontal strips of width 1 and height ε. Note that all items in L and all high gap-rectangles have a height of at least ε. Therefore, non of these items starts and ends in the same strip. Note that, while high gap-rectangles are all initialized in Step 1, and then changed in Step 3c, wide gap-rectangles are initialized strip by strip in Step 3a by taking into account the current high gaprectangles. In particular, in order to initialize the wide gap-rectangles in Strip i, we draw horizontal lines through the bottom edge of each item in L and high gap-rectangle (with redefined height) starting in 19 Strip i, through the top edge of each item in L and high gap-rectangle ending in Strip i, and through the bottom and top edge of Strip i itself (so that all these wide gap-rectangles are entirely contained in the strip). Then, we redefine the widths of these wide gap-rectangles so that they are at most q, as explained in Section 4.1. Since we decreased the widths of the wide gap-rectangles and deleted the wide gap-rectangles without an item in H, there might be some empty space in the strips. On the other hand, there are only q different widths of wide gap-rectangles and we can merge two gap-rectangles if they have the same width and if they are situated on top of each other without overlapping. Furthermore, we want to merge two wide gap-rectangles if we can shift or extend one wide gap-rectangle using the empty space that occurred by rounding the widths. We have to provide the details for steps 3b and 3c. In step 3b, we consider the following operations on a wide gap-rectangle g: (i) shift g left or right; (ii) increase the height of g; (iii) increase the width of g to the one of another wide gap-rectangle; (iv) merge g with another wide gap-rectangle g 0 of the same width, if the top edge of g coincides with the bottom edge of g 0 . Figure 11: Three wide gaprectangles, with an item of H in the lower and upper wide gaprectangle. Figure 12: Decreased widths of the wide gap-rectangles. The wide gap-rectangle in the middle is deleted. Figure 13: Increase the height of the upper gap-rectangle so that it touches the lower one; Operation (ii). We first give a bound on the number of wide gap-rectangles in Strip 1, which is independent of the number of high gap-rectangles. Claim 2 By suitably applying Operations (i)-(iv) in Step 3b, the number of wide gap-rectangles in Strip 1 can be bounded by q/ε. Proof Apply Operation (i) to shift left all the wide gap-rectangles in Strip 1, until their left edge touches either the left edge of the bin, or the right edge of an item in L or a high gap-rectangle (by the definition of wide gap-rectangles, it cannot touch the right edge of another wide gap-rectangle, see Figure 11 and Figure 12). Afterwards, if needed, apply Operation (ii) to increase the height of the wide gap-rectangles starting in Strip 1, by shifting down their bottom edges, until the bottom edge of each of them touches either the top edge of another wide gap-rectangle or the bottom edge of the bin, see Figure 13. Note that, after this operation, the bottom edge of each wide gap-rectangle g starting higher than the bottom edge of the bin touches the top edge of exactly one wide gap-rectangle (note in particular that g cannot have an item in L or a high gap-rectangle below, as their height is at least ε). Consider now two wide gap-rectangles g1 , g2 such that the bottom edge of g2 touches the top edge of g1 . If w(g1 ) ≤ w(g2 ), if needed, g1 can be shifted horizontally by applying Operation (i) so that every point of its top edge touches the bottom edge of g2 , see Figure 14. Then, if w(g1 ) < w(g2 ), the width of g1 can be increased 20 Figure 14: Shift the lower wide gap-rectangle so that it is situated directly under the upper wide gap-rectangle without overlapping; Operation (i) Figure 15: Enlarge the width of the lower wide gap-rectangle so that the widths of both wide gap-rectangles is identical; Operation (iii) Figure 17: Wide gap-rectangles in Strip 1. Figure 16: Merge the two wide gap-rectangles and decrease the total number of wide gap-rectangles by one; Operation (iv) Figure 18: Wide gap-rectangles starting on a small vertical line. to be equal to the width of g2 by applying Operation (iii), see Figure 15. Finally, the two rectangles can be merged by applying Operation (iv), see Figure 16. After applying the above construction, we have that, for two wide gap-rectangles g1 , g2 such that the bottom edge of g2 touches the top edge of g1 , w(g1 ) > w(g2 ). In other words, each vertical line intersects at most q wide gap-rectangles starting in Strip 1 (one for each distinct width), whose widths are increasing from bottom to top, see Figure 17. Given that the width of each wide gap-rectangle is at least ε, this proves the claim. Analogously, we give a bound on the number of wide gap-rectangles in a generic strip, as a function of the number of high gap-rectangles starting below the strip. For this purpose, we first prove an intermediate claim. Claim 3 By suitably applying Operations (i)-(iv) in Step 3b for i > 1, the number of wide gaprectangles starting or ending in any vertical line of height at most ε can be bounded by 2q − 1. Proof We prove the claim on the number of wide gap-rectangles starting in the line; the case of wide gap-rectangles ending in the line is symmetric. First of all, if there is a wide gap-rectangle starting to the right of the line that can be shifted left so as to start in the line, do this by applying Operation (i). Afterwards, consider two wide gap-rectangles g1 , g2 starting in the line, with g2 to the top of g1 but such that the top edge of g1 does not touch the bottom edge of g2 . If there is no other wide gap-rectangle starting in the line between g1 and g2 , assuming w(g1 ) ≤ w(g2 ), apply Operation (iii) to increase the height of g1 , by shifting up its bottom edge, until it touches g1 (the case w(g1 ) > w(g2 ) is symmetric). Note the vertical line has a height of at most ε. Thus, it is not possible that there is a high gaprectangle or an item of L between the two wide gap-rectangles g1 and g2 . Therefore, we can assume that the wide gap-rectangles starting in the line touch each other, see Figure 18. Consider now three wide gap-rectangles g1 , g2 , g3 starting in the line such that the top edge of g1 touches the bottom edge of g2 and the top edge of g2 touches the bottom edge of g3 . If w(g2 ) ≤ min{w(g1 ), w(g3 )}, assuming w(g1 ) ≥ w(g3 ), the width of g2 can be increased to be equal to the width of g3 by applying Operation (iii) and then the two rectangles can be merged by applying Operation (iv) (the case w(g1 ) < w(g3 ) is symmetric). 21 After applying the above transformation, we have that the heights of the wide gap-rectangles starting in the line, considering them from bottom to top, are either strictly increasing, or strictly decreasing, or first strictly increasing and then strictly decreasing, see again Figure 18. This proves the claim as the total number of distinct width values is at most q. Now we are ready to prove the bound for a generic Strip i. Claim 4 By suitably applying Operations (i)-(iv) in Step 3b for i > 1, the number of wide gaprectangles in Strip i can be bounded by q/ε + (2q − 1)(2m + 2/ε + 2), where m is the number of high gap-rectangles starting below Strip i. Proof Apply Operation (i) to try to shift either right or left all wide gap-rectangles in Strip i so that their left or right edge touches the left or right edge either of a high gap-rectangle starting below the strip, or of an item in L, or of the bin. Note that this will not be possible for a subset of the wide gap-rectangles, say G, that end up touching a high gap-rectangle starting in Strip i both to the right and to the left. For the wide gap-rectangles in G, a construction analogous to the one in the proof of Claim 2 shows that their number can be bounded by q/ε. For the remaining wide gap-rectangles, we estimate an upper bound on the number of vertical edges intersecting the Strip i from below and use Claim 3 on each of them. The number of vertical lines of height at most ε on which the wide gap-rectangles not in G may start or end is at most 2m (two for each high gap-rectangle starting below the strip) plus 2 (the left and right edges of the bin) plus 2/ε (for each ε × ε square in which the strip may be subdivided, at most two edges of items in L), i.e., 2m + 2/ε + 2. Therefore, by applying the construction in the proof of Claim 3, we have that the number of wide gap-rectangles not in G starting in the strip is at most (2q − 1)(2m + 2/ε + 2). What remains to be done is to bound the number of high gap-rectangles starting in each strip as a function of the number of wide gap-rectangles in that strip and high gap-rectangles starting below the strip. We consider the symmetric counterparts of Operations (i)-(iv) for a high gap rectangle g, still referred as (i)-(iv), where the only asymmetry is that in Operation (i) we shift high gap-rectangles only down, (whereas shifting wide gap-rectangles both left and right is essential). The counterpart of Claim 3 reads as follows. Claim 5 By suitably applying Operations (i)-(iv), the number of high gap-rectangles starting in any horizontal line of width ε can be bounded by 2q − 1. The bound for a generic Strip i is: Claim 6 By suitably applying operations (i)-(iv), the number of high gap-rectangles starting in Strip i can be bounded by (2q − 1)(2m + 3/ε), where m is the sum of the number of wide gap rectangles in Strip i and the number of high gap-rectangles starting below Strip i. Proof Apply Operation (i) to shift down as much as possible all high gap-rectangles starting in Strip i, possibly stopping when their bottom edge touches the bottom edge of the strip. Then, subdivide each horizontal line in which the high rectangles start into horizontal lines of width (at most) ε and apply the construction in the proof of Claim 5 for each line. The proof of the current claim follows by showing that there are at most 2m+3/ε horizontal lines of width at most ε in which high gap-rectangles could start. To count these lines, subdivide Strip i into 1/ε squares of size ε × ε. In each square, high gap-rectangles can start: 22 A. either in the bottom edge of the square or in the top edge of a wide gap-rectangle not starting nor ending in the square; B. in the top edge of an item in L intersecting the square; C. in the top edge of a wide gap-rectangle starting or ending in the square; D. in the top edge of a high gap-rectangle starting below Strip i and intersecting the square. Summing over all the 1/ε squares, the lines in case A are at most 1/ε, those in case B are at most 2/ε, since at most 2 items in L can intersect each square, and the lines in cases C and D are at most 2m, since each wide gap-rectangle starts and ends once in Strip i and each high gap-rectangle starting below Strip i can intersect at most two squares. At this point it is clear that the total number of wide and high gap-rectangles is bounded by a constant if the constructions in the proofs of the claims above are applied in Steps 3b and 3c in the procedure above. high Namely, letting nwide and ni denote, respectively, the number of wide and high gap-rectangles starting i high + 3/ε), and, for i = 1, . . . , 1/ε, in Strip i, we have the recursion nwide ≤ q/ε, n1 ≤ (2q − 1)(2nwide 1 1 ∑ ∑i−1 high high high i−1 wide ni ≤ q/ε + (2q − 1)(2 h=1 nh + 2/ε + 2), ni ≤ (2q − 1)(2(nwide + h=1 nh ) + 3/ε). i Without going into the (boring) details of the calculation, this yields a bound (O(q))2/ε /ε on the total number p of wide and high gap-rectangles. References [1] N. Bansal, J. Correa, C. Kenyon and M. Sviridenko. Bin packing in multiple dimensions: inapproximability results and approximation schemes. Mathematics of Operations Research 31:31–49, 2006. [2] N. Bansal, A. Caprara, K. Jansen, L. Prädel and M. Sviridenko. A structural lemma in 2dimensional packing, and its implications on approximability. In Y. Dong, D.-Z. Du, O.H. Ibarra (eds.) Proceedings of the 20th International Symposium on Algorithms and Computation (ISAAC 2009), 77–86, Lecture Notes in Computer Science 5878, Springer-Verlag, 2009. [3] N. Bansal, A. Caprara and M. Sviridenko. Improved approximation algorithms for multidimensional bin packing problems. In Proceedings of the 47-th Annual IEEE Symposium on Foundations of Computer Science (FOCS 2006), 697–708, 2006. [4] N. Bansal, A. Caprara and M. Sviridenko. A new approximation method for set covering problems, with applications to multidimensional bin packing. SIAM Journal on Computing, 39:1256–1278, 2009. [5] N. Bansal, A. Lodi and M. Sviridenko. A tale of two dimensional bin packing. In Proceedings of the 46-th Annual IEEE Symposium on Foundations of Computer Science (FOCS 2005), 657–666, 2005. [6] N. Bansal and M. Sviridenko. Two-dimensional bin packing with one dimensional resource augmentation. Discrete Optimization 4:143–153, 2007 [7] A. Caprara. Packing d-Dimensional Bins in d Stages. Mathematics of Operations Research 33:203– 215, 2008. 23 [8] A. Caprara, A. Lodi and M. Monaci, Fast approximation schemes for two-stage, two-dimensional bin packing. Mathematics of Operations Research 30:150–172, 2005. [9] E.G. Coffman, Jr., M.R. Garey, D.S. Johnson and R.E. Tarjan. Performance bounds for leveloriented two-dimensional packing algorithms. SIAM Journal on Computing, 9:808–826, 1980. [10] J.R. Correa. Resource augmentation in two-dimensional packing with orthogonal rotations. Operations Research Letters 34:85–93, 2006. [11] A.V. Fishkin, O. Gerber and K. Jansen. On efficient weighted rectangle packing with large resources. In X. Deng, D.-Z. Du (eds.) Proceedings of the 16-th International Symposium on Algorithms and Computation (ISAAC 2005), 1039–1050, Lecture Notes in Computer Science 3827, Springer-Verlag, 2005. [12] A.V. Fishkin, O. Gerber, K. Jansen and R. Solis-Oba. Packing weighted rectangles into a square. In J. Jedrzejowicz, A. Szepietowski (eds.) Proceedings of the 30-th International Symposium, on Mathematical Foundations of Computer Science (MFCS 2005), 352–363, Lecture Notes in Computer Science 3618, Springer-Verlag, 2005. [13] M.D. Grigoriadis, L.G. Khachiyan, L. Porkolab and J. Villavicencio. Approximate max-min resource sharing for structured concave optimization. SIAM Journal on Optimization, 11:1081–1091, 2001. [14] M. Grötschel, L. Lovász and A. Schrijver. Geometric algorithms and combinatorial optimization. Springer-Verlag, Berlin, 1988. [15] R. Harren and R. van Stee. Improved absolute approximation ratios for two-dimensional packing problems. In S. Naor (ed.) Proceedings of the 12-th International Workshop on Approximation Algorithms for Combinatorial Optimization Problems (APPROX’09), 177–189, 2009. [16] R. Harren, K. Jansen, L. Prädel and R. van Stee. A 5/3 + ε-Approximation for Strip Packing. In F. Dehne and J. Iacono and J.-R. Sack (eds.) Proceedings of the 12-th International Symposium on Algorithms and Data Structures (WADS 2011), 475-487, Lecture Notes in Computer Science 6844, Springer-Verlag, 2011. [17] K. Jansen, L. Prädel and U.M. Schwarz. A 2-approximation for 2D bin packing. In F. Dehne, M. Gavrilova, J.-R. Sack, C.D. Tóth (Eds.)Proceedings of the 11-th International Symposium on Algorithms and Data Structures (WADS 2009), 399–410, Lecture Notes in Computer Science 5664, Springer-Verlag, 2009. [18] K. Jansen and R. Solis-Oba. New approximability results for 2-dimensional packing problems. In L. Kucera, A. Kucera (eds.) Proceedings of the 32-nd International Symposium, on Mathematical Foundations of Computer Science (MFCS 2007), 103–114, Lecture Notes in Computer Science 4708, Springer-Verlag, 2007. [19] K. Jansen and R. Solis-Oba. A polynomial time approximation scheme for the square packing problem. In A. Lodi, A. Panconesi and G. Rinaldi (eds.) Proceedings of the 13-th Conference on Integer Programming and Combinatorial Optimization (IPCO 2008), 184–198, Lecture Notes in Computer Science 5035, Springer-Verlag, 2008. [20] K. Jansen and R. van Stee. On strip packing with rotations. In Proceedings of the 37-th Annual ACM Symposium on the Theory of Computing (STOC 2005), 755–761, 2005. 24 [21] K. Jansen and G. Zhang. Maximizing the total profit of rectangles packed into a rectangle. Algorithmica, 47:323-342, 2007. [22] N. Karmarkar and R.M. Karp. An efficient approximation scheme for the one-dimensional binpacking problem. In Proceedings of the 23-rd Annual IEEE Symposium on Foundations of Computer Science (FOCS 1982), 312–320, 1982. [23] C. Kenyon and E. Rémila. A near-optimal solution to a two-dimensional cutting stock problem. Mathematics of Operations Research, 25:645–656, 2000. [24] C.C. Lee and D.T. Lee. A simple on-line bin packing algorithm. Journal of the ACM, 32:562–572, 1985. [25] J.Y.-T. Leung, T.W. Tam, C.S. Wong, G.H. Young and F.Y.L. Chin. Packing squares into a square. Journal of Parallel Distributed Computation,10:271–275,1990. [26] S.A. Plotkin, D. Shmoys and E. Tardos. Fast approximation algorithms for fractional packing and covering problems. Mathematics of Operations Research, 20:257–301, 1995. [27] A. Steinberg. A strip-packing algorithm with absolute performance bound 2. SIAM Journal on Computing, 26:401–409, 1997. [28] G. Zhang. A 3-approximation algorithm for two-dimensional bin packing. Operations Research Letters, 33:121-126, 2005. Appendix: Proof of Lemma 2 Let V1 , . . . , Vp be the shelves packed into the first bin by NFDH, and Vp+1 be the first shelf packed into the second bin. Let Hj be the height of Vj (i.e., the height of the first, tallest, item in Vj ), Wj be the width of Vj (i.e., the sum of the widths of the items in Vj ), Fj be the width of the first, tallest, item ∑ in Vj , and Aj be the area of the items in Vj . Note that p+1 j=1 Hj > 1, otherwise shelf Vp+1 would be packed in the first bin. In order to prove (iii), note that Wj ≥ 1 − maxi∈I wi for j = 1, . . . , p, otherwise the first item in shelf j + 1 would be packed in shelf j. As all the heights of the items in shelf j are at least Hj+1 , this implies that their total area is at least (1 − maxi∈I wi ) · Hj+1 . Summing over all shelves in the first ∑ ∑p+1 bin we get a(S1 ) ≥ (1 − maxi∈I wi ) · p+1 j=2 Hj from which (iii) follows as j=2 Hj > 1 − H1 = 1 − maxi∈I hi . The proof of (i) and (ii) is slightly more involved. We need inequalities Aj + Aj+1 ≥ Hj+1 for j = 1, . . . , p, holding since all items in Vj and the first item in Vj+1 have all height at least Hj+1 and total width larger than 1. Moreover, we also H1 and A1 + A2 ≥ ∑ need inequalities A1 ≥ F1 · ∑ F1 ·H1 +(1−F1 )H2 . Using the identity a(S1 ) = pj=1 Aj = A1 +A2 /2+Ap /2+ pj=3 (Aj−1 +Aj )/2, we obtain a(S1 ) ≥ A1 /2 + (A1 + A2 )/2 + p ∑ (Aj−1 + Aj )/2 j=3 ≥ F1 · H1 − (F1 · H2 )/2 + H2 /2 + p ∑ Hj /2 j=3 ≥ (F1 · H1 )/2 + (1 − H1 − Hp+1 )/2, 25 (7) ∑ where we also used Ap ≥ 0 in the first inequality and H1 ≥ H2 and pj=2 Hj > 1 − H1 − Hp+1 in the last. We now prove (i). If H1 ≥ 1/2, we have a(S1 ) ≥ A1 ≥ F1 · H1 ≥ H12 ≥ 1/4 and we are done. If H1 < 1/2, note that p ≥ 2. If Hp+1 ≥ 1/4, we have a(S1 ) ≥ A1 + A2 ≥ H2 ≥ 1/4 and we are done. Finally, if Hp+1 < 1/4, (7) implies a(S1 ) > H12 /2 + 3/8 − H1 /2, which is at least 1/4 by a trivial calculation. We finally prove (ii). We apply the same reasoning to the second bin. Let H` be the height of the first shelf in the third bin. The equation analogous to (7) for the second bin is a(S2 ) ≥ (Fp+1 · Hp+1 )/2 + (1 − Hp+1 − H` )/2. (8) Now the proof consists of case analysis: 1. If H1 ≤ 1/4 or Hp+1 ≤ 1/4 then (7) implies a(S1 ) ≥ (1 − H1 − Hp+1 )/2 ≥ 1/4 or respectively a(S2 ) ≥ (1 − Hp+1 − H` )/2 ≥ 1/4 and we are done. 2. If Hp+1 ≥ 1/2, then we have a(S1 ) + a(S2 ) ≥ Hp+1 ≥ 1/2 and we are done. 3. If Hp+1 > 1/4 and p ≥ 2, we have a(S1 ) ≥ A1 + A2 ≥ H2 ≥ 1/4 and we are done (recall that p is the number of shelves in the first bin). 4. Since we have already considered the cases Hp+1 ≤ 1/4 and Hp+1 ≥ 1/2, the only case left is p = 1 and Hp+1 ∈ (1/4, 1/2). (a) If W1 · H2 ≥ 1/4 then a(S1 ) ≥ A1 ≥ W1 · H2 ≥ 1/4 and we are done. (b) Otherwise, since W1 + F2 > 1, we have F2 > 1 − 1/(4H2 ). Since Hp+1 ≤ 1/2, the second bin contains at least two shelves and V2 = Vp+1 is the first shelf. If H` > 1/4, we have a(S2 ) ≥ H3 > 1/4 and we are done. Finally, we must have 1/4 < H2 < 1/2 and H` < 1/4. Using (8) we derive a(S2 ) ≥ (F2 · H2 )/2 + (1 − H2 − H` )/2 ≥ H2 /2 − 1/8 + (1 − H2 − H` )/2 ≥ 1/4. Note that the bounds in (i), (ii) and (iii) are all tight for the example in which all items have height and width 1/2 + ε for arbitrarily small ε, and that the example in Figure 3 shows that a(S1 ) can be arbitrarily small in case (ii). 26