Thread number of a callback in a multithreaded parallel MIP run and other queries on thread safety
Awaiting user inputHello,
I have a separation routine that takes the current fractional xbar and runs a user/lazy cut separation. Suppose this is called from, say, thread 0 and also parallelly from thread 1, I would like to query this thread number and use that as an index in my separation routine. Additionally, the added cuts could be locally valid or globally valid.
What is the thread-safe way to accomplish this? Are there some guidelines that can be provided about what Gurobi API calls are safe to make from within a multithreaded callback subroutine?
I am curious about the following in the documentation page
https://docs.gurobi.com/projects/optimizer/en/current/reference/c/logging.html#c.GRBsetcallbackfunc :
When solving a model using multiple threads, the user callback is only ever called from a single thread, so you don’t need to worry about the thread-safety of your callback.
I do not understand what the above means. Could it please be clarified what this means exactly in light of my requirement to run parallel separations in the MIP tree?
CPLEX seems to expose the following via an information callback: CPX_CALLBACK_INFO_MY_THREAD_NUM
Is there a Gurobi equivalent?
Thank you.
-
Hi,
When a callback is executed, all other threads cease, so we won't have multiple callbacks being executed in parallel. This is what it means when it says “the user callback is only ever called from a single thread”. Consequently, we don't have an equivalent of CPX_CALLBACK_INFO_MY_THREAD_NUM since this information would not be useful.
Additionally, the added cuts could be locally valid or globally valid.
Note that Gurobi only supports globally valid cuts (and lazy constraints). I believe this is also true for CPLEX.
- Riley
1 -
Hi Riley,
>Note that Gurobi only supports globally valid cuts (and lazy constraints). I believe this is also true for CPLEX.
CPLEX offers the following https://www.ibm.com/docs/en/icos/22.2.0?topic=c-cpxxcutcallbackaddlocal-cpxcutcallbackaddlocal which allows one to add a local cut.
We are working on a problem where using the bounds on variables in the branch and bound tree, we develop tighter cuts which are valid only under the subtree rooted at the current node of the BBTree. So, the ability to query current lower and upper bounds on variables is crucial as also the ability to add only locally valid cuts.
So, I would imagine that there is no Gurobi equivalent of the following API either:
https://www.ibm.com/docs/en/cofz/12.9.0?topic=cpxxgetcallbacknodelb-cpxgetcallbacknodelb
https://www.ibm.com/docs/en/cofz/12.9.0?topic=cpxxgetcallbacknodeub-cpxgetcallbacknodeub
Thank you.
0 -
Hi,
CPLEX offers the following https://www.ibm.com/docs/en/icos/22.2.0?topic=c-cpxxcutcallbackaddlocal-cpxcutcallbackaddlocal which allows one to add a local cut
Thank you for letting me know, I was unaware of this routine.
So, I would imagine that there is no Gurobi equivalent of the following API either:
https://www.ibm.com/docs/en/cofz/12.9.0?topic=cpxxgetcallbacknodelb-cpxgetcallbacknodelb
https://www.ibm.com/docs/en/cofz/12.9.0?topic=cpxxgetcallbacknodeub-cpxgetcallbacknodeub
This is correct.
Would you like me to submit feature requests on your behalf?
- Riley
1
Please sign in to leave a comment.
Comments
3 comments