Is there a c++ source/lib to solve 2D Bin Packing with a rectangular bin (not square) and rotation?

HardCoder picture HardCoder · Jan 16, 2012 · Viewed 11.1k times · Source

As the title already says I need C/C++ sourcecode or a library that I can use to solve the Bin Packing problem with 2D rectangular shapes where the bin is also rectangular and the rectangles are also being rotated by 90° angles to fit better. I already have all required values, so I need no online packing algorithm.

I only found a lib that deals with a square bin and without rotation which is not really efficient enough for my needs.

I would really appreciate anything C/C++ handling a rectangular bin and rotation.

Thanks.

PS: The required time for the calculation is not important, only the result is.

PPS: It has to be C or C++, and I didn't find anything useful searching stackoverflow...

Answer

Lalaland picture Lalaland · Jan 16, 2012

http://clb.demon.fi/files/RectangleBinPack.pdf is key. That is the reference on 2d bin packing.

You might be able to modify one of the algorithms in there to satisfy your need. I doubt the rotation is needed, the algorithms are pretty advanced as they are.

This (https://github.com/Lalaland/PixelPacker/blob/master/src/algoMaxRects.cpp) is an example of how to implement the MaxRects algorithm.

The modification you would probably have to make is at the top of the algorithm, when selecting the next rectangle to use. Simply have it also look at the different orientation of the rectangles along with cycling through the whole list.