javascriptalgorithmmathe-commercebin-packing

Toy box challenge - E-commerce Shipment / Container splitting


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:

Problem:

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!


Solution

  • 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)