18

Having all the approaches explained in the blog called "OR in an OB World" (this address) in my mind, I would like to ask the following question:

What is the best practice to make a constraint linear when for a variable in constraints, there is an absolute value expression which has lower and upper bounds? In other words, if a variable needs to cover two separate symmetric areas around zero (but not zero itself), how should it be enforced in the model?

Oguz Toragay
  • 8,652
  • 2
  • 13
  • 41

1 Answers1

14

You need to model disjunctive constraints.

I will assume that variable $x$ is constrained to lie in $L_1 \le x \le U_1$ or $L_2 \le x \le U_2$.

For instance, if you have the constraint $2 \le |x| \le 5$, then choose $L_1 = -5$, $U_1 = -2$, $L_2 = 2$, $U_2 = 5$.

My solution handles a more general case than what you require, but includes your situation as a special case.

Model this as:

b : constrained to be binary (zero or one)

The following constraints encode the disjunctive constraints based on $x$ being in $[L_1,U_1]$ if $b = 0$ and in $[L_2,U_2]$ if $b = 1$.

x <= U1 + b*(U2 - U1)
x >= L1 + b*(L2 - L1)
Mark L. Stone
  • 13,392
  • 1
  • 31
  • 67
  • 1
    Hey Mark! SE kindly set us up with MathJax from the get go; care to edit your answer to use it? :) – LarrySnyder610 May 30 '19 at 22:36
  • 2
    In this case I prefer text which can be copied and pasted as live code, but I;ll change the non-code portion. – Mark L. Stone May 30 '19 at 22:38
  • Thanks @MarkL.Stone that works correctly in my model. – Oguz Toragay Jun 01 '19 at 02:30
  • 1
    Another way to express this is $$L_1(1-b)+L_2 b \le x \le U_1(1-b)+U_2 b.$$ More generally, for $n$ intervals $[L_i,U_i]$, we have \begin{align} \sum_{i=1}^n L_i b_i \le x &\le \sum_{i=1}^n U_i b_i \ \sum_{i=1}^n b_i &=1\end{align} – RobPratt Nov 14 '20 at 02:53