Technical questions regarding binary variables
回答済みHello, 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?
-
正式なコメント
This post is more than two 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 try Gurobot, our chatbot interface offering instant, expert-level support. -
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
投稿コメントは受け付けていません。
コメント
2件のコメント