PHP / C++ space calculations for parcel packing

Posted by Andrew Willis on Stack Overflow See other posts from Stack Overflow or by Andrew Willis
Published on 2012-04-15T22:36:36Z Indexed on 2012/04/15 23:29 UTC
Read the original article Hit count: 301

Filed under:
|
|

I am working on a shopping cart project which requires a 'postage calculator' based on items that the person has in their cart.

Obviously I will be storing the item's dimensions incl. weight and padding in a database and will also store the parcel (box) size and weight that the items will go in to, incl. box padding.

Figuring the weight of the parcels will be easy but I was wondering how to go about figuring how to pack the box via PHP, that is, I would like the code to 'play tetris' with the items to make sure they get the best possible fit, giving accurate postage costs.

Does anybody have any ideas on how best to achieve this or does anybody know of a PHP Class or function that can do this?

EDIT: When I said 'best possible fit' maybe I was being optimistic! Having the script try every possible combination of package distribution within the parcel would be over the top, however I could improve the speed by writing the algoritm in C++ and running the program in PHP when the user 'checks out', the return value being an array with the parcel size and weight (which are all that are needed to calculate postage costs)

© Stack Overflow or respective owner

Related posts about php

Related posts about c++