Retrieving Solutions for Multiple Scenarios

Your first step in retrieving the solutions computed by an optimize call on a multi-scenario model is to query the Status attribute. A status of OPTIMAL indicates that optimal solutions were found (subject to tolerances) for all scenarios that have feasible solutions, and that the other scenarios were determined to be infeasible. If all scenarios were found to be infeasible, the status will be INFEASIBLE. If any scenario is unbounded, the status will be UNBOUNDED. An early termination status code (e.g., TIME_LIMIT) indicates that the outcomes may vary across the different scenarios, and you will have to look at individual scenarios for more information.

Results for individual scenarios can be found in three attributes:

  • ScenNObjVal: The objective value for the solution for scenario number <span>$</span>n<span>$</span>.
  • ScenNObjBound: The best known bound on the optimal objective value for scenario number <span>$</span>n<span>$</span>.
  • ScenNX: The solution vector for scenario number <span>$</span>n<span>$</span>.
The ScenNObjVal and ScenNObjBound attributes are model attributes, while ScenNX is a variable attribute. Again, use the ScenarioNumber parameter to select the scenario you'd like to query.

If your optimize call terminated early, you should use the ScenNObjBound attribute to interpret the results. This attribute provides a bound on the optimal objective value for the selected scenario (much like ObjBound provides a bound for a single model). For example, if ScenNObjVal is 100 for a scenario and ScenNObjBound is 90 (assuming minimization), then you have a solution with a 10% optimality gap for that scenario.

You can also query the ObjVal and ObjBound attributes for a multi-scenario model. The former gives the best objective value for any solution found in any scenario. The latter provides a lower bound on the objective value for any solution that was not found.

Note that ScenNObjVal and ScenNObjBound are computed using the objective function for the corresponding scenario, which you may have changed from the base model.

If you query the ScenNX attribute and no feasible solution has been found for that scenario, you will get a DATA_NOT_AVAILABLE error.

Try Gurobi for Free

Choose the evaluation license that fits you best, and start working with our Expert Team for technical guidance and support.

Evaluation License
Get a free, full-featured license of the Gurobi Optimizer to experience the performance, support, benchmarking and tuning services we provide as part of our product offering.
Academic License
Gurobi supports the teaching and use of optimization within academic institutions. We offer free, full-featured copies of Gurobi for use in class, and for research.
Cloud Trial

Request free trial hours, so you can see how quickly and easily a model can be solved on the cloud.

Search