Skip to contents

NLPModels is the module binding that OptimizationNLPModels reexports: a list holding the evaluation API of NLPModels.jl, reached as NLPModels$obj(nlp, x). It contains obj, grad, objgrad, objcons, cons, jac, jac_coord, jac_structure, jprod, jtprod, hess (dense), hess_coord, hess_structure, hprod, the least squares functions residual, jac_residual, jprod_residual, jtprod_residual, the counter readers neval_obj, neval_grad, ... and sum_counters, increment!, decrement!, reset!, the predicates has_bounds, bound_constrained, unconstrained, linearly_constrained, equality_constrained, inequality_constrained, has_equalities, has_inequalities, the metadata readers get_nvar, get_ncon, ..., nls_meta, coo_prod and coo_sym_prod. Evaluations update the counters of the model as in NLPModels.jl; the functions of an NLPModelsAdaptor() do not count, as in OptimizationNLPModels.

Usage

NLPModels

Format

A named list of functions.

Examples

meta <- NLPModelMeta(2, ncon = 1, lcon = 0, ucon = Inf)
nlp <- AbstractNLPModel(meta, obj = function(x) sum(x^2), cons = function(x) x[1] + x[2] - 1)
NLPModels$cons(nlp, c(1, 2))
#> [1] 2
NLPModels$jac(nlp, c(1, 2))
#>      [,1] [,2]
#> [1,]    1    1
NLPModels$neval_cons(nlp)
#> [1] 1
NLPModels$has_inequalities(nlp)
#> [1] TRUE