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_jconOne constraint - unused
neval_jgradGradient of one constraints - unused
neval_jacJacobian
neval_jprodProduct of Jacobian and vector
neval_jtprodProduct of transposed 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 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)
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.bound_constrainedFunction
bound_constrained(nlp)
bound_constrained(meta)

Returns whether the problem has bounds on the variables and no other constraints.

source
NLPModels.equality_constrainedFunction
equality_constrained(nlp)
equality_constrained(meta)

Returns whether the problem's constraints are all equalities. Unconstrained problems return false.

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.inequality_constrainedFunction
inequality_constrained(nlp)
inequality_constrained(meta)

Returns whether the problem's constraints are all inequalities. Unconstrained problems return true.

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