Try our new documentation site (beta).

Retrieving Solutions

After optimization has completed, you can retrieve solutions from the solution pool using a few parameters and attributes. The SolCount attribute indicates how many solutions were retained by the MIP solver. The best solution can always be obtained through the X attribute. Sub-optimal solutions can be obtained by first setting the SolutionNumber parameter and then querying the Xn attribute to obtain the solution or the PoolObjVal attribute to obtain the objective value for the corresponding solution.

Solutions in the solution pool are ordered from best to worst. For example, to retrieve the worst solution kept by the MIP solver, you'd first query SolCount to determine how many solutions are available, then set the SolutionNumber parameter to SolCount-1, then query the Xn attribute.

The PoolObjBound attribute gives a bound on the objective value of undiscovered solutions (i.e., of solutions that aren't already in the solution pool). Further tree exploration won't find solutions having a better objective value than PoolObjBound.

The difference between this attribute and ObjBound is that the latter gives a bound on the objective for any solution, while PoolObjBound only refers to undiscovered solutions (which are not in the solution pool). PoolObjBound is always at least as tight as ObjBound and it is often strictly tighter than ObjBound if PoolSearchMode=2. If PoolSearchMode=0 or PoolSearchMode=1, then PoolObjBound and ObjBound will always take the same value.

If the solver terminated early (e.g. due to reaching the time limit), you can still use the attribute PoolObjBound to get a count of how many of the <span>$</span>n<span>$</span> best solutions you found: any solutions having objective values that are at least as good as PoolObjBound are among the <span>$</span>n<span>$</span> best. This is illustrated in the examples on the next section.

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

Gurobi Optimization