简体   繁体   English

最小绝对值的Python纸浆优化器

[英]Python pulp optimizer with min absolute value

I'm using pulp ( https://pythonhosted.org/PuLP/ ) for optimization purposes and get issue. 我将纸浆( https://pythonhosted.org/PuLP/ )用于优化目的并出现问题。 I need to use constraint like abs(x) > MIN and I found solution here http://lpsolve.sourceforge.net/5.5/absolute.htm , I just create two constraints: 我需要使用abs(x) > MIN类的约束,并且在http://lpsolve.sourceforge.net/5.5/absolute.htm这里找到了解决方案,我只创建了两个约束:

x + M * B >= MIN
-x + M * (1 - B) >= MIN

Where B is 0 or 1 and M big enough value. 其中B是0或1,M足够大。 The problem is that when I use M ~ 10000 everything works great, but when I use INT_MAX_VALUE or ~ 10000000000 it doesn't work. 问题是,当我使用M〜10000时,一切都很好,但是当我使用INT_MAX_VALUE或〜10000000000时,它不起作用。 Have anyone get issues like this? 有人遇到这样的问题吗?

Maybe you go better with COIN-CBC. 也许您选择COIN-CBC会更好。 I saw your numerical Issues in another post and it seems, it just comes from some VUB constraints. 我在另一篇文章中看到了您的数值问题,看来,它只是来自某些VUB约束。

First the LP solver (CLP) behind CBC is more elaborate then GLPK and second you can use SOS constraints , which model these VUB constraints, which u wanna use for your abs-Function mucht better (without any numerical hazards, it just branches them out). 首先,CBC后面的LP解算器(CLP)更复杂,然后是GLPK,其次,您可以使用SOS约束 ,这些约束可以对这些VUB约束建模,您想将其更好地用于Abs-Function(没有任何数字危险,它只是将它们分支出来) )。 And overall the performance is usually better. 总体而言,性能通常更好。 Feel free to follow up my answer and comment the question. 请随时关注我的回答并评论问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM