Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packing method #230

Open
xBIGDBx opened this issue Apr 21, 2021 · 2 comments
Open

Packing method #230

xBIGDBx opened this issue Apr 21, 2021 · 2 comments

Comments

@xBIGDBx
Copy link

xBIGDBx commented Apr 21, 2021

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

@dvdoug
Copy link
Owner

dvdoug commented Apr 25, 2021

Hi @xBIGDBx

I'll take a look

@dvdoug
Copy link
Owner

dvdoug commented May 3, 2021

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 added a commit that referenced this issue Feb 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants