1 Introduction

Let \(C_n\) be a d-dimensional cube, for \(\ n=1,2,\ldots \), and let \(I^d\) be a d-dimensional cube of edges of length 1. We say that the cubes \(\ C_1, C_2, \ldots \) can be packed into \(I^d\) if it is possible to apply translations and rotations to the sets \(C_n\) so that the resulting translated and rotated cubes are contained in \(I^d\) and have mutually disjoint interiors. The packing is parallel if each edge of any packed cube is parallel to an edge of \(I^d\).

Meir and Moser (1968) proved that any collection of d-dimensional cubes can be parallel packed into the unit d-dimensional cube \(I^d\), provided that the total volume of the cubes is not greater than \(2^{1-d}\). This upper bound is sharp for parallel packing: it is impossible to pack two d-dimensional cubes of edges of length greater than 1/2 into \(I^d\). In particular, two three-dimensional cubes of edge length greater than 1/2 and, consequently, of total volume greater than \(2\cdot (1/2)^3=1/4\), cannot be parallel packed into \(I^3\). In general any two cubes whose sum of edge lengths is greater than 1 block each other in parallel packing; if we pack one of them, there will not be enough space in \(I^d\) to pack the other. In this note we will pack three-dimensional cubes from a collection satisfying an additional condition.

Denote by \(a_n\) the edge length of \(C_n\), for \(\ n=1,2,\ldots \) We say that the cubes \(\ C_1, C_2, \ldots \) are non-blocking, if \(\ a_i+a_j\le 1\ \) for any \(i\ne j\) (compare Januszewski and Zielonka 2023a). In Januszewski and Zielonka (2023b) it is shown that any collection of non-blocking squares, whose total area does not exceed 5/9, can be packed in \(I^2\). The aim of this note is to show that any collection of non-blocking cubes can be parallel packed into \(I^3\), provided that the sum of volumes of the cubes is not greater than 1/3. This upper bound is sharp for parallel packing: nine cubes of edge lengths greater than 1/3 cannot be parallel packed into \(I^3\).

The packing method presented in Sect. 3 is based on the well-known method of Meir and Moser (1968). At the beginning, the cubes are arranged by size, starting with the largest one. Then the cubes are packed in successive layers so that its bottoms are packed into squares. Therefore, we will first describe the algorithm for packing squares.

2 \(MM^+(2D)\)-method

By \(\ [b_1,b_2]\times [c_1,c_2]\), where \(\ b_1 < b_2\ \) and \(\ c_1 < c_2\), we mean the rectangle \(\{ (x,y):\ b_1\le x \le b_2,\ c_1\le y \le c_2 \}\). We will use the method described in Januszewski and Zielonka (2023b), which is a slight modification of the algorithm of Moon and Moser (1967). For the convenience of the reader, we will present a sketch of how we pack the squares.

Fig. 1
figure 1

The packing method \(MM^+(2D)\)

Let \(I^2=[0,1]\times [0,1]\) and let \({\mathcal {S}}\) be a collection of squares \(S_1, S_2, \ldots \) Assume that \(a_n\ge a_{n+1}\) for \(\ n=1,2,\ldots \) and \(\ a_1+a_2 \le 1\), where \(a_n\) denotes the sidelength of \(S_n\). Moreover, assume that \(\ P=[1-w_p,1]\times [1-h_p,1]\) (see Fig. 1), where \(\ 0\le w_p<1\ \) and \(\ 0\le h_p<1\). By \(\textrm{Int} P\) denote the interior of P.

Squares \(S_1, S_2, \ldots \) are packed into \(I^2\setminus P\) in layers \(R_1, R_2,\ldots \). The first layer is either the rectangle \(\ [0,1]\times [0,a_1]\ \) if \(\ \bigl ( [0,1]\times [0,a_1] \bigr ) \cap \textrm{Int} P=\emptyset \ \) or the rectangle \(\ [0,1-w_p]\times [0,a_1]\), otherwise. The squares \(S_1, S_2, \ldots \) are packed into \(I^2\) along the base of the first layer \(R_1\) from left to right. If \(S_{n_1}\) is the first square that cannot be packed in that way, then the new layer \(R_2\), of height \(a_{n_1}\), is created directly above \(R_1\). The base of \(R_2\) is either equal to 1 if \(\ \bigl ( [0,1]\times [a_1,a_1+a_{n_1}] \bigr ) \cap \textrm{Int}P=\emptyset \ \) or equal to \(1-w_p\), otherwise. The squares \(S_{n_1}, S_{n_1+1}, \ldots \) are packed into \(I^2\) along the base of the second layer from left to right. If \(S_{n_2}\) is the first square that cannot be packed in that way in the second layer, then the new layer \(R_3\), of height \(a_{n_2}\), is created directly above the second layer. The base of \(R_3\) is either equal to 1 if \(\ \bigl ( [0,1]\times [a_1+a_{n_1},a_1+a_{n_1}+a_{n_2}]\bigr ) \cap \textrm{Int} P=\emptyset \ \) or equal to \(1-w_p\), otherwise, etc.

Lemma 1

If \(S_z\) is the first square from \({\mathcal {S}}\) that cannot be packed into \(I^2\setminus P\) by the \(MM^+(2D)\)-method, then the total area of squares \(S_1,S_2,\ldots ,S_z\) plus the area of P is greater than \( a_1^2+(1-a_1)^2. \)

Proof

Assume that squares \(S_1, S_2, \ldots , S_{z-1}\) are packed into \(I^2\setminus P\) and that \(S_z\) cannot be packed into \(I^2{\setminus } P\) by the \(MM^+(2D)\)-method. To prove this lemma it is sufficient to show that the square \([a_1,1]\times [a_1,1]\), of area \((1-a_1)^2\), can be covered by \(\ S_2, S_3, \ldots , S_z\ \) and P with some excess (i.e., that the sum of areas of \(\ S_2, S_3, \ldots , S_z\ \) and P is strictly larger than \((1-a_1)^2\)). Let \(n_t=z\) (\(z=n_5\) on Fig. 2).

Let’s move \(S_{n_i}\), i.e., the first square from the layer \(R_{i+1}\), to the place directly behind \(S_{n_i-1}\) so that the lower left vertex of \(S_{n_i}\) is the lower right vertex of \(S_{n_i-1}\) (as the white squares \(S_{n_i}\) on Fig. 2, left), for \(i=1,\ldots ,t\). Then we move up the squares from \(R_1\) (without \(S_{1}\) but with \(S_{n_1}\)) by the distance \(a_{1}\). Moreover, we move up the squares from the layer \(R_i\) (together with \(S_{n_i}\)) by the distance \(a_{n_{i-1}}\), for \(i=2,\ldots ,t\) (see Fig. 2, right).

It should be noted that with this arrangement of squares, the right side of each square \(S_{n_i}\) is outside the layer \(R_{i+1}\) for \(i=1,2,\ldots ,t\). Moreover, \(\ a_{n_1}+a_{n_2}+\dots +a_{n_t}>1-a_1\). This implies that \(\ S_2, S_3, \ldots , S_z\ \) and P permit a covering of \(\ [a_1,1]\times [a_1,1]\) with some excess (see Fig. 3). \(\square \)

Fig. 2
figure 2

Estimation of the total area of packed squares

Fig. 3
figure 3

Lemma 1 in the case when \(\ z=n_1+1=4\)

3 \(MM^+(3D)\)-method

By \(\ [b_1,b_2]\times [c_1,c_2]\times [d_1,d_2]\), where \(\ b_1 < b_2\), \(\ c_1 < c_2\) and \(\ d_1 < d_2\), we mean the box \(\ \{ (x,y,z):\ b_1\le x \le b_2,\ c_1\le y \le c_2,\ d_1\le z \le d_2 \}\). The packing method is a small modification of the algorithm of Meir and Moser (1968).

Let \(\ H=[0,1]\times [0,1]\times [0,h]\). Moreover, let \(C_n\) be a cube of edge length \(a_n\), where \(a_n\ge a_{n+1}\) for \(\ n=1,2,\ldots \) and let \(\ a_1+a_2 \le 1\). Assume that \(\ B=[1-w_b,1]\times [1-l_b,1]\times [h-h_b,h]\) (see Fig. 4), where \(\ 0\le w_b<1\), \(0\le l_b<1 \) and \( 0\le h_b<h\).

