Callback jump MOI interface lazy constraints are not cutting the solution properly

Hey there, can anyone please help me?

I am trying to solve a combinatorial optimization problem through lazy constraints using Gurobi as Solver. Bellow a code of my presets and variables:

model = Model(Gurobi.Optimizer)
set_optimizer_attribute(model, "LazyConstraints", 1) 
@variables(model, begin
    x[i=1:(n-1), j=(i+1):n], Bin 
    y[i=1:(n-1), j=(i+1):n], Bin 
end)
.
.
.
MOI.set(model, MOI.LazyConstraintCallback(), my_callback_function_lazy)
optimize!(model)

My callback function identifies violated cliques and we cut off some of these solutions. After identifying them, I set the lazy constraints through MOI build constraint, as follows:

con = @build_constraint(sum(x[k[1],k[2]] for k in expr) <= (r*(r-1))/2-1)
println(con)
MOI.submit(model, MOI.LazyConstraint(cb_data), con)

As we can see, I tried to print out the constraints added in the model to control which one is entering as lazy constraint. An example printed:

ScalarConstraint{AffExpr, MathOptInterface.LessThan{Float64}}(x[3,4] + x[1,4] + x[1,3], MathOptInterface.LessThan{Float64}(2.0))

I.e., x[3,4] + x[1,4] + x[1,3] <= 2. As metioned before, x is a binary variable, so in that case, I force the three of them to not be at the same time in the solution. However, in the final solution, we have

x[3,4] = 1
x[1,4] = 1
x[1,3] = 1

I don’t know what else to think to fix this. Can you help me?

Ps.: In the Gurobi log they are supposedly being added

Cutting planes:
  Lazy constraints: 91

Can you provide a reproducible example?

1 Like