Conditional constraints with three conditions
AnsweredHi, I am trying to construct conditional constraints, but with three if-then.
If b<B1, then a==B1
if B1<=b<=B2, then a==b
if B2<b, then a==B2
where B1, B2, a, and b are all model variables.
I read the post regarding the constraints. I am wondering if is it necessary to apply Big M or if I can use something like the following:
(Bianry1==1) >> (b<B1)
(Binary2==1) >> (B1<=b)
(Binary2==1) >> (b<=B2)
(Binary3==1) >> (B2<=b)
(Binary1==1) >> (a==B1)
(Binary2==1) >> (a==b)
(Binary3==1) >> (a==B2)
Thanks.
-
Hi,
One approach to implement the constraint in the form \(b < B_1 \rightarrow a = B_1\) is to define an auxiliary binary variable \(y_1\) and implement the following instead:
\[b < B_1 \rightarrow y_1 = 1\]
\[y_1 = 1 \rightarrow a = B_1\]
The form \(y_1 = 1 \rightarrow a = B_1\) can be directly implemented using the Model.addGenConstrIndicator() API. However, the form \[b < B_1 \rightarrow y_1 = 1\] should be implemented using its logically equivalent contrapositive form, i.e.,
\[y_1 \neq1 \rightarrow b \nless B_1 ~~~\mbox{or}~~~ y_1 = 0 \rightarrow b \geq B_1\].
The same approach can be used to implement the other two conditional statements. You might want to check the following relevant posts to your question:
Best regards,
Maliheh
0
Please sign in to leave a comment.
Comments
1 comment