Tools

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 NLPModels, LinearAlgebra
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_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 NLPModels, LinearAlgebra
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

NLPModels.neval_objFunction.

NLPModels.neval_obj(nlp)

Get the number of obj evaluations.

NLPModels.neval_gradFunction.

NLPModels.neval_grad(nlp)

Get the number of grad evaluations.

NLPModels.neval_consFunction.

NLPModels.neval_cons(nlp)

Get the number of cons evaluations.

NLPModels.neval_jconFunction.

NLPModels.neval_jcon(nlp)

Get the number of jcon evaluations.

NLPModels.neval_jgradFunction.

NLPModels.neval_jgrad(nlp)

Get the number of jgrad evaluations.

NLPModels.neval_jacFunction.

NLPModels.neval_jac(nlp)

Get the number of jac evaluations.

NLPModels.neval_jprodFunction.

NLPModels.neval_jprod(nlp)

Get the number of jprod evaluations.

NLPModels.neval_jtprod(nlp)

Get the number of jtprod evaluations.

NLPModels.neval_hessFunction.

NLPModels.neval_hess(nlp)

Get the number of hess evaluations.

NLPModels.neval_hprodFunction.

NLPModels.neval_hprod(nlp)

Get the number of hprod evaluations.

NLPModels.neval_jhprod(nlp)

Get the number of jhprod evaluations.

NLPModels.neval_residual(nlp)

Get the number of residual evaluations.

NLPModels.neval_jac_residual(nlp)

Get the number of jac evaluations.

NLPModels.neval_jprod_residual(nlp)

Get the number of jprod evaluations.

NLPModels.neval_jtprod_residual(nlp)

Get the number of jtprod evaluations.

NLPModels.neval_hess_residual(nlp)

Get the number of hess evaluations.

NLPModels.neval_jhess_residual(nlp)

Get the number of jhess evaluations.

NLPModels.neval_hprod_residual(nlp)

Get the number of hprod evaluations.

sum_counters(counters)

Sum all counters of counters.

sum_counters(nlp)

Sum all counters of problem nlp.

bound_constrained(nlp)
bound_constrained(meta)

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

equality_constrained(nlp)
equality_constrained(meta)

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

NLPModels.has_boundsFunction.
has_bounds(nlp)
has_bounds(meta)

Returns whether the problem has bounds on the variables.

inequality_constrained(nlp)
inequality_constrained(meta)

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

linearly_constrained(nlp)
linearly_constrained(meta)

Returns whether the problem's constraints are known to be all linear.

unconstrained(nlp)
unconstrained(meta)

Returns whether the problem in unconstrained.