Skip to main content

User cuts for relxation

Answered

Comments

6 comments

  • Riley Clement
    • Gurobi Staff

    Hi Konstantin,

    It might be that the PreCrush parameter is the cause, not the cuts.  It would be interesting to hear how it runs if you set PreCrush=1 but not attempt to add cuts.

    It could be worth trying to run two instances of Gurobi in parallel, the first using your cuts and the second not, and have the second one store solutions (either using SolFiles parameter or writing them in a callback) so that the first can read them and use cbSetSolution within a callback (such as MIP callback).

    https://support.gurobi.com/hc/en-us/articles/360043111231-How-do-I-use-multiprocessing-in-Python-with-Gurobi

    - Riley

    0
  • Konstantin Keck
    • First Comment
    • First Question

    Hi Riley,

    Thank you for your response!

    I followed your suggestion: I set PreCrush = 1 and didn’t add cuts. The results remained the same. Just to clarify: the valid inequalities are not modeled as explicit constraints, but instead detected and added dynamically within my get_violated_user_cuts function during the MIPNODE callback. Is this the intended behavior?

    Furthermore, your suggestion on using multiprocessing might be promising. Based on the documentation, would you agree that the following parameters are a reasonable starting point to focus on improving LBs in the first Gurobi instance (I would model all valid inequalities explicitly in the model)?

    model.setParam("Cuts", 2)         # Use aggressive cuts  
    model.setParam("Presolve", 2)     # Aggressive presolve to tighten the model  
    model.setParam("Heuristics", 0)   # Turn off heuristics  
    model.setParam("MIPFocus", 3)     # Focus on improving the bound  
    model.setParam("NodeLimit", 1)    # Only solve the root node (no branching)  

    Thanks again and best regards,
    Konstantin

    0
  • Riley Clement
    • Gurobi Staff

    Hi Konstantin,

    Without experimental evidence to back up the choice of parameter setting (see How can I make accurate comparisons?) I'd set MIPFocus=3, maybe Presolve=2.

    Cuts are already aggressive with MIPFocus=3, so no need to touch that.  Heuristics=0 is extreme.  We tend to only suggest this for models that can be solved in a few tenths of seconds by branching.  I would also leave it at it's default (plus improvement heuristics will be able to act on your heuristic solutions to possibly find improvements).

    Note that NodeLimit=1 will not prolong activity at the node.  It only causes the solve to terminate when it would otherwise branch (I'm not sure if this is what you wanted).

    - Riley

     

    0
  • Konstantin Keck
    • First Comment
    • First Question

    Hi Riley,

    thank you for your advice. The gurobi logtools also look very useful.
    I'll try and work with that.

    Best regards,
    Konstantin

    0
  • Riley Clement
    • Gurobi Staff

    You're welcome.  Gurobi-logtools will have a new major release soon.  In the meantime it is probably worth installing directly from the repository to get the numerous updates since the last release:

    pip install git+https://github.com/Gurobi/gurobi-logtools

    0
  • Konstantin Keck
    • First Comment
    • First Question

    Hi Riley,

    Thank you again for your helpful advice.

    I just wanted to share a quick update regarding my original query on user cuts. In the end, I didn’t implement a callback. Instead, I used the constraint attribute Lazy = -1 directly in the model formulation. This approach gave me the desired behavior.

    I hope this helps other Gurobi users in the future.

    Best regards,
    Konstantin

    0

Please sign in to leave a comment.