Hello,
I would like to use the absolute value in constraints and objective function.
I believe that the absolute value can be desugared to plain linear constraints with shadow variables.
Does PyMathProg support this feature?
I have tried the following:
model('foo')
x = var('x')
y = var('y')
abs(x - y) < 42
which fails with:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: bad operand type for abs(): '_parex'
Best,
Marco
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I would like to use the absolute value in constraints and objective function.
I believe that the absolute value can be desugared to plain linear constraints with shadow variables.
Does PyMathProg support this feature?
I have tried the following:
which fails with:
Best,
Marco
Since abs(x-y) <= 42 is not a linear function, this is not directly supported. However, you can get the same effect in PYMPROG with:
-42 <= x-y <= 42
hope it helps, sorry for the late response.