Skip to main content

Conditional constraints with three conditions

Answered

Comments

1 comment

  • Maliheh Aramon
    Gurobi Staff Gurobi Staff

    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.