How to ensure that two variables are not =/= 0 at the same time without using binaries?
回答済みHello,
In my optimization problem, I need to ensure that two variables (lets call them var1 and var2) are not different than zero at the same time.
I believe the classic approach would be to use binary variables, adding a constraint of the form binvar1 + binvar2 <= 1, and having these two binary variables multiplying var1 and var2 on the objective and constraints.
My problem is that var1 and var2 can be really big vectors, with up to thousands of entries. The bigger they are, the slowest the simulation becomes - I imagine it is because binvar1 and binvar2 also get bigger.
So the question is: is there an elegant solution to ensure such a constraint without using binary variables?
I have tried a "trick" constraint in the form of:
( 1./(1e6*var1 + 1e-6) + 1./(1e6*var2 + 1e-6) ) >= 1e4
but this returns me a warning telling me that gurobi does not support signomial constraints.
Any help is appreciated! Thank you
-
正式なコメント
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 try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Pedro,
You don't have to multiply the binary variables with your continuous ones.
You could use Gurobi's indicator constraints to model
\[\begin{align*}
b=1 &\rightarrow x_1 = 0\\
b=0 &\rightarrow x_2 = 0
\end{align*}\]With the above, always at least one of the two variables \(x_1,x_2\) equals \(0\). This introduces only 1 binary per variable pair, which should be acceptable. Of course, you would have to test whether it is OK for your model's performance.
Continuous "tricks" such as yours always work with tolerances and tend to cause numerical issues.
The warning about Gurobi not supporting signomial terms is correct. Gurobi only support piecewise-linear approximations of signomial terms (cf. addGenConstrXxx) and is thus not suitable for your approach.
Best regards,
Jaromił0
投稿コメントは受け付けていません。
コメント
2件のコメント