BoxPacker
BoxPacker copied to clipboard
Packing method
Hi, I wonder about a way to pack 4 items that can actually be packed into one box without being stackable, but BoxPacker breaks it down into 2.
$packer = new Packer();
$packer->setMaxBoxesToBalanceWeight(1);
$packer->addBox(new TestBox('Truck', 220, 210, 230, 0, 220, 210, 230, 1200));
$packer->addItem(new TestItem('Pallet', 80, 120, 140, 90, TestItem::ROTATION_KEEP_FLAT), 4);
$packedBoxes = $packer->pack();
**response:**
Pallet was packed at co-ordinate (0, 0, 0) with l120, w80, d160
Pallet was packed at co-ordinate (80, 0, 0) with l120, w80, d160
Pallet was packed at co-ordinate (0, 120, 0) with l80, w120, d160
Pallet was packed at co-ordinate (0, 0, 0) with l120, w80, d160
and the fourth pallet in the second package
The effect that I would like to achieve
Is it possible to achieve this arrangement? Thanks for the help
Hi @xBIGDBx
I'll take a look
Hi @xBIGDBx
Your example here is probably the "worst" case of a scenario as far as the packing algorithm is concerned. There are 2 things that are negatively affecting the packing efficiency in this case:
-
All the items are identical, and yet for this particular box shape the best packing density requires to them to packed in different orientations - in most scenarios that I've seen, keeping the same orientation for identical items results in the best packing, so the algorithm has a rule to enforce that. That negatively affects this particular case
-
As an efficiency/calculation tradeoff, the algorithm works by building layers/slices/walls. Here, if I disable the "identical items must have same orientation" rule, the packing looks like below. The algorithm considers the top of the red box/bottom of the blue box to constitute the defining limit of the "first wall" which applies across the whole pallet width.
Is it possible to achieve this arrangement?
Unfortunately not in the short term, but I'll keep this issue open