Cubes \(C_1, C_2, \ldots \) are packed into H in layers \(L_1, L_2,\ldots \) similarly as in the method of Meir and Moser (1968). The base of each layer is a unit square. The first layer is the box \([0,1]\times [0,1]\times [0,a_1]\). The cubes are packed in \(L_1\) so that the bottoms of the cubes are packed into the bottom of the layer according to the \(MM^+(2D)\)-method. If \(\ \bigl ( [0,1]\times [0,1]\times [0,a_1] \bigr ) \cap \textrm{Int} B=\emptyset \), then \(P=\emptyset \) in the \(MM^+(2D)\)-method, otherwise \(P=[1-w_b,1]\times [1-l_b,1]\). If \(C_{n_1}\) is the first cube that cannot be packed in \(L_1\), then the new layer \(L_2\), of height \(a_{n_1}\), is created directly above \(L_1\). The next cubes \(C_{n_1}, C_{n_1+1}, \ldots \) are packed into \(L_2\) so that the bottoms of the cubes are packed into the bottom of the layer according to the \(MM^+(2D)\)-method. If \(\ \bigl ( [0,1]\times [0,1]\times [a_1, a_1+a_{n_1}] \bigr ) \cap \textrm{Int} B=\emptyset \), then \(P=\emptyset \) in the \(MM^+(2D)\)-method, otherwise \(P=[1-w_b,1]\times [1-l_b,1]\). If \(C_{n_2}\) is the first cube that cannot be packed in that way in the second layer, then the new layer \(L_3\), of height \(a_{n_2}\), is created directly above the second layer, etc.

Fig. 4
figure 4

Estimation of the total volume of packed cubes

Lemma 2

If \(C_z\) is the first cube from the collection that cannot be packed into \(H{\setminus } B\) by the \(MM^+(3D)\)-method, then the total volume of cubes \(C_1,C_2,\ldots ,C_z\) plus the volume of B is greater than \( a_1^3+(1-a_1)^2(h-a_1). \)

Proof

Assume that cubes \(C_1, C_2, \ldots , C_z\) are packed into \(H{\setminus } B\) by the \(MM^+(3D)\)-method. Note that to prove this lemma it is sufficient to show that the box \([a_1,1]\times [a_1,1]\times [a_1,h]\) can be covered by \(\ C_2, C_3, \ldots , C_z\ \) and B with some excess. Let \(n_t=z\).

Let’s move \(C_{n_i}\) (the first cube from the layer \(L_{i+1}\)) so that the lower left vertex of the bottom of \(C_{n_i}\) is the lower right vertex of the bottom of \(C_{n_i-1}\), for \(i=1,\ldots ,t\) (as the white cube on Fig. 4, left, where \(i=1\)). Then we move up the cubes from \(L_1\) (without \(C_{1}\) but with \(C_{n_1}\)) by the distance \(a_{1}\). Moreover, we move up the cubes from \(L_i\) (with \(C_{n_i}\)) by the distance \(a_{n_{i-1}}\), for \(i=2,\ldots ,t\) (see Fig. 4, right). Now we move cubes in each layer such that the bottoms of these cubes were placed in the same way as in the description of the proof of Lemma 1, i.e., such that the union of the bottoms of the cubes and the rectangle P (if any) covers the square \([a_1,1]\times [a_1,1]\) in the base of the layer.

It should be noted that with this arrangement of cubes, the right face of each cube \(C_{n_i}\) for \(i=1,2,\ldots ,t\) is either outer of \(L_{i+1}\) or is contained in B. Moreover, \(\ a_{n_1}+a_{n_2}+\cdots +a_{n_t}>h-a_1\). This implies that \(\ C_2, C_3, \ldots , C_z\ \) and B permit a covering of the box \(\ [a_1,1]\times [a_1,1]\times [a_1,h]\) with some excess. \(\square \)

4 Packing of non-blocking cubes into the unit cube

Let \(\ I^3=[0,1]\times [0,1]\times [0,1]\ \) and let \({\mathcal {C}}\) be a collection of cubes \(C_1, C_2, \ldots \) Assume that \(\ a_1+a_2 \le 1\) and that \(a_n\ge a_{n+1}\), where \(a_n\) denotes the edge length of \(C_n\) for \(n=1,2 \ldots \)

Let

$$\begin{aligned} U&=[0,1]\times [0,1]\times [1-a_1,1], \\ H&=[0,1]\times [0,1]\times [0,1-a_2], \\ B&=[1-a_1,1]\times [1-a_1,1]\times [1-a_1,1-a_2]. \end{aligned}$$

Clearly, if \(a_1\ne a_2\), then B is a box of size \(a_1\times a_1\times (a_1-a_2)\).

  • The first four cubes, i.e., \(C_1, C_2, C_3\) and \(C_4\) are packed into the upper corners of U so that \(C_1\) contains B (see Fig. 5, left).

  • If \(a_3+a_4+a_5>1\), then no more cube will be packed into U. Otherwise, we pack \(C_5\) into U as near to the top as it is possible. Apart from \(C_1, C_2, C_3, C_4\) and \(C_5\) no more cube will be packed into U.

  • The remaining cubes are packed into \(H\setminus B\) in corresponding layers \(L_i\) (\(i=1,2,\ldots \)) by the \(MM^+(3D)\)-method (as on Fig. 4 for \(h=1-a_2\)).

