0 4s)
w(s)/s (upper bound)
Interval containing size s i1: (1 - y,l] II: Q/2,1 -
a=0
1 1
w(s)
w(s)/s (upper bound)
1 0
684/419 0
i2: (Y, i/21
l/2
684/419 2 342/265
12: I,: I,: I,:
4/9
11/36
4/3
11/9
5/9 7/18
l/4 l/5 38
5/4 6/5
l/4 l/5
VI
(l/3, Yl (l/4,1/31 (l/5,1/41 (l/6,1/51
16: (l/7,1/61
I,,:
IIs: (l/19,1/18]
(l/(k
38/37
3.8 19+37
38/37 38/37
3’8
- 2)l
- 1)l
342/265 5/3
14/9 5/4 6/5
107 14*37
2*37
107
52*37
4*37
177
20*37
- l),l/(k
Ik-1: (l/k, l/(k Ik: (O,l/kl
j8 13*37
38
I,.$ (l/20,1/19]
I,-,:
38/37
7*37
(l/13,1/12]
l/2
37*37
38/37
l/37
38/37 38/37
38s/37
i3
247
6*37 71
6*37 284
35*37
7*37
445
495
481* 37 l/37 38s/37
481 38/37 38/37
For a = 0, s E I,, and s’ E I,,, 6 2 j 5 j’ < k, upper bound on w(s)/s > upper bound on
Note.
w(s’)/s’.
For example, consider the case for LY> 0, with s1 E II and s2 E 12. Then S=l-(s,+s,)
;+++$y.
2
684
37
w(sJ
ON-LINE
BIN
315
PACKING
TABLE III ListofCasesProvingw(B)<~+$+&forcx>O
W(Q) Sl
4 I, or
z, or II or I1 or
II or I1 or i2
i, i, i, i, i1 iI
$3
12
-
12
-
t
I4
45
13
13
Zj (j
(j 2 5) -
1+:+g*g 1+++:*g l+g+:+$*g
1
1+ g + :*: 1+$+$+&*% 1+:+3*;
:
14
14
or Zj (j 2 2)
Y=&?i<,
:-
I, (i 2 5)
14
Ii
I
s2
t 2
5)
f
-
w(B) + w(s2) + . . . + w(s,) (upper bound)
: 1
1+
:*+ l*f
TABLE IV List of Cases Proving w(B) < t + $ + & for cx= 0 w(B) + w(s2) + . . . +W(S,) (upper bound)
w(sl) Sl
s2
$3
4
12
I 18
i,
12
Zj (j 2 19)
4
Ii (j 2 3)
-
-
-
5
y-3
‘-3x&
y - l/3
13
1+;+-
1
= 37/684 265
4
i2
i2
-
y = 265/684
1 -*2
l/2 1 l-2y=
is
or I2
i,
or
i,
or
12
13
l/12
I2
I2
Ii (j 2 4)
l/3
I2
4 (j 2 3)
-
213
-
-
1
Ii (j 2 3)
14
l+z4*9
< l/4 5
i,
38
+684*37
6*37
1
z+2+-*5
9+9+ii+-*5 9+9+-*-
5 3 154
107
684 7 5
1 3
2*37 1
177
12
4*37 107
2*37
316
RAMANAN
ET AL.
As another example, consider the case for (Y> 0, with si E 1, and s1 E Ii (j 2 5). Then si > i, and S = 1 - si -C $. The S portion of the bin has no piece larger than t, and so w( s)/s I ! for any piece in B other than si. This gives w(B) = w(sJ + i
W(Si) < 1 + : * 2 < 5 + 6.
r=2
As another example, consider the case for (Y= 0, with si E I,, s2 E Z,, and sj E 1s. Then s = 1 - (Si + s2 + S3) < 1 - (; + ; + a) = $. Thus, we know that each of sq,. . . , S, must be smaller than A, and so w(si)/si 5 177/(4*37) for 4 5 i 5 t. This gives
w(B) = w(sl) + W(Q) + w(+) + i W(Si) i=4
< 2 + ; + & + &*177/(4*37) <+++. Tables III and IV enumerate all possible cases, and it is easily checked that the values in the w(B) column are all at most + + $ + &. Thus, the result of the lemma follows. 0 Lemmas 1 and 2 guarantee that the performance ratio of MH is less than + + ; + &. We now show that this bound is essentially tight. LEMMA 3. Let y = z, k = 38, m2 = 9, m3 = 12, and mp = (k - 1) -(p + l)/(k - p - 1) = 37(p + 1)/(37 - p) for 6 I p < k - 2. Then R hmG+i+k-&-
Proof.
We shall exhibit lists L with arbitrarily MI(L) OWL)
3 1 =y+9+=--
1
large OPT(L)
such that
1 987,012 ’
Let n be a multiple of 24,675,300, and let L, = (pl, p2,. . . , p,), L, = qn), L, = ($1, t,>. . . , t,,), L, = (~1, ~2,. . . ,242,J and L, = u,), where pi = : + E, qi = y + E, ti = & + E, ui = & + E, and u. = 1 - 5q for some E, 0 < E < lo- “. Let L be the list obtained by cbncr%%ing these lists; i.e., L = L,L,L, L,L,.
ON-LINE
BIN
317
PACKING
Note that pi + qi + ti + 2ui + ui = 1. Hence, the packing in which each bin contains a pi piece, a qi piece, a ti piece, two ui pieces, and a ui piece is an optimal packing, and so OPT(L) = n. Now consider the packing produced by our algorithm. Note that mz5 =yandm 26 = 5. Since [25yl= 9 and [26y]= 10, 9 tj pieces or 10 ui pieces can be packed in the same bin with a pi piece. Thus, the packing produced by our algorithm consists of n n-p--= 9% n 9%
=
2n low6 2n
64,702n bins, each containing 64,935
bins, each containing
1 pi piece,
1 pi piece, and 9 ti pieces,
1443 9
2n lam,,
lln = 4995 bins, each containing ,
n(1 - l/m,,)/25 2n(l - l/m&/26
1 pi piece, and 10 ui pieces,
= 19n/481 bins, each containing
25 ti pieces,
= 76n/999 bins, each containing 26 ui pieces,
n/2 bins, each containing 2 qi pieces, and n/26,676 Summing,
bins, each containing 26,676 vi pieces.
we obtain
MH(L) OPT(L) Since OFT(L)
3
1
1 = z + 9 + 222 -
= n can be arbitrarily
1 987,012 ’
large, the result follows. 0
Note that 987,012 = 26,676; 37. The discrepancy of l/987,012 in our analysis is due to the weights we assigned to the I,-pieces. For the list considered in the proof of Lemma 3, bins of type B, are completely packed, instead of being only (k - 1)/k full. Lemmas 1, 2, and 3 are summarized by the following theorem. THEOREM
a( p + l)/(k
1. Lety=~,k=38,m,=9,m,=12,andmP=(k-1) - p - 1) = 37( p + 1)/(37 - p) for 6 I p I k - 2. Then
318
RAMANAN ET AL.
i.e.,
1.6156146 < R,,
< 1.(615)*.
4. A GENERAL LOWER BOUND In this section, we show that for a large class of linear-time on-line algorithms based on partitioning the interval (0, 11, including the Modified Harmonic Algorithm, the performance ratio is at least $ + t = 1.61*. Let C be the class of algorithms which behave as follows. If A E C, then A divides the interval (0, l] into disjoint subintervals, including j, =
(1 - y, 11, 4 = C:,1 - ~1, 7, = (Y, $1, I2 = (5, ~1, and IA = (0, Al, for some y and X, $ < y < $, and 0 < A I $. Pieces are classified according to the intervals to which they belong. The packing produced by A must obey the following rules: (Rl) The number of bins which contain only one &-piece (with or without pieces of other types) is a fixed fraction l/m (m need not be an integer, and if this fraction is zero, we take m to be co) of the total number of I,-pieces in the input list. (R2) No bin may contain (i) an Ii-piece and an &piece or (ii) an Ii-piece and an &-piece. (R3) -No bin may contain an IA-piece together with an I,-piece, Ii-piece, 1,-p&e, or an &-piece. For A < $, (X, :I-pieces can be packed in any manner (even with pieces of other types). Note that the Modified Harmonic Algorithm is in C. We have the following lower bound on the performance of any algorithm in C. THEOREM 2.
For any algorithm A E C, R, 2 : + $ = 1.61*.
Proof: We shall exhibit three kinds of lists L with arbitrarily large OPT(L), and show that the average value of A( L)/OPT( L) for these three kinds of lists is at least : + 6. Let n be a positive integer that is a multiple of 6m (for simplicity, we assume that m is rational), and M = [1/(6h)]. Each of these three kinds of lists will be of the form L = L,L,L,, where L, = (u,, ~2,. . . , un), L, = (u,, 4,. . . , u,,), and L, = (tl, t,, . . . , tM,,). Moreover, we will always have ui + ui + it4 ti = 1. Hence, the packing in which each bin contains a ui piece, a ui piece, and M ti pieces is an optimal packing, and so OPT(L) = n.
ON-LINE
BIN
319
PACKING
Let E be such that
(:
Q<&
-VI’ (Y - 9’ (M + 1)“’ (A4 + 1)2 I *
Instance 1. Let ui = : + M&/2, ui = : + M&/2, and ti = 1/(6M) - E. Clearly, ui E It, ui E 12, and ti E IA. Now consider the packing produced by algorithm A. By rules Rl to R3 imposed on the algorithms in class C, this packing consists of n(1 - l/m)/2 bins, each containing 2 vi pieces, n/m bins, each containing 1 ui piece (and maybe 1 ui piece), at least n(1 - l/m) bins, each containing 1 ui piece alone, and at least n/6 bins containing ti pieces. Hence A(L)
2 n(1 - l/m)/2
+ n/m + n(1 - l/m)
+ n/6
= ($ - 1/(2m))n. Since OPT(L)
= n can be arbitrarily
large, we have
R, 2 ; - 1/(2m).
0)
This inequality arises from the fact that if l/m is too small, then only few I,-pieces will be packed in bins of type B,, leading to lot of wasted space. Instance 2. Let z+ =_ 1 - y t ME/~, ui = i + ME/~, and ti = (y - :)/ M - E. Clearly, ui E II, ui E 12, and ti E I,,. Now consider the packing produced by algorithm A. This packing consists of n bins, each containing 1 ui piece, n(1 - l/m)/2 bins, each containing 2 ui pieces, n/m bins, each containing 1 ui piece, and at least [nM/\M/( y - ;)I 1 bins containing ti pieces. Hence A(L)
2 n + n(1 - l/m)/2 2 (2 +y
Since OPT(L)
+ n/m + [nM/[M/(y
- 3)]1
+ 1/(2m))n.
= n can be arbitrarily
large, we have
R, 2 z + y + 1/(2m).
(2)
RAMANAN ET AL..
320
This inequality arises from the fact that if y or l/m is too large, then when L has no I,-pieces, there will be many bins of type B, containing only an I,-piece, ieading to lot of wasted space. Instance 3. Let ui = $ + FE/~, ui = y + ME/~, and t, = ($ - y)/ M - E. Clearly, ui E Zr, ui E Z2, and ti E I,. Now consider the packing produced by algorithm A. This packing consists of n bins, each containing 1 ui piece, at least n/2 bins containing ui pieces, and at least [nM/[ M/( i - y )] 1 bins containing
ti pieces.
Hence A(L)
2 n + n/2 + [nM//M/(~
Since OF’T( L) = n can be abitrarily
-y)jl
2 (2 -y)n.
large, we have
R,22-y.
(3)
This inequality arises from the fact that pieces of size y + E are classified as I,-pieces, and packed exclusively in bins of type &; if y is too small, this will lead to lot of wasted space in bins of type B,. Adding (l), (2), and (3) we have 3R, 2 29/6, or R, 2 3/2 + l/9. 0 Note that for R, = 3/2 + l/9, the inequalities (l), (2), and (3) are satisfied by equality, if we let y = &, and m = 9. For our algorithm analyzed in Section 3, we let m2 = 9. But we let y = $$, slightly less than &. This is because the weights of the I,-pieces, 6 I p I k, were larger than their sizes, and their weights for cu= 0 were larger than their weights for 01 > 0. By choosing a suitable value for y close to &, we obtained R, < : + t + &, which is close to the lower bound result of the above theorem.
5. FURTHER IMPROVEMENTS
In this section, we first show how to successively construct classes of improved algorithms with performance ratio less than $ + $, by dividing (i, l] and (:, +] into more than two parts. For any algorithm in any of these classes, the performance ratio is at least $ + h = 1.583*. As an example of the improvement, we present a linear-time on-line algorithm with performance ratio less than 1.612.. . . We also present an approach to construct linear-time on-line algorithms with better performance ratios. We believe that this approach would lead to an algorithm with performance ratio less than 1.59.
ON-LINE
BIN
PACKING
321
For any h 2 1, consider the class C@) of algorithms which behave as follows. If A E C(l), then A divides the interval (0, l] into disjoint subintervals, including Zi = (1 - y,, 11, Zi, j = (1 - yj+i, 1 - yj], 1 I j I h, Z* = (y,,, l/2], I*, j = (yhpj, yhpj+i], 1
322
RAMANAN
MODIFIED
HARMONIC-2
ET AL.
ALGORITHM
for i := 1 to n do casep,
Zj (j
in
‘1: pack p, in an empty bin of type 3, I, : harmonic pack( pi, i2 ) = 4, 5): harmonic pack( p,, I,) Zk: pack pi in bins of type Bk by Next-Fit I,, t : if there exists a nonempty bin of type B, then pack pi in any such bin, and change the bin’s type to Bl,l else pack pi in an empty bin of type B,,, 1r.s: if there exists a nonempty bin of type B,,, that does not contain an Zl,,-ptece then pack pi in any such bin else if there exists a nonempty bin of type B, then pack pi in any such bin, and change the bin’s type to B,,, else pack pi in an empty bin of type BIT, I,.,: ifp, is the (nrs,tr)th I,,,-piece to arrive thus far for some integer r 2 1 then if there exists a bin of type B,,, containing only an I,,,-piece then pack p, in any such bin else pack pi in an empty bin of type B,,, else harmonic
I,.,: ifp,
I,: ifp,
pack(
pi, I+ 1)
is the (m,,,r)th I,,,-prece to arrive thus far for some integer r > 1 then if for some j = 1,2, there exists a bin of type B,, , containing only an Il. j-piece then pack pi in any such bin else pack p, in an empty bin of type B, else harmonic pack( p, , Z2. 2) is the (m,r)tb Is-piece to arrive thus far for some integer r >_ 1 then if for some j = 1,2, there exists a bin of type B,, , containing only
an
I,, j-piece then pack p, in any such bin else pack pi in an empty bin of type Bl else harmonic i, (6 5 p I k -
pack(
p, , I,)
1): ifp, is the (m,r)th I,-piece to arrive thus far for some integer r 2 1 then if there exists a bin of type B,, B,, r, or B,, s, containing at least one, and at most 1pyt ] - 1 I,-pieces then pack pi in that bin e/se if for some j = 1,2, there exists a bin of type B,, , containing only an I,, j-piece then pack p, in any such bin else pack pi in an empty bin of type Bl else harmonic
pack ( p, , I,)
end.
We have the following Oh).
bound on the performance
of any algorithm
THEOREM 3. For any integer h 2 1, and any algorithm R, 2 ; + 2h/6(2h+1 - 1).
in
A E Cch),
ON-LINE
BIN
323
PACKING
Proof. As in the proof of Theorem 2, we shall exhibit 2h + 1 kinds of lists L with arbitrarily large OFT(L), and show that maxL A( L)/OPT( L) for these kinds of lists is at least $ + 2k/6(2h+1 - 1). Each of these kinds of lists will be of the form L = L,L,L3, where L, = (u,, Q,. . . , un), L, = (u1, u2, * * *, u,,), and L, = (h, f,, . . . , tM,,). Moreover, we will always have ui + ui + Mti = 1. Hence, the packing in which each bin contains a ui piece, a ui piece, and M tj pieces is an optimal packing, and so OFT(L) = n. For each j, 1 I j < h, consider the list L where ui = : + ME/~, ui = yhej + M&/2, and ti = ($ - yhwj)/M - E, where E and M are chosen such - yhej)] ti pieces that ui E Ir,h, ui E 12,j, ti E IA, and exactly [M/(1/2 can be packed in a bin. Considering A( L)/OFT( L) for each of these lists, we have that (since OpT( L) = n can be arbitrarily large) R, 2 2 -
yh-j
-
1/(2m,,j). (4)
For each j, 1 I j I h, consider the list L where ui = 1 - yh-j+ 1 + ui = y,,-, + ME/~, and ti = (yhej+r - y&i)/M - E, where E and M are chosen such that ui E Ir,h-j, ui E I,, j, ti E I,, and exactly t i pieces can be packed in a bin. Considering lM/(Yh-j+l - Yh-j)] A( L)/OFT( L) for each of these lists, we have that (since OFT(L) = n can be arbitrarily large) ME/~,
R, 2 312
+
Y/z-j+1
-
Yh-j
+
1/(2m2,
j).
(5)
Consider the list L where ui = : + ME/~, ui = y,, + ME/~, and ti = ($ - y,)/M - E, where E and M are chosen such that ui E II,h, ui E j,, ti E IA, and exactly 1M/( f - yh)] ti pieces can be packed in a bin. As before, we have R, 2 2 - yh.
(6)
Considering the 2h + 1 inequalities in (4), (5), and (6) we see that the lower bound is obtained when equality holds in each of them. This happens when 2h+l
-
2j
6(2h+’ - 1)
for 1 I j I h. Substituting
and
m,,j=
6(2h+1 - 1) 2h+l
_
2h-j+l
for y, in (6) we get the lower bound R,>;+
2h 6(2h+’
- 1).
RAMANAN
324 COROLLARY
R, > : + &=
ET AL.
3.1. For any integer h 2 1, and any algorithm 1.583*.
For R, = $ + 2h/6(2h+’ - l), the inequalities satisfied by equality, if we let 1 &=2-
2h+l - 2.i
and
6(2h+’ - 1)
A E Cth),
(4), (5), and (6) are 6(2h+1 - 1)
m2,j=
2hil
_
2h-j-i-1
.
So, we can improve upon the algorithm presented in Section 2. The improvement is based on the following partition of the interval (0, 11: (0, l] = ii 6 Ii,j j-l
u 12 fi 12, 6 Ii, j
j=l
i=3
where f, = (1 - yi, 11, Ii, j = (1 - yj+r, 1 - yj], 1 I j I h, 12 = (yh, l/2], IL?, j =(Yh-jy
Ii =(l/(i
+ 1),1/i],
Yh-jtl],
3
l
I,c = (&l/k],
for some h > 1, y,, = : < yi < yz -C . *. < y, < yh+i = $, and k 2 7. All pieces with size in the interval (i, l] are packed in bins of type B,. All other subintervals have their corresponding bin types. In addition, a fixed fraction l/m,, j of the I,, /pieces are packed in bins of type B,, one piece per bin. A bin of type B, containing an Iz, j-piece can also contain an Ii, i-piece for any i > h - j. Note that since we are trying to obtain a performance ratio less than 1.6, a fixed fraction of the &pieces and a fixed fraction of the Is-pieces should also be packed in bins of type B,. For each p, 3 I p I k - 2, a fixed fraction l/m, of the I,-pieces are packed in bins of type B,. For 3 I p I 5, a bin of type B, containing an $-piece can also contain a piece with size in the interval (i, 1 - l/p]. For 6 2 p I k - 2, we can take mP = (k - l)( p + l)/( k - p - l), and pack 1pyt ] of the I,-pieces in a bin of type B,. Such a bin can also contain a piece with size in the interval (4, 1 - yr]. The analysis of the algorithm is tedious because we need to consider h + 4 weighting functions. We believe that by taking suitably large values for h and k, and appropriate values for the yjs and mjs, we can obtain a linear-time on-line algorithm with performance ratio less than 1.59. 6. CONCLUSIONS We presented a new linear-time on-line algorithm, the Modified Harmonic Algorithm, which has an asymptotic performance ratio less than
ON-LINE
BIN PACKING
325
1.(615)*. We showed that for a large class of linear-time on-line algorithms including the Modified Harmonic Algorithm, the performance ratio is at least i + + = 1.61*. Then we showed how to successively construct classes of improved linear-time on-line algorithms. For any algorithm in any of these classes, the performance ratio is at least : + & = 1.583*. We presented an improved algorithm with performance ratio 1.612.. . , and presented an approach to construct linear-time on-line algorithms with better performance ratios. Finally, we observe that our algorithms lead to improved linear-time on-line algorithms for 2dimensional bin packing. For packing rectangles in a strip, we can modify the shelf algorithm of Baker and Schwarz [BS83]. The shelf algorithm takes a parameter r, 0 < r < 1. Pieces with height h such that r k+ ’ c h I rk, for some k 2 0, are packed in shelves of height rk. The widths of the pieces determine their packing in shelves of appropriate height. Any l-dimensional on-line algorithm can be used to pack the pieces in the shelves. Baker and Schwarz studied the O(n) Next-Fit, and the O(n log n) First-Fit shelf algorithms (which use Next-Fit and First-Fit, respectively, to pack the pieces in the shelves), and showed that they have performance ratios 2/r and 1.7/r, respectively. Hence their performance ratios can be made close to that of the corresponding l-dimensional algorithm by taking r to be arbitrarily close to one. Let x be the l-dimensional algorithm with the least performance ratio R,- that we can obtain using the ideas described in Section 5. This algorithm could be used for packing the pieces in the shelves. This leads to a O(n) shelf algorithm with performance ratio R,-/r that can be made close to R,- by taking r to be arbitrarily close to one.
REFERENCES [BS83] [B79a] [B79b] [CGJ84]
[GJ79] iJ731
B. S. BAKER AND J. S. SCHWARZ,Shelf algorithms for twodimensional packing problems, SIAMJ. Compur. 12 (1983), 508-525. D. J. BROWN, “A Lower Bound for On-line One-dimensional Bin Packing Algorithms,” Technical Report R-864, Coordinated Science Laboratory, University of Ilhnois, Urbana, IL, 1979. D. J. BROWN, draft, 1980. E. G. COFFMAN, JR., M. R. GAREY, AND D. S. JOHNSON, Approximation algorithms for bin packing-An updated survey, in “Algorithm Design for Computer System Design” (G. Ausiello, M. Lucertini, and P. Serafini, Eds.), Springer-Verlag, New York, 1984. M. R. GAREY AND D. S. JOHNSON, “Computers and Intractability: A Guide to the Theory of NP-Completeness,” Freeman, San Francisco, 1979. D. S. JOHNSON, “Near-optimal Bin Packing Algorithms,” Technical Report MAC TR-109, Project MAC, Massachusetts Institute of Technology, Cambridge, MA, 1973.
326
RAMANAN
ET AL.
D. S. JOHNSON, Fast algorithms for bin packing, J. Comput. System Sci. 8 (1974), 272-314. [.IDUGG74] D. S. JOHNSON,A. DEMERS,J. D. ULLMAN, M. R. GAREY, AND R. L. GRAHAM, Worst-case performance bounds for simple one-dimensional packing algorithms, SIAM J. Comput. 3 (1974), 299-325. R. M. KARP, Reducibility among combinatorial problems, in “Complexity of w721 Computer Computations” (R. E. Miller and J. W. Thatcher, Eds.), pp. 85-103, Plenum, New York, 1972. [KK82] N. KARMARKAR AND R. M. KARP, An efficient approximation scheme for the one-dimensional bin packing problem, in “Proceedings, 23rd Armu. Symp. on Foundations of Computer Science, Nov. 1982, pp. 312-320, IEEE Computer SW., New York, 1982. [LL83] C. C. LEE AND D. T. LEE, “A New Algorithm for On-line Bin Packing,” Technical Report 83-03-FC-02, Department of Electrical Engineering and Computer Science, Northwestern University, Evanston, IL, 1983. [LL85] C. C. LEE AND D. T. LEE, A simple on-line packing algorithm, J. Assoc. Comput. Mach.32(1985), 562-572. F. M. LIANG, A lower bound for on-line bin packing, Inform. Process. L&t. 10 v-801 (1980), 76-79. [BR84] D. J. BROWN AND P. RAMANAN, On-line bin-packing in linear time, in “Proceedings 1984 Conf. on Information Sciences and Systems,” Princeton University, Princeton, NJ, March 1984, pp. 328-332. A. C. YAO, New algorithms for bin packing, J. Assoc. Comput. Much. 27 (1980), VW 207-227. v741