Results

(class from pyomo.contrib.appsi.base)

class pyomo.contrib.appsi.base.Results[source]

Bases: object

Base class for all APPSI solver results

termination_condition

The reason the solver exited. This is a member of the TerminationCondition enum.

Type:

TerminationCondition

best_feasible_objective

If a feasible solution was found, this is the objective value of the best solution found. If no feasible solution was found, this is None.

Type:

float

best_objective_bound

The best objective bound found. For minimization problems, this is the lower bound. For maximization problems, this is the upper bound. For solvers that do not provide an objective bound, this should be -inf (minimization) or inf (maximization)

Type:

float

Example

Here is an example workflow:

>>> import pyomo.environ as pe
>>> from pyomo.contrib import appsi
>>> m = pe.ConcreteModel()
>>> m.x = pe.Var()
>>> m.obj = pe.Objective(expr=m.x**2)
>>> opt = appsi.solvers.Ipopt()
>>> opt.config.load_solution = False
>>> results = opt.solve(m) 
>>> if results.termination_condition == appsi.base.TerminationCondition.optimal: 
...     print('optimal solution found: ', results.best_feasible_objective) 
...     results.solution_loader.load_vars() 
...     print('the optimal value of x is ', m.x.value) 
... elif results.best_feasible_objective is not None: 
...     print('sub-optimal but feasible solution found: ', results.best_feasible_objective) 
...     results.solution_loader.load_vars(vars_to_load=[m.x]) 
...     print('The value of x in the feasible solution is ', m.x.value) 
... elif results.termination_condition in {appsi.base.TerminationCondition.maxIterations, appsi.base.TerminationCondition.maxTimeLimit}: 
...     print('No feasible solution was found. The best lower bound found was ', results.best_objective_bound) 
... else: 
...     print('The following termination condition was encountered: ', results.termination_condition) 
__init__()[source]

Methods

__init__()

Member Documentation