Question

I am creating a shipping module for a custom webshop (in PHP) that is turning out to be a bit complex (for me anyway);

in the desired shipping procedure, there are (currently) two outer 'shipping boxes/containers' that can each contain a different combination of items/products. There is a big one and a small one, and the small one is obviously cheaper to ship. Items/product (currently) fall into three dimensions of 'inner boxes'.

I am looking for an API/class in which I can input the dimensions of the outer boxes, then the amounts and dimensions of inner boxes (or rather, products) to be shipped. The optimal combination of outer boxes and its contents/packing order should then be calculated, such that the smallest amount of boxes is needed.

Needless to say, I expect the number of outer boxes, inner boxes and their dimensions are probably very likely to change in the future.

Does this even exist?

Était-ce utile?

La solution

This is an instance of the famous Packing problem, most of which is NP-hard. To find an optimal solution to such problems may be very hard or impossible, so you should aim for a good enough solution rather than the optimal one.

You should check out the Bin packing problem which is very similar to your problem, with the difference that you have two different volumes for the bins.

Autres conseils

While you're trying to figure out, and then implement, a bin-packing algorithm to formulate an optimal solution get one of the packers to write down a look-up table for the most frequent combinations of items in an order. From what you've told us you only have 2 sizes of outer box and 3 sizes of inner box, one of your packers can probably finish the look-up table in the time it took me to write this answer.

Now, since you're a software developer, develop code to read the lookup table and to ask for help when a novel combination of items is to be packed. Store these new combinations, and how to pack them, in the lookup table. As the business develops so develop the lookup table.

This approach takes advantage of the superior skills of humans in solving 3D packing problems for reasonable numbers of objects. You don't need an optimal solution, just one that is good enough that your customers don't query the amount of packaging too often -- you are passing the costs on to the customer aren't you ?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top