Theoretical Computer Science 510 (2013) 102–110
Contents lists available at ScienceDirect
Theoretical Computer Science www.elsevier.com/locate/tcs
The generalization of scheduling with machine cost ✩ György Dósa a , Csanád Imreh b,∗ a b
Department of Mathematics, University of Pannonia Veszprém, Egyetem u. 10, H-8200, Hungary Department of Informatics, University of Szeged, Árpád tér 2, H-6720 Szeged, Hungary
a r t i c l e
i n f o
Article history: Received 18 April 2013 Received in revised form 22 August 2013 Accepted 4 September 2013 Communicated by D.-Z. Du Keywords: Online algorithms Scheduling Packing
a b s t r a c t We study a new online resource allocation problem. Usually in resource allocation problems the tasks are presented by rectangles, where the sides describe the time and the resource needed to perform the task. In the online problem the tasks/rectangles arrive one by one according to a list. If we are to perform the task during the shortest possible time, say H, with fixed amount of resource or by minimal resource keeping the completion time below a given bound W , then the problem can be described as online strip packing. Here we consider the problem where neither the resource nor the time is limited; we minimize the objective γ · H + W , where γ is a fixed positive parameter. In the special case γ = 1 we have to pack the incoming rectangles into a container rectangle with perimeter as small as possible. This problem is a generalization of scheduling with machine cost. We present and analyse a shelf-based online algorithm for the solution of the problem. We also consider the semi online case where the list of rectangles is ordered by decreasing height. Finally we study the version where the sizes of the rectangles are not fixed but the algorithm can modify them keeping their area fixed. © 2013 Elsevier B.V. All rights reserved.
1. Introduction In resource allocation problems one has to perform some tasks during the shortest possible time or using a minimal amount of resource. The tasks are usually modeled by rectangles where the sides belong to the processing time and the required amount of resource. If we have fixed amount of resource or we have fixed time to perform the tasks then the problem can be modeled by strip packing where the items has to be packed without rotation and without overlapping into a unit width strip with minimal height. Here we investigate the problem where neither the amount of resource nor the time is fixed. Then the rectangles can be packed into an arbitrary container rectangle and the goal is to minimize a function of the used resource, denoted by H , and the time, denoted by W . In this paper our objective is γ H + W , where γ > 0 is a fixed parameter. If γ = 1 then the cost equals to the half of the perimeter of the container rectangle. In this paper we consider the online version of this resource allocation problem where the rectangles arrive one by one according to a list L, and we have to pack each of them into the container without any information about the further rectangles. We measure the performance of an online algorithm A by comparing it to an optimal offline algorithm OPT using the competitive ratio. An algorithm is called C -competitive in the absolute sense if its cost is never greater than C times the optimal cost. ✩ This work has been partially supported by the Project TÁMOP-4.2.1/B-09/1/KONV-2010-0005 – Creating the Center of Excellence at the University of Szeged, supported by the European Union, co-financed by the European Regional Development Fund. Cs. Imreh was supported by the Alexander von Humboldt Foundation. Gy. Dósa was supported by project K-TET: 10-1-2011-0115 and also acknowledges the financial support of the Hungarian State and the European Union under the TAMOP-4.2.2.A-11/1/KONV-2012-0072. Corresponding author. E-mail addresses:
[email protected] (Gy. Dósa),
[email protected] (Cs. Imreh).
*
0304-3975/$ – see front matter © 2013 Elsevier B.V. All rights reserved. http://dx.doi.org/10.1016/j.tcs.2013.09.009
Gy. Dósa, Cs. Imreh / Theoretical Computer Science 510 (2013) 102–110
103
Related work. Our problem can be considered as the extension of online scheduling with machine cost. In scheduling with machine cost the number of the machines is not given as part of the input but the algorithm has to purchase each machine for a fixed unit cost. The objective function is to minimize the sum of the number of machines and the makespan which objective belong to the sides of an including rectangle of the schedule (thus γ = 1 holds in this model). The incoming jobs can be assigned to any existing (already bought) machine, it means that W is the number of the purchased machines, and the width of each incoming rectangle is just 1. √ The problem was defined in [13] where an (1 + 5 )/2 ≈ 1.618-competitive algorithm was presented for its solution and competitive ratio. Later improved algorithms were given with competitive a lower bound √ √ of 4/3 was given on the possible ratio of (2 6 + 3)/5 ≈ 1.5798 and (2 + 7 )/3 ≈ 1.5486 in [5] and √ [7]. In [7] the lower bound was also improved, it was shown that no algorithm can have smaller competitive ratio than 2. Some further versions of the problem have been also investigated. In [12] the problem with general machine costs, in [19] the problem with preemptive scheduling, in [6] and [16] the problem where it is allowed to reject some jobs were studied. The bicriteria version of this problem in case of unrelated machines is studied in [1]. An another closely related problem is online strip packing. In strip packing the width of the container is fixed and the goal is to pack the elements without overlapping using the minimal height. Only a few online algorithms were presented for that problem. The first algorithms, the shelf algorithms were developed in [3]. The presented algorithms are 7.46 and 6.99 competitive. The first lower bound of 2 for the competitive ratio of any online strip packing algorithm was given in [2]. Later the lower bound was improved to 2.25, 2.43, 2.457 and 2.589 in [14,9,15] and [8]. An improved shelf algorithm and a generalized definition of shelf algorithms were defined in [4], furthermore, a matching lower bound h∞ ≈ 1.69103 on the asymptotic competitive ratio of the shelf algorithms was also presented. The algorithm with the currently smallest competitive ratio is 6.623-competitive, such algorithms were presented in [10] and [17]. Suppose (as above) that the vertical side of the incoming rectangle corresponds to the resource needed to execute the task, and the horizontal side of the rectangle belongs to the time needed to execute the task. In the real life there exist such situations when one can modify the properties of the task (the sides of the rectangle) to use less resource, but using less resource means that it takes more time to execute the task. Or similarly, it is also possible to decrease the time needed to execute the job, but in this case the execution needs more resource. To handle this kind of relaxation it is supposed that one is allowed to change the rectangle keeping its area fixed. This version of the strip packing problem (where the sizes of the rectangles are not fixed but the algorithm can lengthen them keeping the area unchanged) was studied in [11]. In this modified model a 4-competitive algorithm was presented and a lower bound of 1.73 was given on the possible competitive ratio. A further related model is the online multiple strip packing problem where there are more strips and the decision maker is allowed to pack the rectangles into one of them. This problem was studied in [18]. Our results. First we study the online problem and we present a shelf-packing algorithm Shelf (α ), and prove that it is 7.4803-competitive if we choose α , the parameter of the algorithm optimally. For the special case when the rectangles for arrive in a list ordered by decreasing height an another shelf algorithm SDH(β ) is presented which is 2.5-competitive an appropriate choice of β . In case of modifiable rectangles (keeping their area fixed) we present a (2 −
1.1371-competitive algorithm and prove that no online algorithm can have smaller competitive ratio than
√
2)
3 √
2 2
5 4
√
2+2≈
≈ 1.061.
Notations. Let the height and the width of the i-th rectangle be denoted as h i and w i , respectively and let T be the total area of the rectangles. Moreover denote the maximum height and weight of the rectangles by H max and W max . We will use OPT to denote the objective value of the optimal offline solution, and let A denote the value got by an online or semi online algorithm A. We will denote the height and width of the container rectangle in the case of an optimal (offline) solution by H ∗ and W ∗ , respectively, and simply by H and W , respectively, in the case of the solution given by the online algorithm. We will use the following lower bounds on the optimum value several times, thus we define them here. First observe that
OPT = γ H ∗ + W ∗ 2
γ T = LB1 .
We obtain this bound by H ∗ W ∗
√ T using γ H ∗ + W ∗ 2 γ H ∗ W ∗ which comes from comparing the arithmetic and
geometric means. Our second bound is obviously follows by the definition of the problem
OPT = γ H ∗ + W ∗ γ H max + W max = LB2 . The container rectangle will be simply called as container in the following. The number of incoming rectangles will be denoted by n, naturally it is not known in advance only when the sequence stops. 2. The online problem We define the following shelf-packing algorithm for the solution of the problem. The algorithm uses a positive parameter α . We make “shelves” on the top of each other, and we pack the rectangles onto them. These shelves are horizontal stripes. For each integer k the height of a shelf of type k will be 2k . First for any new rectangle we identify the type of the rectangle. The type of the rectangle is k for certain integer k, if 2k−1 < h i 2k holds. Really, each new rectangle can
104
Gy. Dósa, Cs. Imreh / Theoretical Computer Science 510 (2013) 102–110
Fig. 1. The container rectangle resulted by Algorithm Shelf(α ).
be classified into exactly one type. Then we check whether there exists an open shelf of type k. If there exists open shelf of type k, we assign the rectangle to this open shelf. If it’s current (used) width reaches α -times the current height of the container, then we close this shelf and do not use it later. If no open shelf of type k exists then we open a new shelf on the top of all other shelves and put the new rectangle there. After that we close this shelf if it’s current (used) width reaches α -times the current height of the container. We keep only at most one shelf open from each type at any time. The container consists of the existing shelves, its height is the sum of the heights of the shelves, its width is the maximum width of the shelves what is occupied by some rectangle. The detailed description of the algorithm is as below:
Algorithm Shelf(α ) 1. i = 1. 2. After the arrival of rectangle p i = ( w i , h i ) we identify its type k, where 2k−1 < h i 2k holds. 3. If there exists open shelf of type k (i.e. shelf of height 2k ) then put the rectangle onto this shelf as left as possible. If the used width of the shelf reaches α -times the actual height of the container, close the shelf. Go to Step 5. 4. If there is not open shelf of type k then create a new shelf of type k on the top of the existing shelves, and put the rectangle onto it as left as possible. If the used width of the shelf reaches α -times the actual height of the container, close the shelf. Go to Step 5. 5. If there is not more rectangle Stop. Otherwise i = i + 1, go to Step 2. We present the behavior of the algorithm by the following example. Let α = 1, and let the list of the incoming rectangles be as follows. Let r1 = (2, 5/3), then t 1 = 1. The first rectangle is packed on the first shelf of type 1, and the shelf is closed, since the actual height of the container is 2, and it equals to the used width of the shelf. Let r2 = (2, 1), then t 2 = 0. This rectangle opens a shelf of type zero and packed there. Let r3 = (2, 6/5), then t 3 = 1. A new shelf of type 1 is opened at the top, as the previous shelf of type 1 is already closed. Let r4 = (4, 4/5) and r5 = (2/3, 2), then t 4 = 0 and t 5 = 1, and these rectangles are packed on the existing shelves of their types. Let r6 = (4, 7/3), then t 6 = 2 and new shelf of type 2 is opened at the top and the rectangle is packed there. Finally let r7 = (4, 6/5), then t 7 = 1 and he rectangle is packed to its existing shelf since it is still open. The container rectangle is presented in Fig. 1. Theorem 1. Algorithm Shelf(α ) is (4 γα +
α γ +4+
γ α )-competitive.
Proof. Note that for any k there is at most one open shelf at any specific time. For each type k, we call the open shelf the final shelf of type k if there exists open shelf for this specific type. The other shelves are called early. Let H F be the total height of the final shelves and H E be the total height of the early shelves. Let K denote the type of a rectangle with height H max . It means that 2 K −1 < H max 2 K is valid, i.e. the height of the tallest shelf is 2 K . Since there exists at most one final shelf from any smaller type, the total height of the final shelves is at most
HF
∞
2 K −i 2 · 2 K = 4 · 2 K −1 4 · H max .
i =0
Now consider H E . Recall that when any specific shelf is closed, the used width of this shelf is at least α -times the current height of the container. Now denote the heights of the early shelves started from the bottom of the container by k1 , . . . , km , where m is the j number of the early shelves. The height of the container is at least p =1 k p when the j-th early shelf is closed therefore
j
we obtain that the used width of the j-th early shelf is at least α p =1 k p . Moreover, we know that the height of each rectangle is at least the half of the height of the shelf containing it. Therefore we obtain that the total area T of the
Gy. Dósa, Cs. Imreh / Theoretical Computer Science 510 (2013) 102–110
105
rectangles is at least
m 1 2
j =1
k jα
j
1 /2 · α
kp
m
p =1
2 kj
2.
j =1
Therefore we obtained that T α H 2E /4, thus
OPT 2
√ √
γT =2 γ
T
√
√
T
√
α · H E /2 follows. By using lower bound LB1 , we obtain
αγ · H E ,
1 i.e. H E √αγ OPT. The width of the container is bounded by lower bound LB2 and 4(α + γ ) γ we get
α times the height of the container plus the maximum width, thus using the
Shelf (α ) = γ H + W γ H + (α H + W max ) = (α + γ )( H F + H E ) + W max
1 (α + γ ) 4 · H max + √ OPT + W max
αγ
4 1 = (α + γ ) · γ H max + √ OPT + W max
γ
αγ
4 1 (α + γ ) (γ H max + W max ) + √ OPT
γ
αγ
4 1 +√ OPT (α + γ )
α = 4 + γ
γ
αγ
α +4+ γ
and this proves the theorem.
is 8x + 1 −
1 , x2
γ OPT , α
2
Corollary 1. If we use the optimal Proof. Let x =
α γ = 0.46161 choice for a, the algorithm is 7.4803-competitive.
α 2 γ , then the proven bound on the competitive ratio looks as c (x) = 4x + x + 4 + 1/x. The derivative of c (x) 2 x3
+ 8 > 0. Thus c (x) is convex in the interval 0 < x < 1, and the derivative is zero iff 8x + x − 1 = 0. This equation has exactly one real root which is approximately x0 = 0.46161. At this point the value of the competitive ratio is approximately c (x0 ) = 4x20 + x0 + 4 + 1/x0 ≈ 7.4803. 2 3
and the second derivative is 2
3. Rectangles with decreasing height In this section we deal with the subcase when the heights of the incoming rectangles are decreasing. We present here another shelf-algorithm, where the shelves are defined above each other, and we use always only the shelf on the top of the other shelves. This shelf is called the actual shelf. We again use a technical parameter 0 < β 1, it is a fixed real number. Algorithm SDH(β ) (shelf, decreasing height) 1. If the actual width of the actual shelf is at most β -times the actual height of the container, then put the next rectangle on the actual shelf as left as it is possible. 2. Otherwise close the actual shelf, and it will be never used again. Open a new shelf above the already existing shelves, and put the actual rectangle at the left corner of this new shelf. Fig. 2 presents the container rectangle for β = 1 and the input sequence containing the items (4, 4), (4, 3), (4, 3), (3, 2),
(2, 2), (2, 2), (9, 1), (4, 1). Theorem 2. Algorithm SDH(β) is 2.5-competitive, if we use β = 0.6γ . Proof. Recall that the height of the container (the sum of the heights of the shelves) is denoted by H , and the maximum width of the shelves (the width of the container) is denoted by W . Note, that H max = h1 . Suppose that there are m 1 shelves and denote the heights of the shelves by s1 , . . . , sm . Then H = s1 + · · · + sm and it is straightforward that the cost of
106
Gy. Dósa, Cs. Imreh / Theoretical Computer Science 510 (2013) 102–110
Fig. 2. The container rectangle resulted by algorithm SDH.
SDH(β) is z = γ H + W . By the algorithmic rule W β H + W max holds, thus we have
z = γ H + W (β + γ ) H + W max . Now we give a lower bound on the optimum value as follows. We are looking for a lower bound on the total area. Where the container is used (i.e. occupied by some rectangle) we say that it is dense. On the first shelf the height of the shortest (last) rectangle is at least s2 , furthermore the building of the first shelf cannot be finished before the used width of this shelf becomes larger than β times s1 . Thus it follows, that at least a rectangle of height s2 and width β s1 is dense on the first shelf. Similarly there must be a dense area on the second shelf with height s3 and width β(s1 + s2 ), as the actual height of the container is s1 + s2 during the building the second shelf. In general, there is a dense area on the i-th shelf with height si +1 , and width β(s1 + s2 + · · · + si ), for any 1 i m − 1. Thus, using s1 s2 · · · sm and H = s1 + · · · + sm , the total area of the rectangles is at least
T s2 · β s1 + s3 β(s1 + s2 ) + · · · + sm β(s1 + s2 + s3 + · · · + sm−1 )
=β β
2 (s1 + · · · + sm )2 − (s21 + · · · + sm )
2 H 2 − s1 (s1 + · · · + sm ) 2
=β
H 2 − s1 · H 2
.
Thus, applying the lower bounds LB1 and LB2 we are looking the greatest possible value of z/OPT, where the next inequalities hold:
z (β + γ ) H + W max ,
OPT 2
βγ
H 2 − s1 · H
2 OPT γ s1 + W max
where we know that H , W max 0, and 0 s1 H . Let us use the next simplifications: let s1 = x · H for some 0 x 1, and W max = y · H , for some y 0. Then the inequalities look as below:
z H · (β + γ + y ), OPT H · (γ x + y ),
OPT H ·
2(1 − x)β γ ,
(1)
0 x 1 , y 0.
(2)
Naturally, we can suppose that H is normalized to be 1, since this normalization does not influence the maximum value . Then (using only of z/OPT. We show that the algorithm is 2.5-competitive if β/γ = 0.6. First let us suppose that x 16 25 the lower bound (2) on OPT) we get
2.5OPT 2.5(γ x + y ) > 1.6γ + y = γ + β + y z. Now let us suppose that 0 x
16 . 25
In other form this means that
3 5
√
1 − x 1. Thus using (1) and (2) we get that
2.5OPT 1.5 2(1 − x)β γ + (γ x + y ) γ + β + y z holds, if
1.5 2(1 − x)β γ γ (1 − x) + β. To verify it, we divide both sides by
√
1.5 1.2 t +
0.6 t
√
2 1 − x > 0, substitute β γ = 0.6γ 2 and t =
√
1 − x. Then it suffices to prove that
Gy. Dósa, Cs. Imreh / Theoretical Computer Science 510 (2013) 102–110
107
Fig. 3. A container rectangle resulted by Algorithm Expand(1).
√ t 1. Note, that the function f (t ) = t + 0t.6 is convex for t > 0, and has one minimum value at t 0 = 0.6 ≈ 0.77460, thus f (t ) is decreasing for 35 t t 0 , and f (t ) is increasing for t 0 t 1. In both borders the value of f (t ) is just √ 1 + 3/5 = 1.6 which is a little bit smaller than 1.5 1.2 ≈ 1.6432. holds if
3 5
1+β /γ Remark 1. By more difficult calculations the competitive ratio can be proven to be 0 + 1 ≈ 2.4625, if β is chosen to 2β 0 / γ
satisfy β0 /γ ≈ 0.5939. The last value is the unique root of equation x4 − 2x3 − 2x2 + 1 = 0 in [0, 1]. We obtain this value by choosing the optimal parameter, we cannot gain better bound on competitive ratio with the method used in the proof for another choice of β . Remark 2. If we consider such inputs where the height of each rectangle is 1 then we receive the scheduling with machine cost problem. Therefore the lower bound √ which is proved in [7] on scheduling with machine cost implies that no algorithm with smaller competitive ratio than 2 exists for sequences with decreasing height. 4. Modifiable boxes In this section we deal with the online problem, where the rectangles (also called as items) come one by one, but when a new item is revealed, we are allowed to modify this rectangle anyway, except the only constraint that the area of the rectangle must be kept. This is a strong relaxation in the sense that it allows us much, and leads to the radical decrease of the competitive ratio. Let T (k) denote the area of the next item. Note that T (k) determines completely the incoming task since we are allowed to transform the item into an arbitrary form keeping the area fixed. First we describe our intuition behind the scheduling algorithm. For this purpose suppose that γ = 1. Then we try to hold the shape of the container as close to a square as possible, in each step, since the square has the smallest perimeter among the rectangles of the same area. Let a(k) and b(k) denote the smaller and bigger sides of the new item, respectively, after the modification of this item, no matter that which of them is the width or the height. In each step, when a new item is revealed, we modify the next item in an appropriate way, glue it along the bigger side of the container, thus the container is expanded in each step. Let the container be of sizes A (k) B (k), just after the k-th item arrived, and just before the k-th item is assigned. First, of course, A (k) = B (k) = 0. (Note that B (k) can be parallel with the x or with the y axis, as well.) The next item R (k) always will be glued into the B (k) side of the container. If R (k) is small, i.e. T (k) B (k)2 , let the joining side of the new item be b(k) = B (k), then the other side of the new item is a(k) = Tb((kk)) B (k). Otherwise, if
√
T (k) > B (k)2 , the new item is formed to be square, i.e. a(k) = b(k) = T (k), and this new square is also glued at the bigger side of the container. In the latter case a “hole” is created in the expanded container, and this hole will not be used later. The description of the algorithm with γ = 1 is as follows: Algorithm Expand(1) T (k)
Step 1. If the next item is small, i.e. T (k) B (k)2 , then let b(k) = B (k) and a(k) = b(k) B (k), glue the new item along the bigger side of the container rectangle, i.e. let B (k + 1) = max{ B (k), √A (k) + a(k)} and A (k + 1) = min{ B (k), A (k) + a(k)}. Step 2. If the new item is big, i.e. T (k) > B (k)2 , then let a(k) = b(k) = T (k), glue the new item along the bigger side of the used rectangle, i.e. let A (k + 1) = a(k) and B (k + 1) = A (k) + a(k). Step 3. If there is no new item, end, otherwise go to Step 1. Remark 3. Surely Step 2 is performed for k = 1, as the first rectangle is modified to be square, and fixed (in the plane). Moreover A (k + 1) A (k) and B (k + 1) B (k) obviously hold for any k 1. Fig. 3 presents an example which shows how Algorithm Expands(1) packs the rectangles. Note that the first rectangle is modified to be square, then the second rectangle is small. The third rectangle is the only one that is big, thus a hole is created near the second rectangle on its right side, and this hole is not used. Since in our model γ is not necessarily unit, we will use the next technique to reduce the general case to γ = 1. We will use a virtual container. At any time the virtual container has the same width as the real container, but has height γ times
108
Gy. Dósa, Cs. Imreh / Theoretical Computer Science 510 (2013) 102–110
the height of the real container. In addition, at any time when a new (real) item of area T (k) comes, we create a virtual item with area γ · T (k). If after the modification the height and width of the new item will be h and w, respectively, the virtual item has height γ · h and width w. Note, that during execution of Algorithm Expand(1), the next step is always done by using only the actual sides of the container and the area of the actual item. Thus, if γ = 1, we apply Algorithm Expand(1) for the actual virtual container and virtual item to get the suitable sides of the item. Then if the virtual item is glued to the horizontal (or vertical) side of the virtual container, the same operation is performed on the real item, it is glued to the horizontal (or vertical) side of the real container similarly. The sides of the new real container are modified appropriately to the modified sides of the virtual container. The given algorithm is denoted as Algorithm Expand(γ ). From this point let A (k) and B (k) mean the smaller and bigger sides of the virtual container, similarly let a(k) and b(k) denote the smaller and bigger sides of the new virtual item, but T (k) still means the area of the incoming real item! We denote the total area of the holes in the virtual container created up to the k-th round of the algorithm as H (k). Note that this is the total not used area of the virtual container. Now we prove that the competitive ratio of Algorithm Expand(γ ) is √ at most
21 4
≈ 1.1456. First we establish some useful lemmas.
Lemma 1. At any step of the algorithm B (k) 2 · A (k) holds. Proof. The statement follows form the construction of the virtual container. We use induction for the proof. In the beginning (assigning the first virtual item which is a square) the statement is trivially true. Suppose that this statement is true for a given k < n and consider the (k + 1)-th rectangle. Case 1. Suppose that Step 1 is applied to pack the rectangle. Then we obtain that a(k) B (k) holds. If B (k + 1) = B (k), then applying Remark 3 it follows that B (k + 1) = B (k) 2 A (k) 2 A (k + 1). Otherwise B (k + 1) = A (k) + a(k) and A (k + 1) = B (k), then B (k + 1) = A (k) + a(k) B (k) + B (k) = 2 A (k + 1) holds again. Case 2. Now suppose that Step 2 is applied to pack the next rectangle, i.e. the new rectangle is big. Then A (k) A (k + 1) = a(k), thus B (k + 1) = a(k) + A (k) 2a(k) = 2 A (k + 1), and the lemma holds as well. 2 Lemma 2. The total hole H (k) in the virtual container is at most
H (k)
1 5
A (k) · B (k).
(3)
Proof. We prove the lemma by induction. After the first step (assigning the first rectangle) there is no hole in the virtual container, thus the statement holds. Now let us consider a later state of the algorithm. If the next (virtual) item is small, i.e. Step 1 is applied, then H (k + 1) = H (k), i.e. the hole is not increased in this step. Since A (k + 1) A (k) and B (k + 1) B (k) hold by Remark 3, the statement trivially holds. Thus suppose that the next (virtual) item is big, i.e. Step 2 is applied. Then a(k) > B (k), moreover H (k + 1) = H (k) + A (k) · (a(k) − B (k)), while A (k + 1) = a(k) and B (k + 1) = a(k) + A (k). Let the size of B (k) be normalized, only for the purpose of this proof, i.e. let B (k) = 1. Moreover, for the sake of simplicity let us use the notations A (k) = x 1, and a(k) = 1 + y for some y 0. Since B (k) 2 A (k), we also know that 1/2 x. Then (3) can be written in the equivalent form
H (k) x/5,
(4)
moreover H (k + 1) = H (k) + xy, (the hole is increased exactly by xy), while A (k + 1) = 1 + y and B (k + 1) = 1 + x + y. Applying the induction assumption (4), it suffices to show that
H (k + 1) = H (k) + xy x/5 + xy = x(1 + 5 y )/5 (1 + y )(1 + x + y )/5. The inequality x(1 + 5 y ) (1 + y )(1 + x + y ) can be written into the equivalent form below:
0 2 y − 4xy + y 2 + 1. This inequality holds because the right-hand side has the smallest possible value if x = 1, then its value is y 2 − 2 y + 1 = ( y − 1)2 0. 2 √
Theorem 3. Algorithm Expand(γ ) is
21 4
≈ 1.1456-competitive.
Proof. Recall that the cost of Algorithm Expand(γ ) is z = γ · H + W , where H and W are the height and width of the real √ container, respectively; and LB1 = 2 γ T , where T is the total area of the real items. Note, that the height and the width of the virtual container √ are just γ · H and W , thus z equals to the sum of the sides of the virtual container, while the value of LB1 equals to 2 T 0 , where T 0 = γ T is the total area of the virtual items. In the proof we will use the following lower
Gy. Dósa, Cs. Imreh / Theoretical Computer Science 510 (2013) 102–110
109
√
bound called LB3 instead of LB1 . LB3 = 2 T 1 , where T 1 is a lower estimate of the occupied space in the virtual container. T 1 equals to the area of the virtual container minus the upper bound given in (3) of the previously created holes in the virtual√container minus the exact area of the hole which is created in the last step of the algorithm. We will show that z LB 3
2
21 4
holds at any step of the algorithm. We prove this inequality by induction. Consider the first item. Then LB3 is
γ T (1) because we had no previous items thus the upper bound given in (3) is 0 and no hole is created during packing √ γ T (1) and LBz3 = 1 421 .
the first rectangle. On the other hand the virtual item is formed into a square, therefore z = 2 √
Now let k < n and suppose that LBz 421 holds after packing the k-th item. We will prove that the inequality is valid after 3 packing the (k + 1)-th rectangle as well. We distinguish the following two cases depending on the new rectangle. Case 1. First suppose that the (k + 1)-th item is assigned by Step 2. We use the same simplification that is used in Lemma 2, i.e. let the size of B (k) be normalized to 1. Then A (k) = x for some 1/2 x 1. By Lemma 2, after handling the k-th item the hole is at most x/5. Since Step 2 is applied, a(k) > B (k), A (k + 1) = a(k) and B (k + 1) = A (k) + a(k). Since by using the normalization B (k) = 1 holds, we can write a(k) = 1 + y with some y 0. Thus A (k + 1) = 1 + y and B (k + 1) = 1 + x + y, and the increased value of the hole is H (k + 1) = H (k) + xy x/5 + xy. We are interested in the maximum possible value of
z
(1 + x + y ) + (1 + y )
= √
2 (1 + x + y )(1 + y ) − xy − x/5)
LB3
= 2
x + 2y + 2 y2
+ 2 y + 4x/5 + 1
(5)
.
2x+6 y +5 y 2 +1 which is positive. Thus it follows that we get the 4 x+2 y + y 2 +1)3 5
The derivative of this expression regarding x is
10(
biggest value of the expression of (5), if x is as big as possible, i.e. in case x = 1. Follows that
z
LB3
2
2y + 3 y2
+ 2 y + 9 /5
(6)
.
By derivating this expression (regarding y) we get
1
2(
3 /5 − y y2
+ 2 y + 9/5)3
,
where the denominator is positive, the numerator is positive if y < 3/5, and becomes negative if y > 3/5. Thus the biggest value of (6) is given if y = 3/5, and we get
z
6 /5 + 3
√
2 9/25 + 6/5 + 9/5
LB3
= √
21
21
2 9 + 30 + 45
= √
2 84
√
=
21
4
.
Case 2. Now suppose that Step 1 is applied for handling the (k + 1)-th item. In this case (by using the previous simplifications of the notation) B (k) = 1, A (k) = x for some 1/2 x 1. After handling the k-th item the hole is at most x/5, and the hole is not increased in the actual step. As Step 1 is applied, b(k) = B (k) = 1 and a(k) B (k), let a(k) = y for some 0 y 1. Also, B (k + 1) = max{1, x + y } and A (k + 1) = min{1, x + y }, thus z = A (k + 1) + B (k + 1) = 1 + x + y and T 1 = x + y − x/5. We need to show that
1+x+ y
z
= √
2 x + y − x/5
LB3
√
21
(7)
4
holds where 1/2 x 1 and 0 y 1. Note, that substituting y = 0, the given value of (7) is at most hypothesis. By derivation of (7) regarding y we get
2x + 3 y − 2
10(
4 x+ 5
√
21 , 4
by the induction
(8)
,
y )3
where the value of the numerator at y = 0 is at most zero since 1/2 x 1. As y grows, at y = 2−32x the numerator becomes zero, and then it remains positive (while the √denominator is positive). Thus the biggest possible values of √ expression
(7) are given if y = 0 or y = 1. Since (7) is at most After the substitution formula (7) seems as
2+x
2
,
4 x+1 5
the derivative of the this expression (regarding x) is
21 4
if y = 0, it suffices only to see whether (7) is at most
21 , 4
if y = 1.
(9)
110
Gy. Dósa, Cs. Imreh / Theoretical Computer Science 510 (2013) 102–110
2x + 1 0, 10( 45 x + 1)3 thus the maximum value of (9) is given when x = 1, and we get
z
√
3
√
LB3
2 9 /5
=
5
2
√
√
=
20
4
<
21
4
.
2 √
5−4p Remark 4. By more complicated analysis it can be shown, that the algorithm is c ( p ) = √ -competitive, if p satisfies 2 1− √p
√
0 < p 1/5 and 1 − 2 p (1 − p ) 2p. This valid range of p values is [ p 0 , 1/5], where p 0 = 2−4 2 ≈ 0.14645. Since function c ( p ) is increasing regarding p, we get the best upper estimate substituting the smallest possible value of p, i.e. p = p 0 . Then we get that the competitive ratio is at most
5 − (2 −
2
√
2)
√
2+ 2 4
=
3+ 2+
√
2
√ ≈ 1.1371. 2
Finally we prove the following lower bound on the possible competitive ratio. √
Theorem 4. No algorithm can have smaller competitive ratio than
3 2 4
≈ 1.0607.
Proof. Consider an arbitrary√online algorithm. Start the sequence by a unit square. The algorithm modifies it into an a × 1/a rectangle, with a 1. If a √ 2, then the sequence of rectangles is ended, the optimal cost is 2 and the cost of the algorithm
√
√
is a + 1/a 2 + 1/ 2 = 3 2 2 , thus the claim follows. Otherwise a new rectangle arrives with area 4a2 . The algorithm can transform it into a c × 4a2 /c rectangle and its√cost is max{a, c } + 1/a + 4a2 /c. It is easy to see that this cost is at least 2a + 1/a + 2a = 4a + 1/a. The optimal cost is 2 4a2 + 1, therefore the ratio of the costs is
4a + 1/a
√
2 4a2 + 1
.
On the other hand this ratio is not smaller than
√
3 2 4
if 2a2 − 1/a2 7/2 which inequality is valid if 1 a
√
2.
2
References [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19]
Y. Azar, U. Bhaskar, L. Fleischer, D. Panigrahi, Online mixed packing and covering, Proc. SODA 2013 (2012) 85–100. B.S. Baker, D.J. Brown, H.P. Katseff, Lower bounds for two dimensional packing algorithms, Acta Inform. 8 (1982) 207–225. B.S. Baker, J.S. Schwartz, Shelf algorithms for two dimensional packing problems, SIAM J. Comput. 12 (1983) 508–525. J. Csirik, G. Woeginger, Shelf algorithms for on-line strip packing, Inf. Process. Lett. 63 (1997) 171–175. Gy. Dósa, Y. He, Better online algorithms for scheduling with machine cost, SIAM J. Comput. 33 (2004) 1035–1051. Gy. Dósa, Y. He, Scheduling with machine cost and rejection, J. Comb. Optim. 12 (4) (2006) 337–350. Gy. Dósa, Z. Tan, New upper and lower bounds for online scheduling with machine cost, Discr. Optim. 7 (3) (2010) 125–135. R. Harren, W. Kern, Improved lower bound for online strip packing, in: Proceedings of the 9th International Workshop on Algorithms and Online Algorithms, in: Lect. Notes Comput. Sci., vol. 7164, 2011, pp. 211–218. J.L. Hurink, J.J. Paulus, Online scheduling of parallel jobs on two machines is 2-competitive, Oper. Res. Lett. 36 (1) (2008) 51–56. J.L. Hurink, J.J. Paulus, Improved online algorithms for parallel job scheduling and strip packing, Theor. Comput. Sci. 412 (7) (2011) 583–593. Cs. Imreh, Online strip packing with modifiable boxes, Oper. Res. Lett. 29 (2001) 79–86. Cs. Imreh, On-line scheduling with general machine cost functions, Discrete Appl. Math. 157 (2009) 2070–2077. Cs. Imreh, J. Noga, Scheduling with machine cost, in: Proc. APPROX’99, in: Lect. Notes Comput. Sci., vol. 1761, 1999, pp. 168–176. B. Johannes, Scheduling parallel jobs to minimize the makespan, J. Sched. 9 (5) (2006) 433–452. W. Kern, J. Paulus, A tight analysis of Brown–Baker–Katseff sequences for online strip packing, J. Comb. Optim. (2013), http://dx.doi.org/10.1007/ s10878-012-9463-1, in press. J. Nagy-György, Cs. Imreh, On-line scheduling with machine cost and rejection, Discrete Appl. Math. 155 (2007) 2546–2554. D. Ye, X. Han, G. Zhang, A note on online strip packing, J. Comb. Optim. 17 (4) (2009) 417–423. D. Ye, X. Han, G. Zhang, On-line multiple strip packing, Theor. Comput. Sci. 412 (3) (2011) 233–239. Y.W. Jiang, Y. He, Preemptive online algorithms for scheduling with machine cost, Acta Inform. 41 (2005) 315–340.