1

I have multiple rectangular frames, with different fixed heights. The width should be minimized and there is a maximum width. Then there are many different smaller rectangles. These should be packed into these frames. It doesn't matter in which frame the rectangles are as long as the total used area can be reduced, which is also the main goal: to use the smallest possible area.

It is not necessarily the case that all the frames have to be used if the area can be reduced in this way. Additionally, if one frame is completely filled it will just add another frame with the same height.

I would like to solve this problem with an algorithm in Java. Does anyone of you have a suitable approach?

After some research, https://www.codeproject.com/Articles/210979/Fast-optimizing-rectangle-packing-algorithm-for-bu sounds good to me so far, but you would have to somehow extend it to use not only one enclosing rectangle, but a few different ones.

3
  • Thanks for your response @candied_orange. Asking to find something other than an approach wasn't the intention here. And the problem is to find a resource-friendly approach instead of just doing hundreds and thousands of iterations. Commented Jul 4, 2020 at 8:02
  • Thank you for your edit. Welcome to the site. Commented Jul 4, 2020 at 8:03
  • Maybe I've played to much tetris, but fixed heights and minimized width really thru me off because I expect packing to go from bottom to top not side to side. Commented Jul 4, 2020 at 8:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.