As stated in the Home page, we consider the nonlinear optimization problem in the following format:
To develop an optimization algorithm, we are usually worried not only with
f(x) and c(x), but also with their derivatives.
Namely,
\nabla f(x), the gradient offat the pointx;\nabla^2 f(x), the Hessian offat the pointx;J(x) = \nabla c(x)^T, the Jacobian ofcat the pointx;\nabla^2 f(x) + \sum_{i=1}^m y_i \nabla^2 c_i(x), the Hessian of the Lagrangian function at the point(x,y).
There are many ways to access some of these values, so here is a little reference guide.
The following naming should be easy enough to follow. If not, click on the link and go to the description.
!means inplace;_coordmeans coordinate format;_densemeans dense format;prodmeans matrix-vector product;_opmeans operator (as in LinearOperators.jl);_linand_nlnrespectively refer to linear and nonlinear constraints.
Feel free to open an issue to suggest other methods that should apply to all NLPModels instances.
| Function | NLPModels function |
|---|---|
f(x) |
obj, objgrad, objgrad!, objcons, objcons! |
\nabla f(x) |
grad, grad!, objgrad, objgrad! |
\nabla^2 f(x) |
hess, hess_op, hess_op!, hess_coord, hess_coord!, hess_dense!, hess_structure, hess_structure!, hprod, hprod! |
c(x) |
cons_lin, cons_lin!, cons_nln, cons_nln!, cons, cons!, objcons, objcons! |
J(x) |
jac_lin, jac_nln, jac, jac_lin_op, jac_lin_op!, jac_nln_op, jac_nln_op!,jac_op, jac_op!, jac_lin_coord, jac_lin_coord!, jac_nln_coord, jac_nln_coord!, jac_coord, jac_coord!, jac_dense!, jac_lin_structure, jac_lin_structure!, jac_nln_structure, jac_nln_structure!, jac_structure, jprod_lin, jprod_lin!, jprod_nln, jprod_nln!, jprod, jprod!, jtprod_lin, jtprod_lin!, jtprod_nln, jtprod_nln!, jtprod, jtprod! |
\nabla^2 L(x,y) |
hess, hess_op, hess_coord, hess_coord!, hess_dense!, hess_structure, hess_structure!, hprod, hprod!, jth_hprod, jth_hprod!, jth_hess, jth_hess_coord, jth_hess_coord!, ghjvprod, ghjvprod! |
If only a subset of the functions listed above is implemented, you can indicate which ones are not available when creating the NLPModelMeta, using the keyword arguments
grad_available, jac_available, hess_available, jprod_available, jtprod_available, and hprod_available.
You can also specify whether the Jacobian of the constraints and the Hessian of the objective or Lagrangian are sparse using the keyword arguments sparse_jacobian and sparse_hessian.
For the Nonlinear Least Squares models, f(x) = \tfrac{1}{2} \Vert F(x)\Vert^2,
and these models have additional function to access the residual value
and its derivatives. Namely,
J_F(x) = \nabla F(x)^T\nabla^2 F_i(x)
If only a subset of the functions listed above is implemented, you can indicate which ones are not available when creating the NLSMeta, using the keyword arguments jac_residual_available, hess_residual_available, jprod_residual_available, jtprod_residual_available, and hprod_residual_available.