How can I programmatically determine how to fit smaller boxes into a larger package? [closed]

This is a Bin Packing problem, and it’s NP-hard. For small number of objects and packages, you might be able to simply use the brute force method of trying every possibility. Beyond that, you’ll need to use a heuristic of some sort. The Wikipedia article has some details, along with references to papers you probably want to check out.

The alternative, of course, is to start with a really simple algorithm (such as simply ‘stacking’ items) and calculate a reasonable upper-bound on shipping using that, then if your human packers can do better, you make a slight profit. Or discount your calculated prices slightly on the assumption that your packing is not ideal.

Leave a Comment