Fig. 5
figure 5

Packing of non-blocking cubes

Theorem 3

Any collection of non-blocking cubes with total volume not greater than 1/3 can be packed into the unit cube.

Proof

Denote by \(\ C_1, C_2, \ldots \) the cubes in the collection. Without loss of generality we can assume that \(\ a_1 \ge a_2 \ge \cdots \), where \(a_n\) is the edge length of \(C_n\), for \(\ n=1,2,\ldots \)

We will show that if the cubes cannot be packed into \(I^3\), then \(\ a_1^3+a_2^3+\cdots >1/3\), which is a contradiction. Clearly, \(\ a_5\le a_2\le 1/2\ \) (if \(\ a_1\ge a_2 >1/2\), then \(C_1\) and \(C_2\) block each other). Consider two cases.

Case 1: \(\ 2a_2+a_5>1\) .

The volume of B is equal to \(a_1^2(a_1-a_2)\). If the cubes cannot be packed into \(I^3\), then, by Lemma 2, the sum of volumes of the cubes is greater than

$$\begin{aligned}&a_1^3+a_2^3+a_3^3+a_4^3+ a_5^3+(1-a_5)^2(1-a_2-a_5)-a_1^2(a_1-a_2)\\&\quad = a_1^2a_2+a_2^3+a_3^3+a_4^3+ a_5^3+(1-a_5)^2(1-a_2-a_5)\\&\quad \ge 2a_2^3+3a_5^3+(1-a_2-a_5)(1-a_5)^2. \end{aligned}$$

We find the global minimum of the function

$$\begin{aligned} f(a_2,a_5)=2a_2^3+3a_5^3+(1-a_2-a_5)(1-a_5)^2 \end{aligned}$$

in the domain \(D_1\) given by the following inequalities

