Skip to content

Not optimal packing in a box #608

@patryk-kolorama

Description

@patryk-kolorama

Hi,
I have a problem with optimal packaging of items in a box.
I have 3 types of box depths that are cut to the desired length but not exceeding the courier's limit.

So I made a while loop from the smallest possible size to the longest package + mountings box length in the order

$w=400;
while ($w<=2360) {
$packer->addBox(new MyBox('Box120 '.$w, $w, 285, 120, 1200, 25000));
$packer->addBox(new MyBox('Box160 '.$w, $w, 285, 160, 1200, 25000));
$packer->addBox(new MyBox('Box250 '.$w, $w, 285, 250, 1200, 25000));
$w += 10;
}
For now, in the example, I made the same outer dimensions as the inner ones

Items to pack are blinds and a box with mountings

$packer->addItem(new MyItem('mountings', 282, 110, 160, 500), 1);
$packer->addItem(new MyItem('blind 50mm', 2260, 218, 80, 1380), 1);
$packer->addItem(new MyItem('blind 35mm ', 1585, 192, 60, 5050), 1);
$packer->addItem(new MyItem('blind 50mm', 1175, 218, 80, 5190), 1);
$packer->addItem(new MyItem('blind 35mm', 1028, 191, 60, 3210), 1);
$packer->addItem(new MyItem('blind 35mm', 1028, 192, 60, 3200), 1);

https://boxpacker.io/en/master/visualiser.html?packing=%7B%22items%22%3A%5B%5B%22blind+50mm%22%2C218%2C1175%2C80%5D%2C%5B%22blind+35mm%22%2C192%2C1028%2C60%5D%2C%5B%22blind+35mm%22%2C191%2C1028%2C60%5D%2C%5B%22blind+50mm%22%2C218%2C2260%2C80%5D%2C%5B%22blind+35mm%22%2C192%2C1585%2C60%5D%2C%5B%22mountings%22%2C110%2C282%2C160%5D%5D%2C%22boxes%22%3A%5B%5B%22Box250+1180%22%2C285%2C1180%2C250%2C%5B%5B0%2C0%2C0%2C0%2C218%2C1175%2C80%5D%2C%5B1%2C0%2C0%2C80%2C192%2C1028%2C60%5D%2C%5B2%2C0%2C0%2C140%2C191%2C1028%2C60%5D%5D%5D%2C%5B%22Box250+2260%22%2C285%2C2260%2C250%2C%5B%5B3%2C0%2C0%2C0%2C218%2C2260%2C80%5D%2C%5B4%2C0%2C0%2C80%2C192%2C1585%2C60%5D%2C%5B5%2C0%2C1585%2C80%2C282%2C110%2C160%5D%5D%5D%5D%7D

And the problem is that the algorithm uses the box with mountings to pack it into two 250 boxes instead of two 160 boxes.
When I removed
$packer->addBox(new MyBox('Box250 '.$w, $w, 285, 250, 1200, 25000));
it was packed as it should be.
I thought that maybe it doesn't rotate the box with mountings, but this option is enabled.

https://boxpacker.io/en/master/visualiser.html?packing=%7B%22items%22%3A%5B%5B%22blind+50mm%22%2C218%2C2260%2C80%5D%2C%5B%22blind+50mm%22%2C218%2C1175%2C80%5D%2C%5B%22blind+35mm%22%2C192%2C1028%2C60%5D%2C%5B%22blind+35mm%22%2C192%2C1585%2C60%5D%2C%5B%22blind+35mm%22%2C191%2C1028%2C60%5D%2C%5B%22mountings%22%2C110%2C282%2C160%5D%5D%2C%22boxes%22%3A%5B%5B%22Box160+2260%22%2C285%2C2260%2C160%2C%5B%5B0%2C0%2C0%2C0%2C218%2C2260%2C80%5D%2C%5B1%2C0%2C0%2C80%2C218%2C1175%2C80%5D%2C%5B2%2C0%2C1175%2C80%2C192%2C1028%2C60%5D%5D%5D%2C%5B%22Box160+1700%22%2C285%2C1700%2C160%2C%5B%5B3%2C0%2C0%2C0%2C192%2C1585%2C60%5D%2C%5B4%2C0%2C0%2C60%2C191%2C1028%2C60%5D%2C%5B5%2C0%2C1585%2C0%2C282%2C110%2C160%5D%5D%5D%5D%7D

In my example, I would rather have a box with mountings to make the box longer than choose a larger one.
But idk how to do this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions