Skip to main content

multiple conditions in indicator constraint

Answered

Comments

1 comment

  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi Kaiyu,

    It is possible to model the above with additional binary variables \(\delta_i\) and the constraints

    \[\begin{align}
    T_i + q_i &\geq Q - M \cdot \delta_i + 0.00001 \\
    T_i + q_i &\leq Q + M \cdot (1 - \delta_i) \\
    \end{align}\]

    The above sets \(\delta_i=1\) if \(T_i + q_i \leq Q\) and \(\delta_i = 0 \) if \(T_i + q_i \geq Q + 0.00001\). Here I used \(T_i\) for \(TotalLoad_i\). The small offset \(0.00001\) is necessary to model the strict inequality constraint. \(M\) is a constant big-M value, which can very likely be set equal to \(2Q\) (depending on the bounds of \(T_i\) and \(q_i\).

    We can now model the two \(\texttt{if}\)-clauses with 2 indicator constraints

    \[\begin{align}
    x_{ij} = 1 &\rightarrow T_j = T_i \cdot \delta_i + q_j\\
    x_{ij} = 1 &\rightarrow U_i = 1 - \delta_i
    \end{align}\]

    Please note that \(T_i \cdot \delta_i\) is a bilinear term and the indicator constraint feature allows linear expressions only. Thus, you will have to introduce an additional variable and reformulate the bilinear term as described in How to linearize the product of a binary and a non-negative continuous variable?

    Please note that the above formulation is not guaranteed to be the best one and there may be a better one possible.

    Best regards,
    Jaromił

    0

Please sign in to leave a comment.