Evaluator API
Description
Argos.AbstractNLPEvaluator — TypeAbstractNLPEvaluatorAbstractNLPEvaluator implements the bridge between the problem formulation (see ExaPF.AbstractFormulation) and the optimization solver. Once the problem formulation bridged, the evaluator allows to evaluate:
- the objective;
- the gradient of the objective;
- the constraints;
- the Jacobian of the constraints;
- the Jacobian-vector and transpose-Jacobian vector products of the constraints;
- the Hessian of the objective;
- the Hessian of the Lagrangian.
API Reference
Optimization
Argos.optimize! — Functionoptimize!(optimizer, nlp::AbstractNLPEvaluator, x0)Use optimization routine implemented in optimizer to optimize the optimal power flow problem specified in the evaluator nlp. Initial point is specified by x0.
Return the solution as a named tuple, with fields
status::MOI.TerminationStatus: Solver's termination status, as specified by MOIminimum::Float64: final objectiveminimizer::AbstractVector: final solution vector, with same ordering as theVariablesspecified innlp.
optimize!(optimizer, nlp::AbstractNLPEvaluator)Wrap previous optimize! function and pass as initial guess x0 the initial value specified when calling initial(nlp).
Examples
nlp = ExaPF.ReducedSpaceEvaluator(datafile)
optimizer = Ipopt.Optimizer()
solution = ExaPF.optimize!(optimizer, nlp)
Notes
By default, the optimization routine solves a minimization problem.
Attributes
Argos.Variables — TypeVariables <: AbstractNLPAttribute endAttribute corresponding to the optimization variables attached to a given AbstractNLPEvaluator.
Argos.Constraints — TypeConstraints <: AbstractNLPAttribute endAttribute corresponding to the constraints attached to a given AbstractNLPEvaluator.
Argos.n_variables — Functionn_variables(nlp::AbstractNLPEvaluator)Get the number of variables in the problem.
Argos.n_constraints — Functionn_constraints(nlp::AbstractNLPEvaluator)Get the number of constraints in the problem.
Argos.constraints_type — Functionconstraints_type(nlp::AbstractNLPEvaluator)Return the type of the non-linear constraints of the evaluator nlp, as a Symbol. Result could be :inequality if problem has only inequality constraints, :equality if problem has only equality constraints, or :mixed if problem has both types of constraints.
Callbacks
Argos.update! — Functionupdate!(nlp::AbstractNLPEvaluator, u::AbstractVector)Update the internal structure inside nlp with the new entry u. This method has to be called before calling any other callbacks.
Argos.objective — Functionobjective(nlp::AbstractNLPEvaluator, u)::Float64Evaluate the objective at given variable u.
Argos.gradient! — Functiongradient!(nlp::AbstractNLPEvaluator, g, u)Evaluate the gradient of the objective, at given variable u. Store the result inplace in the vector g.
Note
The vector g should have the same dimension as u.
Argos.constraint! — Functionconstraint!(nlp::AbstractNLPEvaluator, cons, u)Evaluate the constraints of the problem at given variable u. Store the result inplace, in the vector cons.
Note
The vector cons should have the same dimension as the result returned by n_constraints(nlp).
Argos.jacobian! — Functionjacobian!(nlp::AbstractNLPEvaluator, jac::AbstractMatrix, u)Evaluate the Jacobian of the constraints, at variable u. Store the result inplace, in the m x n dense matrix jac.
Argos.jacobian_coo! — Functionjacobian_coo!(nlp::AbstractNLPEvaluator, jac::AbstractVector, u)Evaluate the (sparse) Jacobian of the constraints at variable u in COO format. Store the result inplace, in the nnzj vector jac.
Argos.jprod! — Functionjprod!(nlp::AbstractNLPEvaluator, jv, u, v)Evaluate the Jacobian-vector product $J v$ of the constraints. The vector jv is modified inplace.
Let (n, m) = n_variables(nlp), n_constraints(nlp).
uis a vector with dimensionnvis a vector with dimensionnjvis a vector with dimensionm
Argos.jtprod! — Functionjtprod!(nlp::AbstractNLPEvaluator, jv, u, v)Evaluate the transpose Jacobian-vector product $J^{T} v$ of the constraints. The vector jv is modified inplace.
Let (n, m) = n_variables(nlp), n_constraints(nlp).
uis a vector with dimensionnvis a vector with dimensionmjvis a vector with dimensionn
Argos.ojtprod! — Functionojtprod!(nlp::AbstractNLPEvaluator, jv, u, σ, v)Evaluate the transpose Jacobian-vector product J' * [σ ; v], with J the Jacobian of the vector [f(x); h(x)]. f(x) is the current objective and h(x) constraints. The vector jv is modified inplace.
Let (n, m) = n_variables(nlp), n_constraints(nlp).
jvis a vector with dimensionnuis a vector with dimensionnσis a scalarvis a vector with dimensionm
Argos.hessian! — Functionhessian!(nlp::AbstractNLPEvaluator, H, u)Evaluate the Hessian ∇²f(u) of the objective function f(u). Store the result inplace, in the n x n dense matrix H.
Argos.hessian_coo! — Functionhessian_coo!(nlp::AbstractNLPEvaluator, hess::AbstractVector, u)Evaluate the (sparse) Hessian of the constraints at variable u in COO format. Store the result inplace, in the nnzh vector hess.
Argos.hessprod! — Functionhessprod!(nlp::AbstractNLPEvaluator, hessvec, u, v)Evaluate the Hessian-vector product ∇²f(u) * v of the objective evaluated at variable u. Store the result inplace, in the vector hessvec.
Note
The vector hessprod should have the same length as u.
Argos.hessian_lagrangian_prod! — Functionhessian_lagrangian_prod!(nlp::AbstractNLPEvaluator, hessvec, u, y, σ, v)Evaluate the Hessian-vector product of the Lagrangian function $L(u, y) = f(u) + \sum_i y_i c_i(u)$ with a vector v:
\[∇²L(u, y) ⋅ v = σ ∇²f(u) ⋅ v + \sum_i y_i ∇²c_i(u) ⋅ v\]
Store the result inplace, in the vector hessvec.
Arguments
hessvecis aAbstractVectorwith dimensionn, which is modified inplace.uis aAbstractVectorwith dimensionn, storing the current variable.yis aAbstractVectorwith dimensionn, storing the current constraints' multipliersσis a scalar, encoding the objective's scalingvis a vector with dimensionn.
Argos.hessian_lagrangian_penalty_prod! — Functionhessian_lagrangian_penalty_prod!(nlp::AbstractNLPEvaluator, hessvec, u, y, σ, d, v)Evaluate the Hessian-vector product of the Augmented Lagrangian function $L(u, y) = f(u) + \sum_i y_i c_i(u) + \frac{1}{2} d_i c_i(u)^2$ with a vector v:
\[∇²L(u, y) ⋅ v = σ ∇²f(u) ⋅ v + \sum_i (y_i + d_i) ∇²c_i(u) ⋅ v + \sum_i d_i ∇c_i(u)^T ∇c_i(u)\]
Store the result inplace, in the vector hessvec.
Arguments
hessvecis aAbstractVectorwith dimensionn, which is modified inplace.uis aAbstractVectorwith dimensionn, storing the current variable.yis aAbstractVectorwith dimensionn, storing the current constraints' multipliersσis a scalarvis a vector with dimensionn.dis a vector with dimensionm.
Utilities
Argos.reset! — Functionreset!(nlp::AbstractNLPEvaluator)Reset evaluator nlp to default configuration.