【问题标题】:Python-How to terminate The integer linear programming(ILP) function when it finds solution in CVXOPTPython-如何在 CVXOPT 中找到解时终止整数线性规划(ILP)函数
【发布时间】:2016-09-08 14:42:25
【问题描述】:
我想在找到一个解决方案时终止解决,我该怎么做?
现在它返回如下内容:
* 62: obj = -8.419980000e+05 inf = 0.000e+00 (0)
OPTIMAL LP SOLUTION FOUND
Integer optimization begins...
+ 62: mip = not found yet >= -inf (1; 0)
+ 149: >>>>> -1.370260000e+05 >= -7.939630000e+05 479.4% (26; 0)
+ 1390: >>>>> -1.375090000e+05 >= -4.261680000e+05 209.9% (264; 27)
+ 28323: mip = -1.375090000e+05 >= -1.921510000e+05 39.7% (2232; 1534)
+ 52571: mip = -1.375090000e+05 >= -1.781890000e+05 29.6% (2983; 3596)
【问题讨论】:
标签:
python-2.7
linear-programming
glpk
【解决方案1】:
我认为没有好方法这样做。
这些高级用法通常是通过对求解器的更多直接访问来完成的(与像这样的包装器相反;我假设您仍在使用 cvxopt 就像在其他问题中一样)。
一些备注:
- 我没有找到任何支持这种提前中止的求解器参数
-
cbc(我更喜欢 glpk;通过
setMaximumSolutions 支持这一点,但我认为 cvxopt 中没有包装器)
-
您可以尝试什么:
- 设置
objll或objuldocs
objul (default: +DBL_MAX)
Upper limit of the objective function. If the objective function reaches this limit and continues increasing, the solver stops the search. This parameter is used in the dual simplex only.
objll (default: -DBL_MAX)
Lower limit of the objective function. If the objective function reaches this limit and continues decreasing, the solver stops the search. This parameter is used in the dual simplex method only.
- 所以:如果您要最小化,请将
objll 设置为巨大值(或更好:预期的最差解值 = 最大值)
- 如果要最大化,请将
objul 设置为微小值(可能为负值;或更好:预期的最差解值 = 最小值)