I have the following constraints I'm trying to model in Linear Integer Programming. I will try out diverse solvers for this later, but first I need to model the problem.
Given the integer variables: x1, x2, x3, x4, y1, y2, y3, y4, I have the following constraints:
IF (y1 ≤ y3 ≤ y2 OR y1 ≤ y4 ≤ y2)
THEN (x1 ≥ x4 OR x2 ≥ x3)
Additionally for all of these variables I have upper and lower bounds.
I think I have to use the "big M" technique, but I'm not sure how to handle the logical OR in the IF condition and in the THEN condition and how to built up one complete model.
Does anyone of you know how to resolve this? Many thanks in advance.
1 Answer 1
You have the following condition:
IF ((y1 <= y3) AND (y3 <= y2)) OR ((y1 <= y4) AND (y4 <= y2))
THEN (x1 >= x4) OR (x2 >= x3)
For each logical term, you'll need a new binary variable. At each "level" of the logical statements, you'll use the binary variables from the previous level. So:
z1 = 1
iffy1 <= y3
z2 = 1
iffy3 <= y2
z3 = 1
iffz1 = 1 AND z2 = 1
z4 = 1
iffy1 <= y4
z5 = 1
iffy4 <= y2
z6 = 1
iffz3 = 1 AND z4 = 1
z7 = 1
iffx1 >= x4
z8 = 1
iffx2 >= x3
Then you'll have a constraint that says:
- if
z3 = 1 OR z6 = 1
thenz7 = 1 OR z8 = 1
Let's take one type of constraint at a time.
z1 = 1
iff y1 <= y3
:
y3 - y1 + 1 <= Mz1
y1 - y3 <= M(1 - z1)
The logic is: If y3 > y1 - 1
, i.e., y3 >= y1
, then z1
must equal 1. If y1 > y3 + 1
, i.e., y1 > y3
, then z1
must equal 0.
Note that if the y
variables are continuous, not integer, then replace the 1
s with some small number. This isn't ideal from a numerical perspective though.
Constraints 2, 4, 5, 7, and 8 are similar.
z3 = 1
iff z1 = 1 AND z2 = 1
:
z1 + z2 <= 2z3
z3 <= z1
z3 <= z2
The logic is: If z1
and z2
both equal 1, then z3
must equal 1. If either of them equals 0, then z3
must equal 0.
Constraint 6 is similar.
if z3 = 1 OR z6 = 1
then z7 = 1 OR z8 = 1
:
z3 + z6 <= 2(z7 + z8)
The logic is: If z3 = 1
or z6 = 1
, then z7
or z8
must equal 1.
-
$\begingroup$ Thank you for your detailed and comprehensive answer, I think I got it know. $\endgroup$Claudi– Claudi2019年05月20日 08:03:54 +00:00Commented May 20, 2019 at 8:03
-
$\begingroup$ Shouldn't it rather be: y3 - y1 + 1 <= Mz1, y1 - y3 - 1 < M(1 - z1) --> with a < instead of a <= in the second line, for the case when y1 > y3 and y1 - y3 = 1 ? $\endgroup$Claudi– Claudi2019年05月20日 11:11:53 +00:00Commented May 20, 2019 at 11:11
-
$\begingroup$ You're right that the constraint was incorrect, but you can't use strict inequalities in ILPs; so the correct constraint should be
y1 - y3 <= M(1 - z1)
; I have edited it above. $\endgroup$LarrySnyder610– LarrySnyder6102019年05月20日 12:39:53 +00:00Commented May 20, 2019 at 12:39
Explore related questions
See similar questions with these tags.
x
andy
variables are continuous, correct? $\endgroup$