Inquiry on Asynchronous Optimization Calls Using Gurobipy in Python Environment
AnsweredDear Gurobi Support Team,
For your information, we are currently using the Gurobipy package (version 10.0.2) for modeling optimization problems and making optimization calls. We are running these on a Gurobi Cloud cluster and using Python (version 3.11.4).
In this context, we aim to perform asynchronous optimization calls in our cloud environment. We have three main objectives, listed in decreasing order of criticality for our application:
- To allow the halting of the optimization process and the return of the solution found up to the point of halting.
- To enable the simultaneous execution of multiple problems on the same cluster, while limiting the number of threads per problem.
- To allow other operations to be performed while the optimization process is ongoing (we understand that this can also be achieved through native Python methods).
We are aware that this functionality is implemented through the GRBModel.optimizeasync()
method, as mentioned in the documentation. However, it appears that this is not available (at least not under that name) in the Gurobipy package, but only in APIs for other languages like Java and C++.
Could you please guide us on how to utilize the functionalities provided by this method in Python?
Thank you for your assistance.
-
Hi Gabriel,
We do not support asynchronous optimization in Python because the gurobipy module is not thread-safe. Therefore, there is no method similar to the GRBModel.optimizeasync() method of C++ Gurobi API in the Gurobi Python API.
- We support batch optimization with Gurobi Cluster Manager (see the batchmode.py python example). Unfortunately, this option is not still available via the Gurobi Instant Cloud. However, this feature is in our roadmap and will be added to the Gurobi Instant Cloud at some point in the future Gurobi releases.
- You can use the Python multiprocessing module to spawn multiple Gurobi jobs to be run in parallel in the Gurobi Instant Cloud. The runs will be done synchronously. If this is an option for you, you might find the article on How do I use multiprocessing in Python with Gurobi? useful. I think this option covers all your three objectives.
Best regards,
Maliheh
1
Please sign in to leave a comment.
Comments
1 comment