BoxPacker icon indicating copy to clipboard operation
BoxPacker copied to clipboard

Packing method

Open xBIGDBx opened this issue 3 years ago • 2 comments

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

boxpacker and the fourth pallet in the second package

The effect that I would like to achieve real

Is it possible to achieve this arrangement? Thanks for the help

xBIGDBx avatar Apr 21 '21 22:04 xBIGDBx

Hi @xBIGDBx

I'll take a look

dvdoug avatar Apr 25 '21 15:04 dvdoug

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:

  1. 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

  2. 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.

image

Is it possible to achieve this arrangement?

Unfortunately not in the short term, but I'll keep this issue open

dvdoug avatar May 03 '21 20:05 dvdoug