Tools
Functions evaluations
After calling one the API functions to get a function value, the number of times that function was called is stored inside the NLPModel. For instance
using ADNLPModels, LinearAlgebra, NLPModels
nlp = ADNLPModel(x -> dot(x, x), zeros(2))
for i = 1:100
   obj(nlp, rand(2))
end
neval_obj(nlp)100Some counters are available for all models, some are specific. In particular, there are additional specific counters for the nonlinear least squares models (the ones with residual below).
| Counter | Description | 
|---|---|
neval_obj | Objective | 
neval_grad | Gradient | 
neval_cons | Constraints | 
neval_cons_lin | Linear constraints | 
neval_cons_nln | Nonlinear constraints | 
neval_jcon | One constraint - unused | 
neval_jgrad | Gradient of one constraints - unused | 
neval_jac | Jacobian | 
neval_jac_lin | Linear constraints Jacobian | 
neval_jac_nln | Nonlinear constraints Jacobian | 
neval_jprod | Product of Jacobian and vector | 
neval_jprod_lin | Product of linear constraints Jacobian and vector | 
neval_jprod_nln | Product of nonlinear constraints Jacobian and vector | 
neval_jtprod | Product of transposed Jacobian and vector | 
neval_jtprod_lin | Product of transposed linear constraints Jacobian and vector | 
neval_jtprod_nln | Product of transposed nonlinear constraints Jacobian and vector | 
neval_hess | Hessian | 
neval_hprod | Product of Hessian and vector | 
neval_jhess | Individual Lagrangian Hessian evaluations | 
neval_jhprod | Product of Hessian of j-th function and vector | 
neval_residual | Residual function of nonlinear least squares model | 
neval_jac_residual | Jacobian of the residual | 
neval_jprod_residual | Product of Jacobian of residual and vector | 
neval_jtprod_residual | Product of transposed Jacobian of residual and vector | 
neval_hess_residual | Sum of Hessians of residuals | 
neval_jhess_residual | Hessian of a residual component | 
neval_hprod_residual | Product of Hessian of a residual component and vector | 
To get the sum of all counters except cons, jac, jprod and jtprod called for a problem, use sum_counters.
using ADNLPModels, LinearAlgebra, NLPModels
nlp = ADNLPModel(x -> dot(x, x), zeros(2))
obj(nlp, rand(2))
grad(nlp, rand(2))
sum_counters(nlp)2Querying problem type
There are some utility functions for querying the problem type:
has_bounds: True when not all variables are free.bound_constrained: True for problems with bounded variables and no other constraints.equality_constrained: True when problem is constrained only by equalities.has_equalities: True when problem has at least one equality constraint.inequality_constrained: True when problem is constrained by inequalities.has_inequalities: True when problem has at least one inequality constraint that isn't a bound.linearly_constrained: True when problem is constrained by equalities or inequalities known to be linear.unconstrained: True when problem is not constrained.