Or-tools 模型标签解决方案,约束条件未被遵守,标记为“OPTIMAL”

huangapple go评论62阅读模式
英文:

Or-tools model label solution with contraints not respected as "OPTIMAL"

问题

我尝试了一个新的混合整数线性规划(MILP)模型,但一直出现奇怪的错误。可能这个模型需要一些修正,也许一些约束条件存在冲突。在选择了一个最优解后,我尝试再次检查是否所有约束条件都得到满足,结果发现它们没有被满足。这种行为正常吗?为什么如果约束条件没有被满足,解被认为是最优的?

此外,我想知道是否有任何工具可以帮助我调试or-tools中的MILP模型。

谢谢。

英文:

I was trying a new MILP model and kept getting strange errors. Probably this model needs some corrections, maybe some constraints are in conflict with each other. After selecting an OPTIMAL solution I tried to check again if all the constraints were met and found that they were not. Is this behavior normal? Why is the solution considered OPTIMAL if the constraints are not met?

Also, I was wondering if there are any tools that can help me debug MILP models in or-tools.

Thanks

答案1

得分: 2

所有MIP求解器都使用容差进行计算。

明显的例子是

100000 * bool_var + 1 == 100000

将愉快地返回OPTIMAL,其中bool_var = 1 - 1e-5。

此外,使用大范围的系数/界限会导致大量数值错误。因此,它们进行权衡。精确性与近似解决的问题数量之间的权衡。

因此,请减小您的范围,并查看违反的约束条件。

如果您需要精确计算,并且您的问题是整数问题,您可以使用CP-SAT来解决它。这是一个非常好的(非混合)整数求解器。

英文:

All MIP solvers use tolerances for computation.

The obvious example is

   100000 * bool_var + 1 == 100000

will happily return OPTIMAL with bool_var = 1 - 1e-5.

Furthermore using a large range of coefficients/bounds leads to lots of numerical errors. So they make tradeoffs. Exactness vs number of problems approximately solved.

So, reduce your ranges, and look at the violated constraints.

If you want exact computation and your problem is integral, you can use CP-SAT to solve it. It is a very good (non mixed) integer solver.

huangapple
  • 本文由 发表于 2023年4月19日 15:42:33
  • 转载请务必保留本文链接:https://go.coder-hub.com/76051887.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定