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)
100

Some counters are available for all models, some are specific. In particular, there are additional specific counters for the nonlinear least squares models.

CounterDescription
neval_objObjective
neval_gradGradient
neval_consConstraints
neval_cons_linLinear constraints
neval_cons_nlnNonlinear constraints
neval_jconOne constraint - unused
neval_jgradGradient of one constraints - unused
neval_jacJacobian
neval_jac_linLinear constraints Jacobian
neval_jac_nlnNonlinear constraints Jacobian
neval_jprodProduct of Jacobian and vector
neval_jprod_linProduct of linear constraints Jacobian and vector
neval_jprod_nlnProduct of nonlinear constraints Jacobian and vector
neval_jtprodProduct of transposed Jacobian and vector
neval_jtprod_linProduct of transposed linear constraints Jacobian and vector
neval_jtprod_nlnProduct of transposed nonlinear constraints Jacobian and vector
neval_hessHessian
neval_hprodProduct of Hessian and vector
neval_jhessIndividual Lagrangian Hessian evaluations
neval_jhprodProduct of Hessian of j-th function and vector
neval_residualResidual function of nonlinear least squares model
neval_jac_residualJacobian of the residual
neval_jprod_residualProduct of Jacobian of residual and vector
neval_jtprod_residualProduct of transposed Jacobian of residual and vector
neval_hess_residualSum of Hessians of residuals
neval_jhess_residualHessian of a residual component
neval_hprod_residualProduct 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))
sum_counters(nlp)
2

Querying problem type

There are some variable for querying the problem type:

Docs

Missing docstring.

Missing docstring for Counters. Check Documenter's build log for details.

NLPModels.sum_countersFunction
sum_counters(counters)

Sum all counters of counters except cons, jac, jprod and jtprod.

source
sum_counters(nlp)

Sum all counters of problem nlp except cons, jac, jprod and jtprod.

source
NLPModels.has_equalitiesFunction
has_equalities(nlp)

Returns whether the problem has constraints and at least one of them is an equality. Unconstrained problems return false.

source
NLPModels.has_inequalitiesFunction
has_inequalities(nlp)

Returns whether the problem has constraints and at least one of them is an inequality. Unconstrained problems return false.

source