Online Packing to Minimize Area or Perimeter
OOnline Packing to Minimize Area or Perimeter
Mikkel Abrahamsen ∗ Lorenzo Beretta ∗ January 21, 2021
Abstract
We consider online packing problems where we get a stream of axis-parallel rectangles. Therectangles have to be placed in the plane without overlapping, and each rectangle must be placedwithout knowing the subsequent rectangles. The goal is to minimize the perimeter or the area of theaxis-parallel bounding box of the rectangles. We either allow rotations by 90 ◦ or translations only.For the perimeter version we give algorithms with an absolute competitive ratio slightly less than4 when only translations are allowed and when rotations are also allowed.We then turn our attention to minimizing the area and show that the asymptotic competitiveratio of any algorithm is at least Ω( √ n ), where n is the number of rectangles in the stream, andthis holds with and without rotations. We then present algorithms that match this bound in bothcases and the competitive ratio is thus optimal to within a constant factor. We also show that thecompetitive ratio cannot be bounded as a function of Opt . We then consider two special cases.The first is when all the given rectangles have aspect ratios bounded by some constant. Theparticular variant where all the rectangles are squares and we want to minimize the area of thebounding square has been studied before and an algorithm with a competitive ratio of 8 has beengiven [Fekete and Hoffmann, Algorithmica, 2017]. We improve the analysis of the algorithm andshow that the ratio is at most 6, which is tight.The second special case is when all edges have length at least 1. Here, the Ω( √ n ) lower bound stillholds, and we turn our attention to lower bounds depending on Opt . We show that any algorithmfor the translational case has an asymptotic competitive ratio of at least Ω( √ Opt ). If rotations areallowed, we show a lower bound of Ω( √ Opt ). For both versions, we give algorithms that matchthe respective lower bounds: With translations only, this is just the algorithm from the general casewith competitive ratio O ( √ n ) = O ( √ Opt ). If rotations are allowed, we give an algorithm withcompetitive ratio O (min {√ n, √ Opt } ), thus matching both lower bounds simultaneously. Problems related to packing appear in a plethora of big industries. For instance, two-dimensional versionsof packing arise when a given set of pieces have to be cut out from a large piece of material so as tominimize waste. This is relevant to clothing production where cutting patterns are cut out from a rollof fabric, and similarly in leather, glass, wood, and sheet metal cutting.In some applications, it is important that the pieces are placed in an online fashion. This means thatthe pieces arrive one by one and we need to decide the placement of one piece before we know the onesthat will come in the future. This is in contrast to offline problems, where all the pieces are known inadvance. Problems related to packing were some of the first for which online algorithms were describedand analyzed. Indeed, the first use of the terms “online” and “offline” in the context of approximationalgorithms was in the early 1970s and used for algorithms for bin-packing problems [14].In this paper, we study online packing problems where the pieces can be placed anywhere in the planeas long as they do not overlap. The goal is to minimize the region occupied by the pieces. The pieces areaxis-parallel rectangles, and they may or may not be rotated by 90 ◦ . We want to minimize the size ofthe axis-parallel bounding box of the pieces, and the size of the box is either the perimeter or the area.This results in four problems: PerimeterRotation , PerimeterTranslation , AreaRotation , and
AreaTranslation . ∗ Basic Algorithms Research Copenhagen (BARC), University of Copenhagen. BARC is supported by the VILLUMFoundation grant 16582. Lorenzo Beretta received funding from the European Union’s Horizon 2020 research and innovationprogram under the Marie Sk(cid:32)lodowska-Curie grant agreement No. 801199. a r X i v : . [ c s . C G ] J a n ompetitive analysis The competitive ratio of an online algorithm is the equivalent of the approx-imation ratio of an (offline) approximation algorithm. The usual definitions [7, 9, 11] of competitiveratio (or worst case ratio , as it may also be called [11]) can only be used to describe that the cost ofthe solution produced by an online algorithm is at most some constant factor higher than the cost
Opt of the optimal (offline) solution. In the study of approximation algorithms, it is often the case that theapproximation ratio is described not just as a constant, but as a more general function of the input. Inthe same way, we generalize the definition of competitive ratios to support such statements about onlinealgorithms.Consider an algorithm A for one of the packing problems studied in this paper. Let L be the setof non-empty streams of rectangular pieces. For a stream L ∈ L , we define A ( L ) to be the cost of thepacking produced by A and let Opt ( L ) be the cost of the optimal (offline) packing. We say that A hasan absolute competitive ratio of f ( L ), for some function f : L −→ R + which may just be a constant, ifsup L ∈L A ( L ) Opt ( L ) f ( L ) ≤ . We say that A has an asymptotic competitive ratio of f ( L ) iflim sup c −→∞ (cid:18) sup (cid:26) A ( L ) Opt ( L ) f ( L ) | L ∈ L and Opt ( L ) = c (cid:27)(cid:19) ≤ . In this paper, the functions f ( L ) that we consider will be (i) constants, (ii) functions of the numberof pieces n = | L | , (iii) functions of Opt ( L ).By definition, if A has an absolute competitive ratio of f ( L ), then A also has an asymptotic compet-itive ratio of f ( L ), but A may also have a smaller asymptotic competitive ratio g ( L ) < f ( L ). However,the following easy lemma shows that for the problems studied in this paper, any constant asymptoticcompetitive ratio can be matched to within an arbitrarily small difference by an absolute competitiveratio. Lemma 1.
For the problems studied in this paper, if an algorithm A has an asymptotic competitive ratioof some constant c > , then for every ε > , there is an algorithm A (cid:48) with absolute competitive ratio c + ε . It follows that any constant lower bound on the absolute competitive ratio is also a lower bound onthe asymptotic competitive ratio.Proof. Let n >
Opt ( L ) ≥ n , we have A ( L ) c Opt ( L ) ≤ ε/c . When the first piece p of a stream L is given, A (cid:48) chooses a scale factor λ > p is scaled up by λ , theresulting piece p (cid:48) := λp alone has cost n (i.e., the area or the perimeter of p (cid:48) is n ). The algorithm A (cid:48) now imitates the strategy of A on the stream λL we get by scaling up all pieces of L by λ . We then getthat A (cid:48) ( L )( c + ε ) Opt ( L ) = A ( λL )( c + ε ) Opt ( λL ) ≤ (1 + ε/c ) cc + ε = 1 . For this reason, we do not distinguish between absolute and asymptotic competitive ratios when theratio is a constant. Note that the argument does not work when the competitive ratio is a non-constantfunction of
Opt . Results and structure of the paper
We develop online algorithms for the perimeter versions
Peri-meterRotation and
PerimeterTranslation , both with a competitive ratio slightly less than 4.These algorithms are described in Section 2. The idea is to partition the positive quadrant into bricks ,which are axis-parallel rectangles with aspect ratio √
2. In each brick, we build a stack of pieces whichwould be too large to place in a brick of smaller size. Online packing algorithms using higher-dimensionalbricks were described by Januszewski and Lassak [15] and our algorithms are inspired by an algorithmof Fekete and Hoffmann [13] that we will get back to. Interestingly, we show in Section 2.2 that a moredirect adaptation of the algorithm of Fekete and Hoffmann has a competitive ratio of at least 4, andis thus inferior to the algorithm we describe. We also give a lower bound of 4 / / AreaRotation and
AreaTranslation . We show inSection 3.1 that for any algorithm A processing a stream of n pieces cannot achieve a better competitive2 easure Version Trans./Rot. Lower bound Upper bound Perimeter General Translation 4 /
3, Sec. 2.3 4 − ε , Sec. 2.1Rotation 5 /
4, Sec. 2.3 4 − ε , Sec. 2.1Area General Translation Ω( √ n ) & ∀ f : Ω( f ( Opt )),Sec. 3.1 O ( √ n ), Sec. 3.2Rotation Ω( √ n ) & ∀ f : Ω( f ( Opt )),Sec. 3.1 O ( √ n ), Sec. 3.2Sq.-in-sq. N/A 16/9, Sec. 3.3 6, Sec. 3.3Long edges Translation Ω( √ Opt ), Sec. 3.4 O ( √ n ) = O ( √ Opt ),Sec. 3.5Rotation Ω(max {√ n, √ Opt } ),Sec. 3.1 and 3.4 O (min {√ n, √ Opt } ),Sec. 3.5Table 1: Results of this paper.ratio than Ω( √ n ), and this holds for all online algorithms and with and without rotations allowed. Italso holds in the special case where all the edges of pieces have length at least 1. We furthermoreshow that when the pieces can be arbitrary, there can be given no bound on the competitive ratio as afunction of Opt for
AreaRotation nor
AreaTranslation . In Section 3.2 we describe the algorithms
DynBoxTrans and
DynBoxRot , which achieve a O ( √ n ) competitive ratio for AreaTranslation and
AreaRotation , respectively, for an arbitrary stream of n pieces. This is thus optimal up to aconstant factor when measuring the competitive ratio as a function of n . Both algorithms use a row ofboxes of exponentially increasing width and dynamically adjusted height. In these boxes, we pack piecesusing a next-fit shelf algorithm, which is a classic online strip packing algorithm first described by Bakerand Schwartz [6].We then turn our attention to two special cases.The first special case is when the aspect ratio is bounded by a constant α ≥
1. A case of particularinterest is when all pieces are squares, i.e., α = 1. It is natural to have the same requirement to thecontainer as to the pieces, so let us assume that the goal is to minimize the area of the axis-parallelbounding square of the pieces, and call the problem SquareInSquareArea . This problem was studiedby Fekete and Hoffmann [13], and they gave an algorithm for the problem and proved that it was 8-competitive. We prove that the same algorithm is in fact 6-competitive and that this is tight. It easilyfollows that if the aspect ratio is bounded by an arbitrary constant α ≥ O (1)-competitive algorithm.The second special case is when all edges are long , that is, when they have length at least 1 (anyother constant will work too). In Section 3.4, we show that under this assumption, there is a lower boundof Ω( √ Opt ) for the asymptotic competitive ratio of
AreaTranslation , whereas for
AreaRotation ,we get the lower bound Ω( √ Opt ). In Section 3.5, we provide algorithms for the area versions when theedges are long. For both problems
AreaRotation and
AreaTranslation , we give algorithms thatmatch the lower bounds of Section 3.4 to within a constant factor. With translations only, this is just thealgorithm from the general case with competitive ratio O ( √ n ) = O ( √ Opt ). The algorithm with ratio O ( √ Opt ) for the rotational case follows the same scheme as the algorithms for arbitrary rectangles ofSection 3.2, but differ in the way we dynamically increase boxes’ heights. We finally describe an algo-rithm for the rotational case with competitive ratio O (min {√ n, √ Opt } ), thus matching the lower boundsΩ( √ n ) and Ω( √ Opt ) simultaneously. Actually, the two lower bounds for
AreaRotation can be sum-marized by Ω(max {√ n, √ Opt } ), while we manage to achieve a competitive ratio of O (min {√ n, √ Opt } ).However, this gives no contradiction, it simply proves that the edge cases that have a competitive ratioof at least Ω( √ Opt ) must satisfy
Opt = O ( n ), and those for which the competitive ratio is at leastΩ( √ n ) satisfy n = O ( √ Opt ).We summarize the results in Table 1.
Related work
The literature on online packing problems is rich. See the surveys of Christensen, Khan,Pokutta, and Tetali [9], van Stee [25, 26], and Csirik and Woeginger [11] for an overview. It seems that3he vast majority of previous work on online versions of two-dimensional packing problems is concernedwith either bin packing (packing the pieces into a minimum number of unit squares) or strip packing(packing the pieces into a strip of unit width so as to minimize the total height of the pieces). From amathematical point of view, we find the problems studied in this paper perhaps even more fundamentalthan these important problems in the sense that we give no restrictions on where to place the pieces,whereas the pieces are restricted by the boundaries of the bins and the strip in bin and strip packing.Another related problem is to find the critical density of online packing squares into a square. Inother words, what is the maximum Σ ≤ k given m -gons into a convex container of minimum area with edges in n fixed directions. When the m -gonscan be non-convex, the running time is O (( m + n ) k − ( n + log m )), and when they are convex, therunning times are O (( m + n ) k ( n + log m )) or O ( m k − ( n k +1 + log m )). Milenkovich and Daniels [22]described different algorithms for the same problems. Milenkovich [21] also studied the same problemwhen arbitrary rotations are allowed and the container is either a strip with a fixed width, a homothetof a given convex polygon, or an arbitrary rectangle (as in our work). He gave (1 + ε )-approximationalgorithms (no explicit running times are given, but they are apparently also exponential).Some algorithms have been described for computing the packing of two or three convex polygons thatminimizes the perimeter or area of the convex hull or the bounding box [1, 5, 17, 23].Alt [2] demonstrated how a ρ -approximation algorithm for strip packing (axis-parallel rectangleswith translations) can be turned into a (1 + ε ) ρ -approximation algorithm for the offline version of Area-Translation , for any constant ε >
0. The same technique works for
AreaRotation . The idea is toapply the strip packing algorithm to strips of increasing widths and in the end choose the packing thatresulted in the smallest area. Therefore, the same technique cannot be applied in the online setting,where we need to choose a placement for each piece and stick with it. Alt also mentioned that findinga minimum area bounding box of a set of convex polygons with arbitrary rotations allowed can bereduced to the problem where the pieces are axis-parallel rectangles with only translations allowed. Thisreduction increases the approximation ratio by a factor by 2. The reduction does not work when thepieces can be only translated, but Alt, de Berg, and Knauer [4] gave a 17 . n ≤ unit squares, with arbitrary rotations allowed. A long line of mathematical research has been devotedto this problem, initiated by Erd˝os and Graham [12] in 1975, and it is still an active research area [10]. In Section 2.1, we present two online algorithms to minimize the perimeter of the bounding box: the algo-rithm
BrickTranslation solves the problem
PerimeterTranslation , where we can only translatepieces; the algorithm
BrickRotation solves the problem
PerimeterRotation , where also rotationsare allowed. Both algorithms achieve a competitive ratio of 4. In Section 2.3, we show a lower bound of4 / / Algorithm for translations
We pack the pieces into non-overlapping bricks ; a technique first de-scribed by Januszewski and Lassak [15] which was also used by Fekete and Hoffmann [13] for the prob-lem
SquareInSquareArea . Let a k -brick be a rectangle of size √ − k × √ − k − if k is even and √ − k − × √ − k if k is odd. A brick is a k -brick for some integer k .4 k B k +1 B k +2 B k +3 B † B † † B † † Figure 1: Left: Fundamental bricks. Middle: Splitting a brick. Right: Rectangular pieces packed in abrick.Figure 2: Left: Some pieces have been packed by the algorithm. The bricks in D are drawn with fatedges. Right: A new piece arrives. There is already a brick of the suitable size in D , but there is notenough room, so a new brick of the same size is added to D where the piece is placed.We tile the positive quadrant using one k -brick B k for each integer k as in Figure 1 (left): if k iseven, B k is the k -brick with lower left corner (0 , √ − k − ) and otherwise, B k is the k -brick with lowerleft corner ( √ − k − , B k are called the fundamental bricks. We define B >k := (cid:83) i>k B i and B ≥ k := B >k − , so that B >k is the k -brick immediately below (if k is even) or to the left (if k isodd) of B k .An important property of a k -brick B is that it can be split into two ( k + 1)-bricks: B † B † B † B if k iseven and the lower half of B if k is odd.We define a derived brick recursively as follows: a derived brick is either (i) a fundamental brick B k or (ii) B † B †
2, where B is a derived brick. We introduce an ordering ≺ of the derived k -bricksas follows. Consider two derived k -bricks D and D such that D ⊂ B i and D ⊂ B j . If i > j , then D ≺ D . Else, if i = j then the bricks D and D are both obtained by splitting the fundamental brick B i , and the number of splits is (cid:96) := i − k . Hence the bricks have the forms D = B i † b † b † . . . † b (cid:96) and D = B i † b b . . . b (cid:96) , where b ij ∈ { , } for i ∈ { , } and j ∈ { , . . . , (cid:96) } . We then define D ≺ D if( b , b , . . . , b (cid:96) ) precedes ( b , b , . . . , b (cid:96) ) in the lexicographic ordering.We say that a k -brick is suitable for a piece p of size w × h if the width and height of the brick are atleast w and h , respectively, and if that is not the case for a ( k + 1)-brick. We will always pack a givenpiece p in a derived k -brick that is suitable for p .We now explain how we pack pieces into one specific brick; see Figure 1 (right). The first piece p thatis packed in a brick B is placed with the lower left corner of p at the lower left corner of B . Suppose nowthat some other pieces p , . . . , p i have been packed in B . If k is even, then p , . . . , p i form a stack withthe left edges contained in the left edge of B , and we place p on top of p i (again, with the left edge of p contained in the left edge of B ). Otherwise, p , . . . , p i form a stack with the bottom edges contained inthe bottom edge of B , and we place p to the right of p i (again, with the bottom edge of p contained inthe bottom edge of B ). We say that a brick has room for a piece p if the packing scheme above places p within B , and it is apparent that an empty suitable brick for p has room for p .The algorithm BrickTranslation maintains the collection D of non-overlapping derived bricks,such that one or more pieces have been placed in each brick in D ; see Figure 2. Before the first piecearrives, we set D := ∅ . Suppose that some stream of pieces have been packed, and that a new piece p appears. Choose k such that a k -brick is suitable for p . If there exists a derived k -brick D ∈ D such that5 B † B † B † † Figure 3: Brick B is sparse , brick B † empty , brick B † dense . Brick B † † B † D has room for p , then we pack p in D . Else, let D be the minimum derived k -brick (with respect tothe ordering ≺ described before) such that D is interior-disjoint from each brick in D ; we then add D to D and pack p in D . Theorem 2.
The algorithm
BrickTranslation has a competitive ratio strictly less than 4 for
Peri-meterTranslation .Proof.
We can assume, without loss of generality, that after we have packed the last rectangle, we have (cid:83)
D ⊆ B ≥ and (cid:83) D (cid:54)⊆ B ≥ . As shown in Figure 3, we define a derived k -brick B ⊆ B ≥ to be • sparse if B ∈ D and the total height (if k is even, else width) of pieces stacked in B is less thanhalf of the height (if k is even, else width) of B , • dense if B ∈ D and B it is not sparse, • free if B is interior-disjoint from each brick in D , and • empty if B is a maximal (w.r.t. inclusion) free brick. Remark 3.
Sparse, dense and empty bricks together cover B ≥ , in fact every brick in D is either sparseor dense, and any brick in B ≥ that is interior-disjoint from bricks in D is contained in some empty brick. Remark 4.
Every k -brick D ∈ D contains pieces for which it is suitable. Therefore, if k is odd D contains a piece of height at least √ − k /
2, and if k is even D contains a piece of width at least √ − k / Remark 5.
Every k -brick D ∈ D that is dense contains pieces with total area at least 1 / D . To see this, suppose that k is even, so that D is √ − k × √ − k − , then thanks to density the totalheight of pieces in D is at least half of its height, moreover thanks to Remark 4 all the pieces containedin D have width at least √ − k /
2. If k is odd we prove it analogously. Remark 6.
Consider two k -bricks M and N . If M ≺ N and M is free, then N is free. To prove this it issufficient to consider the step in which the first piece p is placed within N and N † b † . . . † b (cid:96) is added to D . Then, N † b † . . . † b (cid:96) should be the ≺ -minimum free suitable k -brick, but M † b † . . . † b (cid:96) ≺ N † b † . . . † b (cid:96) gives a contradiction. It follows that whenever we have a set S of k -bricks that contains a free k -brick,then also max ≺ S is free. This turns out to be useful multiple times along the proof, choosing S to bethe set of k -bricks not contained in a strictly larger empty brick. Remark 7.
There exists no empty 0-brick, otherwise D ⊆ B ≥ . Moreover, for every k ≥ k -brick and one empty k -brick. In fact, a new empty (resp. sparse) k -brick is createdonly when no empty (resp. sparse) k -brick exists. 6 M Case (1) Case (2.1) M Case (3.1.1.1.2) Case (3.1.1.2)
MMw
Case (3.2.1.1.1) Mw Case (3.2.1.2) Mw Case (3.2.1) Mw Case (3.2.1.2.2.1.2) Mw Case (3.2.1.2.2.2)
M M M
Case (3.2.2) Case (3.2.2.1) Case (3.2.2.2.2.1)
Figure 4: Some of the cases listed in the proof of Theorem 2 are shown. The grey area must fit withinthe bounding box considered in the case analysis.In the following we prove an upper bound on the competitive ratio
Alg / Opt , where
Alg is theperimeter of the bounding box achieved by our online algorithm and
Opt is the optimal perimetercomputed offline. Hence, we need some techniques to provide an upper bound on
Alg and a lowerbound on
Opt . For
Alg , we will simply show a bounding box, in fact the perimeter of any boundingbox containing all the pieces provides an upper bound to the minimum perimeter bounding box. For
Opt , let A be the total area of pieces and L be the maximum length of an edge of a piece. If L > A then the minimum perimeter bounding box cannot have a smaller perimeter than a box of size L × A/L .Otherwise, if L ≤ A we have a weaker lower bound given by the box √ A ×√ A . Throughout the analysiswe consider semiperimeters instead of perimeters to improve readability.We denote with A ( empty ) , A ( sparse ) , A ( dense ) the total area of empty, sparse and dense bricksrespectively. Thanks to Remark 3, we have that A ( empty ) + A ( sparse ) + A ( dense ) = A ( B ≤ ) = √
2. Wedenote with A pcs the total area of pieces in the stream. Thanks to Remark 5, we have A pcs ≥ A ( dense ) / k be the smallest integer such that there exists a k -brick in D , and let M ∈ D be the ≺ -maximal k -brick. From our assumptions, it follows that k ≥ Case Tree Case (1) [ M is a -brick ] 7hanks to Remark 4 every piece in M has width at least 1 /
2. Let h be the total height of piecesstacked in M , then a bounding box of size size 1 × ( √ / h ) is obtained cutting the topmost part of M ; see Figure 4. We can easily bound Opt with 1 / × h , and we get AlgOpt ≤ √ + h + h ≤ √ < . Case (2) [ M is a k -brick for k ≥ Case (2.1) [ There exist a -brick N and a -brick N that are empty ]Thanks to Remark 6 we can choose N = B † N = B † †
2. In fact, for B † S as the set of all 1-bricks, while for B † † S to be the set of all 2-bricks that arenot contained in a larger free brick. Thus, we can cut the topmost half of B and get Alg ≤ / · √ A ( empty ) ≤ (cid:88) i ≥ A ( B i ) ≤ √ A ( sparse ) ≤ (cid:88) i ≥ A ( B i ) = √
24 (thanks to case (2) clause there is no sparse 1-brick) A pcs ≥ A ( dense )4 ≥ A ( B ≥ ) − A ( sparse ) − A ( empty )4 ≥ √ Opt : Opt ≥ · (cid:112) A pcs = (cid:115) √ AlgOpt ≤ √ (cid:113) √ ≈ . < . Case (2.2) [ For j = 1 or j = 2 there does not exist an empty j -brick ]In this case we just use Alg ≤ √
2. Then we have A ( empty ) ≤ (cid:88) i ≥ ∧ i (cid:54) = j A ( B i ) ≤ √ j = 2) A ( sparse ) ≤ (cid:88) i ≥ A ( B i ) = √ A pcs ≥ / · √
2, and finally
Opt ≥ · (cid:114) √ (cid:114) √ AlgOpt ≤ √ (cid:113) √ ≈ . < . Case (3) [ M is a -brick ]For the rest of the proof L will be the length of the longest edge among all pieces. Since M is a1-brick, we have √ / < L ≤ √ /
2. Here we have two cases.
Case (3.1) [ There does not exists an empty -brick ]Here we have two cases. Case (3.1.1) [ For j = 2 and j = 3 there exists an empty j -brick ]Here we have three cases. Case (3.1.1.1) [ M is the fundamental brick B ] 8hanks to Remark 6 we can assume B † † B † † † Case (3.1.1.1.1) [ M is dense ]Since M = B is the ≺ -maximal k -brick in D , then there does not exist a sparse 1-brick. A ( empty ) ≤ (cid:88) i ≥ A ( B i ) ≤ √ A ( sparse ) ≤ (cid:88) i ≥ A ( B i ) = √ A pcs ≥ √ , and finally Opt ≥ · (cid:115) √
28 = (cid:115) √ AlgOpt ≤ √ (cid:113) √ ≈ . < . Case (3.1.1.1.2) [ M is sparse ]Then, we can cut the rightmost part of B ≥ and get a 3 / × √ A ( empty ) ≤ (cid:88) i ≥ A ( B i ) ≤ √ A ( sparse ) ≤ (cid:88) i ≥ A ( B i ) ≤ √ A pcs ≥ √ /
16. Since L > / > √ /
16 we finally have
Opt ≥ L + A pcs L ≥ √
24 + 14 (minimizing over L ∈ [ √ / , √ / AlgOpt ≤ / √ √ + ≈ . < . Case (3.1.1.2) [ M = B † B † † B ≥ and get a 1 × √ / L bounding box; see Figure 4. We have A ( empty ) ≤ (cid:88) i ≥ A ( B i ) ≤ √ A ( sparse ) ≤ (cid:88) i ≥ A ( B i ) ≤ √ A pcs ≥ √ /
16. Since L > / > √ /
16 we finally have
Opt ≥ L + A pcs L ≥ L + √ L AlgOpt ≤ √ / LL + √ L ≤ √ < . (maximizing over L ∈ [ √ / , √ / Case (3.1.1.3) [ M = B † B † † B ≥ . Case (3.1.2) [ For j = 2 or j = 3 there does not exist an empty j -brick ]9 ( empty ) ≤ (cid:88) i ≥ ∧ i (cid:54) = j A ( B i ) ≤ √ j = 3) A ( sparse ) ≤ (cid:88) i ≥ A ( B i ) ≤ √ A pcs ≥ · √
2. Since L > / > · √ Opt ≥ L + A pcs L ≥ √
24 + 516 (minimizing over L ∈ [ √ / , √ / AlgOpt ≤ √ √ + ≈ . < . Case (3.2) [ There exists an empty -brick ]Thanks to Remark 6 we can assume B † Case (3.2.1) [ M is the fundamental brick B ]Let w be the total width of pieces stacked in M . Since B † B ≥ and get a (1 / w ) × √ w only improves ourestimates, we consider the corner case w = 0. Now we have two cases. Case (3.2.1.1) [ There does not exist an empty -brick ]Here we have two cases. Case (3.2.1.1.1) [ For j = 3 and j = 4 there exists an empty j -brick ]Thanks to Remark 6 we can assume B † † † B † † † † B ≥ and get a 1 / × (7 / · √
2) bounding box; see Figure 4. We have A ( empty ) ≤ (cid:88) i ≥ ∧ i (cid:54) =2 A ( B i ) ≤ √ A ( sparse ) ≤ (cid:88) i ≥ A ( B i ) ≤ √ A pcs ≥ √ /
32. Since L > / > √ /
32 we finally have
Opt ≥ L + A pcs L ≥ √
24 + 18
AlgOpt ≤ / / · √ √ + ≈ . < . Case (3.2.1.1.2) [ For j = 3 or j = 4 there does not exist an empty j -brick ] A ( empty ) ≤ (cid:88) i ≥ ∧ i (cid:54) =2 ,j A ( B i ) ≤ √ j = 4) A ( sparse ) ≤ (cid:88) i ≥ A ( B i ) ≤ √ A pcs ≥ / · √
2. Since L > / > / · √ Opt ≥ L + A pcs L ≥ √
24 + 532
AlgOpt ≤ / √ √ + ≈ . < . ase (3.2.1.2) [ There exists an empty -brick ]Thanks to Remark 6 we can assume B † † B ≥ and get a 1 / × (3 / · √
2) bounding box; see Figure 4. Here we have two cases.
Case (3.2.1.2.1) [ There does not exist an empty -brick ] A ( empty ) ≤ (cid:88) i ≥ ∧ i (cid:54) =3 A ( B i ) ≤ √ A ( sparse ) ≤ (cid:88) i ≥ A ( B i ) ≤ √ A pcs ≥ √ /
64. Since L > / > √ /
64 we finally have
Opt ≥ L + A pcs L ≥ √
24 + 116
AlgOpt ≤ + √ √ + ≈ . < . Case (3.2.1.2.2) [ There exists an empty -brick ]Thanks to Remark 6 we can assume B † † † Case (3.2.1.2.2.1) [ There does not exist an empty -brick ]Here we have two cases. Case (3.2.1.2.2.1.1) [ For j = 5 or j = 6 there does not exist an empty j -brick ] A ( empty ) ≤ (cid:88) i ≥ ∧ i (cid:54) =4 ,j A ( B i ) ≤ √ j = 6) A ( sparse ) ≤ (cid:88) i ≥ A ( B i ) ≤ √ A pcs ≥ / · √
2. Since L > / > / · √ Opt ≥ L + A pcs L ≥ √
24 + 5128
AlgOpt ≤ + √ √ + ≈ . < . Case (3.2.1.2.2.1.2) [ For j = 5 and j = 6 there exists an empty j -brick ]Thanks to Remark 6 we can assume B † † † † † B † † † † † † B ≥ and get a 1 / × (11 / · √
2) bounding box; see Figure 4. We have A ( empty ) ≤ (cid:88) i ≥ ∧ i (cid:54) =4 A ( B i ) ≤ √ A ( sparse ) ≤ (cid:88) i ≥ A ( B i ) ≤ √ A pcs ≥ √ / L > / > √ /
128 we finally have
Opt ≥ L + A pcs L ≥ √
24 + 132
AlgOpt ≤ + √ √ + ≈ . < . Case (3.2.1.2.2.2) [ There exists an empty -brick ]11hanks to Remark 6 we can assume B † † † † B ≥ and get a 1 / × (5 / · √
2) bounding box; see Figure 4. Now it remains to bound
Opt , and wejust assume
Opt ≥ L ≥ √ /
4, finally
AlgOpt ≤ + √ √ ≈ . < . Case (3.2.2) [ M = B † L be the length of the longest of pieces’ edges then, according to Remark 4, √ / ≤ L ≤ √ /
2. We can cut the topmost part of B ≥ and get a 1 × ( √ / L ) bounding box; seeFigure 4. Here we have two cases. Case (3.2.2.1) [ There exists a -brick in D ]Thanks to Remark 4, we have a piece of width at least 1 /
4, and combining this with the fact that wehave a piece of height L , it is apparent that Opt ≥ / L ; see Figure 4. Thus, AlgOpt ≤ √ + L + L ≤ √ < L ∈ [ √ / , √ / Case (3.2.2.2) [ There does not exist a -brick in D ]Here we have two cases. Case (3.2.2.2.1) [ There does not exist an empty -brick ] A ( empty ) ≤ (cid:88) i ≥ ∧ i (cid:54) =2 A ( B i ) ≤ √ A ( sparse ) ≤ (cid:88) i ≥ A ( B i ) ≤ √ A pcs ≥ √ /
16. Since L > / > √ /
16 we finally have
Opt ≥ L + A pcs L ≥ L + √ L AlgOpt ≤ √ + LL + √ L ≤ √ < L ∈ [ √ / , √ / Case (3.2.2.2.2) [ There exists an empty -brick ] Thanks to Remark 6 we can assume B † Case (3.2.2.2.2.1) [ There exists an empty -brick ]Thanks to Remark 6 we can assume B † † B ≥ and get a 3 / × ( √ / L ) bounding box; see Figure 4. Now it remains to bound Opt . We have A ( empty ) ≤ (cid:88) i ≥ A ( B i ) ≤ √ A ( sparse ) ≤ (cid:88) i ≥ ∧ i (cid:54) =2 A ( B i ) ≤ √ A pcs ≥ √ /
32. Since L > / > √ /
32 we finally have
Opt ≥ L + A pcs L ≥ L + √ L AlgOpt ≤ + √ + LL + √ L ≤ . < L ∈ [ √ / , √ / ase (3.2.2.2.2.2) [ There does not exist an empty -brick ] A ( empty ) ≤ (cid:88) i ≥ ∧ i (cid:54) =3 A ( B i ) ≤ √ A ( sparse ) ≤ (cid:88) i ≥ ∧ i (cid:54) =2 A ( B i ) ≤ √ A pcs ≥ / · √
2. Since L > / > / · √ Opt ≥ L + A pcs L ≥ L + 3 √ L AlgOpt ≤ √ + LL + √ L ≤ . < L ∈ [ √ / , √ / Algorithm using rotations
The algorithm
BrickRotation is almost identical to
BrickTranslation ,but with the difference that we rotate each piece so that its height is at least its width.
Theorem 8.
The algorithm
BrickRotation has a competitive ratio of strictly less than 4 for
Peri-meterRotation .Proof.
The analysis of
BrickTranslation carried out in the proof of Theorem 2 still holds, in fact allthe estimates on
Opt derived from consideration about area are still valid, and the only delicate spotis case (3.2.2.1). In that case we assume to have a piece p having an edge of length L ∈ [ √ / , √ / D . Thanks to Remark 4 there exists a piece q of size w q × h q with w q ≥ /
4, moreover we rotate every piece so that 1 / ≤ w q ≤ h q . Finally, a box that contains both p and q must have size at least L × w q or L × h q , hence Opt ≥ min { L + w q , L + h q } ≥ L + 14 . This gives exactly the same bound showed in case (3.2.2.1) and completes the proof.
Here we consider the algorithm we get by making a slight change to
BrickTranslation . Supposethat the very first piece p arrives and that a k -brick is suitable for p . Instead of placing p in B k (as BrickTranslation would do), we consider the brick B >k to be a fundamental brick (although in theoriginal algorithm, it was an infinite union of fundamental bricks) and we place p in B >k . Thus, we arenever going to use the fundamental bricks B i individually, for i > k . From here on, the algorithm does as BrickTranslation : Whenever a new piece arrives, we place it in the first derived brick of the suitablesize that has room. This behavior is similar to the algorithm for the problem
SquareInSquareArea that was described by Fekete and Hoffmann [13]. That problem is studied in more detail in Section 3.3,and for that problem, the algorithm seems to be no worse than ours.Interestingly, the following theorem together with Theorem 2 implies that the modified algorithm isworse for the problem
PerimeterTranslation . Theorem 9.
The modified version of
BrickTranslation has a competitive ratio of at least for theproblem PerimeterTranslation .Proof.
For any ε (cid:48) >
0, we can make an instance realizing a competitive ratio of more than 4 − ε (cid:48) asfollows. Figure 5 shows the packing produced by the modified and the original algorithm. We first givethe algorithm the rectangle (1 / √ ε ) × ε for an infinitesimal ε >
0. The rectangle is placed in B > by the modified algorithm. For a large odd integer k , we then feed the algorithm with small rectanglesof size ( √ − k − + ε ) × ( √ − k + ε ) until B † k − ε × (1 / ε ), which is13 > B † B † B † B > B B † † B † B † † † B † † † B † † † B † † † Figure 5: Left: A configuration produced by the modified version of
BrickTranslation . Right: Theconfiguration produced by the original algorithm
BrickTranslation .placed in B †
2. We again give the algorithm many small rectangles until B † † † k − / √ ε ) × ε , which is placed in B † † †
2. Finally,we fill B † † † k −→ ∞ , the bounding box of the produced packing converges to B ≥ , so it has aperimeter as B − . On the other hand, observe that as ε −→
0, we have Σ −→ A ( B ) / A ( B ), sincethe small rectangles fill out bricks with a total area of A ( B ) and with density 1 /
4. In the limit, all thepieces can actually be packed into B , so Opt is at most the perimeter of B . But the perimeter of B − is 4 times that of B , which finishes the proof. Lemma 10.
Consider any algorithm A for the problem PerimeterTranslation . Then the competitiveratio of A is at least / .Proof. We first feed A with two unit squares. Let the bounding box of the two squares have size a × b and suppose without loss of generality that a ≤ b . Then a ≥ b ≥
2. We now give A a rectangleof size 2 × ε for a small value ε >
0. The produced packing has a bounding box of perimeter more than8, whereas the optimal has perimeter 6 + 2 ε . Therefore, the competitive ratio is ε = ε . By letting ε −→
0, we get that the ratio is at least 4 / Lemma 11.
Consider any algorithm A for the problem PerimeterRotation . Then the competitiveratio of A is at least / .Proof. We first feed A with three unit squares. Let the bounding box of the three squares have size a × b and suppose without loss of generality that a ≤ b . Suppose first that b <
3. Then we must have a ≥ ε × ε >
0. The produced packing has a bounding box of size at least (2 + ε ) × ε ) × ε .On the other hand, if b ≥
3, we give the algorithm one more unit square. The produced packing hasa bounding box of size at least 2 × ×
4, and thus perimeter at least 10, while the optimalpacking has size 2 × ε = ε , and by letting ε −→
0, we get that the ratiois at least 5 /
4. 14
Area versions
In this section we show that, if we allow pieces to be arbitrary rectangles, we cannot bound the competitiveratio for neither
AreaTranslation nor
AreaRotation as a function of the area
Opt of the optimalpacking. However we will be able to bound the competitive ratio as a function of the total number n ofpieces in the stream. Lemma 12.
Consider any algorithm A solving AreaTranslation or AreaRotation and let any m ∈ N and p ∈ R be given. There exists a stream of n = m + 1 rectangles such that (i) the rectanglescan be packed into a bounding box of area p , and (ii) algorithm A produces a packing with a boundingbox of area at least mp .Proof. We first feed A with m rectangles of size p × pm . These rectangles have total area p . Let a × b be the size of the bounding box of the produced packing.Suppose first that a ≥ pm and b ≥ pm hold. We then feed A with a long rectangle of size pm × pm .The produced packing has a bounding box of area at least pm · pm = mp . The optimal packing is topack the m small rectangles along the long rectangle, which would produce a packing with boundingbox of size pm × pm = 2 p .Otherwise, we must have b > pm or a > pm , since ab ≥ p . We then feed A with a square of size p × p . The produced packing has a bounding box of area at least p · pm = mp . The optimal packingis obtained stacking the m thin rectangles on top of the big square, which produces a packing withbounding box of size p × p = 2 p . Corollary 13.
Let A be an algorithm for AreaTranslation or AreaRotation . Then A does nothave an asymptotic, and hence also absolute, competitive ratio which is a function of Opt .Proof.
Let f be any function of Opt . For any value
Opt = c , we choose p := (cid:112) c/
2. We now choose m > f ( c ) and obtain that the competitive ratio is at least mp p = m/ > f ( c ) = f ( Opt ). Corollary 14.
Let A be an algorithm for AreaTranslation or AreaRotation . If A has an asymp-totic competitive ratio of f ( n ) , where n = | L | is the number of pieces in the stream, then f ( n ) = Ω( √ n ) .This holds even when all edges of the pieces are required to have length at least .Proof. We choose p := m . Then all edges have length at least 1, and the competitive ratio is at least mp p = m/ √ n ). Here, Opt can be arbitrarily big by choosing m big enough, so it is a lower boundon the asymptotic competitive ratio. In this section we provide algorithms that solve
AreaTranslation and
AreaRotation with a com-petitive ratio of O ( √ n ), where n is the total number of pieces. Thus we match the bounds provided inthe previous section.We first describe the algorithm DynBoxTrans that solves
AreaTranslation . We assume toreceive a stream of pieces p , . . . , p n of unknown length n , such that piece p i has size w i × h i . For each k ∈ Z , we define a rectangular box B k with a size varying dynamically. After pieces p , . . . , p j have beenprocessed B k has size 2 k × T j , where T j := H j √ j + 7 H j and H j := max i =1 ,...,j h i . We place the boxeswith their bottom edges on the x -axis and in order such that the right edge of B k − is contained in theleft edge of B k ; see Figure 6. Furthermore, we place the lower left corner of box B at the point (1 , , B k is wide enough for a piece p i = w i × h i if w i ≤ k . If a box B k is wideenough for p i , we can pack p i in B k using the online strip packing algorithm NFS k that packs rectanglesinto a strip of width 2 k . The algorithm NFS k is the next-fit shelf algorithm first described by Baker andSchwartz [6]. The algorithm packs pieces in shelves (rows), and each shelf is given a fixed height of 2 j for some j ∈ Z when it is created; see Figure 7. The width of each shelf is 2 k , since this is the width ofthe box B k . 15 k B k − B k − T j k Figure 6: The algorithm
DynBoxTrans packs pieces into the boxes B k that form a row. Every boxhas height T j that is dynamically updated.Figure 7: A packing produced by the next-fit shelf algorithm using four shelves.16 piece of height h , where 2 j − < h ≤ j , is packed in a shelf of height 2 j . We divide the shelves intotwo types. If the total width of pieces in a shelf is more than 2 k − we call that shelf dense , otherwise wesay it is sparse . The algorithm NFS k places each piece as far left as possible into the currently sparseshelf of the proper height. If there is no sparse shelf of this height or the sparse shelf has not room forthe piece, a new shelf of the appropriate height is created on top of the top shelf, and the piece is placedthere at the left end of this new shelf. This ensures that at any point in time there exists at most onesparse shelf for each height 2 j .If we allow the height of the box B k to grow large enough with respect to shelves’ heights, the spacewasted by sparse shelves becomes negligible and we obtain a constant density strip packing, as stated inthe following lemma. Lemma 15.
Let (cid:101) H be the total height of shelves in B k , and H max be the maximum height among piecesin B k . If (cid:101) H ≥ H max , then the pieces in B k are packed with density at least / .Proof. Let 2 m − < H max ≤ m , so that (cid:101) H ≥ · m . For each i ≤ m we have at most one sparse shelf ofheight 2 i and each shelf of B k has height at most 2 m , hence the total height of sparse shelves is at most (cid:80) i ≤ m i = 2 m +1 , so the total height of dense shelves is at least (cid:101) H − m +1 ≥ (cid:101) H/
3. Thus, the total areaof the dense shelves is at least 2 k · (cid:101) H/ i . Into that shelf, we have packed pieces of height at least 2 i − ,and the total width of these pieces is at least 2 k − . Hence, the density of pieces in the shelf is at least1 /
4. Therefore, the total area of pieces in B k is at least 2 k · (cid:101) H/
12. On the other hand, the area of thebounding box is 2 k · (cid:101) H , that yields the desired density.Now we are ready to describe how the algorithm works. When the first piece p arrives, let 2 k −
The algorithm
DynBoxTrans has an absolute competitive ratio of O ( √ n ) for the problem AreaTranslation on a stream of n pieces.Proof. First, define Σ j as the total area of the first j pieces, W := max i =1 ,...,n w i and recall that H j =max i =1 ,...,j h i and T j = H j √ n +7 H j . Let B k be the last active box, so that we can enclose all the pieces ina bounding box of size 2 k +1 × T n , and bound the area returned by the algorithm as Alg = O (2 k H n √ n ).On the other hand we are able to bound the optimal offline packing as Opt = Ω(Σ n + W H n ).If the active box never changed, then we have 2 k < W that implies Alg = O ( W H n √ n ) = Opt · O ( √ n ). Otherwise, let B (cid:96) be the last active box before B k , and p j be the first piece put in B k . Here wehave two cases. Case (1) [ w j > (cid:96) ] In this case we have 2 k < W that implies Alg = O ( W H n √ n ) = Opt · O ( √ n ). Case (2) [ w j ≤ (cid:96) ] In this case we have k = (cid:96) + 1. Denote with (cid:102) H i the total height of shelves in B i .Then we have (cid:102) H (cid:96) ≥ T j − H j = H j √ n + 6 H j , otherwise we could pack p j in B (cid:96) . Thus, we can applyLemma 15 and conclude that the box B (cid:96) of size 2 (cid:96) × T j is filled with constant density. Here we have twocases. Case (2.1) [ (cid:102) H k ≤ T j ] In this case we have Alg = O (2 k T j ) and, thanks to the constant density packingof B (cid:96) we have Σ j = Θ(2 (cid:96) (cid:102) H (cid:96) ) = Θ(2 k T j ). Since Opt ≥ Σ j , we get Alg = O ( Opt ). Case (2.2) [ (cid:102) H k > T j ] In this case we have Alg = O (2 k (cid:102) H k ). Moreover, (cid:102) H k = O ( H n + Σ n / k ), in fact if2 s − < H n ≤ s , then the total height of sparse shelves is (cid:80) i ≤ s i = 2 s +1 = O ( H n ). Furthermore, denseshelves are filled with constant density, therefore their total height is at most O (Σ n / k ). Finally, we needto show that 2 k = O ( W √ n ). Thanks to the constant density packing of B (cid:96) , we have 2 k H j √ j = O (2 (cid:96) T j ) = O (Σ j ). We can upper bound the size of every piece p i for i ≤ j with W × H j and obtain Σ j ≤ n · W H j .Plugging it in the previous estimate and dividing both sides by H j √ n we get 2 k = O ( W √ n ). Now wehave Alg = O (2 k (cid:102) H k ) = O (2 k H n + Σ n ) = O ( W H n √ n + Σ n ) = Opt · O ( √ n ).17 × − ε − ε dcba × − ε − ε AB C EFGQ Q Q Q D Figure 8: Left: A 2 × × × Q , . . . , Q are placed within the bounding square.The algorithm DynBoxRot is obtained from
DynBoxTrans with a slight modification: beforeprocessing any piece p i we rotate it so that w i ≤ h i . In this way, it still holds that Opt = Ω(Σ n + W H n )and the proof of Theorem 16 works also for the following. Theorem 17.
The algorithm
DynBoxRot has an absolute competitive ratio of O ( √ n ) for the problem AreaRotation on a stream of n pieces. In this section, we will consider the special case where the aspect ratio of all pieces is α = 1, i.e., all thepieces are squares. Furthermore, we will measure the size of the packing as the area of the minimumaxis-parallel bounding square , and we call the resulting problem SquareInSquareArea . Since we geta constant competitive ratio in this case, it follows that for other values of α and when allowing thebounding box to be a general rectangle, one can likewise achieve a constant competitive ratio. We firstgive a lower bound. Lemma 18.
Consider any algorithm A for the problem SquareInSquareArea . Then the competitiveratio of A is at least / .Proof. We first give A four 1 × (cid:96) × (cid:96) . If (cid:96) ≥
3, the boundingsquare of the four 1 × ×
3, while the optimal packing has size 2 ×
2, whichgives ratio at least 9 /
4. Otherwise, if (cid:96) <
3, we give a 2 × × × / − ε ) × (4 − ε ) bounding square containingboth a 2 × × × − δ ) × (3 − δ ) bounding box. We refer to notation in Figure 8 (left) and notice that we have a < b <
1, and analogously c < d <
1. Without loss of generality, we can assume a, d < × x i , y i ) be the coordinates of the bottomleft corner of square Q i . Stating that Q i and Q j are disjoint is equivalent to max {| x i − x j | , | y i − y j |} ≥ ABDE and
GCDF : note that each of them can contain atmost two squares. Indeed, given Q i and Q j completely contained in ABDE , it holds | y i − y j | ≤ − ε thus | x i − x j | ≥
1. If three squares Q , Q , Q are completely contain in ABDE then we have, withoutloss of generality, x ≤ x − ≤ x − Q , Q , Q has size at least3 ×
3, that gives a contradiction. The same holds for
GCDF .18 E E F F U k F k B > k E E E U k B > k Figure 9: Left: A 2 k -packing. The grey bricks are non-empty and may have been split into smallerbricks. Right: The 2 k -packing produced by BrickTranslation when providing the algorithm withenough copies of the square S k (the small grey squares), showing that the competitive ratio can bearbitrarily close to 6.Finally, every Q i is either fully contained in ABDE or GCDF hence, without loss of generality,we can assume that Q , Q are contained in ABDE and Q , Q are contained in GCDF . This impliesthat x ≤ x − y ≤ y −
1, again without loss of generality. Observe that x ≤ x + 1 − ε and y ≤ y + 1 − ε . Q and Q are disjoint, using the previous characterization we have two cases.First, | x − x | ≥ x > x , therefore we have x ≤ x − ≤ x −
2. Else, | y − y | ≥ y ≤ y − ≤ y − Q i s in a (3 − δ ) × (3 − δ ) boundingsquare.We are now going to analyze the competitive ratio of the algorithm BrickTranslation (in fact,the algorithm
BrickRotation has the exact same behavior when the pieces are squares). Note that abrick can never contain more than one piece. The algorithm is almost the same as the one described byFekete and Hoffmann [13]. The slight difference is addressed in Section 2.2 and it is shown there that thebehavior as described by Fekete and Hoffmann makes a worse algorithm for the problem
Perimeter-Translation . However, even though the two algorithms will not always produce identical packingsfor the problem
SquareInSquareArea , the analysis of the following theorem seems to hold for bothversions, so for the problem
SquareInSquareArea , the algorithms are equally good.
Theorem 19.
The algorithm
BrickTranslation has a competitive ratio of for SquareInSquare-Area . The analysis is tight.Proof.
Suppose a stream of squares have been packed by
BrickTranslation , and let
Alg be the areaof the bounding square of the resulting packing. Let B k be the largest elementary brick in which a squarehas been placed. Suppose without loss of generality that k = 0, so that B k has size 1 × / √ B ≥ k ,which contains all the packed squares, has size 1 × √ k -packing, for a non-negative integer k ; see Figure 9 (left). As k increases, so do the requirements to a 2 k -packing, in the sense that a(2 k + 2)-packing is also a 2 k -packing, but the other way is in general not the case. Define F := B ≥ and U := B . A packing is a 0-packing if pieces have been placed in U (the brick U may or maynot have been split in smaller bricks). Hence, the considered packing is a 0-packing by the assumptionthat a piece has been placed in B . Suppose that we have defined a 2 k -packing for some integer k . A(2 k + 2)-packing is a 2 k -packing with the additional requirements that19 the brick U k has been split into L := U k † E k +1 := U k † • the right brick E k +1 is empty, • the left brick L has been split into F k +2 := L † U k +2 := L †
2, and • U k +2 is non-empty, and thus also F k +2 is non-empty.The symbols U j , E j , F j have been chosen such that the brick is a j -brick, i.e., the index tells the sizeof the brick.Consider a 2 k -packing. It follows from the definition that along the top edge of B ≥ from theright corner (1 , √
2) to the left corner (0 , √ E , E , . . . , E k − of empty bricks ofdecreasing size, and finally meet a non-empty brick U k which may have been split into smaller bricks. Claim 20.
If the packing is a k -packing and not a (2 k + 2) -packing, then Alg / Opt < . Since we pack a finite number of squares, the produced packing is a 2 k -packing but not a (2 k + 2)-packing for some sufficiently large k , so Claim 20 implies Theorem 19.Let us now prove Claim 20. We first compute the area of the brick U k and the total areas of thebricks F , F , . . . , F k , as these areas will be used often: u k := | U k | = 2 − k / √ f k := k (cid:88) i =0 | F i | = 2 | B ≥ | − u k − − k √ . (2)1) Suppose first that U k has not been split into smaller bricks. Then, since U k is non-empty by as-sumption, we know that U k contains a square S of size s × s where s ∈ ( s l , s h ] = (cid:16) √ − k − , √ − k − (cid:105) .Since the bricks E , E , . . . , E k − are all empty, we get that the upper edge of the bounding squarecoincides with the upper edge of S , and we thus have Alg ≤ Alg ( s ) := ( √ − ( √ − k − − s )) . The largest empty brick in the bricks F i can have size | U k | /
2, so the total size of empty bricks in F , F , . . . , F k is | U k | . Moreover, the density of squares into bricks is at least 1 / √ Opt ≥ Opt ( s ) := f k − u k √ s = 1 − − k s . In the case that k = 0, we get AlgOpt ≤ Alg ( s ) Opt ( s ) = 2 s √ s + 12 s . A simple analysis shows that the fraction is largest when s = s l , so we get the bound AlgOpt ≤ s l √ s l + 12 s l = 3 + 2 √ < . k >
0. We divide into two cases of whether s is in the lower or the upper halfof the range ( s l , s h ]. For the lower half, that is, s ∈ ( s l , s l + s h ], we get AlgOpt ≤ Alg ( s l + s h ) Opt ( s l ) = 96 · k + (24 √ − · k − √ · k − . It is straightforward to check that (24 √ − · k − √ < · ( −
4) for all k ≥
1, so it followsthat the ratio is less than 6.For the upper half, that is, s ∈ [ s l + s h , s h ], we get AlgOpt ≤ Alg ( s h ) Opt ( s l + s h ) = 96 · k · k + 6 √ − . As 6 √ − >
0, the ratio is less than 6. 20) We now assume that U k has been split into a L and E k +1 , which are the left and right halfs of U k , respectively.2.1) We first suppose that E k +1 is not empty. This implies that there is no empty (2 k + 1)-brick in F , F , . . . , F k , U k . Hence, each empty brick in the bricks F , F , . . . , F k , U k is a(2 k + 2)-brick or smaller, so these empty bricks have total size at most u k /
2. We then get
Opt ≥ f k + u k − u k / √ − k > . Since
Alg ≤
2, it follows that
AlgOpt < E k +1 is empty.2.2.1) Suppose now that L has not been split into smaller bricks. Then L contains a square S of size s × s for s ∈ ( s l , s h ] = (cid:16) √ − k − , √ − k − (cid:105) . As in case 1, we get Alg ≤ Alg ( s ) := ( √ − ( √ − k − − s )) . Note that there is no empty (2 k + 1)-brick in the bricks F , F , . . . , F k , so these brickscontain a total area of at most u k / Opt ≥ Opt ( s ) := f k − u k / √ s . We then get the bound
AlgOpt ≤ Alg ( s h ) Opt ( s l ) = 24 · k + (12 √ − · k − √ · k − . Here, it is straightforward to verify that (12 √ − · k − √ < · ( −
1) for all k ≥
0, and hence the ratio is less than 6.2.2.2) We now assume that L has been split into F k +2 and U k +2 , which are the bottom andtop parts, respectively.2.2.2.1) Suppose that U k +2 is empty. Since also E , E , . . . , E k +1 are empty, we get that Alg ≤ ( √ − √ − k − / .Note that each empty bricks in the bricks F , F , . . . , F k +2 can have size at most u k /
8, so the total size of the empty bricks is at most u k / u k +1 , and we get Opt ≥ f k +1 − u k +1 √ . We therefore get
AlgOpt ≤ · k − · k + 38 · k − . Here, it is straightforward to check that − · k + 3 < · ( −
2) for all k ≥
0, so theratio is less than 6.2.2.2.2) We are finally left with the case that U k +2 is not empty. But then all the requirementsare satisfied for the packing to be a (2 k + 2)-packing.We now observe that the analysis is tight. To this end, we show that for any given k and a small ε >
0, we can force the algorithm to produce a 2 k -packing, such that as k −→ ∞ and ε −→
0, the ratio
Alg Σ tends to 6, where Σ is the total area of the packed squares. Let ε k := ε √ − k , (cid:96) k := √ − k / ε k ,and let S k be a square of size (cid:96) k × (cid:96) k . We now feed the algorithm with copies of S k . This will eventuallyresult in a 2 k -packing, where each non-empty brick is a 2 k -brick; see Figure 9 (right). Let n k be thenumber needed to produce the 2 k -packing. The density in each non-empty brick is ρ ε := | S k || B k | . As ε −→
0, we get that ρ ε −→ √ . As k −→ ∞ , the area of non-empty bricks converges to | B ≤ | = √ .Hence, we have Σ −→ √ · √ = . We then get Alg Σ −→ / = 6. Furthermore, the optimal packingof the squares is to place them so that their bounding box is a square of size (cid:100)√ n k (cid:101) (cid:96) k × (cid:100)√ n k (cid:101) (cid:96) k . As k −→ ∞ , we then have Σ Opt −→
1. Hence, we have
AlgOpt −→ .4 More lower bounds when edges are long We already saw in Corollary 14 that as a function of n , the competitive ratio of an algorithm for Area-Translation or AreaRotation must be at least Ω( √ n ), even when all edges have length 1. In thissection, we give lower bounds in terms of Opt for the same case. Note that the assumption that theedges are long is needed for these bounds to be matched by actual algorithms, since Corollary 13 statesthat without the assumption, the competitive ratio cannot be bounded as a function of
Opt . Theorem 21.
Consider any algorithm A for the problem AreaTranslation with the restriction thatall edges of the given rectangles have length at least . If A has an asymptotic competitive ratio f ( Opt ) as a function of Opt , then f ( Opt ) = Ω( √ Opt ) . Remark 22.
Note that when the edges are long, Ω( √ Opt ) = Ω( √ n ), so this bound is stronger thanthe Ω( √ n ) bound of Corollary 14. Proof of Theorem 21.
For any n ∈ N , we do as follows. We first provide A with n unit squares. Let thebounding box of the produced packing of these squares have size a × b . Assume without loss of generalitythat a ≤ b , so that b ≥ n . We now give A the rectangle n ×
1. The optimal offline solution to this setof rectangles has a bounding box of size n ×
2. The packing produced by A has a bounding box of sizeat least n × n = Ω( √ Opt ) · Opt . Theorem 23.
Consider any algorithm A for the problem AreaRotation with the restriction that alledges of the given rectangles have length at least . If A has a competitive ratio f ( Opt ) as a function of Opt , then f ( Opt ) = Ω( √ Opt ) .Proof. For any n ∈ N , we do as follows. We first provide A with n unit squares. Let the boundingbox of the produced packing of these squares have size a × b . Assume without loss of generality that a ≤ b . If a ≥ n / , we give A the rectangle 1 × n . Otherwise, we have b > n / , and then we give A the square n × n . In either case, there is an optimal offline solution of area 2 n , but the bounding boxof the packing produced by A has area at least n / = Ω( √ Opt ) · Opt . In this section, we describe algorithms that match lower bounds of Section 3.4. We analyze thesealgorithms under the assumption that we feed them with rectangles with edges of length at least 1 (ofcourse, any other positive constant will also work), but we require no bound on the aspect ratio. Underthis assumption, we observe that
DynBoxTrans has absolute competitive ratio O ( √ Opt ) for
Area-Translation . We then describe the algorithm
DynBoxRot √ Opt , which we prove to have absolutecompetitive ratio O ( √ Opt ) for
AreaRotation . By Theorems 21 and 23, both algorithms are optimalto within a constant factor.In previous sections we proved lower bounds of Ω( √ n ) and Ω( √ Opt ) for
AreaRotation . Theycan be summarized stating that
AreaRotation has a competitive ratio of Ω(max {√ n, √ Opt } ). Thelast theorem of this section, describes the algorithm DynBoxRot √ n ∧ √ Opt that simultaneously matchesboth lower bounds achieving a competitive ratio of O (min {√ n, √ Opt } . At a first sight it may seemthat this algorithm contradicts the lower bound of Ω(max {√ n, √ Opt } ); however this simply proves thatthe edge cases that have a competitive ratio of at least Ω( √ Opt ) must satisfy
Opt = O ( n ). Likewise,those for which the competitive ratio is at least Ω( √ n ) satisfy n = O ( √ Opt ). Translations only
Under the long edge assumption, we have n ≤ Opt . Therefore,
DynBoxTrans achieves a competitive ratio of O ( √ n ) = O ( √ Opt ) for
AreaTranslation and matches the boundstated in Theorem 21.
Rotations allowed
Now we tackle the
AreaRotation problem and describe the algorithm
Dyn-BoxRot √ Opt . We define the threshold function T j = Σ / j + 7 H j , where H j = max i =1 ,...,j h i and Σ j isthe total area of pieces p , . . . , p j . DynBoxRot √ Opt is obtained by running
DynBoxRot , as describedin Section 3.2, employing this new threshold T j . 22 heorem 24. The algorithm
DynBoxRot √ Opt has an absolute competitive ratio of O ( √ Opt ) for theproblem AreaRotation , where
Opt is the area of the optimal offline packing.Proof.
This proof is similar to the one of Theorem 16. Define W := max i =1 ,...,n w i . Recall that in DynBoxRot we preprocess every piece p rotating it so the w p ≤ h p , hence W ≤ √ Σ n . Let B k be thelast active box, so that we can enclose all the pieces in a bounding box of size 2 k +1 × T n , and bound thearea returned by the algorithm as Alg = O (2 k H n + 2 k Σ / n ). On the other hand we are able to boundthe optimal offline packing as Opt = Ω(Σ n + W H n ).If the active box never changed, then we have 2 k < W that implies Alg = O ( W H n + Σ / n ) = Opt · O ( √ Opt ). Otherwise, let B (cid:96) be the last active box before B k , and p j be the first piece put in B k .Here we have two cases. Case (1) [ w j > (cid:96) ] In this case we have 2 k < W that implies Alg = O ( W H n +Σ / n ) = Opt · O ( √ Opt ). Case (2) [ w j ≤ (cid:96) ] In this case we have k = (cid:96) + 1. Denote with (cid:102) H i the total height of shelves in B i .Then we have (cid:102) H (cid:96) ≥ T j − H j = Σ / j + 6 H j , otherwise we could pack p j in B (cid:96) . Thus, we can applyLemma 15 and conclude that the box B (cid:96) of size 2 (cid:96) × T j is filled with constant density. Here we have twocases. Case (2.1) [ (cid:102) H k ≤ T j ] In this case we have Alg = O (2 k T j ) and, thanks to the constant density packingof B (cid:96) we have Σ j = Θ(2 (cid:96) (cid:102) H (cid:96) ) = Θ(2 k T j ). Since Opt ≥ Σ j , we get Alg = O ( Opt ). Case (2.2) [ (cid:102) H k > T j ] In this case we have Alg = O (2 k (cid:102) H k ). Moreover, (cid:102) H k = O ( H n + Σ n / k ), in fact if2 s − < H n ≤ s , then the total height of sparse shelves is (cid:80) i ≤ s i = 2 s +1 = O ( H n ). Furthermore, denseshelves are filled with constant density, therefore their total height is at most O (Σ n / k ). Finally, we needto show that 2 k = O ( √ Σ n ). Thanks to the constant density packing of B (cid:96) , we have 2 k Σ / j = O (2 (cid:96) T j ) = O (Σ j ). Dividing both sides by Σ / j we get 2 k = O (Σ / j ). In the end notice that, thanks to the long edgehypotheses H n ≤ Σ n and we have Alg = O (2 k (cid:102) H k ) = O (2 k H n + Σ n ) = O (Σ / n ) = Opt · O ( √ Opt ).So far we managed to match the competitive ratio lower bounds of Ω( √ n ) and Ω( √ Opt ) employingtwo different algorithms:
DynBoxRot and
DynBoxRot √ Opt . A natural question is whether is itpossible to match the performance of these algorithms simultaneously, having an algorithm that achievesa competitive ratio of O (min {√ n, √ Opt } ). We give an affirmative answer by describing the algorithm DynBoxRot √ n ∧ √ Opt .Again, we employ the same scheme of
DynBoxRot with a different threshold function. This timethe definition of T j is slightly more involved. First define (cid:101) T j = (cid:40) Σ / j + 7 H j , if Σ j < j H j √ n + 7 H j , otherwise.Later we will write (cid:101) T j as (cid:101) T j = { Σ j When used on the problem AreaRotation , the algorithm DynBoxRot √ n ∧ √ Opt has anabsolute competitive ratio of O (min {√ n, √ Opt } ) , where Opt is the area of the optimal offline packingand n is the total number of pieces in the stream.Proof. Again, we define W := max i =1 ,...,n w i . Recall that in DynBoxRot we preprocess every piece p rotating it so the w p ≤ h p , hence W ≤ √ Σ n . Let B k be the last active box, so that we can enclose allthe pieces in a bounding box of size 2 k +1 × T n . There exists a n (cid:48) ≤ n such that T n = (cid:101) T n (cid:48) . We can boundthe area returned by the algorithm as Alg = O (cid:16) k (cid:101) T n (cid:48) (cid:17) = O (cid:16) k H n (cid:48) + { Σ n (cid:48) 23e bound the optimal offline packing as Opt = Ω(Σ n + W H n ). If the active box never changed, thenwe have 2 k < W that implies ALG = O (cid:16) W H n + { Σ n (cid:48) BrickRotation to pack the bounding boxes of thepieces. Since the area of each piece is at least half of the area of its bounding box, the density of theproduced packing is at least half of the density of the packing of the bounding boxes. This results in anincrease of the competitive ratio by a factor of at most √ O (1), and this seems to be a very interesting question for future research. In order to designsuch an algorithm, it would be sufficient to show that for some constants δ > > 0, there is anonline algorithm that packs any stream of convex polygons of diameter at most δ and total area at mostΣ into the unit square, which is in itself an interesting problem. The three-dimensional version of thisquestion has a negative answer, even for offline algorithms: Alt, Cheong, Park, and Scharf [3] showedthat for any n ∈ N , there exists a finite number of 2D unit disks embedded in 3D that cannot all bepacked by translation in a cube with edges of length n . References [1] Hee-Kap Ahn and Otfried Cheong. Aligning two convex figures to minimize area or perimeter. Algorithmica , 62(1-2):464–479, 2012.[2] Helmut Alt. Computational aspects of packing problems. Bulletin of the EATCS , 118, 2016.[3] Helmut Alt, Otfried Cheong, Ji-won Park, and Nadja Scharf. Packing 2D disks into a 3D container.In International Workshop on Algorithms and Computation (WALCOM 2019) , pages 369–380, 2019.[4] Helmut Alt, Mark de Berg, and Christian Knauer. Approximating minimum-area rectangular andconvex containers for packing convex polygons. In , pages 25–34, 2015.[5] Helmut Alt and Ferran Hurtado. Packing convex polygons into rectangular boxes. In , pages 67–80, 2000.[6] Brenda S. Baker and Jerald S. Schwarz. Shelf algorithms for two-dimensional packing problems. SIAM Journal on Computing , 12(3):508–525, 1983.[7] Allan Borodin and Ran El-Yaniv. Online computation and competitive analysis . Cambridge Uni-versity Press, 2005.[8] Brian Brubach. Improved bound for online square-into-square packing. In , pages 47–58, 2014.[9] Henrik I. Christensen, Arindam Khan, Sebastian Pokutta, and Prasad Tetali. Approximation andonline algorithms for multidimensional bin packing: A survey. Computer Science Review , 24:63–79,2017.[10] Fan Chung and Ron Graham. Efficient packings of unit squares in a large square. Discrete &Computational Geometry , 2019.[11] J´anos Csirik and Gerhard J. Woeginger. On-line packing and covering problems. In Amos Fiat andGerhard J. Woeginger, editors, Online Algorithms: The State of the Art , pages 147–177. Springer,1998.[12] Paul Erd˝os and Ron Graham. On packing squares with equal squares. Journal of CombinatorialTheory, Series A , 19(1):119–123, 1975.[13] S´andor P. Fekete and Hella-Franziska Hoffmann. Online square-into-square packing. Algorithmica ,77(3):867–901, 2017.[14] Amos Fiat and Gerhard J. Woeginger. Competitive analysis of algorithms. In Amos Fiat andGerhard J. Woeginger, editors, Online Algorithms: The State of the Art , pages 1–12. Springer,1998.[15] Janusz Januszewski and Marek Lassak. On-line packing sequences of cubes in the unit cube. Ge-ometriae Dedicata , 67(3):285–293, 1997.[16] Marek Lassak. On-line potato-sack algorithm efficient for packing into small boxes. PeriodicaMathematica Hungarica , 34(1-2):105–110, 1997.2517] Hyun-Chan Lee and Tony C. Woo. Determining in linear time the minimum area convex hull oftwo polygons. IIE Transactions , 20(4):338–345, 1988.[18] Boris D. Lubachevsky and Ronald L. Graham. Dense packings of congruent circles in rectangleswith a variable aspect ratio. In Boris Aronov, Saugata Basu, J´anos Pach, and Micha Sharir, editors, Discrete and Computational Geometry: The Goodman-Pollack Festschrift , pages 633–650. 2003.[19] Boris D. Lubachevsky and Ronald L. Graham. Minimum perimeter rectangles that enclose congruentnon-overlapping circles. Discrete Mathematics , 309(8):1947–1962, 2009.[20] Victor J. Milenkovic. Translational polygon containment and minimal enclosure using linear pro-gramming based restriction. In Proceedings of the twenty-eighth annual ACM symposium on Theoryof Computing (STOC 1996) , pages 109–118, 1996.[21] Victor J. Milenkovic. Rotational polygon containment and minimum enclosure using only robust2D constructions. Computational Geometry , 13(1):3–19, 1999.[22] Victor J. Milenkovic and Karen Daniels. Translational polygon containment and minimal enclosureusing mathematical programming. International Transactions in Operational Research , 6(5):525–554, 1999.[23] Dongwoo Park, Sang Won Bae, Helmut Alt, and Hee-Kap Ahn. Bundling three convex polygons tominimize area or perimeter. Computational Geometry , 51:1–14, 2016.[24] E. Specht. High density packings of equal circles in rectangles with variable aspect ratio. Computers& Operations Research , 40(1):58 –69, 2013.[25] Rob van Stee. SIGACT news online algorithms column 20: the power of harmony. SIGACT News ,43(2):127–136, 2012.[26] Rob van Stee. SIGACT news online algorithms column 26: Bin packing in multiple dimensions.