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

Inefficient packing #272

Closed
dvdoug opened this issue Jan 16, 2022 · 8 comments
Closed

Inefficient packing #272

dvdoug opened this issue Jan 16, 2022 · 8 comments

Comments

@dvdoug
Copy link
Owner

dvdoug commented Jan 16, 2022

Not sure if I should open a separate task or not but here is a similar example that is actually much simpler:

  • 5 units of an item which is 2.6 L x 2.6 W x 4.6 H inches
  • One box option that is 7.25 L x 7.25 W x 6.5 H inches (a USPS flat rate box)

This should be able to fit up to 6 units by laying 4 on their side and stacking those 4 two high and then the remaining two upright. However, BoxPacker splits it into two boxes (first one with 3 units shown) but you can see how six would be able to fit:

image

Originally posted by @colinmollenhour in #264 (comment)

@colinmollenhour
Copy link
Contributor

Hi @dvdoug what are the chances realistically of you being able to make optimizations to the algorithm to address problems such as this in 2022?

@dvdoug
Copy link
Owner Author

dvdoug commented Jul 31, 2022

Hi @colinmollenhour

🤞 I should have time around October to come back and have a proper attempt at issues like this - unfortunately while it's easy(ish) to figure out which packing decision is being non-optimal in any given situation, it's usually the case (it is here) that tweaking things to make one packing scenario better tends to regress others - and sadly I haven't had the time recently for complicated issues, only simple ones.

Please rest assured though, this is not an abandoned lib

@colinmollenhour
Copy link
Contributor

@dvdoug Thanks for the update. Let me know when you start if you need any assistance from my team with testing or otherwise.

dvdoug added a commit that referenced this issue Feb 5, 2023
@dvdoug dvdoug closed this as completed in 27bb78e Mar 9, 2024
@colinmollenhour
Copy link
Contributor

Hi Doug, thanks for tackling and fixing this issue! Is it simply fixed, or does the usage need to be changed to take advantage of the changes to fix it? Do you have any further info on the logic behind the changes?

@dvdoug
Copy link
Owner Author

dvdoug commented Mar 17, 2024

When released, it will be automatic - it will still only consider the allowed rotations (e.g. keep flat will be respected) but instead of simply running the heuristic to guess at the best orientation and then firmly sticking to it, if there are items that don't fit into the box, it will go back and retry starting with by placing that first item in each of the other orientations to see if a better result can be obtained

@dvdoug
Copy link
Owner Author

dvdoug commented Mar 17, 2024

By restricting the try-everything version to just the first item, performance on the whole doesn't suffer - although there will be additional extra packings done inside the new loop (potentially 3x slower), this is more than offset by the extra packing efficiency meaning that the weight redistributor doesn't kick in as much (or at all when going from 2 to 1)

@colinmollenhour
Copy link
Contributor

colinmollenhour commented Mar 21, 2024 via email

@dvdoug
Copy link
Owner Author

dvdoug commented Apr 1, 2024

Many thanks for that offer @colinmollenhour but happily employed currently so I'll need to decline

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