Indicator function constraints with three conditions
AnsweredI have an optimization problem using gurobi c++:
objective: minimize L(u),
where L(u) = {1/2 - u, if u<=0; 1/2(1-u)^2, if 0<u<1; 0, otherwise. }
How can I create constraints with this indicator function with binary variables and addGenConstrIndicator()?
Please help, thanks.
-
Official comment
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. -
In your case you could use the following formulation
\[\begin{align*}
b_0 = 1 &\rightarrow u \leq 0\\
b_0 = 1 &\rightarrow w = 0.5 - u\\
b_1 = 1 &\rightarrow u_{aux} = u\\
b_1 = 1 &\rightarrow w = 0.5 - u_{aux} + 0.5v\\
b_1 = 0 &\rightarrow u_{aux} = 0\\
b_2 = 1 &\rightarrow u \geq 1\\
b_2 = 1 &\rightarrow w = 0\\
b_0 + b_1 + b_2 &= 1\\
v &= u_{aux}^2\\
b_i &\in \{0,1\}, u_{aux} \in [0,1], v \in [0,1]
\end{align*}\]The constraints with \(\rightarrow\) are indicator constraints. Note that your model is nonconvex, thus you will have to set the NonConvex parameter. Note that the auxiliary variable \{v\} is needed to avoid the product \(u_{aux}^2 \cdot b_1\). Variable \(w\) holds the value of your function \(L(u)\).
0
Post is closed for comments.
Comments
2 comments