Ipopt

(class from pyomo.contrib.solver.solvers.ipopt)

class pyomo.contrib.solver.solvers.ipopt.Ipopt(**kwds: Any)[source]

Bases: SolverBase

Interface to the Ipopt NLP solver (NL file based)

Class configuration

This class leverages the Pyomo Configuration System for managing configuration options. See the discussion on configuring class hierarchies for more information on how configuration class attributes, instance attributes, and method keyword arguments interact.

CONFIG:
  • tee (TextIO_or_Logger, default=False) – tee accepts bool, io.TextIOBase, or logging.Logger (or a list of these types). True is mapped to sys.stdout. The solver log will be printed to each of these streams / destinations.

  • working_dir (Path, optional) – The directory in which generated files should be saved. This replaces the keepfiles option.

  • load_solutions (Bool, default=True) – If True, the values of the primal variables will be loaded into the model.

  • raise_exception_on_nonoptimal_result (Bool, default=True) – If False, the solve method will continue processing even if the returned result is nonoptimal.

  • symbolic_solver_labels (Bool, default=False) – If True, the names given to the solver will reflect the names of the Pyomo components. Cannot be changed after set_instance is called.

  • timer (optional) – A timer object for recording relevant process timing data.

  • threads (NonNegativeInt, optional) – Number of threads to be used by a solver.

  • time_limit (NonNegativeFloat, optional) – Time limit applied to the solver (in seconds).

  • solver_options (dict, optional) – Options to pass to the solver.

  • executable (Executable, default='ipopt') – Preferred executable for ipopt. Defaults to searching the PATH for the first available ipopt.

  • writer_config (NLWriter.CONFIG, optional) – nlwriter

__init__(**kwds: Any) None[source]

Methods

__init__(**kwds)

api_version()

Return the public API supported by this interface.

available()

Test if the solver is available on this system.

has_linear_solver(linear_solver)

Determine if Ipopt has access to the specified linear solver

is_persistent()

True if this supports a persistent interface to the solver.

solve(model, **kwds)

Solve a model using Ipopt

version()

Return the solver version found on the system.

Attributes

CONFIG

Global class configuration; see CONFIG.

name

config

Instance configuration; see CONFIG.

Member Documentation

classmethod api_version()

Return the public API supported by this interface.

Returns:

A solver API enum object

Return type:

SolverAPIVersion

available() Availability[source]

Test if the solver is available on this system.

Nominally, this will return True if the solver interface is valid and can be used to solve problems and False if it cannot. Note that for licensed solvers there are a number of “levels” of available: depending on the license, the solver may be available with limitations on problem size or runtime (e.g., ‘demo’ vs. ‘community’ vs. ‘full’). In these cases, the solver may return a subclass of enum.IntEnum, with members that resolve to True if the solver is available (possibly with limitations). The Enum may also have multiple members that all resolve to False indicating the reason why the interface is not available (not found, bad license, unsupported version, etc).

Returns:

available – An enum that indicates “how available” the solver is. Note that the enum can be cast to bool, which will be True if the solver is runnable at all and False otherwise.

Return type:

Availability

has_linear_solver(linear_solver: str) bool[source]

Determine if Ipopt has access to the specified linear solver

This solves a small problem to detect if the Ipopt executable has access to the specified linear solver.

Parameters:

linear_solver (str) – The linear solver to test. Accepts any string that is valid for the linear_solver Ipopt option.

is_persistent() bool

True if this supports a persistent interface to the solver.

Returns:

is_persistent – True if the solver is a persistent solver.

Return type:

bool

solve(model, **kwds) Results[source]

Solve a model using Ipopt

Keyword Arguments:
  • tee (TextIO_or_Logger, default=False) – tee accepts bool, io.TextIOBase, or logging.Logger (or a list of these types). True is mapped to sys.stdout. The solver log will be printed to each of these streams / destinations.

  • working_dir (Path, optional) – The directory in which generated files should be saved. This replaces the keepfiles option.

  • load_solutions (Bool, default=True) – If True, the values of the primal variables will be loaded into the model.

  • raise_exception_on_nonoptimal_result (Bool, default=True) – If False, the solve method will continue processing even if the returned result is nonoptimal.

  • symbolic_solver_labels (Bool, default=False) – If True, the names given to the solver will reflect the names of the Pyomo components. Cannot be changed after set_instance is called.

  • timer (optional) – A timer object for recording relevant process timing data.

  • threads (NonNegativeInt, optional) – Number of threads to be used by a solver.

  • time_limit (NonNegativeFloat, optional) – Time limit applied to the solver (in seconds).

  • solver_options (dict, optional) – Options to pass to the solver.

  • executable (Executable, default='ipopt') – Preferred executable for ipopt. Defaults to searching the PATH for the first available ipopt.

  • writer_config (NLWriter.CONFIG, optional) – nlwriter

version() tuple[int, int, int] | None[source]

Return the solver version found on the system.

Returns:

version – A tuple representing the version

Return type:

tuple

CONFIG = <pyomo.contrib.solver.solvers.ipopt.IpoptConfig object>

Global class configuration; see CONFIG.

config

Instance configuration; see CONFIG.