secnot / rectpack

Python 2D rectangle packing library
Apache License 2.0
457 stars 103 forks source link

Is it possible to know the percentage of utilised/wasted area? #11

Open Thavasidurai opened 7 years ago

Thavasidurai commented 7 years ago

In my case I really don't worry about performance time so I would like to use different sort order and algorithm to find out the best result. Can you please guide me based on what or how can I compare one result with other to find the best?

secnot commented 7 years ago

There are two common cases:

total_area_used = sum([bin.used_area() for bin in packer])

bins_used = len(packer)

The algorithm that usually obtains the best packing is one of the variants of MaxRects using PackingBin.Global selection, and ordering the rectangles in descending order by area or lside.

But if I rememver correctly the time complexity is high O(n3) but depends on the number of rectangles that fit per bin, if it is too high maxrects is not practical and you should use guillotine

Thavasidurai commented 7 years ago

Thank you so much for your quick response :-)