Harmonic Algorithms for Packing
-dimensional Cuboids Into Bins
Abstract
We explore approximation algorithms for the -dimensional geometric bin packing problem (BP). Caprara [8] gave a harmonic-based algorithm for BP having an asymptotic approximation ratio (AAR) of (where ). However, their algorithm doesn’t allow items to be rotated. This is in contrast to some common applications of BP, like packing boxes into shipping containers. We give approximation algorithms for BP when items can be orthogonally rotated about all or a subset of axes. We first give a fast and simple harmonic-based algorithm having AAR . We next give a more sophisticated harmonic-based algorithm, which we call , having AAR . This gives an AAR of roughly for 3BP with rotations, which improves upon the best-known AAR of . In addition, we study the multiple-choice bin packing problem that generalizes the rotational case. Here we are given sets of -dimensional cuboidal items and we have to choose exactly one item from each set and then pack the chosen items. Our algorithms also work for the multiple-choice bin packing problem. We also give fast and simple approximation algorithms for the multiple-choice versions of D strip packing and D geometric knapsack.
Acknowledgements.
I want to thank my advisor, Prof. Arindam Khan, for his valuable comments, and Arka Ray for helpful suggestions.
1 Introduction
Packing of rectangular and cuboidal items is a fundamental problem in computer science, mathematics, and operations research. Packing problems find numerous applications in practice, e.g., physical packing of concrete 3D items during storage or transportation [7], cutting prescribed 2D pieces from cloth or metal sheet while minimizing the waste [16], etc. In this paper, we study packing of -dimensional (D) cuboidal items (for ).
Let be a set of number of D cuboidal items, where each item has length at most one in each dimension. A feasible packing of items into a D cuboid is a packing where items are placed inside the cuboid parallel to the axes without any overlapping. A D unit cube is a D cuboid of length one in each dimension. In the D bin packing problem (BP), we have to compute a feasible packing of (without rotating the items) into the minimum number of bins that are D unit cubes. Let denote the minimum number of bins needed to pack .
BP is NP-hard, as it generalizes the classic bin packing problem [9]. Thus, we study approximation algorithms. For BP, the worst-case approximation ratio usually occurs only for small pathological instances. Thus, the standard performance measure is the asymptotic approximation ratio (AAR). For an algorithm , AAR is defined as:
where is the set of all problem instances. and are the number of bins used by and the optimal algorithm, respectively, on .
Coffman et al. [10] initiated the study of approximation algorithms for rectangle packing. They studied packing algorithms such as First-Fit Decreasing Height (FFDH) and Next-Fit Decreasing Height (NFDH). In his seminal paper, Caprara [8] devised a polynomial-time algorithm for BP called (Harmonic Decreasing Height), where is a parameter to the algorithm. has AAR equal to , where is a decreasing function of and . The algorithm is based on an extension of the harmonic algorithm [24] for 1BP.
A limitation of is that it does not allow rotation of items. This is in contrast to some real-world problems, like packing boxes into shipping containers (), where items can often be rotated orthogonally, i.e., rotation around all or a subset of axes [1, 30]. Orientation constraints may sometimes limit the vertical orientation of a box to one dimension (“This side up”) or to two (of three) dimensions (e.g., long but low and narrow box should not be placed on its smallest surface). These constraints are introduced to deter goods and packaging from being damaged and to ensure the stability of the load. One of our primary contributions is presenting variants of that work for generalizations of BP that capture the notion of orthogonal rotation of items.
1.1 Prior Work
For 2BP, Bansal et al. [3] obtained AAR of even for the case with rotations, using a more sophisticated algorithm that used properties of harmonic rounding. Then there has been a series of improvements [3, 19] culminating with the present best AAR of 1.406 [5], for both the cases with and without orthogonal rotations. Bansal et al. [6] showed that BP is APX-hard, even for . They also gave an asymptotic PTAS for BP where all items are D squares.
Closely related to BP is the D strip packing problem (SP), where we have to compute a packing of (without rotating the items) into a D cuboid (called a strip) that has length one in the first dimensions and has the minimum possible length (called height) in the dimension.
For 2SP, an asymptotic PTAS was given by Kenyon and Rémila [22]. Jansen and van Stee [21] extended this to the case with orthogonal rotations. For 3SP, when rotations are not allowed, Bansal et al. [4] gave a harmonic-based algorithm achieving AAR of . Recently, this has been improved to [20]. Miyazawa and Wakabayashi [25] studied 3SP and 3BP when rotations are allowed, and gave algorithms with AAR 2.64 and 4.89, respectively. Epstein and van Stee [13] gave an improved AAR of 2.25 and 4.5 for 3SP and 3BP with rotations, respectively. The algorithm also works for SP and has an AAR of . For online BP, there are harmonic-based -asymptotic-approximation algorithms [12, 11], which are optimal for memory algorithms.
1.2 Multiple-Choice Packing
We will now define the D multiple-choice bin packing problem (MCBP). This generalizes BP and captures the notion of orthogonal rotation of items. This perspective will be helpful in designing algorithms for the rotational case. In MCBP, we’re given a set , where for each , is a set of items, henceforth called an itemset. We have to pick exactly one item from each itemset and pack those items into the minimum number of bins. See Fig. 1 for an example of 2MCBP.
We can model rotations using multiple-choice packing: Given a set of items, for each item , create an itemset that contains all allowed orientations of . Then the optimal solution to will tell us how to rotate and pack items in .
Some algorithms for 2D bin packing with rotations assume that the bin is square [3, 19, 5]. This assumption holds without loss of generality when rotations are forbidden, because we can scale the items. But if rotations are allowed, this won’t work because items and that are rotations of each other may stop being rotations of each other after they are scaled. Multiple-choice packing algorithms can be used in this case. For each item , we will create an itemset that contains scaled orientations of .
Multiple-choice packing problems have been studied before. Lawler gave an FPTAS for the multiple-choice knapsack problem [23]. Patt-Shamir and Rawitz gave an algorithm for multiple-choice vector bin packing having AAR and a PTAS for multiple-choice vector knapsack [27]. Similar notions have been studied in the scheduling of malleable or moldable jobs [31, 18].
1.3 Our Contributions
After the introduction of the harmonic algorithm for online 1BP by Lee and Lee [24], many variants have found widespread use in multidimensional packing problems (both offline and online) [8, 3, 4, 2, 12, 11, 17, 28, 29]. They are also simple, fast, and easy to implement. For example, among algorithms for 3SP, 2BP and 3BP with practical running time, harmonic-based algorithms provide the best AAR.
In our work, we extend harmonic-based algorithms to MCBP. MCBP subsumes the rotational case for geometric bin packing, and we believe MCBP is an important natural generalization of geometric bin packing that may be of independent interest.
In Section 3, we describe ideas from [8] that help us devise harmonic-based algorithms for MCBP. In Section 4, we show an -time algorithm for MCBP, called , having an AAR of , where is the number of itemsets and is the total number of items across all the itemsets. is a fast and simple algorithm that works in two stages: In the first stage, we select the smallest item from each itemset (we will precisely define smallest in Section 4). In the second stage, we pack the selected items into bins using a variant of the algorithm.
In Section 5, we show an algorithm for MCBP, called , having an AAR of and having a running time of . For , this matches the present best AAR for the case where rotations are forbidden. Also, for large , this gives an AAR of roughly for 3D bin packing when orthogonal rotations are allowed, which is an improvement over the previous best AAR of [13], an improvement after fourteen years.
As harmonic algorithms are ubiquitous in bin packing, we expect our results will have applications in other related problems.
Our techniques can be extended to some other packing problems, like strip packing and geometric knapsack. In LABEL:sec:hdhk-sp, we define the D multiple-choice strip packing problem (MCSP) and extend Caprara’s algorithm [8] to MCSP. The algorithm has AAR and runs in time , where is the number of itemsets and is the total number of items across all itemsets. In LABEL:sec:hdhks, we define the D multiple-choice knapsack problem (MCKS), and for any , we show an -time algorithm that is -approximate.
2 Preliminaries
Let . For a set , define . For an -dimensional vector , define . For a set of items and any function , is defined to be , unless stated otherwise.
The length of a D item in the dimension is denoted by . Define . For a D cuboid , call the first dimensions base dimensions and call the dimension height. For a set of items, is the number of items in . Let denote the number of bins used by a packing of items into bins.
2.1 Multiple-Choice Packing
Let be a set of itemsets. Define to be the union of all itemsets in .
Let be a set of items that contains exactly one item from each itemset in . Formally, for each itemset , . Then is called an assortment of . Let denote the set of all assortments of . In MCBP, given an input instance , we have to select an assortment and output a bin packing of , such that the number of bins used is minimized. Therefore, .
3 Important Ideas from the Algorithm
In this section, we will describe some important ideas behind the algorithm for BP by Caprara [8]. These ideas are the building blocks for our algorithms for MCBP.
3.1 Weighting Functions
Fekete and Schepers [14] present a useful approach for obtaining lower bounds on the optimal solution to bin packing problems. Their approach is based on weighting functions.
Definition 1.
is a weighting function iff for all and ,
(Weighting functions are also called dual feasible functions (DFFs)).
Theorem 1.
Let be a set of D items that can be packed into a bin. Let be weighting functions. For , define as the item whose length is in the dimension, for each . Then can be packed into a D bin (without rotating the items).
Theorem 1 is proved in LABEL:sec:dff-trn.
3.2 The Harmonic Function
To obtain a lower-bound on using Theorem 1, Caprara [8] defined a function . For an integer constant , is defined as
was originally defined and studied by Lee and Lee [24] for their online algorithm for 1BP, except that they used instead of . Define as
Define to be the smallest positive constant such that is a weighting function. We call the harmonic weighting function. We can efficiently compute as a function of using ideas from [24]. Table 1 lists the values of for the first few . It can also be proven that is a decreasing function of and .
3 | 4 | 5 | 6 | 7 | ||
3 | 2 |
For a D cuboid , define to be the cuboid whose length is in the dimension, for each . For a set of D cuboids, let . Similarly define and . Define to be a -dimensional vector whose component is . Note that there can be at most different values of . Sometimes, for the sake of convenience, we may express as an integer in .
Theorem 2.
For a set of of D items, .
Proof.
Let . Let be the items in the bin in the optimal bin packing of . By Theorem 1 and because is a weighting function, fits in a bin. Therefore,
3.3 The Subroutine
From the algorithm by Caprara [8], we extracted out a useful subroutine, which we call , that satisfies the following useful property:
Property 2.
The algorithm takes a sequence of D items such that all items have type and (here is the last item in sequence ). It returns a packing of into a single D bin in time, where .
The design of and its correctness can be inferred from Lemma 4.1 in [8]. We use as a black-box subroutine in our algorithms, i.e., we only rely on Property 2; we don’t need to know anything else about . Nevertheless, for the sake of completeness, in LABEL:sec:hdhkunit, we give a complete description of and prove its correctness.
4 Fast and Simple Algorithm for MCBP ()
We will now describe an algorithm for BP called the full-harmonic algorithm (). We will then extend it to MCBP. The algorithm works by first partitioning the items based on their vector (type vector is defined in Section 3.2). Then for each partition, it repeatedly picks the smallest prefix such that and packs into a D bin using . See Algorithm 1 for a more precise description of . Note that has a running time of .
Theorem 3.
The number of bins used by is less than , where is the number of distinct s of items (so ).
Proof.
Let be the items in of type . Suppose uses bins to pack . For each type , the first bins have at least 1, so . Therefore, total number of bins used is . ∎
Lemma 4 (Corollary to Theorems 3 and 2).
uses less than bins, where is the number of distinct item s.
Theorem 5.
Let be a MCBP instance. Let , i.e., is the assortment obtained by picking from each itemset the item having the minimum value of . Then the number of bins used by is less than , where is the number of distinct s of items in (so ).
Proof.
For any assortment , . Let be the assortment in an optimal packing of . By Theorems 3 and 2, the number of bins used by is less than
Let and . We can find in time and compute in time. This gives us an -time algorithm for MCBP having AAR .
4.1 BP with Rotations
As mentioned before, we can solve the rotational version of BP by reducing it to MCBP. Specifically, for each item in the BP instance, we create an itemset containing all orientations of , and we pack the resulting MCBP instance using . Since an item can have up to allowed orientations, this can take up to time. Hence, the running time is large when is large. However, we can do better for some special cases.
When the bin has the same length in each dimension, then for any item , is independent of how we orient . Hence, we can orient the items arbitrarily and then pack them using in time.
Suppose there are no orientation constraints, i.e., all orientations of each item are allowed. Let be the length of the bin in the dimension, for each . To use to pack , we need to find the best orientation for each item , i.e., we need to find a permutation for each item such that is minimized. This can be formulated as a maximum-weight bipartite matching problem on a graph with vertices in each partition: for every and , the edge has a non-negative weight of . So, using the Kuhn-Munkres algorithm [26], we can find the best orientation for each item in time. Hence, we can pack using in time.
5 Better Algorithm for MCBP ()
Here we will describe a -asymptotic-approximate algorithm for MCBP that is based on and Lueker and Fernandez de la Vega’s APTAS for 1BP [15]. We call our algorithm Harmonic Guess-and-Pack (). This improves upon that has AAR .
Definition 3.
For a D item , let , and . Let be a rectangle of height and width . For a set of D items, define and .
For any , the algorithm returns a bin packing of , where is a set of D itemsets. first converts to a set of 2D itemsets. It then computes , which is a structured bin packing of (we formally define structured later). Finally, it uses the algorithm to convert into a bin packing of the D itemsets , where is very close to . See Algorithm 2 for a more precise description. We show that , which proves that has an AAR of . This approach of converting items to 2D, packing them, and then converting back to D is very useful, because most of our analysis is about how to compute a structured 2D packing, and a packing of 2D items is easier to visualize and reason about than a packing of D items.
A 2D bin packing is said to be shelf-based if items are packed into shelves and the shelves are packed into bins, where a shelf is a rectangle of width 1. See Fig. 2 for an example. A structured bin packing is a shelf-based bin packing where the heights of the shelves satisfy some additional properties (we describe these properties later). The algorithm repeatedly guesses the number and heights of shelves and computes a structured packing of those shelves into bins. Then for each packing , the algorithm tries to pack an assortment of into the shelves in plus maybe one additional shelf. If succeeds, call the resulting bin packing . Otherwise, returns null. is the value of with the minimum number of bins across all guesses by .
We prove that the AAR of is by showing that for some , we have and is not null.
We will now precisely define structured bin packing and state the main theorems on .
5.1 Structured Packing
Definition 4 (Slicing).
Slicing a 1D item is the operation of replacing it by items and such that .
Slicing a rectangle using a vertical cut is the operation of replacing by two rectangles and where and . Slicing using a horizontal cut is the operation of replacing by two rectangles and where and .
Definition 5 (Shelf-based -fractional packing).
Let be a constant. Let be a set of rectangular items. Items in are said to be ‘-large’ and items in are said to be ‘-small’. A -fractional bin packing of is defined to be a packing of into bins where items in can be sliced (recursively) using vertical cuts only, and items in can be sliced (recursively) using both horizontal and vertical cuts.
A shelf is a rectangle of width 1 into which we can pack items such that the bottom edge of each item in the shelf touches the bottom edge of the shelf. A shelf can itself be packed into a bin. A -fractional bin packing of is said to be shelf-based iff (all slices of) all items in are packed into shelves, the shelves are packed into the bins, and items in are packed outside the shelves (and inside the bins). Packing of items into a shelf is said to be tight iff the top edge of some item (or slice) in touches the top edge of .
Definition 6 (Structured packing).
Let be a set of rectangles and let be a packing of empty shelves into bins. Let be the set of heights of shelves in (note that is not a multiset, i.e., we only consider distinct heights of shelves). Then is said to be structured for iff and each element in is the height of some -large item in .
A shelf-based -fractional packing of is said to be structured iff the shelves in the packing are structured for . Define to be the number of bins in the optimal structured -fractional packing of .
relies on the following key structural theorem. We formally prove it in Section A.2 and give an outline of the proof here.
Theorem 6 (Structural theorem).
Let be a set of D items. Let be a constant. Then .
Proof outline.
Let . Let and be the -large and -small items in , respectively.
We give a simple greedy algorithm to pack into shelves. Let be the shelves output by this algorithm. We can treat as a 1BP instance, and as a sliceable 1D item of size . We prove that an optimal 1D bin packing of gives us an optimal shelf-based -fractional packing of .
We use linear grouping by Lueker and Fernandez de la Vega [15]. We partition into linear groups of size each. Let be the height of the first 1D item in the group. Let be the 1BP instance obtained by rounding up the height of each item in the group to for all . Then contains at most distinct sizes, so the optimal packing of gives us a structured -fractional packing of . Therefore, . Let be the 1BP instance obtained by rounding down the height of each item in the group to for all . We prove that contains at most distinct sizes and that .
We model packing as a linear program, denoted by , that has at most variables and non-trivial constraints. The optimum extreme point solution to , therefore, has at most positive entries, so .
5.2 Subroutines
5.2.1
The algorithm takes a set of 2D itemsets and a constant as input. We will design so that it satisfies the following theorem.
Theorem 7.
returns all possible packings of empty shelves into at most bins such that each packing is structured for . returns at most packings, where , , and . Its running time is .
works by first guessing at most distinct heights of shelves. It then enumerates all configurations, i.e., different ways in which shelves can be packed into a bin. It then guesses the configurations in a bin packing of the shelves. can be easily implemented using standard techniques. For the sake of completeness, we give a more precise description of and prove Theorem 7 in Section A.3.
5.2.2
takes as input a set of 2D itemsets, a constant , and a bin packing of empty shelves that is structured for . It tries to pack an assortment of into the shelves in .
works by rounding up the width of all -large items in to a multiple of . This would increase the number of shelves required by 1, so it adds another empty shelf. It then uses dynamic programming to pack an assortment into the shelves, such that the area of the chosen -small items is minimum. This is done by maintaining a dynamic programming table that keeps track of the number of itemsets considered so far and the remaining space in shelves of each type. If it is not possible to pack the items into the shelves, then outputs null. In Section A.4, we give the details of this algorithm and formally prove the following theorems:
Theorem 8.
If there exists an assortment of having a structured -fractional bin packing , then does not output null.
Theorem 9.
If the output of is not null, then the output is a shelf-based -fractional packing of some assortment of such that and the distinct shelf heights in are the same as that in .
Theorem 10.
runs in time. Here , .
5.2.3
For a set of D items, is an algorithm that converts a shelf-based packing of into a packing of having roughly the same number of bins.
For a D item , (called base type) is defined to be a -dimensional vector whose component is . Roughly, works as follows: It first slightly modifies the packing so that items of different base types are in different shelves and -small items are no longer sliced using horizontal cuts. Then it converts each 2D shelf to a D shelf of the same height using (a D shelf is a cuboid where the first dimensions are equal to 1).
In Section A.5, we formally describe and prove the following theorem.
Theorem 11.
Let be a set of D items having distinct base types (there can be at most distinct base types, so ). Let be a shelf-based -fractional packing of where shelves have distinct heights. Then returns a packing of into less than bins in time.
Now that we have mentioned the guarantees of all the subroutines used by , we can prove the correctness and running time of .
5.3 Correctness and Running Time of
Theorem 12.
The number of bins used by to pack is less than
Here is the number of distinct base types in .
Proof.
Let be the assortment in an optimal bin packing of . Let . Let be the optimal structured -fractional bin packing of . Then by the definition of . By Theorem 7, . Let . By Theorem 8, is not null. By Theorem 9, is structured for and .
By Theorem 11, we get that
By Theorem 6 (structural theorem) and using , we get
Therefore, is less than
Theorem 13.
runs in time , where , , and .
Proof.
Follows from Theorems 7, 10 and 11. ∎
LABEL:sec:hgap:improve-time gives hints on improving the running time of .
5.4 BP with Rotations
We can solve the rotational version of BP by reducing it to MCBP and using the algorithm. Since each item can have up to orientations, the running time is polynomial in , which is large when is large. But we can do better for some special cases.
When the bin has the same length in each dimension, then for any item , is invariant to permuting the first dimensions. In the first step of , we replace each D item by a rectangle of width and height . So, instead of considering all orientations, we just need to consider at most different orientations, where each orientation has a different length in the dimension.
Suppose there are no orientation constraints, i.e., all orientations of each item are allowed. Let be the length of the bin in the dimension, for each . Analogous to the trick in Section 4.1, we first fix the dimension of the item and then optimally permute the first dimensions using a max-weight bipartite matching algorithm. Hence, we need to consider only orientations instead of .
References
- [1] Mauro Maria Baldi, Guido Perboli, and Roberto Tadei. The three-dimensional knapsack problem with balancing constraints. Applied Mathematics and Computation, 218(19):9802–9818, 2012. doi:10.1016/j.amc.2012.03.052.
- [2] János Balogh, József Békési, György Dósa, Leah Epstein, and Asaf Levin. A new and improved algorithm for online bin packing. In ESA, pages 5:1–5:14, 2018. doi:10.4230/LIPIcs.ESA.2018.5.
- [3] Nikhil Bansal, Alberto Caprara, and Maxim Sviridenko. A new approximation method for set covering problems, with applications to multidimensional bin packing. SIAM Journal on Computing, 39(4):1256–1278, 2010. doi:10.1137/080736831.
- [4] Nikhil Bansal, Xin Han, Kazuo Iwama, Maxim Sviridenko, and Guochuan Zhang. A harmonic algorithm for the 3d strip packing problem. SIAM J. Comput., 42(2):579–592, 2013. doi:10.1137/070691607.
- [5] Nikhil Bansal and Arindam Khan. Improved approximation algorithm for two-dimensional bin packing. In SODA, pages 13–25, 2014. doi:10.1137/1.9781611973402.2.
- [6] Nikhil Bansal and Maxim Sviridenko. New approximability and inapproximability results for 2-dimensional bin packing. In SODA, pages 196–203, 2004.
- [7] Andreas Bortfeldt and Gerhard Wäscher. Constraints in container loading–a state-of-the-art review. European Journal of Operational Research, 229(1):1–20, 2013. doi:10.1016/j.ejor.2012.12.006.
- [8] Alberto Caprara. Packing -dimensional bins in stages. Mathematics of Operations Research - MOR, 33:203–215, 02 2008. doi:10.1287/moor.1070.0289.
- [9] Edward G. Coffman, János Csirik, Gábor Galambos, Silvano Martello, and Daniele Vigo. Bin packing approximation algorithms: survey and classification. In Handbook of combinatorial optimization, pages 455–531. Springer New York, 2013.
- [10] Edward G. Coffman, Michael R. Garey, David S. Johnson, and Robert E. Tarjan. Performance bounds for level-oriented two-dimensional packing algorithms. SIAM Journal on Computing, 9:808–826, 1980. doi:10.1137/0209062.
- [11] János Csirik and André van Vliet. An on-line algorithm for multidimensional bin packing. Oper. Res. Lett., 13(3):149–158, 1993. doi:10.1016/0167-6377(93)90004-Z.
- [12] Leah Epstein and Rob van Stee. Optimal online algorithms for multidimensional packing problems. SIAM J. Comput., 35(2):431–448, 2005. doi:10.1137/S0097539705446895.
- [13] Leah Epstein and Rob van Stee. This side up! ACM Trans. Algorithms, 2(2):228–243, 2006. doi:10.1145/1150334.1150339.
- [14] Sándor P. Fekete and Jörg Schepers. A general framework for bounds for higher-dimensional orthogonal packing problems. Mathematical Methods of Operations Research, 60(2):311–329, 2004. doi:10.1007/s001860400376.
- [15] Wenceslas Fernandez de la Vega and George S. Lueker. Bin packing can be solved within 1+ in linear time. Combinatorica, 1(4):349–355, 1981. doi:10.1007/BF02579456.
- [16] Paul C. Gilmore and Ralph E. Gomory. A linear programming approach to the cutting-stock problem. Operations research, 9(6):849–859, 1961. doi:10.1287/opre.9.6.849.
- [17] Xin Han, Francis YL Chin, Hing-Fung Ting, Guochuan Zhang, and Yong Zhang. A new upper bound 2.5545 on 2D online bin packing. ACM Transactions on Algorithms (TALG), 7(4):1–18, 2011. doi:10.1145/2000807.2000818.
- [18] Klaus Jansen. A approximation algorithm for scheduling moldable and non-moldable parallel tasks. In SPAA, pages 224–235, 2012. doi:10.1145/2312005.2312048.
- [19] Klaus Jansen and Lars Prädel. New approximability results for two-dimensional bin packing. In SODA, pages 919–936, 2013. doi:10.1007/s00453-014-9943-z.
- [20] Klaus Jansen and Lars Prädel. A new asymptotic approximation algorithm for 3-dimensional strip packing. In SOFSEM, pages 327–338, 2014. doi:10.1007/978-3-319-04298-5_29.
- [21] Klaus Jansen and Rob van Stee. On strip packing with rotations. In STOC, pages 755–761. ACM, 2005. doi:10.1145/1060590.1060702.
- [22] Claire Kenyon and Eric Rémila. Approximate strip packing. In FOCS, pages 31–36, 1996. doi:10.1109/SFCS.1996.548461.
- [23] Eugene L Lawler. Fast approximation algorithms for knapsack problems. Mathematics of Operations Research, 4(4):339–356, 1979. doi:10.1287/moor.4.4.339.
- [24] C. C. Lee and D. T. Lee. A simple on-line bin-packing algorithm. J. ACM, 32(3):562–572, July 1985. doi:10.1145/3828.3833.
- [25] Flavio Keidi Miyazawa and Yoshiko Wakabayashi. Three-dimensional packings with rotations. Computers & Operations Research, 36(10):2801–2815, 2009. doi:10.1016/j.cor.2008.12.015.
- [26] James Munkres. Algorithms for the assignment and transportation problems. Journal of the Society for Industrial and Applied Mathematics, 5(1):32–38, 1957.
- [27] Boaz Patt-Shamir and Dror Rawitz. Vector bin packing with multiple-choice. Discrete Applied Mathematics, 160(10-11):1591–1600, 2012. doi:10.1016/j.dam.2012.02.020.
- [28] Prakash Ramanan, Donna J Brown, Chung-Chieh Lee, and Der-Tsai Lee. On-line bin packing in linear time. Journal of Algorithms, 10(3):305–326, 1989. doi:10.1016/0196-6774(89)90031-X.
- [29] Steven S Seiden. On the online bin packing problem. Journal of the ACM (JACM), 49(5):640–671, 2002. doi:10.1145/585265.585269.
- [30] Y. G. Stoyan and Andrey M. Chugay. Packing different cuboids with rotations and spheres into a cuboid. Advances in Decision Sciences, 2014, 2014.
- [31] Hu Zhang and Klaus Jansen. Scheduling malleable tasks. In Handbook of Approximation Algorithms and Metaheuristics. Chapman & Hall/CRC, 2007.
Appendix A Details of the Algorithm
This section gives details of the subroutines used by . It also proves the theorems claimed in Section 5.
A.1 Preliminaries
Definition 7.
Let and be sets of 1D items. Then is defined to be a predecessor of (denoted as ) iff there exists a one-to-one mapping such that .
Observation 14.
Let where is the corresponding mapping. Then we can obtain a packing of from a packing of , by packing each item in the place of . Hence, .
Definition 8 (Canonical shelving).
Let be a set of rectangles. Order the items in in non-increasing order of height (break ties arbitrarily but deterministically) and greedily pack them into tight shelves, slicing items using vertical cuts if necessary. The set of shelves thus obtained is called the canonical shelving of , and is denoted by . (The canonical shelving is unique because ties are broken deterministically.)
See Fig. 3 for an example of canonical shelving.
Suppose a set of rectangular items is packed into a set of shelves. Then we can interpret as a 1BP instance where the height of each shelf is the size of the corresponding 1D item. We will now prove that the canonical shelving is optimal, i.e., any shelf-based bin packing of items can be obtained by first computing the canonical shelving and then packing the shelves into bins like a 1BP instance.
Lemma 15.
Let be a set of rectangles packed inside shelves . Let . Then .
Proof.
We say that a shelf is full if the total width of items in a shelf is 1. Arrange the shelves in non-increasing order of height, and arrange the items in non-increasing order of height. Then try to pack into using the following greedy algorithm: For each item , pack the largest possible slice of into the first non-full shelf and pack the remaining slice (if any) in the next shelf. If this greedy algorithm succeeds, then within each shelf of , there is a shelf of , so . We will now prove that this greedy algorithm always succeeds.
For the sake of proof by contradiction, assume that the greedy algorithm failed, i.e., for an item (or slice) there was a non-full shelf but . Let be the items (and slices) packed before and be the shelves before . Therefore, .
All items in have height at least , so all shelves in have height at least . All shelves after have height less than . Therefore, is exactly the set of shelves of height at least .
In the packing , can only be packed into shelves of height at least , so . But this contradicts . Therefore, the greedy algorithm cannot fail. ∎
Lemma 16.
Consider the inequality , where for each , . Let be the number of solutions to this inequality. Then .
Proof.
The proof of is a standard result in combinatorics.
To prove , note that we can choose each independently. ∎
A.2 Structural Theorem
Let be a set of D items. Let . Let be a constant. Let and . Let . Let , i.e., contains shelves. We can interpret as a single sliceable 1D item of size .
We will show the existence of a structured -fractional packing of into at most bins. This would prove Theorem 6.
Definition 9 (Linear grouping [15]).
Arrange the 1D items in non-increasing order of size and number them from 1 to . Let . Let be the first items, be the next items, and so on. is called the linear group of . This gives us linear groups. Note that the last group, , may have less than items.
Let be the size of the first item in . Let . For , let be the items obtained by decreasing the height of items in to . For , let be the items obtained by increasing the height of items in to .
Let and . We call a down-rounding of and an up-rounding of .
Lemma 17.
.
Proof.
Since each shelf in has height more than , .
Lemma 18.
.
Proof.
It is trivial to see that . For , all (1D) items in both and have height , and . Therefore, and hence
Lemma 19.
.
Proof.
In the canonical shelving of , let be the shelf. Let be the height of . Let be the total area of the items in . Since the shelves are tight, items in have height at least . So, and
Lemma 20.
.
Proof.
A.2.1 LP for Packing
We will formulate an integer linear program for bin packing .
Let such that . Then is called a configuration. represents a set of 1D items that can be packed into a bin and where items are from . Let be the set of all configurations. We can pack at most items into a bin because . By Lemma 16, we get .
Let be the number of bins packed according to configuration . Bin packing is equivalent to finding the optimal integer solution to the following linear program, which we denote as .
Here the first set of constraints say that for each , all of the shelves should be covered by the configurations in . The second constraint says that we should be able to pack into the non-shelf space in the bins.
Lemma 21.
.
Proof.
Let be an optimal extreme-point solution to . By rank-lemma, has at most non-zero entries. Let be a vector where . Then is an integral solution to and . ∎
The dual of , denoted by , is
where | |||
A.2.2 Weighting Function for a Feasible Solution to
We will now see how to obtain a monotonic weighting function from a feasible solution to . To do this, we adapt techniques from Caprara’s analysis of [8]. Such a weighting function will help us upper-bound in terms of .
We first describe a transformation that helps us convert any feasible solution of to a feasible solution that is monotonic. We then show how to obtain a weighting function from this monotonic solution.
Transformation 10.
Let be a feasible solution to . Let . Define and . Then change to .
Lemma 22.
Let be a feasible solution to . Let be the new solution obtained by applying Transformation 10 with parameter . Then is feasible for .
Proof.
For a configuration , let , where . Since is feasible for , . As per Transformation 10,
If , then , so would be feasible for . So now assume that .
Let be a configuration. Define . Let
Then, .
Also, .
Since , is a configuration.
Therefore, is feasible for . ∎
Definition 11.
Let be a feasible solution to . Let
Then is called the monotonization of .
Lemma 23.
Let be a feasible solution to . Let be the monotonization of . Then is a feasible solution to .
Proof.
can be obtained by multiple applications of Transformation 10: first with , then with , and so on till . Then by Lemma 22, is feasible for . ∎
Let be an optimal solution to . Let be the monotonization of . Then define the function as
Lemma 24.
is a monotonic weighting function.
Proof.
is monotonic by the definition of monotonization.
Let be a finite set such that . Let , let and for , let . Let such that . Let .
(for , each element in is at least ) | ||||
Since , is a configuration. Therefore,
(by definition of ) | ||||
() | ||||
( is a configuration and is feasible for by Lemma 23) |
∎
Lemma 25.
For , let . Then .
Proof.
Let be an optimal solution to . Let be the monotonization of .
In the canonical shelving of , suppose a rectangular item (or a slice thereof) lies in shelf where . Then , where . This is because shelves in are tight. If , then . If , then . We are guaranteed that for , and each shelf , .
(by definition of ) | ||||
(by definition of ) | ||||
(since for ) | ||||
( is optimal for ) |
By strong duality of linear programs, .
See 6
A.3 Guessing Shelves and Bins
We want to return all possible packings of empty shelves into at most bins such that each packing is structured for .
Let . Let . starts by picking the distinct heights of shelves by iterating over all subsets of of size at most . The number of such subsets is at most . Let be one such guess, where . Without loss of generality, assume .
Next, needs to decide the number of shelves of each height and a packing of those shelves into bins. Let such that . Then is called a configuration. represents a set of shelves that can be packed into a bin and where shelves have height . Let be the set of all configurations. We can pack at most items into a bin because . By Lemma 16, we get
There can be at most bins, and has to decide the configuration of each bin. By Lemma 16, the number of ways of doing this is at most . Therefore, computes all configurations and then iterates over all combinations of these configs.
This completes the description of and proves Theorem 7.
A.4
takes as input a set of 2D itemsets, a packing of empty shelves into bins and constant . It tries to pack into and one additional shelf. Before we design , let us see how to handle a special case, i.e., where is simple.
Definition 12.
A set of 2D itemsets is -simple iff the width of each -large item in is a multiple of .
Let be a bin packing of empty shelves. Let be the distinct heights of the shelves in , where . We will use dynamic programming to either pack a simple instance into or claim that no assortment of can be packed into . Call this algorithm .
Let . For , define , i.e., contains the first itemsets from . Let be a vector. Let be the set of all assortments of that can be packed into shelves, where the shelf has height and width . For a set of items, define as the total area of -small items in . Define . If , then we let .
We will show how to compute for all and all using dynamic programming. Let there be shelves in having height . Then for and , can be packed into iff is at most the area of non-shelf space in .
Note that in any solution corresponding to , we can assume without loss of generality that the item from is placed in the smallest shelves possible. This is because we can always swap with the slices of items in those shelves. This observation gives us the following recurrence relation for :
(1) |
Here is a vector obtained as follows: If is -small, then . Otherwise, initialize to . Let be the largest integer such that . For varying from to 2, subtract from and . Then subtract from . The new value of is defined to be the output of .
The recurrence relation allows us to compute for all and using dynamic programming in time time, where . With a bit more work, we can also compute the corresponding assortment , if one exists. Therefore, computes a packing of into if one exists, or returns null if no assortment of can be packed into .
Now we will look at the case where is not -simple. Let be the instance obtained by rounding up the width of each -large item in to a multiple of , where . Let be the bin packing obtained by adding another bin to containing a single shelf of height . computes and and returns the output of .
See 9
Proof.
Follows from the definition of . ∎
See 8
Proof.
Let be the items obtained by rounding up the width of each item in to a multiple of . Then is an assortment of . We will show that fits into , so will not output null.
Slice each item into two pieces using a vertical cut such that one piece has width equal to the original width of in , and the other piece has width less than . This splits into sets and . contains at most items, each of width less than . Therefore, we can pack into and we can pack into the newly-created shelf of height . Therefore, can be packed into , so won’t output null. ∎
See 10
Proof.
The running time of is dominated by computing for all and , which takes time. Since is structured for , the number of distinct shelves in , which is , is at most . ∎
A.5
Let be a set of D items. Let be a shelf-based -fractional bin packing of into bins. Let there be distinct heights of shelves in : . We want to design an algorithm that returns a packing of into approximately bins.
Define and . Let there be distinct base types in (so ).
A.5.1 Separating Base Types
We will now impose an additional constraint over : items in each shelf must have the same . This will be helpful later, when we will try to compute a packing of D items .
Separating base types of is easy, since we can slice them in both directions. An analogy is to think of a mixture of multiple immiscible liquids of different densities settling into equilibrium.
Let there be shelves of height . Let be the items packed into shelves of height . Therefore, . Let be the items of base type .
For each , pack into shelves of height (slicing items if needed). For these newly-created shelves, define the of the shelf to be the of the items in it. Let the number of newly-created shelves of height be . Then
of these shelves can be packed into existing bins in place of the old shelves. The remaining shelves can be packed on the base of new bins.
Therefore, by using at most new bins, we can ensure that for every shelf, all items in that shelf have the same . These new bins don’t contain any items from . Call this new bin packing . This transformation takes time.
A.5.2 Forbidding Horizontal Slicing
We will now use to compute a shelf-based bin packing of where items in can be sliced using vertical cuts only.
Let be the items in of base type . Pack items into shelves using . Suppose used shelves to pack . For , let be the height of the shelf. Let and . Since for , all items in the shelf have height at least ,
Therefore, . Let be the set of these newly-created shelves.
Use Next-Fit to pack into the space used by in . uses at most bins in (recall that ). A height of less than will remain unpacked in each of those bins. The total height occupied by in is . Therefore, Next-Fit will pack a height of more than .
Some shelves in may still be unpacked. Their total height will be less than . We will pack these shelves into new bins using Next-Fit. The number of new bins used is at most . Call this bin packing . The number of bins in is at most .
A.5.3 Shelf-Based D packing
We will now show how to convert the packing of that uses bins into a packing of that uses D bins.
First, we repack the items into the shelves. For each , let be the set of shelves in of . Let be the items packed into . Compute and pack the shelves into . This is possible by Lemma 15.
This repacking gives us an ordering of shelves in . Number the shelves from 1 onwards. All items have at most 2 slices. If an item has 2 slices, and one slice is packed into shelf number , then the other slice is packed into shelf number . The slice in shelf is called the leading slice. Every shelf has at most one leading slice.
Let be the shelf of . Let be the set of unsliced items in and the item whose leading slice is in . Order the items in arbitrarily, except that the sliced item, if any, should be last. Then . So, we can use