secnot / rectpack

Python 2D rectangle packing library
Apache License 2.0
463 stars 104 forks source link

Non-optimal solution when rectangles are rotated #22

Open harriv opened 6 years ago

harriv commented 6 years ago

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 commented 6 years ago

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:

harriv commented 6 years ago

SkylineMwfWm algorithm seems to solve at least this problem ok.