• 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ł

Hi Jaromił,

Thank you so much and save my life!!!