Creating a new environment with an existing model
AnsweredHi,
I am writing a branch-and-cut procedure in C using the Gurobi C APIs for my optimisation problem. I wish to use multi-threading to solve the various nodes of the search tree in parallel. I understand that it is not safe to create multiple threads to solve different models within the same environment. So I must create a different environment for each thread. However, since the models differ only slightly, it would be efficient if the same model could be extended within a new environment instead of creating one from scratch. Kindly let me know if that is possible or if there is a workaround.
Thanks and regards,
Pawan
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Pawan,
If your changes are only in the linear objective function coefficients, variable bounds, or constraints right-hand sides, then you should have a look into Gurobi's Multi-Scenario feature.
However, since the models differ only slightly, it would be efficient if the same model could be extended within a new environment instead of creating one from scratch. Kindly let me know if that is possible or if there is a workaround.
It is often best to solve models in sequence, i.e., solve a model to optimality, perform changes, then re-optimize. This way, Gurobi may be able to re-use the previous solution either for a warm-start or as an initial solution.
Unfortunately, there is no good workaround to achieve thread safety. However, model creation usually takes a very small portion of the overall solution time so you could let each process create its own environment and model and then solve them all in parallel.
Best regards,
Jaromił1
Post is closed for comments.
Comments
2 comments