解决python中的非线性bin装箱优化问题

问题描述

是否有直接方法(例如,带有常用求解器的某些模块)来解决源自python中众所周知的bin打包问题(例如,参见https://en.wikipedia.org/wiki/Bin_packing_problem)的问题?

详细来说,其中s(i)是物品的重量的装箱问题

minimize K = sum_j y_j                    # use as less bins as possible
s.t. sum_i s(i)x_i,j <= B*y_j for all j   # bin capacity B must not be exceeded
     sum_j x_i,j = 1 for all i            # all items have been fit in exactly one bin
     x_i,j,y_j being integer variables in {0,1}

应扩展为以下目标函数K_nonlinear

minimize K_nonlinear = sum_j (y_j + Std({s(i)}) for all x_i,j =1)
s.t. # the same constraints as the bin packing problem (above)

因此,不仅应该使正在使用的垃圾箱数量最小化,而且还应该使共享垃圾箱的所选项目的标准偏差最小化(这通常会导致一些必要的折衷)。因此,我认为问题变成了非线性。

对于任何使用python来解决此问题的建议,我深表感谢(python api足够了,算法本身也可以用任何其他语言实现)。

到目前为止,我已经尝试扩展有关目标函数中其他部分的现有箱式装箱求解器(基于Coin-or分支和割式求解器),但失败了。大概是由于诱发的非线性所致。

非常感谢

解决方法

代替标准偏差,可能更容易将范围max-min最小化。这可以用线性方式表示:

  Minimize xmax-xmin
  xmax >= x[i]  for all i
  xmin <= x[i]  for all i

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...