Technical questions regarding binary variables
AnsweredHello, I have a purely technical question about Gurobi. Suppose I have the variable \(y_{ijk} \in [0;1]\) . Now I want to define a binary variable \(x_{ijk}\) that takes the value 1 if \(y_{ijk}=1\) and 0 otherwise. The constraint \(y_{ijk}\geq x_{ijk}\) should ensure this. If \(y_{ijk}=1\) applies, then \(x_{ijk}=1\) can apply, but if \(y_{ijk}<1\) , then \(x_{ijk}=1\) can never apply. Does the solver then automatically set \(x_{ijk}=0\) ? And how can I prevent \(x_{ijk}=0\) from applying in the first case, since the constraint does not exclude this?
-
Hi Lorenz,
You could use a small tolerance \(\epsilon = 1e-4\) and model your condition using indicator constraints.
\[\begin{align*}
x = 1 &\rightarrow\, y = 1\\
x = 0 &\rightarrow\, y \leq 1 - \epsilon
\end{align*}\]The above states that if \(x=1\) then also \(y=1\) and if \(x=0\) then \(y<1\).
Please note that the usage of a small tolerance is required, because you are trying to model a strict inequality, but Gurobi does not support these. It is very important to not choose the tolerance \(\epsilon > 0\) too small. In particular it should always be at least one order of magnitude larger than the FeasibilityTol.
Best regards,
Jaromił0
Please sign in to leave a comment.
Comments
1 comment