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.
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)
2
Querying problem type
There are some variable 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.
Docs
Missing docstring for Counters
. Check Documenter's build log for details.
NLPModels.neval_obj
— Functionneval_obj(nlp)
Get the number of obj
evaluations.
NLPModels.neval_grad
— Functionneval_grad(nlp)
Get the number of grad
evaluations.
NLPModels.neval_cons
— Functionneval_cons(nlp)
Get the number of cons
evaluations.
NLPModels.neval_cons_lin
— Functionneval_cons_lin(nlp)
Get the number of cons
evaluations.
NLPModels.neval_cons_nln
— Functionneval_cons_nln(nlp)
Get the number of cons
evaluations.
NLPModels.neval_jcon
— Functionneval_jcon(nlp)
Get the number of jcon
evaluations.
NLPModels.neval_jgrad
— Functionneval_jgrad(nlp)
Get the number of jgrad
evaluations.
NLPModels.neval_jac
— Functionneval_jac(nlp)
Get the number of jac
evaluations.
NLPModels.neval_jac_lin
— Functionneval_jac_lin(nlp)
Get the number of jac
evaluations.
NLPModels.neval_jac_nln
— Functionneval_jac_nln(nlp)
Get the number of jac
evaluations.
NLPModels.neval_jprod
— Functionneval_jprod(nlp)
Get the number of jprod
evaluations.
NLPModels.neval_jprod_lin
— Functionneval_jprod_lin(nlp)
Get the number of jprod
evaluations.
NLPModels.neval_jprod_nln
— Functionneval_jprod_nln(nlp)
Get the number of jprod
evaluations.
NLPModels.neval_jtprod
— Functionneval_jtprod(nlp)
Get the number of jtprod
evaluations.
NLPModels.neval_jtprod_lin
— Functionneval_jtprod_lin(nlp)
Get the number of jtprod
evaluations.
NLPModels.neval_jtprod_nln
— Functionneval_jtprod_nln(nlp)
Get the number of jtprod
evaluations.
NLPModels.neval_hess
— Functionneval_hess(nlp)
Get the number of hess
evaluations.
NLPModels.neval_hprod
— Functionneval_hprod(nlp)
Get the number of hprod
evaluations.
NLPModels.neval_jhess
— Functionneval_jhess(nlp)
Get the number of jhess
evaluations.
NLPModels.neval_jhprod
— Functionneval_jhprod(nlp)
Get the number of jhprod
evaluations.
NLPModels.neval_residual
— Functionneval_residual(nlp)
Get the number of residual
evaluations.
NLPModels.neval_jac_residual
— Functionnevaljacresidual(nlp)
Get the number of jac
evaluations.
NLPModels.neval_jprod_residual
— Functionnevaljprodresidual(nlp)
Get the number of jprod
evaluations.
NLPModels.neval_jtprod_residual
— Functionnevaljtprodresidual(nlp)
Get the number of jtprod
evaluations.
NLPModels.neval_hess_residual
— Functionnevalhessresidual(nlp)
Get the number of hess
evaluations.
NLPModels.neval_jhess_residual
— Functionnevaljhessresidual(nlp)
Get the number of jhess
evaluations.
NLPModels.neval_hprod_residual
— Functionnevalhprodresidual(nlp)
Get the number of hprod
evaluations.
NLPModels.sum_counters
— Functionsum_counters(counters)
Sum all counters of counters
except cons
, jac
, jprod
and jtprod
.
sum_counters(nlp)
Sum all counters of problem nlp
except cons
, jac
, jprod
and jtprod
.
NLPModels.bound_constrained
— Functionbound_constrained(nlp)
bound_constrained(meta)
Returns whether the problem has bounds on the variables and no other constraints.
NLPModels.equality_constrained
— Functionequality_constrained(nlp)
equality_constrained(meta)
Returns whether the problem's constraints are all equalities. Unconstrained problems return false.
NLPModels.has_equalities
— Functionhas_equalities(nlp)
Returns whether the problem has constraints and at least one of them is an equality. Unconstrained problems return false.
NLPModels.has_bounds
— Functionhas_bounds(nlp)
has_bounds(meta)
Returns whether the problem has bounds on the variables.
NLPModels.inequality_constrained
— Functioninequality_constrained(nlp)
inequality_constrained(meta)
Returns whether the problem's constraints are all inequalities. Unconstrained problems return true.
NLPModels.has_inequalities
— Functionhas_inequalities(nlp)
Returns whether the problem has constraints and at least one of them is an inequality. Unconstrained problems return false.
NLPModels.linearly_constrained
— Functionlinearly_constrained(nlp)
linearly_constrained(meta)
Returns whether the problem's constraints are known to be all linear.
NLPModels.unconstrained
— Functionunconstrained(nlp)
unconstrained(meta)
Returns whether the problem in unconstrained.