Absolute value as a linear programming constraint?

Suppose I want to use absolute values in a constraint equation for linear or mixed integer programming - i.e. suppose I need one of the form abs(x1) + abs(x2) <= 1.
How would I incorporate this in the constraint matrix in MATLAB?

2 comentarios

Matt J
Matt J el 22 de Jun. de 2013
There are no absolute value expressions in the example you've given.
Mike Vukovich
Mike Vukovich el 22 de Jun. de 2013
Sorry, it was a typo... corrected.

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 22 de Jun. de 2013
Editada: Matt J el 22 de Jun. de 2013
abs(x1+x2)<=1
is equivalent to the constraints
x1+x2<=1
-(x1+x2)<=1

5 comentarios

Mike Vukovich
Mike Vukovich el 22 de Jun. de 2013
How would I use this in the constraint matrix in linprog, though?
Matt J
Matt J el 22 de Jun. de 2013
Editada: Matt J el 22 de Jun. de 2013
I've showed you that you can convert abs(x1+x2)<=1 to linear inequalities. You would express the inequalities in matrix form the way you always do.
You didn't answer the question. The original question was how to code abs(x1)+abs(x2)<=1 as a constraint. You changed it to abs(x1+x2)<=1 in your answer, which is not equivalent to what the question was asking.
James Tursa
James Tursa el 8 de Abr. de 2020
Editada: James Tursa el 8 de Abr. de 2020
Correct. This constraint abs(x1) + abs(x2) <= 1 is actually inside a diamond with vertices at (1,0), (0,1), (-1,0), and (0,-1). So there would be four inequality constraints involved for the four line segments, not just two.
Matt J
Matt J el 8 de Abr. de 2020
Editada: Matt J el 8 de Abr. de 2020
The original question was how to code abs(x1)+abs(x2)<=1 as a constraint.
I suspect the original question was abs(x1+x2) and was later edited....
However, abs(x1) + abs(x2) <= 1 can be represented by 4 inequality constraints, as James says:
[1 1 * [x1;x2] <=[1;1;1;1]
1 -1
-1 1
-1 -1]

Iniciar sesión para comentar.

Preguntada:

el 21 de Jun. de 2013

Editada:

el 8 de Abr. de 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by