PyomoExternalCyIpoptProblem

(class from pyomo.contrib.pynumero.algorithms.solvers.pyomo_ext_cyipopt)

class pyomo.contrib.pynumero.algorithms.solvers.pyomo_ext_cyipopt.PyomoExternalCyIpoptProblem(pyomo_model, ex_input_output_model, inputs, outputs, outputs_eqn_scaling=None, nl_file_options=None)[source]

Bases: CyIpoptProblemInterface

__init__(pyomo_model, ex_input_output_model, inputs, outputs, outputs_eqn_scaling=None, nl_file_options=None)[source]

Create an instance of this class to pass as a problem to CyIpopt.

Parameters:
  • pyomo_model (ConcreteModel) – The ConcreteModel representing the Pyomo part of the problem. This model must contain Pyomo variables for the inputs and the outputs.

  • ex_input_output_model (ExternalInputOutputModel) – An instance of a derived class (from ExternalInputOutputModel) that provides the methods to compute the outputs and the derivatives.

  • inputs (list of Pyomo variables (VarData)) – The Pyomo model needs to have variables to represent the inputs to the external model. This is the list of those input variables in the order that corresponds to the input_values vector provided in the set_inputs call.

  • outputs (list of Pyomo variables (VarData)) – The Pyomo model needs to have variables to represent the outputs from the external model. This is the list of those output variables in the order that corresponds to the numpy array returned from the evaluate_outputs call.

  • outputs_eqn_scaling (list or array-like or None) – This sets the value of scaling parameters for the additional output equations that are generated. No scaling is done if this is set to None.

Methods

__init__(pyomo_model, ex_input_output_model, ...)

Create an instance of this class to pass as a problem to CyIpopt.

constraints(primals)

Return the residuals of the constraints evaluated at x as a numpy ndarray

g_lb()

Return the lower bounds on the constraints as a numpy ndarray

g_ub()

Return the upper bounds on the constraints as a numpy ndarray

gradient(primals)

Return the gradient of the objective function evaluated at x as a numpy ndarray

hessian(x, y, obj_factor)

Return the values for the hessian evaluated at x as a numpy ndarray of nonzero values corresponding to the rows and columns specified in the hessianstructure method.

hessianstructure()

Return the structure of the hessian in coordinate format.

intermediate(alg_mod, iter_count, obj_value, ...)

Callback that can be used to examine or report intermediate results.

jacobian(primals)

Return the values for the jacobian evaluated at x as a numpy ndarray of nonzero values corresponding to the rows and columns specified in the jacobianstructure

jacobianstructure()

Return the structure of the jacobian in coordinate format.

load_x_into_pyomo(primals)

Use this method to load a numpy array of values into the corresponding Pyomo variables (e.g., the solution from CyIpopt)

objective(primals)

Return the value of the objective function evaluated at x

scaling_factors()

Return the values for scaling factors as a tuple (objective_scaling, x_scaling, g_scaling).

solve(x[, lagrange, zl, zu])

Solve a CyIpopt Problem

x_init()

Return the initial values for x as a numpy ndarray

x_lb()

Return the lower bounds on x as a numpy ndarray

x_ub()

Return the upper bounds on x as a numpy ndarray

Member Documentation

constraints(primals)[source]

Return the residuals of the constraints evaluated at x as a numpy ndarray

g_lb()[source]

Return the lower bounds on the constraints as a numpy ndarray

g_ub()[source]

Return the upper bounds on the constraints as a numpy ndarray

gradient(primals)[source]

Return the gradient of the objective function evaluated at x as a numpy ndarray

hessian(x, y, obj_factor)[source]

Return the values for the hessian evaluated at x as a numpy ndarray of nonzero values corresponding to the rows and columns specified in the hessianstructure method. Note: return ONLY the lower diagonal of this symmetric matrix.

hessianstructure()[source]

Return the structure of the hessian in coordinate format. That is, return (rows,cols) where rows and cols are both numpy ndarray objects that contain the row and column indices for each of the nonzeros in the hessian. Note: return ONLY the lower diagonal of this symmetric matrix.

intermediate(alg_mod, iter_count, obj_value, inf_pr, inf_du, mu, d_norm, regularization_size, alpha_du, alpha_pr, ls_trials)

Callback that can be used to examine or report intermediate results. This method is called each iteration

jacobian(primals)[source]

Return the values for the jacobian evaluated at x as a numpy ndarray of nonzero values corresponding to the rows and columns specified in the jacobianstructure

jacobianstructure()[source]

Return the structure of the jacobian in coordinate format. That is, return (rows,cols) where rows and cols are both numpy ndarray objects that contain the row and column indices for each of the nonzeros in the jacobian.

load_x_into_pyomo(primals)[source]

Use this method to load a numpy array of values into the corresponding Pyomo variables (e.g., the solution from CyIpopt)

Parameters:

primals (numpy array) – The array of values that will be given to the Pyomo variables. The order of this array is the same as the order in the PyomoNLP created internally.

objective(primals)[source]

Return the value of the objective function evaluated at x

scaling_factors()[source]

Return the values for scaling factors as a tuple (objective_scaling, x_scaling, g_scaling). Return None if the scaling factors are to be ignored

solve(x, lagrange=None, zl=None, zu=None)

Solve a CyIpopt Problem

Checks whether __init__ has been called before calling cyipopt.Problem.solve

x_init()[source]

Return the initial values for x as a numpy ndarray

x_lb()[source]

Return the lower bounds on x as a numpy ndarray

x_ub()[source]

Return the upper bounds on x as a numpy ndarray