Skip to main content

Can we add user cuts on root node only?

Answered

Comments

2 comments

  • 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

Please sign in to leave a comment.

Powered by Zendesk