Efficient 1-Space Bounded Hypercube Packing Algorithm

A space bounded O(d/logd)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$ O(d/\log d)$$\end{document}-competitive hypercube packing algorithm with one active bin only is presented. As a starting point we give a simple 1-space bounded hypercube packing algorithm with competitive ratio (3/2)d+O((21/16)d)\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$ (3/2)^{d}+O((21/16)^d)$$\end{document}, for d≥3.\documentclass[12pt]{minimal} \usepackage{amsmath} \usepackage{wasysym} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsbsy} \usepackage{mathrsfs} \usepackage{upgreek} \setlength{\oddsidemargin}{-69pt} \begin{document}$$d\ge 3.$$\end{document}


Introduction
In the bin packing problem, we receive a sequence S of items of different sizes that must be packed into a finite number of bins in a way that minimizes the number of bins used. When all the items of S are accessible, the packing method is called offline. The packing method is called online, when items arrive one by one and each item has to be packed irrevocably into a bin before the next item is presented.
One can consider an online method with t bins available for packing at each point in time. It is called t-space bounded. There are three types of bins: active, open and closed. At each point in time, exactly t bins are declared active. At the beginning, t bins are declared active and the remaining bins are open (there are no closed bins). Each incoming item is packed into one of the active bins; the remaining open bins are not available at this moment. We can decide to close an active bin. The most frequent reason for doing this is not enough space to pack an incoming item, however there may be other reasons based on the packing algorithm. When an active bin is closed, a new bin from among open bins is declared active. None of the closed bins is used again. It is natural to expect a packing method to be less efficient with fewer number of active bins. An unbounded space model does not impose any limits on the number of active bins.
Let S be a sequence of items, let A(S) be the number of bins used by algorithm A and let OPT(S) be the minimum possible number of bins used to pack items from S. The asymptotic competitive ratio for algorithm A is defined as: Online bin packing is a classical problem studied for more than forty years. Onedimensional bin packing was first investigated in [27] (see also [20]), where the performance ratio of the First Fit algorithm was proved to be 17/10. The Next Fit algorithm with performance ratio not greater than 2 was discussed in [19]. Revised First Fit presented in [30] has performance ratio 5/3. The article also gives the lower bound 3/2 on the competitive ratio. The result was then improved in [3,22] (the lower bound not smaller than 1.53635) and in [28], where the reader can find the lower bound 1.54014. First Fit and Best Fit algorithms can be found in [7]. The authors of the article [23] improve the upper bound to 1.61217 and give the lower bound 1.58333 for the class of Modified Harmonic algorithms. Seiden in [24] further improved the upper bound to 1.58889. Moreover, the upper bound 1.5813 was proved by Heydrich and van Stee (see [14]). Recently, the lower bound on the asymptotic competitive ratio of any online algorithm for bin packing was improved to 1.54278 (see [2]). Furthermore, an algorithm AH (Advanced Harmonic) whose asymptotic competitive ratio does not exceed 1.57829 was presented in [1].
Coppersmith and Raghavan in [5] presented the 2-dimensional online bin packing algorithm with competitive ratio 3.25. The result was later improved in [6] to 3.0625 and in [13] to 2.7834. Further improvements can be found in [25], where the authors show the upper bound of 2.66013 of the asymptotic competitive ratio. Currently the upper bound stands at 2.5545 (see [12]).
The classical 1-dimensional result in bin packing comes from Lee and Lee [21]. The authors presented an online bounded-space algorithm called Harmonic with the lower bound with the competitive ratio ∞ ≈ 1.69103 . The authors also showed that there is no bounded space algorithm with performance ratio below ∞ .
In the Harmonic algorithm and its improvements when the asymptotic competitive ratio approaches the optimal value, the number of active bins diverges to infinity. A question arises: What asymptotic competitive ratio can be achieved when the number of active bins is bounded above by a small natural number? This question was addressed by Woeginger in [29] whose Simplified Harmonic 6-space bounded online algorithm has competitive ratio beneath 17/10. Let d ≥ 3 . We focus on the problem of packing d-dimensional hypercubes of the edge lengths not greater than 1 into a bin (a hypercube of the edge length 1).
The problem of multidimensional bin packing is discussed in [4]. Although previous studies used space bounded models, the number of active bins was usually large (for example, greater than 9 in [8]). The paper [8] by Epstein

