Indicator constraints with quadratic terms may have bugs?

When I use the indicator constraint, I find that it sometimes causes the model to be infeasible, but I can solve the model when I set a feasible solution as a constraint.

I know that the indicator can only contain linear constraints, so I create a variable to represent the quadratic terms in it. juMP doesn’t report errors, but sometimes it doesn’t work and I’m confused.

My code is as follow:

indt = @variable(model, [1:pipeNum, 1:Horizon], binary=true)

for ij in setdiff(1:pipeNum, ijGC), t in 1:Horizon
    x_M_t_avg = (x_M_t[ij, 1, t] + x_M_t[ij, 2, t]) / 2
    i, j = idx2ft(GS_fnode, GS_tnode, ij)
    term1 = @variable(model)
    term2 = @variable(model)
    term3 = @variable(model)
    @constraints(model, begin
        term1 == x_M_t_avg^2
        term2 == x_p_t[i, t]^2
        term3 == x_p_t[j, t]^2
    @constraints(model, begin
        indt[ij, t] => {x_p_t[i, t] - x_p_t[j, t] >= 0}
        indt[ij, t] => {x_M_t_avg >= 0}
        indt[ij, t] => {term1 == GS_K2[ij] .* (term2 - term3)}

        !indt[ij, t] => {x_p_t[i, t] - x_p_t[j, t] <= 0}
        !indt[ij, t] => {x_M_t_avg <= 0}
        !indt[ij, t] => {-term1 == GS_K2[ij] .* (term2 - term3)}

Can you provide the solver and data to make this reproducible?

What do you mean by doesn’t work?

What happens if you use set_start_value.(x_M_t, feasible_solution_x_M_t) instead?

But if your claim is that Gurobi reports infeasible without the constraint, and feasible with the constraint, then this seems like a problem in Gurobi, not JuMP or Gurobi.jl. You should contact Gurobi support.

You can create an MPS file to send them by going

GRBwrite(unsafe_backend(model), "model.mps")

Thank you very much! I contacted Gurobi and they reported it as a bug.


I contacted Gurobi and they reported it as a bug

Nice work!