9

I know that sometimes we can use absolute values into the objective functions or constraints. Is it always possible to use them, anywhere ?

Example of use of absolute values:

Minimize |a+b+c| + |a-c| s.t.
 |a| + b > 3
 | |a| - |b| | <= 5 
 | |b| - 3 | = 0
permanganate
  • 301
  • 1
  • 2
  • 9

3 Answers3

10

All constraints in a linear program are convex (if $x,y$ satisfy the constraints, then $tx+(1-t)y$ also does for all $0 \leq t \leq 1$). The constraint $|a|+b > 3$ is not convex, since $(4,0)$ and $(-4,0)$ are both solutions while $(0,0)$ is not. It is also not closed, which is another reason why you cannot use it in a linear program (change $>$ to $\geq$). The constrict $|a|+b \leq 3$, however, can be used, since it is equivalent to the pair of constraints $a+b \leq 3$ and $(-a)+b \leq 3$.

So absolute values can sometimes be expressed in the language of linear programming, but not always.

Yuval Filmus
  • 280,205
  • 27
  • 317
  • 514
8

I've found out a very interesting document that answers my question: http://lpsolve.sourceforge.net/5.5/absolute.htm It's about integer programming and it covers all possible cases I think. See section >= minimum to handle abs(X) >= minimum. Here is another one with more tricks: http://orinanobworld.blogspot.de/2012/07/modeling-absolute-values.html

There are several methods described in the links above. The "Binary method" is exactly what I wanted: let's assume you want to remove $|x|$ ($x$ is a variable) wherever it appears in your program, and you know that $|x|$ cannot be greater than a constant $m$. Then, perform the following:

  • add new variables $x^+$, $x^-$ and $b$
  • add constraint $x = x^+ - x^-$
  • add constraints $b \in \left\{0,1\right\}$, $0 \leq x^+ \leq b \cdot m$ and $0 \leq x^- \leq (1-b) \cdot m$
  • replace $|x|$ by $x^+ + x^-$ wherever it appears
permanganate
  • 301
  • 1
  • 2
  • 9
0

I think you can just get rid of |x| if you slightly modify the simplex algorithm. Only variables that are in the basis set can ever be > 0. So you let $x = x^+ - x^-$ with the additional condition that $x^+$, $x^-$ are not non-zero at the same time, and replace $|x| = x^+ + x^-$. You enforce the condition by not allowing $x^+$ and $x^-$ into the basis set at the same time.

I've not tried this actually :-( But a variation where I didn't want a variable to be restricted to positive values (just x ≤ 3 instead of 0 ≤ x ≤ 3) worked very well this way.

gnasher729
  • 32,238
  • 36
  • 56