HACKER Q&A
📣 chirau

How do I find the smallest box than can fit x smaller boxes in it?


I have a packing problem. I have a 5 packages, that I want to fit in one big box to ship. The big box is priced per unit volume.

Is there a formula or algorithm to find the smallest big box that will fit a certain number of smaller packages?

As a sample, here is a sample of 5 packages which i need to get into one cheapest big box:

L x W x H 11.1 x 10.0 x 4.0 9.3 x 6.8 x 4.8 17.0 x 3.3 x 1.7 5.1 x 4.7 x 3.9 17.7 x 11.8 x 2.8

If there is a reusable solution or method to finding the big box size, it would be much appreciated.


  👤 dane-pgp Accepted Answer ✓
Here is the abstract of a paper from 2000 titled "The Three-Dimensional Bin Packing Problem"[0]:

"The problem addressed in this paper is that of orthogonally packing a given set of rectangular-shaped items into the minimum number of three-dimensional rectangular bins. The problem is strongly NP-hard and extremely difficult to solve in practice. Lower bounds are discussed, and it is proved that the asymptotic worst-case performance ratio of the continuous lower bound is 1/8. An exact algorithm for filling a single bin is developed, leading to the definition of an exact branch-and-bound algorithm for the three-dimensional bin packing problem, which also incorporates original approximation algorithms. Extensive computational results, involving instances with up to 90 items, are presented: It is shown that many instances can be solved to optimality within a reasonable time limit."

That sounds slightly different, if you have to specify the size of the big box up front, but you may be able to efficiently explore different values for the L x W x H of the big box once you know the optimum packing for a given set of lengths.

[0] https://pubsonline.informs.org/doi/abs/10.1287/opre.48.2.256...