Search code examples
phpmathbin-packing

Fitting parcel in parcel machine box algorithm


Yesterday I asked another question and found out that there is a bin packing problem and that it has no solution at the moment.

So I decided to reformulate my question making it more task-specific and to ask it once again.

I have a parcel machine with 3 different types of boxes:

Array(
    "S" => Array(
        "width" => 380,
        "length" => 640,
        "height" => 90,
    ),
    "M" => Array(
        "width" => 380,
        "length" => 640,
        "height" => 190,
    ),
    "L" => Array(
        "width" => 380,
        "length" => 640,
        "height" => 390,
    ),
);

I also have a parcel which contains N boxes, each with known dimensions:

Array(
    "PRODUCT_1" => Array(
        "width" => $x1,
        "length" => $y1,
        "height" => $z1,
    ),
    "PRODUCT_2" => Array(
        "width" => $x2 ,
        "length" => $y2 ,
        "height" => $z2,
    ),
    ...
    "PRODUCT_N" => Array(
        "width" => $xN ,
        "length" => $yN ,
        "height" => $zN,
    ),
)

Is there any way to determine in which parcel machine box my parcel will fit?


Solution

  • I spent two days of googling and finally I found a small PHP library that works my needs: https://boxpacker.io/en/stable/.

    Lots of thanks to an Doug Wright!