• Gurobi Staff

Hi Canqi Yao,

Your callback has been called 1894330 times for a total of 362.67 seconds. This makes it roughly to 0.19 milliseconds per callback, which is not too much. What you could try is to reduce the number of values which you have to re-calculate and pre-calculate them outside of the callback.
If the values of

N = model._coeff[0]K = model._coeff[1]

are fixed, then you could pre-calculate most of the objects and values you use in the callback and then acces them, e.g., via

model._someValue

Best regards,
Jaromił

Hi Jaromił

Apart from reducing time in callback function, can we decrease the number of calling callback function by choosing some nodes with callback function added?

Best

Canqi

• Gurobi Staff

Hi Canqi,

You cannot directly choose the nodes where the callback is being called or not being called, as the callback $$\texttt{MIPNODE}$$ is always called whenever a mip node is explored within the B&B algorithm.

You could implement a counter, and only compute a cut at every n-th call. You could also check the MIPNODE_NODCNT and only compute a cut whenever this value has some specific properties, e.g., is a multiple of 2 or similar.

Best regards,
Jaromił