How to remove scenarios from Multi-Scenario Gurobi model or transfer it to a normal single Scenario model?
Hi,
I'm using the Gurobi Multi-Scenario model (scenarios are based on right-hand sides) and I solve it iteratively. So in each iteration, I have a new base model and a new set of scenarios (which is different from the previous set of scenarios). The issue here is that in some iterations I do not have a multi-scenario problem so I like to keep using the Gurobi syntax for a single scenario model while using the same model. (e.g., using RHS instead of ScenRHS).
First: I was wondering how can I delete the previous scenarios from the model before proceeding to the next iteration (i.e, change the model back to a single scenario and then define a new set of scenarios)?
Second: how can I change back a model from multiple scenarios to a single scenario?
Third: In case I use single scenario syntaxes (e.g., RHS) on a multi-scenario model. Does it apply the changes only to the base model?
Your help is much appreciated!
-
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?. -
For the first question, if you want to delete a scenario after you have called model.optimize() it is not possible. While you are building your model, it is possible to delete a scenario by decreasing the value of NumScenarios attribute.
For your second question, you can change the model back to a single scenario after the optimization has been completed. Use the model.singleScenarioModel() attribute to change your multi-scenario model to a single scenario.
In case you use the standard query attributes of Gurobi in a multi-scenario model while not setting the single scenario model attribute, it will only capture the attributes of the base model. In fact, querying a given RHS attribute on a multi-scenario model will return an error if you use the standard constr.RHS
I hope these may help you.
0
Post is closed for comments.
Comments
2 comments