3
a space bounded multidimensional hypercube packing algorithm with competitive ratio O(d∕ log d) , however the number of active bins is about d∕ log d . In this paper we describe a hypercube packing algorithm with competitive ratio O(d∕ log d) and with one active bin only. Articles [15,17] provide optimal estimates for online packing of hypercubes to a single bin for d ≥ 4 : any sequence of d-dimensional hypercubes of total volume not greater than 2 1−d can be packed online into a unit hypercube. The first paper concerns the case d ≥ 5 , the second d = 4 . Online packing of hyperboxes into a single bin is studied in [18], where the following upper bound is presented: any sequence of d-dimensional hyperboxes of the edge length smaller than or equal to 1 with total volume not greater than (3 − 2 An algorithm with competitive 2 d+1 that uses only one active bin is presented in the article [31]. In the same paper the authors provide 1-space bounded algorithm for hyperbox packing with competitive ratio 4 d . Algorithms with smaller competitive ratios can be found in [11], where the authors give hyperbox packing methods with ratios (3.5) d and 12 ⋅ 3 d . 1-space bounded 2-dimensional online packing algorithms were studied in [32] (a 4.3-competitive algorithm) and [10] (a 3.888-competitive algorithm). The 2-space bounded 3.8165-competitive algorithm can be found in [16]. The 3-space bounded 3.577-competitive algorithm is presented in [9].
In the first part of the paper we provide the online algorithm tt(d) (with two types of small items) that uses one active bin only with competitive ratio not greater than which is a significant improvement of the previous result ( 2 d+1 , see [31]). The algorithm distinguishes three types of hypercubes: big, 2-small and 3-small. Big hypercubes are packed alone, while the last two types are packed starting from the opposite corners of the bin. Counting the number of 2-and 3-small hypercubes that could be packed together led us to Gould's sequence and a sequence of its partial sums linked with odd entries in Pascal's triangle, which we consider to be a fact worth noting.
The second part of the paper contains the algorithm har(d) in which about d∕ log d types of items are distinguished. The algorithm is a generalization of the tt(d) algorithm and is based on the well-known Harmonic algorithm. Instead of using weights we give a direct proof that also in 1-space bounded model the competitive ratio O(d∕ log d) is achievable.

3
Algorithmica (2020) 82:3216-3249 Each small item is either 2-small or 3-small. Items from these classes will be packed starting from the opposite vertices of the hypercube. Any bin B can be partitioned into 2 d congruent hypercubes called 2-cubes as well as into 3 d congruent hypercubes called 3-cubes (see Fig. 1). Moreover, in the course of packing every k-cube can be partitioned into 2 d n congruent hypercubes with the edge lengths 1∕(k ⋅ 2 n ) , called k-subcubes, for k ∈ {2, 3} and n ∈ {0, 1, 2, …} . 2-cubes [3-cubes]  The order of 3-cubes in B is defined in an analogous way. Furthermore, each subcube has a number assigned to it. Any bin B is partitioned into congruent 2-subcubes with the edge length 1/2, numbered from 1 to 2 d . If S is the subcube with the edge length 1/2 and with number 1 ( 1 ∈ {1, … , 2 d } ), then all 2-subcubes with the edge length 1∕2 2 (the partition of S) are numbered in an arbitrary order from 2 d ( 1 − 1) + 1 to 2 d 1 (see Fig. 2). Moreover, if S is the subcube with the edge length 1∕2 2 and with number , then all 2-subcubes with the edge length 1∕2 3 (the partition of S) are numbered in an arbitrary order from 2 d ( 2 − 1) + 1 to 2 d 2 . Generally, 2 d congruent 2-subcubes forming the partition of S are numbered in an arbitrary order Similarly, any bin B is partitioned into congruent 3-subcubes with the edge length 1/3, numbered from 1 to 3 d . If S is the subcube with the edge length 1/3 and with number 1 ( 1 ∈ {1, … , 3 d } ), then all 3-subcubes with the edge length 1∕(2 ⋅ 3) (the partition of S) are numbered in an arbitrary order from 2 d ( 1 − 1) + 1 to 2 d 1 (see Fig. 2). Moreover, if S is the subcube with the edge length 1∕(2 ⋅ 3) and with number 2 ( 2 ∈ {1, … , 6 d } ), then all 3-subcubes with the edge length 1∕(2 2 ⋅ 3) (the partition of S) are numbered in an arbitrary order from 2 d ( 2 − 1) + 1 to 2 d 2 . Generally, 2 d congruent 3-subcubes into which the 3-subcube with number is divided are numbered in an arbitrary order from 2 d ( − 1) + 1 to 2 d .

Packing Algorithm
If C i is a k-small item, then denote by K i the smallest hypercube of the edge lengths from the set { 1 k , 1 2k , 1 4k , …} into which C i can be packed, k ∈ {2, 3} . For example, if a i = 10∕81 ( C i is 2-small), then K i is a hypercube of the edge length 1/8; if a i = 10∕31 , then the edge length of the smallest hypercube K i containing the 3-small item C i equals 1/3.
A k-subcube of B is empty if its interior has an empty intersection with any item packed so far.
Algorithm tt(d) for packing of C i into B . Example We need to pack a sequence of four items C 1 , C 2 , C 3 , C 4 according to the tt(3) algorithm, see Fig. 3. The edge lengths of arriving items are 1/9, 1/2, 10/81 and 10/31.
The first hypercube is a 3-small item. Moreover C 1 = K 1 and thus it is packed into the empty 3-subcube with the greatest number (inside the 3-cube numbered 27, see Fig. 2). The hypercube C 2 = K 2 is packed into the first 2-cube. For C 3 the smallest 2-subcube into which it can be packed is congruent to a cube K 3 of the edge length 1/8. C 3 is packed into K 3 and then K 3 is packed into a 2-subcube of the second 2-cube. Finally, C 4 is packed into a cube K 4 of the edge length 1/3, which is then packed into the empty 3-cube with the greatest number, which would be the 3-cube with number 26.
Denote by |A| the d-dimensional volume of an item A.
Proof Recall that K i is congruent to the smallest 2-subcube into which C i can be packed. C i is 2-small thus its edge length is greater than 3 −1 ⋅ 2 −n and not greater than 2 −n−1 for some non-negative integer n. We use that lower bound in calculations.

◻
We now give the analogous lemma for 3-small items. 3 = 3∕4 d and let either k = 2 or k = 3 . We say that a k-subcube is used for packing, provided a k-small item was packed into it.

Fig. 3 Four items packed according to the tt(3) algorithm
Lemma 3 Assume that C i is the first k-small item that cannot be packed into a kcube of a bin B by our algorithm. Denote by m k the number of k-cubes (of the edge lengths k −1 ) used for packing. Then the total volume of all k-small items preceding C i packed into B is greater than k m k ⋅ k −d − |C i |.
Proof Let C i be a k-small item. By the assumption, there is no empty k-subcube greater than or congruent to K i , i.e., all empty k-subcubes in B are smaller than K i . Furthermore, for each i = 1, 2, … there are at most 2 d − 1 empty k-subcubes congruent to 2 −i K i . Notice that if there were 2 d empty k-subcubes congruent to 2 −i K i , they would form a whole empty k-subcube congruent to 2 −i+1 K i (recall that the algorithm imposes packing to the subcube with the smallest number).
The total volume of empty k-subcubes in B is smaller than By Lemmas 1 and 2 we know that the total volume of k-small items packed into B is greater than ◻

2-Cubes Versus 3-Cubes
Denote by n 2 the number of 2-cubes used for packing and by U n 2 the union of 2-cubes used for packing in a bin B . Moreover, denote by n − 3 the number of 3-cubes contained in B⧵U n 2 .
We want to have a relation between n − 3 and n 2 . In Lemma 4 we will present a recursive formula. Clearly, n − 3 also depends on d, thus we will use the notation n − 3 = y d (n 2 ) (see Fig. 4).
For d ≥ 2 the values of the sequence y d can be calculated inductively (see the bottom row of Fig. 5). There is a 1-1 correspondence between 3-cubes in a d-dimensional unit hypercube and 3-cubes in three (d − 1)-dimensional unit hypercubes. Assign all 3 d−1 hypercubes C 3 [0] to 3-cubes in the first (d − 1)-dimensional unit hypercube, all 3 d−1 hypercubes C 3 [1∕3] to 3-cubes in the second (d − 1) -dimensional unit hypercube and finally all hypercubes C 3 [2∕3] to 3-cubes in the third (d − 1)-dimensional unit hypercube (see Fig. 6 were used for packing. There is no empty hypercube C 3 [0] as well as there is no empty hypercube C 3 [1∕3] . Let m be an integer such that n 2 = 2 d−1 + m . Obviously, exactly m hypercubes C 2 [1∕2] were used for packing. The number of empty 3-cubes is exactly the same as in the dimension d − 1 and equals y d−1 (m).
Consequently, we get the following inductive formula Note that the sequence y d (n 2 ) is directly related to Gould's sequence, what is proved in "Appendix 1". Now we give the relation between the number n 2 of 2-cubes used for packing and the number n − 3 = y d (n 2 ).

Lemma 4
Let n 2 be the number of 2-cubes already used for packing, let U n 2 be the union of all 2-cubes used for packing and let n − 3 be the number of 3-cubes contained in B⧵U n 2 . For d ≥ 1 and n 2 ≤ 2 d we get Proof Let and let n − 3 = y d (n 2 ) . We will show that The inequality is obvious for n 2 = 0, 2 d−1 , 2 d and arbitrary d.
Notice that for d = 1 the inequality holds true.
The rest of the proof goes by induction. Let d ≥ 2.
Case 1 n 2 < 2 d−2 . By the inductive assumption, Observe that there are integers j and k such that Using the inductive definition of the sequence (2), i.e., y d (

Competitive Ratio
Lemma 5 Assume that only small items are in the sequence S. The total volume of small items packed into any closed bin B is greater than Proof By Lemma 3 we know that the total volume of 2-small items packed into B is greater than 2 n 2 ⋅ 2 −d − 2 −d . Moreover, the total volume of 3-small items packed into B is greater than Proof Let S be a sequence of items of the total volume v, let 1 denote the number of big items in S and let be the number of bins used to pack items from S according to the tt(d) algorithm.
Obviously, OPT(S) ≥ v as well as OPT(S) ≥ 1 . By Lemma 5 and Rule (1) from the description of the tt(d) algorithm we have i.e., Consequently, the asymptotic competitive ratio for tt(d) algorithm is not greater than ◻

The har(d) Algorithm for d ≥ 5
In this section we describe a one-space bounded algorithm for packing d-dimensional hypercubes with competitive ratio O(d∕ log d) . The har(d) algorithm is based on the well-known Harmonic algorithm as well as on the tt(d) algorithm and thus some definitions, notations and even lemmas are similar to those related to the tt(d) algorithm. For instance, if all the hypercubes have the edge lengths from the set {1∕2, 1∕4, 1∕8, 1∕16, … } , then the algorithm works exactly the same as the tt(d) algorithm. Some of the presented bounds are not sharp and can be improved; we preferred non-optimal constants rather than complicated calculations.
By a 1 × a 2 × ⋯ × a d we mean a hyperbox such that its edges parallel to the k-th axis of the coordinate system are of the length a k , for

Intuition About How the Algorithm Works
Different types of items are packed into different active bins by the Harmonic algorithm. Since any unit d-dimensional hypercube can be divided into 2 d hypercubes of the edge length 1/2 (we called such hypercubes 2-cubes, see Sect. 2.2), our first idea for packing with one active bin only was to place different items into different 2-cubes instead of into many active bins. Unfortunately, the losses were too large. For example, any unit hypercube can be partitioned into hypercubes of the edge length 1/5, but a 2-cube cannot. Any 2-cube contains only 2 d hypercubes of the edge length equal to 1/5. Consequently, only (4∕5) d of any 2-cube is occupied by such hypercubes and this ratio is close to zero for large dimensions d. If hypercubes were packed into B 1 = 1 d−1 × (1∕2) , then 4/5 of B 1 would be occupied. Unfortunately, each unit hypercube contains only two hyperboxes congruent to B 1 . Therefore items should be packed into hyperboxes smaller than B 1 but larger than 2-cubes.
In the online version of packing we do not know anything about the size of incoming items, so we should prepare an empty space to pack items of different sizes. For the items of the edge length 1/t, where t = 5, 7, 9, 11, … we will reserve an empty space in special hyperboxes 1 d−q × (1∕2) q−1 × (1∕t) , called layers of the height 1/t. Let us mention that q = q(t) depends on t and that q( For example, the items of the edge length 1/5 will be packed into layers . Such a layer contains 5 d−4 ⋅ 2 3 hypercubes of the edge length 1/5. This means that 64/125 of the layer is occupied by the hypercubes and this ratio does not depend on d. The items of the edge length 1/t, for t ∈ {7, 9} , will be packed into layers 1 d−4 × (1∕2) 3 × (1∕t) . Since 1 5 + 1 7 + 1 9 < 1 2 , it is possible to create three layers (of pairwise disjoint interiors) of the height 1/5, 1/7 and 1/9 in any hyperbox 1 d−4 × (1∕2) 4 . At least 64/125 of any layer of the height 1/t is occupied by hypercubes of the edge length 1/t. Similarly, it is possible to create eight layers 1 d−5 × (1∕2) 4 × (1∕t) , for t = 11, 13, … , 25 , in any hyperbox 1 d−5 × (1∕2) 5 (we have 1 11 + 1 13 + ⋯ + 1 23 + 1 25 < 1 2 ) . In a similar way, layers 1 d−6 × (1∕2) 5 × (1∕t) , for t = 27, 29, … , 69 , will be created in 1 d−6 × (1∕2) 6 . Generally, layers of small height will be created in hyperboxes with comparatively large number of edges of the length 1/2. The number of such hyperboxes in the active bin is relatively large. In any case, despite many edges of the layer are of the length 1/2, at least 64/125 of any layer of the height 1/t is occupied by hypercubes of the edge length 1/t. Items (d-dimensional hypercubes) will first be packed into hypercubes, called m-cubes, of the edge lengths 1∕2, 1∕3, 1∕4, 1∕5, 1∕6, 1∕7, … in our main method. For each m-cube we describe a place in the bin into which this hypercube will be packed. First, we will assign an open B-box (the union of some 2-cubes). Then we will determine the right place in the open B-box to pack the hypercube. Some of m-cubes will be contained in layers created in open B-boxes. The hypercubes of the edge length 1/2 will be packed into open 2-cubes. The hypercubes of the edge length 1/3 will be placed into open B-boxes 1 d−3 × (1∕2) 3 . Moreover, the items of the edge lengths 1/(2t) will be packed next to the items of the edge lengths 1/t, for t = 2, 3, ….
All open hyperboxes have pairwise disjoint interiors. Moreover, all created layers have pairwise disjoint interiors.
Since hypercubes will be packed into layers 1 d−q × (1∕2) q−1 × (1∕t) , where q ≥ 4 , we will assume that in this section. Let us add that it is possible to modify the algorithm and create layers also in smaller dimensions. However, such a modified algorithm would not be effective. Even for d = 5 the upper bound presented in Theorem 2 is distinctively worse than the one given in the proof Theorem 1. The aim of this paper is to present a one-space bounded algorithm efficient for large d.
Example Incoming items will be packed into open hyperboxes of a proper size. Let d = 5 . At the beginning of the packing process three hyperboxes are open in the active bin; the place of the bin into which these hyperboxes are contained is determined by the box(d) algorithm described in Sect. 3.2. H 1 will be called BC 2 -box in Sect. 3.6; hypercubes of the edge length 1∕2, 1∕4, 1∕8, … will be packed into it. H 3 will be called BC 3 -box; hypercubes of the edge length 1∕3, 1∕6 , 1∕12, … will be packed into it. H 2 will be called BL 4 -box; three layers of the height 1/5, 1/7 and 1/9 are created in it.
The items of the edge lengths are packed as on Fig. 7. The first item is placed into H 1 . We will use the aux + (5) algorithm described in Sect. 3.4: the first item is packed in the first 2-subcube of the edge length 1/4 contained in H 1 . The second item is placed into H 3 . We will use the aux + (5) algorithm described in Sect. 3.4: the item is packed in the first subcube of the edge length 1/3 contained in H 3 . The third item is packed into H 1 by the aux + (5) algorithm; it is packed into the first empty 2-subcube of H 1 of the edge length 1/4 (see Fig. 7, left). The fourth item is packed in H 2 into the layer

B-Boxes
As it was said in Sect. 3.1, items will be packed into open hyperboxes with pairwise disjoint interiors. Any hypercube of the edge length 1/2 was packed in the empty 2-cube with the smallest number by the tt(d) algorithm. We will present a similar method for hyperboxes that are the union of 2-cubes.
For example, Fig. 8 is the B 1 -box with number 1 and number 2 is assigned to the other B 1 -box B⧵H 1 . Moreover, H 1 contains: two B 2 -boxes with numbers 1 and 2 as well as four B 3 -boxes with numbers 1, 2, 3 and 4, eight B 4 -boxes with numbers 1, 2, … , 8 and so on.
Proof H z is a B q -box for some q ∈ {0, … , d} . Obviously, |H z | = 2 −q . Since it is not possible to open a B-box congruent to H z , there are no empty B k -boxes in B for k ≤ q . There can be at most one empty B q+1 -box. Otherwise suppose there are two empty B q+1 -boxes X 1 and X 2 . These B q+1 -boxes of B are not contained in one B q -box, because that would make a whole empty B q -box in B . Therefore X 1 and X 2 lay in different B q -boxes, say X 2 is in a B q -box with a higher number than X 1 is. Let X ′ 2 be the complementary half of X 2 in a B q -box they lay in. Since there is no empty B qbox, X ′ 2 contains an open B-box. It means that a B q+1 -box X ′ 2 contains an open B-box and has higher number than X 1 that is empty. This contradicts the box(d) algorithm. Therefore there is at most one empty B q+1 -box in B.
Using the above argument we obtain at most one empty B k -box of B for each k ∈ {q + 1, … , d} with the interior disjoint with other empty B-boxes of B.
Finally, the empty space in B does not exceed ◻

Layers and m-Cubes
To prepare an empty space for incoming items of different sizes, we will create layers of the height 1/t, for t = 5, 7  Fig. 7 and only layers of the height 1/5, 1/7 and 1/9 were created. Ultimately, we will take m close to 4d∕ log d in the proof of Theorem 2.
By an m-cube K + we mean a hypercube of the edge length 1∕(t ⋅ 2 p ) , where p ≥ 0 is an integer and t ∈ {1, 2, … , m} . We say then that K + is a cube of type (t, p). When the value of p can be arbitrary we say that K + is a cube of class t.
For instance, 6-cubes have the edge lengths from the set while cubes of class 6 have the edge lengths from the set 1 6 , 1 12 , 1 24 , … . Let us note that any cube of type (2 n ⋅ t, p) is also of type (t, p + n) . This fact will be used in the description (Rule 5) of the har + (d) algorithm. For instance, the 6-cube of the edge length 1 32 = 1 as well as (2, 3 + 1). By a (t, q)-layer we mean 1 d−q × (1∕2) q−1 × (1∕t) ; the value 1/t is called the height of the layer (see Fig. 9).
Clearly, each (2, q)-layer is a B q -box. We emphasize the fact that in the process of packing we will only use layers for t being odd. In the main packing method q depends on t (for detailed description see Sect. 3.5): if t ∈ {5, 7, 9} , then q = 4 ; if t = 11 , then q = 5 ; if t = 111 , then q = 6, ….
⋅ t d−q cubes of type (t, 0) are contained in each (t, q)-layer. The volume of any (t, q)-layer equals 2 1−q ⋅ t −1 . Observe that Since t ≥ 2 q−2 + 1 , we get This implies that at least 64/125 of any (t, q)-layer is occupied by cubes of type (t, 0). ◻ 125 .

Auxiliary Algorithm aux + (d)
If all items have the edge lengths from the set {1∕2, 1∕4, 1∕8, …} , then we will use the tt(d) algorithm described in Sect. 2. Each item will be packed into the proper subcube with the smallest number contained in the union of hypercubes of the edge length 1/2. Similarly, each item of the edge length slightly smaller than either 1/2 or 1/4 or 1/8, ...will be packed into the proper subcube with the smallest number contained in the union of hypercubes of the edge length 1/2. In the main packing method the items of the edge length slightly smaller than either 1/t or 1/(2t) or 1/(4t), ...will be placed into layers of the height 1/t (for odd t ≥ 5 ). More precisely, the items will be packed into the union of hypercubes of the edge length 1/t contained in layers of the height 1/t. Therefore we need an algorithm that packs items into hypercubes. Our algorithm is similar to the tt(d) algorithm. Let 10 ≤ m ≤ 2 d−1 be an even number and let either 3 ≤ t ≤ m − 1 be an odd number or t = 2 . Moreover let p be a non-negative integer.
Consider the union U T of cubes of type (t, 0) with pairwise disjoint interiors. All cubes are numbered with successive positive integers (compare Fig. 2, left, where t = 2 ). Furthermore, 2 d cubes of type (t, p) contained in the cube of type (t, p − 1) with number are numbered in an arbitrary order from 2 d ( − 1) + 1 to 2 d .
Consider a sequence K + 1 , K + 2 , … of cubes of class t. We say that a cube of type (t, p) of U T is empty if its interior has an empty intersection with any cube packed so far.
Algorithm aux + (d) for packing of K + i into U T .
• pack K + i into the empty hypercube of U T with the smallest number that is congruent to K + i .
If U T is the unit hypercube partitioned into the union of 2 d many 2-cubes and if t = 2 , then aux + (d) works exactly the same as the tt(d) algorithm. For instance, the first item from the Example of Sect. 3.1 is packed by the aux + (d) algorithm into the first hypercube of the edge length 1/4; the third item is packed into the first empty hypercube of the edge length 1/8. The second item is packed by the aux + (d) algorithm into the first hypercube of the edge length 1/3 contained in H 3 . The third item is packed by the aux + (d) algorithm into the first hypercube of the edge length 1/5 contained in the proper layer (see Fig. 7).

Lemma 8
Let S t be a sequence of cubes of class t. If K + z is the first hypercube from S t that cannot be packed in U T by aux + (d) algorithm, then the total volume of hypercubes packed in U T plus the volume of K + z is greater than |U T |.
Proof We proceed as in the proof of Lemma 3. Since K + z is a cube of class t, there is p ≥ 0 such that K + z is a cube of type (t, p). Clearly, there is no empty cube of type (t, q) in U T for any q ≤ p . Furthermore, for each q > p there are at most 2 d − 1 empty cubes of type (t, q). The total volume of empty cubes in U T is smaller than This implies that the sum of the volumes of all cubes packed into U T is greater than |U T | − t ⋅ 2 p −d . By |K + z | = (t ⋅ 2 p ) −d , it follows that the total volume of items packed in U T is greater than |U T | − |K + z |. ◻

Layers in B-Boxes
Since the series ∑ ∞ j=2 1 2j−1 is divergent, there is no space in the bin to create too many layers of different heights.

Proof
This implies that:

Description of the har + (d) Algorithm
The main algorithm is presented in two steps. First, we give the algorithm har + (d) that packs only m-cubes into the unit cube B . Then we provide the final algorithm har(d): a method of packing items of arbitrary sizes into B . Simply we will pack any item into the smallest possible m-cube and then this m-cube will be packed into B.
Let d ≥ 5 . Moreover, let 10 ≤ m ≤ 2 d−1 be an even number. Since some m-cubes will be packed into B q(m−1) -boxes, i.e., hypercubes 1 d−q(m−1) × (1∕2) q(m−1) , first we show that By the choice of q(t) (see Sect. 3.5) we know that n q(m−1)−1 < m − 1 ≤ n q(m−1) . By Lemma 9 we get We distinguish two classes of B-boxes based on the size of items packed into them: • BC-boxes (see Figs. 10 and 11); • BL-boxes in which layers will be created (see Fig. 12).
Each time a B-box is opened it is assigned to one of those classes and we mention whether it is a BC-or a BL-box.
At the beginning of the process of packing the following B-boxes are open in B: • two BC-boxes: one B d -box called BC 2 -box into which hypercubes of the edge lengths 1∕2, 1∕4, 1∕8, … will be packed and one B 3 -box called BC 3 -box into which hypercubes of the edge lengths 1∕3, 1∕6, 1∕12, … will be packed; • q(m − 1) − 3 many BL-boxes: one B k -box called BL k -box, for each k = 4, 5, … , q(m − 1).
Note that it is possible to pack m-cubes of types (2, 0) and (3, 0) into one Bbox, as in the tt(d) algorithm, however we will pack these cubes separately to simplify the calculations.
Three layers are created in the first open BL 4 -box: one (5, 4)-layer, one (7, 4)-layer and one (9, 4)-layer as on Fig. 12. Let us note that 5 = n 3 + 2 and 9 = n 4 . Then, depending on the size of incoming items it is possible that in the second open BL 4 -box only two (5, 4)-layers were created as on Fig. 12, right. It is also possible that in the second open BL 4 -box only one (5, 4)-layer and one (9, 4)-layers were created (see Fig. 13).
We will use the algorithm aux + (d) , therefore we enumerate m-cubes contained in layers. All cubes of type (t,0) contained in the created (t, q)-layer with number are numbered in an arbitrary order from 1 2  If it is impossible, we create a new (t, q(t))-layer in an open BL q(t) -box (as low with respect to x d -axis as possible). If there were u created layers of the height 1/t so far, then the cubes of type (t, 0) contained in the created layer are numbered we open a new BL q(t) -box: an empty B q(t) -box with the smallest number (compare the box(d) algorithm) and create at the bottom of this box (with respect to x d -axis) a new (t, q(t))-layer to pack K + i . 5. If t is an even number but not a power of 2 and p ≥ 0 is arbitrary, then there is an odd number t 1 and an integer s such that K + i is also of type (t 1 , s + p) . If t 1 = 3 , then K + i is packed as described in Rule (3) into BC 3 -boxes. If t 1 ≥ 5 , then K + i is packed as described in Rule (4) into BL q(t 1 ) -boxes.

Packing Density
In this subsection we will show that the total volume of m-cubes packed into each closed bin is greater than 1/9. Assume that m-cubes were packed into B by the algorithm aux + (d) and that B is closed.

Lemma 10
Denote by v bc the total volume of BC-boxes (contained in a closed bin B ) into which at least one m-cube was packed. The total volume of m -cubes packed in BC-boxes is greater than 8 27 v bc − 2 −3 − 2 −d .
Proof Each BC 2 -box is a cube of type (2, 0) (see Fig. 10). Each The total volume of basic boxes is greater than or equal to The total volume of cubes of type (2, 0) and (3, 0) contained in basic boxes is greater than By Lemma 8, the sum of the volumes of m-cubes packed in basic boxes plus the volumes of the first m-cubes packed in the last BC 2 -and BC 3 -boxes is greater than the total volume of basic boxes. Consequently, the total volume of all m-cubes packed in BC-boxes is greater than 2 Proof Each BL-box is a B k -box for some k ∈ {4, 5 … , q(m − 1)}.
Since n q(t)−1 < t ≤ n q(t) and both t and n q(t)−1 are odd numbers, it follows that t ≥ n q(t)−1 + 2 . By Lemma 9 we get This means, by Lemma 7, that at least 64/125 of any (t, q(t))-layer is occupied by cubes of type (t, 0).
For k ∈ {4, 5, … , q(m − 1)} denote by b k the number of open BL k -boxes. If b k ≥ 2 , then the first b k − 1 boxes are called basic. Observe that at least 3/5 of any basic BL k -box is occupied by layers. The reason is that the height of the highest layer that can be created in any B q -box is not greater than 1∕5 . Since in any basic BL k -box there is no space to create a new layer, the sum of the heights of all layers contained in any basic BL k -box is greater than 1 2 − 1 5 = 3 10 (see Fig. 13). This implies that the total volume of all layers created in a BL k -box is greater than 3 10 ⋅ ( 1 2 ) k−1 . This volume divided by the volume 2 −k of a BL k -box gives the desired ratio.
Finally we estimate the total volume of packed m-cubes. Let t ∈ {4, 5, … , q(m − 1)} . Among all (t, q(t))-layers created in BL-boxes, the last (t, q(t))-layer is called not-full and the remaining layers are full. Since there is at most one not-full layer of each size, by the choice of n k we deduce that the sum of volumes of not-full layers is smaller than

3
The total volume of basic BL-boxes is greater than The total volume of created layers is greater than 3 5 (v bl − 1∕8) . The total volume of full layers is greater than 3 5 (v bl − 1∕8) − 1 8 . Since at least 64/125 of any (t, q(t))-layer is occupied by cubes of type (t, 0), by Lemma 8 we deduce that the total volume of packed m-cubes is greater than If v bc > 13 24 , then by Lemma 10 we obtain that the total volume of packed m-cubes is greater than If v bc ≤ 13 24 , by Lemmas 10 and 11 we deduce that the total volume of packed items is greater than

Algorithm har(d)
Let 10 ≤ m ≤ 2 d−1 be an even number. Moreover let C 1 , C 2 , … be a sequence of items (hypercubes). For each C i from the sequence let K + i be the smallest m-cube containing C i . For example, if C i is a hypercube of the edge length greater than 1/2, then K + i is the unit hypercube (a cube of type (1, 0)). An m-cube K + i is big, provided its edge length is greater than 1/m; in that case we say also that the item C i is big. Clearly, any big cube K + i is a cube of type (t, 0) for t ∈ {1, 2, … , m − 1} ; we say also that in that case C i is a big t-item.
An m-cube K + j is small, provided its edge length is not greater than 1/m; in that case we say also that the item C j is small.
Algorithm har(d) for packing of C i into B.
• First find the smallest m-cube K + i containing C i . Then pack K + i together with C i ⊂ K + i by the algorithm har + (d).

Competitive Ratio O(d∕ log D)
Let 10 ≤ m ≤ 2 d−1 be an even number.

Lemma 14
If d ≥ 5 , then the asymptotic competitive ratio of the har(d) algorithm is not greater than 9 m+2 m d + m − 1 .
Proof Let S be a sequence of items of the volume v, let j denote the number of big j-items in S and let be the number of bins used to pack items from S according to the har(d) algorithm. In particular, 1 is equal to the number of hypercubes of the edge lengths greater than 1/2 (big 1-items) and 2 denotes the number of hypercubes of the edge lengths greater than 1/3 but not greater than 1/2. Two items of the edge lengths greater than 1/2 cannot be packed into one bin. This implies that OPT(S) ≥ 1 . Moreover, 2 d + 1 items of the edge lengths greater than 1/3 cannot be packed into one bin also. For example, if 2 = 2 d + 1 , then OPT(S) > 1 ; if 2 = 2 ⋅ 2 d + 1 , then OPT(S) > 2 ; Thus OPT(S) ≥ 2 ∕2 d . Finally, j d + 1 items of the edge lengths greater than 1∕(j + 1) cannot be packed into one bin. Consequently, OPT(S) ≥ j ⋅ j −d for j ≥ 1. Let Since OPT(S) ≥ v as well as OPT(S) ≥ j ⋅ j −d for j ≥ 1 , it follows that If − 2 1 − 1 ≤ 0 , then Consider the case when − 2 1 − 1 > 0. Each big t-item was packed into a big cube of type (t, 0). The total volume of big cubes of type (t, 0) containing a big t-item equals t ⋅ t −d while the total volume of big t-items is greater than t ⋅ (t + 1) −d .
The last bin from among bins can be almost empty. Only one bin (from among bins) can be almost empty. By the description of the har(d) algorithm (Rule 1) we deduce that in two consecutive bins only one small item and only one 1-big item can be packed. Consequently, in 2 1 bins the average occupation can be close to 2 −d−1 . We will omit the volume of items packed into these 2 1 + 1 bins in our computations.

Appendix 1: The Reverse 2-Cubes Versus 3-Cubes Sequence and Its Increments
Let n ≥ 0 , we define y(n) to be an increasing sequence made from y d (2 d − n) , i.e., and for arbitrary n ≥ 2 let d be the smallest integer greater than or equal to log 2 n , then Let x(n) be the sequence of increments of y(n) We will prove that the sequence x(n) is a Gould's sequence, see [26].

Fact 1
The sequence x(n) starts with 1 and can be defined inductively: When the first 2 d elements of the sequence x(n) are given, the next 2 d elements are defined Proof Let d ≥ 0 and 0 < l ≤ 2 d . y(0) = 0, y(1) = 1, y(n) = y d (2 d − n).