3

Edit: I'm looking for an efficient Ruby, JavaScript, Java or Python implementation of 3D bin-packing with the constraints below

I'm looking for an efficient algorithm for correctly identifying the number of containers required to store a list of items. The context is around generating the accurate number and type of shipping labels for an e-commerce order.

Given:

  • Items have a known width, length, depth and weight
  • Items have a packing type specifying that they can be combined with other items in the same container ("over-pack"), or must be shipped in their own container ("ship-alone")
  • Containers have a known width, length, depth and weight capacity
  • Multiple containers are available of varying sizes and capacities

Problem:

  • A list of items exists, possibly of varying sizes and packing types, and possibly in multiple quantities. Split the list of items so that they can be stored in the minimum number of containers possible

I figure this is an interesting volumetric math challenge that a few of you might enjoy. I'm looking to figure out the best programmatic solution to this.

Grateful to receive solutions in any language with a preference for Java, JavaScript, Python or Ruby.

Thanks in advance!

Alex Norcliffe
  • 2,309
  • 1
  • 16
  • 20
  • This is a variation on the https://en.wikipedia.org/wiki/Knapsack_problem but with complexities added to account for the fact that some items require their own container ("ship-alone") – Alex Norcliffe Jul 20 '16 at 19:41

1 Answers1

1

This is exactly the 3D bin-packing problem.

The requirement of "ship alone" is simply reduced by putting these elements out and shipping them alone, which leaves you with the others.

Finding the minimal number of containers needed to pack them is now the bin-packing problem in 3 dimensional space.

This problem is undortunately Strongly NP-Hard, so unlike knapsack - there is no known pseudo polynomial optimal solution to it.

This article discusses the problem: The Three-Dimensional Bin Packing Problem (Martello et al)

amit
  • 166,614
  • 24
  • 210
  • 314
  • In the end I actually solved this much more simply (and, naively). I use a lookup table of container types with multiple examples of combinations of packing units they can contain. Each product is measured by the size of packing unit it requires (rather than the exact dimensions). Then, starting from the largest packing units in the order, I choose container types based on the example capacities in the lookup table, and decrement the remaining small/medium/large units needed to be packed. Took a few hours to write. Do you know if there is a name for this kind of solution? (Other than "lazy"..) – Alex Norcliffe Jul 21 '16 at 22:26
  • Thanks for your time, btw! – Alex Norcliffe Jul 21 '16 at 22:37