$$\begin{aligned} {\left\{ \begin{array}{ll} a_5>1-2a_2 \\ a_5\le a_2 \\ a_2\le \frac{1}{2} \end{array}\right. }. \end{aligned}$$

Since \(f'_{a_2}(a_2,a_5)=6a_2^2-(1-a_5)^2\) and \(a_5=1-\sqrt{6}a_2<1-2a_2\), the stationary points are outside our domain.

The boundary of the triangle \(D_1\) consists of three segments.

  • The segment \(a_5=1-2a_2\) with \(1/3\le a_2\le 1/2\). The function

    $$\begin{aligned} f_1(a_2)&=f(a_2,1-2a_2)=2a_2^3+3(1-2a_2)^3\\&\quad +(1-a_2-1+2a_2)(1-1+2a_2)^2 =-18a_2^3+36a_2^2-18a_2+3 \end{aligned}$$

    is increasing for \(a_2\in \left[ 1/3,1/2\right] \). This means that \(f_1(a_2)\ge f_1(1/3)=1/3\).

  • The segment \(a_5=a_2\) with \(1/3\le a_2\le 1/2\). The function

    $$\begin{aligned} f_2(a_2)&=f(a_2,a_2)=5a_2^3+(1-2a_2)(1-a_2)^2 =3a_2^3+5a_2^2-4a_2+1 \end{aligned}$$

    is increasing for \(a_2\in \left[ 1/3,1/2\right] \). Consequently, \(f_2(a_2)\ge f_2(1/3)=1/3\).

  • The segment \(a_2=1/2\) with \(0<a_5<1/2\). The function

    $$\begin{aligned} f_3(a_5)&=f\Bigl (\frac{1}{2},a_5\Bigr )=2\Bigl (\frac{1}{2}\Bigr )^3+3a_5^3+\Bigl (1-\frac{1}{2}-a_5\Bigr )(1-a_5)^2 \\&=2a_5^3+\frac{5}{2}a_5^2-2a_5+\frac{3}{4} \end{aligned}$$

    for \(a_5\in [0,1/2]\) reaches its lowest value \((809-73\sqrt{73})/432>1/3\) at \(a_5=(\sqrt{73}-5)/12\).

Thus, the lowest value of the function f in the given domain is equal to 1/3.

Case 2: \(\ 2a_2+a_5\le 1\). This implies that \(C_5\) is packed into U.

If the cubes cannot be packed into \(I^3\), then, by Lemma 2, the sum of volumes of the cubes is greater than

$$\begin{aligned}&a_1^3+a_2^3+a_3^3+a_4^3+ a_5^3+a_6^3+(1-a_6)^2(1-a_2-a_6)-a_1^2(a_1-a_2)\\&\quad =a_1^2a_2+a_2^3+a_3^3+a_4^3+ a_5^3+a_6^3+(1-a_6)^2(1-a_2-a_6)\\&\quad \ge 2a_2^3+4a_6^3+(1-a_2-a_6)(1-a_6)^2. \end{aligned}$$

We find the global minimum of the function

$$\begin{aligned} g(a_2,a_6)=2a_2^3+4a_6^3+(1-a_2-a_6)(1-a_6)^2 \end{aligned}$$

in the domain \(D_2\) given by the following inequalities

$$\begin{aligned} {\left\{ \begin{array}{ll} a_6\le a_2 \\ a_2\le \frac{1}{2}. \\ a_6> 0 \end{array}\right. } \end{aligned}$$

All four stationary points

$$\begin{aligned}&P_1\left( \frac{\sqrt{54-{6\sqrt{6}}}+{6\sqrt{6}}}{27+\sqrt{6}},-\frac{2 \sqrt{54-{6\sqrt{6}}}+3 \sqrt{6}-2}{9 \sqrt{6}+2}\right) ,\\&P_2\left( -\frac{\sqrt{54-{6\sqrt{6}}}-{6\sqrt{6}}}{27+\sqrt{6}},\frac{2 \sqrt{54-{6\sqrt{6}}}-3 \sqrt{6}+2}{9 \sqrt{6}+2}\right) , \\&P_3\left( -\frac{\sqrt{54+{6\sqrt{6}}}+{6\sqrt{6}}}{27-\sqrt{6}},-\frac{2 \sqrt{54+{6\sqrt{6}}}+3 \sqrt{6}+2}{9 \sqrt{6}-2}\right) ,\\&P_4\left( \frac{\sqrt{54+{6\sqrt{6}}}-{6\sqrt{6}}}{27-\sqrt{6}},\frac{2 \sqrt{54+{6\sqrt{6}}}-3 \sqrt{6}-2}{9 \sqrt{6}-2}\right) \end{aligned}$$

are outside the domain \(D_2\).

The boundary of \(D_2\) consists of three segments.

  • The segment \(a_6=a_2\) with \(0\le a_2\le 1/2\). The function

    $$\begin{aligned} g_1(a_2)&=g(a_2,a_2)=6a_2^3+(1-2a_2)(1-a_2)^2 =4a_2^3+5a_2^2-4a_2+1 \end{aligned}$$

    for \(a_2\in [0,1/2]\) reaches its lowest value \((701-73\sqrt{73})/216\approx 0.358>1/3\) at \(a_2=(\sqrt{73}-5)/12\approx 0.295\).

  • The segment \(a_2=1/2\) with \(0\le a_6\le 1/2\). The function

    $$\begin{aligned} g_2(a_6)&=g\Bigl (\frac{1}{2},a_6\Bigr )=2\Bigl (\frac{1}{2}\Bigr )^3+4a_6^3+\Bigl (1-\frac{1}{2}-a_6\Bigr )(1-a_6)^2 \\&=4 a_6^3 + \Bigl (\frac{1}{2} - a_6\Bigr ) (1 - a_6)^2 + \frac{1}{4} \end{aligned}$$

    for \(a_6\in [0,1/2]\) reaches its lowest value \((1394-97\sqrt{97})/972>1/3\) at \(a_6=(\sqrt{97}-5)/18\approx 0.269\).

  • The segment \(a_6=0\) with \(0\le a_2\le 1/2\). Observe that

    $$\begin{aligned} g_3(a_2)&=g\left( a_2,0\right) =2a_2^3+1-a_2>1-a_2\ge \frac{1}{2} \end{aligned}$$

    for \(a_2\in [0,1/2]\).

Thus, the lowest value of the function g in the given domain is greater than 1/3. \(\square \)

In \(\lambda \)-packing cubes are grouped in batches (comp. Januszewski and Zielonka 2022 and Januszewski and Zielonka 2023). Cubes arrive online and they are stored in a buffer until either the total volume of stored cubes is greater than or equal to \(\lambda \) or all cubes have already arrived. Then cubes from the buffer are packed offline into a unit capacity bin and the buffer is emptied. The following problem arises: what is the smallest \(\lambda \) such that any collection of non-blocking cubes of total volume not greater than 1/3 can be \(\lambda \)-packed into \(I^3\)?