Condition within a condition in constraint
Awaiting user inputHow could I model my constraints in general and implement in Python Gurobi with the following conditions:
when \(q=0 \rightarrow y=0\) and when \(q=1\),
\[\begin{equation}
y = \begin{cases}
d & \mathrm{if }\; d\leq b\\
b & \mathrm{otherwise.}
\end{cases}
\end{equation}\]
where \(q\) is a binary variable, \(y\) is a continuous variable and \(b\), \(d\) are constants.

Hi Syed,
In this case, could you elaborate more on the nature of the \(b\) and \(d\) terms? If they are both constant parameters, then both values should be available when the model is constructed. Otherwise they depend on the values of some other optimization variables making \(b\) and \(d\) optimization variables as well. How does the fact that \(b,d\) are lists take effect here? Do you actually want to introduce multiple constraints of the above form or do you want to check whether all values in \(d\) are \(\leq\) than \(b\)?
Best regards,
Jaromił
Please sign in to leave a comment.
Comments
3 comments