Skip to main content

Can we add user cuts on root node only?

Answered

Comments

3 comments

  • Official comment
    Simranjit Kaur
    Gurobi Staff Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?.
  • Jaromił Najman
    Gurobi Staff Gurobi Staff

    Hi,

    It is possible to add cuts at root node only. The value \(\texttt{MIPNODE_NODCNT}\) provides you the current number of B&B nodes inside a callback. If this number equals \(0\), then you are at the root node. You can add an \(\texttt{if}\)-clause checking for the \(\texttt{MIPNODE_NODCNT}\) inside your callback.

    Also, how to set a specific condition to force Gurobi to branch after adding user cut on root node only?

    You can define a private model variable, e.g.,

    model._terminate_callback = False

    and use and set it inside your callback, e.g.,

    if where == GRB.Callback.MIPNODE:
    if model._terminate_callback:
    return
    if some_condition == True:
    model._terminate_callback = True

    Best regards,
    Jaromił

    0
  • Cheng-Lung Chen
    Gurobi-versary
    First Comment
    First Question

    Hi Jaromił,

    Thank you so much and save my life!!!

    0

Post is closed for comments.