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?

  • 2
    $\begingroup$ If I understand you correctly, you can introduce two variables; one taking the value if the expression was negative and one taking the value if it is positive. $\endgroup$ May 30 '19 at 22:02
  • 2
    $\begingroup$ Are you saying that variable $x$ should have domain $[-b, -a]\cup [a,b]$ where $a\neq 0$ and $b>a$ are parameters? $\endgroup$
    – prubin
    May 30 '19 at 22:25
  • $\begingroup$ @prubin this is exactly what I want. $\endgroup$ Jun 1 '19 at 2:28

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)
  • 1
    $\begingroup$ Hey Mark! SE kindly set us up with MathJax from the get go; care to edit your answer to use it? :) $\endgroup$
    – LarrySnyder610
    May 30 '19 at 22:36
  • 2
    $\begingroup$ In this case I prefer text which can be copied and pasted as live code, but I;ll change the non-code portion. $\endgroup$ May 30 '19 at 22:38
  • $\begingroup$ Thanks @MarkL.Stone that works correctly in my model. $\endgroup$ Jun 1 '19 at 2:30
  • 1
    $\begingroup$ 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} $\endgroup$
    – RobPratt
    Nov 14 '20 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.