Skip to main content

Do lazy constraints always cut integer solutions?

Answered

Comments

7 comments

  • Nicolas Zerega
    • Gurobi-versary
    • First Comment
    • First Question

    I'm still wondering about this. As of now I've been able to keep the updated incumbent outside gurobi and then do the analysis with it. But would like to check why it is being cut and not accepted inside the solver and, also, why is it cut when adding the trivial lazy constraint.
    I will check with other cut types and see if it does the same

     

    Best regards,

    Nicolas Zerega

    0
  • Mario Ruthmair
    • Gurobi Staff Gurobi Staff

    Hi Nicolas,

    I am still trying to understand your case. If the incumbent does not violate the added lazy constraint, the solution should be accepted, and the incumbent value should update.
    What I am wondering is that the numbers of added user cuts and lazy constraints shown by the solver at the end do not correspond to your output lines. Are you probably adding other cuts that cut off the incumbent?

    Best regards,
    Mario

    0
  • Matthias Hellwig
    • Gurobi-versary
    • First Comment

    Dear Mario,

    I have a very similar problem with the lazy constraints, if I understand the previous question correctly.

    I can give you a very simple example.

    I have the problem

    min x + y + z

    and add then the constraints x >= 1, y>=1, z=>1 lazily, where x,y,z binary.

    So, my callback is active for "where == GRB.Callback.MIPSOL" (C#.NET API). The problem that i experience is that gurobi is invoking my callback multiple times for the solution (0,0,0)  and therefore i have to add the lazy constraint x >= 1 multiple times (like 5 times). I would have expected that i have to add that constraint only once and then (0,0,0) is cutoff and i get a new feasible solution (1,0,0) from Gurobi. Consequently, the incumbent does not change as the Nicolas above describes. Is there something buggy or is that just a wrong assumption from my side that the constraints - once added - are valid for the rest of the solving process?

     

    Reproducible under C#.net API with a Gurobi 11.0.0 ComputeServer.

    0
  • Matthias Hellwig
    • Gurobi-versary
    • First Comment

    Update: Playing a bit around with this it seems that the added constraints from the first four callback calls are just ignored (for whatever reason). So as a workaround I can add 0 = 1 four times and then it works as expected.

    0
  • Marika Karbstein
    • Gurobi Staff Gurobi Staff

    Hi Matthias,

    The behavior you experience is probably due to parallel solves, which Tobias describes in more detail in this comment.

    Best regards,
    Marika

    0
  • Mario Ruthmair
    • Gurobi Staff Gurobi Staff

    Hi Matthias,

    Since the solver is using multiple threads by default, it can happen that different heuristics or other components (in different threads) find the same solution. In this case, it is not surprising since the solution (0,0,0) is trivial. If you add lazy cuts, those cuts must be evaluated and propagated to the other threads. This happens only at specific synchronization points. Duplicate cuts will be discarded, then.

    So, in practice, you may see the same solution in the MIPSOL callback more than once. You should consider those callbacks independently, i.e., add cuts to cut off an infeasible solution independently of what you already did in previous callbacks. Adding infeasible cuts like 0=1 can lead to problems, maybe not in this toy example, but in more complex ones.

    0
  • Matthias Hellwig
    • Gurobi-versary
    • First Comment

    Thanks. Marika Karbstein & Mario Ruthmair.

    0

Please sign in to leave a comment.