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.
Counter | Description |
---|---|
neval_obj | Objective |
neval_grad | Gradient |
neval_cons | Constraints |
neval_jcon | One constraint - unused |
neval_jgrad | Gradient of one constraints - unused |
neval_jac | Jacobian |
neval_jprod | Product of Jacobian and vector |
neval_jtprod | Product of transposed Jacobian and vector |
neval_hess | Hessian |
neval_hprod | Product of Hessian and vector |
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 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:
bound_constrained
: True for problems with bounded variables and no other constraints.equality_constrained
: True when problem is constrained only by equalities.has_bounds
: True when not all variables are free.inequality_constrained
: True when problem is constrained by inequalities.linearly_constrained
: True when problem is constrained by equalities or inequalities known to be linear.unconstrained
: True when problem is not constrained.
Docs
NLPModels.neval_obj
— Function.NLPModels.neval_obj(nlp)
Get the number of obj
evaluations.
NLPModels.neval_grad
— Function.NLPModels.neval_grad(nlp)
Get the number of grad
evaluations.
NLPModels.neval_cons
— Function.NLPModels.neval_cons(nlp)
Get the number of cons
evaluations.
NLPModels.neval_jcon
— Function.NLPModels.neval_jcon(nlp)
Get the number of jcon
evaluations.
NLPModels.neval_jgrad
— Function.NLPModels.neval_jgrad(nlp)
Get the number of jgrad
evaluations.
NLPModels.neval_jac
— Function.NLPModels.neval_jac(nlp)
Get the number of jac
evaluations.
NLPModels.neval_jprod
— Function.NLPModels.neval_jprod(nlp)
Get the number of jprod
evaluations.
NLPModels.neval_jtprod
— Function.NLPModels.neval_jtprod(nlp)
Get the number of jtprod
evaluations.
NLPModels.neval_hess
— Function.NLPModels.neval_hess(nlp)
Get the number of hess
evaluations.
NLPModels.neval_hprod
— Function.NLPModels.neval_hprod(nlp)
Get the number of hprod
evaluations.
NLPModels.neval_jhprod
— Function.NLPModels.neval_jhprod(nlp)
Get the number of jhprod
evaluations.
NLPModels.neval_residual
— Function.NLPModels.neval_residual(nlp)
Get the number of residual
evaluations.
NLPModels.neval_jac_residual
— Function.NLPModels.neval_jac_residual(nlp)
Get the number of jac
evaluations.
NLPModels.neval_jprod_residual
— Function.NLPModels.neval_jprod_residual(nlp)
Get the number of jprod
evaluations.
NLPModels.neval_jtprod_residual
— Function.NLPModels.neval_jtprod_residual(nlp)
Get the number of jtprod
evaluations.
NLPModels.neval_hess_residual
— Function.NLPModels.neval_hess_residual(nlp)
Get the number of hess
evaluations.
NLPModels.neval_jhess_residual
— Function.NLPModels.neval_jhess_residual(nlp)
Get the number of jhess
evaluations.
NLPModels.neval_hprod_residual
— Function.NLPModels.neval_hprod_residual(nlp)
Get the number of hprod
evaluations.
NLPModels.sum_counters
— Function.sum_counters(counters)
Sum all counters of counters
.
sum_counters(nlp)
Sum all counters of problem nlp
.
NLPModels.bound_constrained
— Function.bound_constrained(nlp)
bound_constrained(meta)
Returns whether the problem has bounds on the variables and no other constraints.
NLPModels.equality_constrained
— Function.equality_constrained(nlp)
equality_constrained(meta)
Returns whether the problem's constraints are all equalities. Unconstrained problems return false.
NLPModels.has_bounds
— Function.has_bounds(nlp)
has_bounds(meta)
Returns whether the problem has bounds on the variables.
NLPModels.inequality_constrained
— Function.inequality_constrained(nlp)
inequality_constrained(meta)
Returns whether the problem's constraints are all inequalities. Unconstrained problems return true.
NLPModels.linearly_constrained
— Function.linearly_constrained(nlp)
linearly_constrained(meta)
Returns whether the problem's constraints are known to be all linear.
NLPModels.unconstrained
— Function.unconstrained(nlp)
unconstrained(meta)
Returns whether the problem in unconstrained.