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

without preset bin sizes #19

Open
gareth-ib opened this issue Aug 18, 2018 · 1 comment
Open

without preset bin sizes #19

gareth-ib opened this issue Aug 18, 2018 · 1 comment

Comments

@gareth-ib
Copy link

is it possible to use this without setting bin sizes? In my scenario I just want all my rectangles to fit in the smallest space possible, whatever that shape may be

@secnot
Copy link
Owner

secnot commented Aug 18, 2018

Hi

Not directly but it can be used to find an approximation. For example:

  • Get the total area of the rectangles to find the side of the square where they would all fit with a perfect packing.
side = sqrt(sum(r.area() for r in rectangles))
  • Create a packer using pack_algo= MaxRectsBlsf and sort_algo = SORT_LSIDE

  • Add a bin with the same width as the square, and ten times its height

  • Pack all the rectangles and search the result for the one at the top.

  • The minimum height for the bin to fit all the rectangles is the top of the previous rectangle.

The packing will not be perfect but you can play with the initial width, rectangle order, algorithms, and search for the combination wasting less area in the packing.

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