这实际上是一个相当困难的问题,即使是正方形而不是矩形。
这是一个想法。将其作为一个背包整数程序来处理,它可以让您对解决方案有所了解。 (根据定义,它不会为您提供最佳解决方案。)
IP 公式启发式
Say you have a total of n rectangles, r1, r2, r3, ..., rn
Let the area of each rectangle be a1, a2, a3, ..., an
Let the area of the large circle you are given be *A*
决策变量
Xi = 1 if rectangle i is selected. 0 otherwise.
目标
Minimize [A - Sum_over_i (ai * Xi)]
受制于:
Sum_over_i (ai x Xi) <= A # Area_limit constraint
Xk = 1 for each rectangle k that has to be selected
您可以使用任何求解器来解决这个问题。
现在,这是一种启发式方法的原因是该解决方案完全忽略了圆内矩形的排列。它还最终将矩形“切割”成更小的块以适合圆圈内。 (这就是为什么 Area_limit 约束是一个弱界限。)
相关参考
This Math SE 问题解决了它的“经典”版本。
you can look at the link 在那里作为 cmets 提供,用于几个巧妙的解决方案,包括将相同大小的正方形封装在一个圆圈内。