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

Non-optimal solution when rectangles are rotated #22

Open
harriv opened this issue Sep 18, 2018 · 2 comments
Open

Non-optimal solution when rectangles are rotated #22

harriv opened this issue Sep 18, 2018 · 2 comments

Comments

@harriv
Copy link

harriv commented Sep 18, 2018

Hi,

I tried to pack 2 by 3 rectangles to bin sized 4 by 6. If I enable rotation, I get 3 packed rectangles instead 4:

image

With rotation disabled I get 4 packed rectangles as expected.

I'm running with default settings:

packer = newPacker(rotation=False)
How to fix this?

@secnot
Copy link
Owner

secnot commented Sep 18, 2018

Hi

Packing is a np-hard problem so the algorithms used are heuristic, this means that they usually won't find the optimal solution.

But you can improve your solution in two ways:

  • If the number of rectangles is small you can search all the possible combinations using DFS and choose the optimal.
  • If the number of rectangles is too big, you can use this library and create several packers with different algorithms and options, then choose the best packing between them.

@harriv
Copy link
Author

harriv commented Sep 18, 2018

SkylineMwfWm algorithm seems to solve at least this problem ok.

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