How Indicator constraint can be triggered with multiple variables?
AnsweredDear members
I am trying to trigger indicator constraint with multiple variables but unfortunately, it shows error Indicator constraints can only be triggered by a single binary variable at a given value. I am trying to achieve the following:-
if a+b+c==0 then d==1 -------> model.addContrs((a+b+c==0)>>(d==1))
where a,b,c,d are all binary variables.
Is there any other way to achieve this in gurobi
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Dear Parijat,
This is not directly possible through indicator constraints. However, you can add an auxiliary binary variable \(\delta\) to model the relationship if \(a+b+c\geq 1 \Leftrightarrow \delta=1\). To model this, you can use the constraints
\[\begin{align}
a+b+c & \geq 1 - 3(1-\delta) \\
a+b+c & \leq 1+ 3\delta
\end{align}\]You can then use \(\delta\) to model your indicator constraint. Note that the scalar \(3\) was chosen because you add \(3\) binary variables and the maximum sum of these is \(3\). More, information can be found in the stackexchange post How to write if else statement in linear programming?
Best regards,
Jaromił0 -
For \(a+b+c=0 \Rightarrow d=1\) with all variables binary, you could write equivalently \(a+b+c+d \geq 1\), or as an indicator constraint, \(d = 0 \Rightarrow a+b+c \geq 1\).
0 -
Thanks, Jaromil and Robert for your descriptive explanation
0
Post is closed for comments.
Comments
4 comments