add a constrain for two related variables
回答済みhello,
In my case study, I have two variables that can not take a value at the same time. which means if one of them takes a value the other should be zero. Can I add a constant like that?
-
正式なコメント
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?. -
Hi!
This sounds like Indicator constraints might be helpful here. These allow modeling such variable relations.
Cheers,
Matthias0 -
thank you so much, but I did not recognize well how to use it. How to give the indicator a value. Can you give me a simple example, please?
0 -
To help give an example, could you tell us a bit more about your variables? What variable type are they (integer, binary, continuous)? Do they have bounds?
0 -
I have two continuous variables, I want one of them to be 0 when the other takes a value more than 0. such as battery charging/discharging variables. they cannot have values more than 0 at the same time.
0 -
For 2 continuous variables, one way to formulate what you want would be
\[\begin{align}
x_1 &\leq \delta_1 x_1^U\\
x_2 &\leq \delta_2 x_2^U\\
\delta_1 + \delta_2 &= 1\\
\delta_1 &, \delta_2 \in \{0,1\}\\
x_1 &\in [0,x_1^U], x_2 \in [0, x_2^U]
\end{align}\]This way, when \(x_1 > 0\), then \(\delta_1 = 1\) and thus \(\delta_2=0\) and \(x_2=0\). An analogous statement holds when \(x_2 > 0\). Please note that it is possible that \(x_1=x_2=0\).
0
投稿コメントは受け付けていません。
コメント
6件のコメント