I have two binaries, $\alpha_{ts,it}$ and $\alpha_{ts,gshp} \in \{0,1\} $, and two reals $T_{it}$ and $T_{ts}$ which have upper and lower bounds. How can I model $\alpha_{ts,it}=1$ if the following constraints are met:

  1. $T_{ts}\geqslant-7$
  2. $T_{it}\leqslant14$
  3. $T_{ts}-T_{it}\geqslant5$
  4. $\alpha_{ts,gshp}=0$



  • $\begingroup$ If you know precision of your variables and accept it being up to given number of digits, then just calculate all the comparisons: blog.adamfurmanek.pl/2015/11/21/ilp-part-14 $\endgroup$ Sep 10 '18 at 18:29
  • $\begingroup$ I'm confused. If $\alpha_{ts,it} = 1$ just substitute the variable with $1$ in each equation. $\endgroup$
    – orlp
    Sep 10 '18 at 18:49
  • $\begingroup$ What does "as long as" mean? Do you mean that if those 4 constraints are met then you require $\alpha_{ts,it}=1$? Or do you mean that if $\alpha_{ts,it}=1$ then you require that those 4 constraints hold? Also, do you know upper and lower bounds for $T_{it}$ and $T_{ts}$? I suggest referring to cs.stackexchange.com/q/12102/755, cs.stackexchange.com/q/51025/755, cs.stackexchange.com/q/67163/755. $\endgroup$
    – D.W.
    Sep 10 '18 at 19:14
  • 1
    $\begingroup$ Thanks for the reformulation. Rather than writing "stuff. correction: never mind, I actually meant other stuff", please just edit the question to remove the incorrect material, and replace it with the correct version. We have revision history, so no need to keep around the old version or to mark what has changed. See cs.meta.stackexchange.com/q/657/755. Also please make sure to incorporate all relevant information into the question, so people don't have to read the comments to understand what you are asking (then flag the comments as no longer needed once you've done that). Thanks! $\endgroup$
    – D.W.
    Sep 11 '18 at 20:07

I might have found a solution to my problem by using four auxiliary binary variables $\alpha_1$, $\alpha_2$, $\alpha_3$ and $\alpha_4$ $\epsilon\ \{0,1\} $. The constraints 1.-4. are rewritten using the big-M method.

Constraint 1

  • $T_{ts}\geqslant -7-M\cdot (1-\alpha_1)$
  • $T_{ts}\leqslant -7+M\cdot \alpha_1$

Constraint 2

  • $T_{it}\leqslant 15+M\cdot (1-\alpha_2)$
  • $T_{it}\geqslant 15-M\cdot \alpha_2$

Constraint 3

  • $T_{ts}-T_{it}+M\cdot (1-\alpha_3)\geqslant 5$
  • $T_{ts}-T_{it}-M\cdot \alpha_3\leqslant 5$

Constraint 4

  • $\alpha_{ts,it}=1-\alpha_{ts,gshp}$

Constraint 5

  • $\alpha_{ts,it}\geqslant \alpha_1+\alpha_2+\alpha_3+\alpha_4-3$
  • $\alpha_{ts,it}\leqslant \alpha_1$
  • $\alpha_{ts,it}\leqslant \alpha_2$
  • $\alpha_{ts,it}\leqslant \alpha_3$
  • $\alpha_{ts,it}\leqslant \alpha_4$

This might be a solution. Unfortunately computational time is exploding. Does someone know a less time-consuming workaround?

Best SR89


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.