Search code examples
pythonmathematical-optimizationlinear-programminginteger-programmingpulp

Python pulp optimizer with min absolute value


I'm using pulp (https://pythonhosted.org/PuLP/) for optimization purposes and get issue. 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:

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

Where B is 0 or 1 and M big enough value. 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. Have anyone get issues like this?


Solution

  • Maybe you go better with COIN-CBC. I saw your numerical Issues in another post and it seems, it just comes from some VUB constraints.

    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). And overall the performance is usually better. Feel free to follow up my answer and comment the question.