APPSI
Auto-Persistent Pyomo Solver Interfaces
- APPSI Base Classes
TerminationCondition
TerminationCondition.error
TerminationCondition.infeasible
TerminationCondition.infeasibleOrUnbounded
TerminationCondition.interrupted
TerminationCondition.licensingProblems
TerminationCondition.maxIterations
TerminationCondition.maxTimeLimit
TerminationCondition.minStepLength
TerminationCondition.objectiveLimit
TerminationCondition.optimal
TerminationCondition.unbounded
TerminationCondition.unknown
Results
Solver
PersistentSolver
PersistentSolver.Availability
PersistentSolver.add_block()
PersistentSolver.add_constraints()
PersistentSolver.add_params()
PersistentSolver.add_variables()
PersistentSolver.available()
PersistentSolver.config
PersistentSolver.get_duals()
PersistentSolver.get_primals()
PersistentSolver.get_reduced_costs()
PersistentSolver.get_slacks()
PersistentSolver.is_persistent()
PersistentSolver.load_vars()
PersistentSolver.remove_block()
PersistentSolver.remove_constraints()
PersistentSolver.remove_params()
PersistentSolver.remove_variables()
PersistentSolver.set_instance()
PersistentSolver.set_objective()
PersistentSolver.solve()
PersistentSolver.symbol_map
PersistentSolver.update_config
PersistentSolver.update_params()
PersistentSolver.update_variables()
PersistentSolver.version()
SolverConfig
SolverConfig.time_limit
SolverConfig.stream_solver
SolverConfig.load_solution
SolverConfig.symbolic_solver_labels
SolverConfig.report_timing
SolverConfig.add()
SolverConfig.content_filters
SolverConfig.declare()
SolverConfig.declare_as_argument()
SolverConfig.declare_from()
SolverConfig.display()
SolverConfig.domain_name()
SolverConfig.generate_documentation()
SolverConfig.generate_yaml_template()
SolverConfig.get()
SolverConfig.import_argparse()
SolverConfig.initialize_argparse()
SolverConfig.items()
SolverConfig.iteritems()
SolverConfig.iterkeys()
SolverConfig.itervalues()
SolverConfig.keys()
SolverConfig.name()
SolverConfig.reset()
SolverConfig.set_default_value()
SolverConfig.set_domain()
SolverConfig.set_value()
SolverConfig.setdefault()
SolverConfig.unused_user_values()
SolverConfig.user_values()
SolverConfig.value()
SolverConfig.values()
MIPSolverConfig
MIPSolverConfig.mip_gap
MIPSolverConfig.relax_integrality
MIPSolverConfig.add()
MIPSolverConfig.content_filters
MIPSolverConfig.declare()
MIPSolverConfig.declare_as_argument()
MIPSolverConfig.declare_from()
MIPSolverConfig.display()
MIPSolverConfig.domain_name()
MIPSolverConfig.generate_documentation()
MIPSolverConfig.generate_yaml_template()
MIPSolverConfig.get()
MIPSolverConfig.import_argparse()
MIPSolverConfig.initialize_argparse()
MIPSolverConfig.items()
MIPSolverConfig.iteritems()
MIPSolverConfig.iterkeys()
MIPSolverConfig.itervalues()
MIPSolverConfig.keys()
MIPSolverConfig.load_solution
MIPSolverConfig.name()
MIPSolverConfig.report_timing
MIPSolverConfig.reset()
MIPSolverConfig.set_default_value()
MIPSolverConfig.set_domain()
MIPSolverConfig.set_value()
MIPSolverConfig.setdefault()
MIPSolverConfig.stream_solver
MIPSolverConfig.symbolic_solver_labels
MIPSolverConfig.time_limit
MIPSolverConfig.unused_user_values()
MIPSolverConfig.user_values()
MIPSolverConfig.value()
MIPSolverConfig.values()
UpdateConfig
UpdateConfig.check_for_new_or_removed_constraints
UpdateConfig.check_for_new_or_removed_vars
UpdateConfig.check_for_new_or_removed_params
UpdateConfig.update_constraints
UpdateConfig.update_vars
UpdateConfig.update_params
UpdateConfig.update_named_expressions
UpdateConfig.add()
UpdateConfig.content_filters
UpdateConfig.declare()
UpdateConfig.declare_as_argument()
UpdateConfig.declare_from()
UpdateConfig.display()
UpdateConfig.domain_name()
UpdateConfig.generate_documentation()
UpdateConfig.generate_yaml_template()
UpdateConfig.get()
UpdateConfig.import_argparse()
UpdateConfig.initialize_argparse()
UpdateConfig.items()
UpdateConfig.iteritems()
UpdateConfig.iterkeys()
UpdateConfig.itervalues()
UpdateConfig.keys()
UpdateConfig.name()
UpdateConfig.reset()
UpdateConfig.set_default_value()
UpdateConfig.set_domain()
UpdateConfig.set_value()
UpdateConfig.setdefault()
UpdateConfig.unused_user_values()
UpdateConfig.user_values()
UpdateConfig.value()
UpdateConfig.values()
- Solvers
- Gurobi
- Handling Gurobi licenses through the APPSI interface
GurobiResults
Gurobi
Gurobi.Availability
Gurobi.add_block()
Gurobi.add_constraints()
Gurobi.add_params()
Gurobi.add_sos_constraints()
Gurobi.add_variables()
Gurobi.available()
Gurobi.cbCut()
Gurobi.cbGet()
Gurobi.cbGetNodeRel()
Gurobi.cbGetSolution()
Gurobi.cbLazy()
Gurobi.cbSetSolution()
Gurobi.cbUseSolution()
Gurobi.config
Gurobi.get_duals()
Gurobi.get_gurobi_param_info()
Gurobi.get_linear_constraint_attr()
Gurobi.get_model_attr()
Gurobi.get_primals()
Gurobi.get_quadratic_constraint_attr()
Gurobi.get_reduced_costs()
Gurobi.get_slacks()
Gurobi.get_sos_attr()
Gurobi.get_var_attr()
Gurobi.gurobi_options
Gurobi.is_persistent()
Gurobi.load_vars()
Gurobi.release_license()
Gurobi.remove_block()
Gurobi.remove_constraints()
Gurobi.remove_params()
Gurobi.remove_sos_constraints()
Gurobi.remove_variables()
Gurobi.reset()
Gurobi.set_callback()
Gurobi.set_gurobi_param()
Gurobi.set_instance()
Gurobi.set_linear_constraint_attr()
Gurobi.set_objective()
Gurobi.set_var_attr()
Gurobi.solve()
Gurobi.symbol_map
Gurobi.update()
Gurobi.update_config
Gurobi.update_params()
Gurobi.update_variables()
Gurobi.version()
Gurobi.write()
- Handling Gurobi licenses through the APPSI interface
- Ipopt
IpoptConfig
IpoptConfig.NoArgument
IpoptConfig.add()
IpoptConfig.content_filters
IpoptConfig.declare()
IpoptConfig.declare_as_argument()
IpoptConfig.declare_from()
IpoptConfig.display()
IpoptConfig.domain_name()
IpoptConfig.generate_documentation()
IpoptConfig.generate_yaml_template()
IpoptConfig.get()
IpoptConfig.import_argparse()
IpoptConfig.initialize_argparse()
IpoptConfig.items()
IpoptConfig.iteritems()
IpoptConfig.iterkeys()
IpoptConfig.itervalues()
IpoptConfig.keys()
IpoptConfig.load_solution
IpoptConfig.name()
IpoptConfig.report_timing
IpoptConfig.reset()
IpoptConfig.set_default_value()
IpoptConfig.set_domain()
IpoptConfig.set_value()
IpoptConfig.setdefault()
IpoptConfig.stream_solver
IpoptConfig.symbolic_solver_labels
IpoptConfig.time_limit
IpoptConfig.unused_user_values()
IpoptConfig.user_values()
IpoptConfig.value()
IpoptConfig.values()
Ipopt
Ipopt.Availability
Ipopt.add_block()
Ipopt.add_constraints()
Ipopt.add_params()
Ipopt.add_variables()
Ipopt.available()
Ipopt.config
Ipopt.get_duals()
Ipopt.get_primals()
Ipopt.get_reduced_costs()
Ipopt.get_slacks()
Ipopt.has_linear_solver()
Ipopt.ipopt_options
Ipopt.is_persistent()
Ipopt.load_vars()
Ipopt.nl_filename()
Ipopt.options_filename()
Ipopt.remove_block()
Ipopt.remove_constraints()
Ipopt.remove_params()
Ipopt.remove_variables()
Ipopt.set_instance()
Ipopt.set_objective()
Ipopt.sol_filename()
Ipopt.solve()
Ipopt.symbol_map
Ipopt.update_config
Ipopt.update_params()
Ipopt.update_variables()
Ipopt.version()
Ipopt.writer
- Cplex
CplexConfig
CplexConfig.add()
CplexConfig.content_filters
CplexConfig.declare()
CplexConfig.declare_as_argument()
CplexConfig.declare_from()
CplexConfig.display()
CplexConfig.domain_name()
CplexConfig.generate_documentation()
CplexConfig.generate_yaml_template()
CplexConfig.get()
CplexConfig.import_argparse()
CplexConfig.initialize_argparse()
CplexConfig.items()
CplexConfig.iteritems()
CplexConfig.iterkeys()
CplexConfig.itervalues()
CplexConfig.keys()
CplexConfig.load_solution
CplexConfig.mip_gap
CplexConfig.name()
CplexConfig.relax_integrality
CplexConfig.report_timing
CplexConfig.reset()
CplexConfig.set_default_value()
CplexConfig.set_domain()
CplexConfig.set_value()
CplexConfig.setdefault()
CplexConfig.stream_solver
CplexConfig.symbolic_solver_labels
CplexConfig.time_limit
CplexConfig.unused_user_values()
CplexConfig.user_values()
CplexConfig.value()
CplexConfig.values()
CplexResults
Cplex
Cplex.Availability
Cplex.add_block()
Cplex.add_constraints()
Cplex.add_params()
Cplex.add_variables()
Cplex.available()
Cplex.config
Cplex.cplex_options
Cplex.get_duals()
Cplex.get_primals()
Cplex.get_reduced_costs()
Cplex.get_slacks()
Cplex.is_persistent()
Cplex.load_vars()
Cplex.log_filename()
Cplex.lp_filename()
Cplex.remove_block()
Cplex.remove_constraints()
Cplex.remove_params()
Cplex.remove_variables()
Cplex.set_instance()
Cplex.set_objective()
Cplex.solve()
Cplex.symbol_map
Cplex.update_config
Cplex.update_params()
Cplex.update_variables()
Cplex.version()
Cplex.writer
- Cbc
CbcConfig
CbcConfig.add()
CbcConfig.content_filters
CbcConfig.declare()
CbcConfig.declare_as_argument()
CbcConfig.declare_from()
CbcConfig.display()
CbcConfig.domain_name()
CbcConfig.generate_documentation()
CbcConfig.generate_yaml_template()
CbcConfig.get()
CbcConfig.import_argparse()
CbcConfig.initialize_argparse()
CbcConfig.items()
CbcConfig.iteritems()
CbcConfig.iterkeys()
CbcConfig.itervalues()
CbcConfig.keys()
CbcConfig.load_solution
CbcConfig.name()
CbcConfig.report_timing
CbcConfig.reset()
CbcConfig.set_default_value()
CbcConfig.set_domain()
CbcConfig.set_value()
CbcConfig.setdefault()
CbcConfig.stream_solver
CbcConfig.symbolic_solver_labels
CbcConfig.time_limit
CbcConfig.unused_user_values()
CbcConfig.user_values()
CbcConfig.value()
CbcConfig.values()
Cbc
Cbc.Availability
Cbc.add_block()
Cbc.add_constraints()
Cbc.add_params()
Cbc.add_variables()
Cbc.available()
Cbc.cbc_options
Cbc.config
Cbc.get_duals()
Cbc.get_primals()
Cbc.get_reduced_costs()
Cbc.get_slacks()
Cbc.is_persistent()
Cbc.load_vars()
Cbc.log_filename()
Cbc.lp_filename()
Cbc.remove_block()
Cbc.remove_constraints()
Cbc.remove_params()
Cbc.remove_variables()
Cbc.set_instance()
Cbc.set_objective()
Cbc.soln_filename()
Cbc.solve()
Cbc.symbol_map
Cbc.update_config
Cbc.update_params()
Cbc.update_variables()
Cbc.version()
Cbc.writer
- HiGHS
HighsResults
Highs
Highs.Availability
Highs.add_block()
Highs.add_constraints()
Highs.add_params()
Highs.add_sos_constraints()
Highs.add_variables()
Highs.available()
Highs.config
Highs.get_duals()
Highs.get_primals()
Highs.get_reduced_costs()
Highs.get_slacks()
Highs.highs_options
Highs.is_persistent()
Highs.load_vars()
Highs.remove_block()
Highs.remove_constraints()
Highs.remove_params()
Highs.remove_sos_constraints()
Highs.remove_variables()
Highs.set_instance()
Highs.set_objective()
Highs.solve()
Highs.symbol_map
Highs.update()
Highs.update_config
Highs.update_params()
Highs.update_variables()
Highs.version()
- MAiNGO
MAiNGOConfig
MAiNGOConfig.NoArgument
MAiNGOConfig.add()
MAiNGOConfig.content_filters
MAiNGOConfig.declare()
MAiNGOConfig.declare_as_argument()
MAiNGOConfig.declare_from()
MAiNGOConfig.display()
MAiNGOConfig.domain_name()
MAiNGOConfig.generate_documentation()
MAiNGOConfig.generate_yaml_template()
MAiNGOConfig.get()
MAiNGOConfig.import_argparse()
MAiNGOConfig.initialize_argparse()
MAiNGOConfig.items()
MAiNGOConfig.iteritems()
MAiNGOConfig.iterkeys()
MAiNGOConfig.itervalues()
MAiNGOConfig.keys()
MAiNGOConfig.load_solution
MAiNGOConfig.mip_gap
MAiNGOConfig.name()
MAiNGOConfig.relax_integrality
MAiNGOConfig.report_timing
MAiNGOConfig.reset()
MAiNGOConfig.set_default_value()
MAiNGOConfig.set_domain()
MAiNGOConfig.set_value()
MAiNGOConfig.setdefault()
MAiNGOConfig.stream_solver
MAiNGOConfig.symbolic_solver_labels
MAiNGOConfig.time_limit
MAiNGOConfig.unused_user_values()
MAiNGOConfig.user_values()
MAiNGOConfig.value()
MAiNGOConfig.values()
MAiNGO
MAiNGO.Availability
MAiNGO.add_block()
MAiNGO.add_constraints()
MAiNGO.add_params()
MAiNGO.add_sos_constraints()
MAiNGO.add_variables()
MAiNGO.available()
MAiNGO.config
MAiNGO.get_duals()
MAiNGO.get_primals()
MAiNGO.get_reduced_costs()
MAiNGO.get_slacks()
MAiNGO.is_persistent()
MAiNGO.load_vars()
MAiNGO.maingo_options
MAiNGO.remove_block()
MAiNGO.remove_constraints()
MAiNGO.remove_params()
MAiNGO.remove_sos_constraints()
MAiNGO.remove_variables()
MAiNGO.set_instance()
MAiNGO.set_objective()
MAiNGO.solve()
MAiNGO.symbol_map
MAiNGO.update()
MAiNGO.update_config
MAiNGO.update_params()
MAiNGO.update_variables()
MAiNGO.version()
- Gurobi
APPSI solver interfaces are designed to work very similarly to most Pyomo solver interfaces but are very efficient for resolving the same model with small changes. This is very beneficial for applications such as Benders’ Decomposition, Optimization-Based Bounds Tightening, Progressive Hedging, Outer-Approximation, and many others. Here is an example of using an APPSI solver interface.
>>> import pyomo.environ as pe
>>> from pyomo.contrib import appsi
>>> import numpy as np
>>> from pyomo.common.timing import HierarchicalTimer
>>> m = pe.ConcreteModel()
>>> m.x = pe.Var()
>>> m.y = pe.Var()
>>> m.p = pe.Param(mutable=True)
>>> m.obj = pe.Objective(expr=m.x**2 + m.y**2)
>>> m.c1 = pe.Constraint(expr=m.y >= pe.exp(m.x))
>>> m.c2 = pe.Constraint(expr=m.y >= (m.x - m.p)**2)
>>> opt = appsi.solvers.Ipopt()
>>> timer = HierarchicalTimer()
>>> for p_val in np.linspace(1, 10, 100):
>>> m.p.value = float(p_val)
>>> res = opt.solve(m, timer=timer)
>>> assert res.termination_condition == appsi.base.TerminationCondition.optimal
>>> print(res.best_feasible_objective)
>>> print(timer)
Extra performance improvements can be made if you know exactly what
changes will be made in your model. In the example above, only
parameter values are changed, so we can setup the
UpdateConfig
so that the solver
does not check for changes in variables or constraints.
>>> timer = HierarchicalTimer()
>>> opt.update_config.check_for_new_or_removed_constraints = False
>>> opt.update_config.check_for_new_or_removed_vars = False
>>> opt.update_config.update_constraints = False
>>> opt.update_config.update_vars = False
>>> for p_val in np.linspace(1, 10, 100):
>>> m.p.value = float(p_val)
>>> res = opt.solve(m, timer=timer)
>>> assert res.termination_condition == appsi.base.TerminationCondition.optimal
>>> print(res.best_feasible_objective)
>>> print(timer)
Solver independent options can be specified with the
SolverConfig
or derived
classes. For example:
>>> opt.config.stream_solver = True
Solver specific options can be specified with the
solver_options()
attribute. For example:
>>> opt.solver_options['max_iter'] = 20
Installation
There are a few ways to install Appsi listed below.
Option1:
pyomo build-extensions
Option2:
cd pyomo/contrib/appsi/
python build.py
Option3:
python
>>> from pyomo.contrib.appsi.build import build_appsi
>>> build_appsi()