World's most popular travel blog for travel bloggers.

[Solved]: Linear programming with absolute values

, , No Comments
Problem Detail: 

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 
Asked By : permanganate

Answered By : permanganate

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 $0 \leq b \leq 1$, $0 \leq x^+ \leq b \cdot m$ and $0 \leq x^- \leq (1-b) \cdot m$
  • replace $|x|$ by $x^+ + x^-$ wherever it appears
Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/44705

0 comments:

Post a Comment

Let us know your responses and feedback