build_nlpmodel_meta(cache) returns the NLPModelMeta() of an
optimization cache (from init()) or problem: its variables and
starting point, the bounds of the variables (infinite when absent), the
bounds of the constraints, zero multipliers, the sense, and the sizes of
the dense Jacobian (ncon * nvar) and of the lower triangle of the
Hessian (nvar * (nvar + 1) / 2).
Usage
build_nlpmodel_meta(cache)
NLPModelsAdaptor(cache, meta = NULL, counters = Counters())Arguments
- cache
An
OptimizationCacheorOptimizationProblem.- meta
An
NLPModelMeta;build_nlpmodel_meta(cache)whenNULL.- counters
A
Counters()object.
Details
NLPModelsAdaptor(cache, meta, counters) exposes the cache as a model of
the NLPModels interface: NLPModels functions evaluate the objective,
gradient, constraints, dense Jacobian (column by column), lower triangle
of the Hessian of the Lagrangian and the Jacobian products of the
problem, as OptimizationNLPModels does for the solvers that take an
NLPModel.
Examples
prob <- OptimizationProblem(function(u, p) sum((u - p)^2), c(0, 0), c(1, 2),
lb = c(-5, -5), ub = c(5, 5))
cache <- init(prob, LBFGSB())
meta <- build_nlpmodel_meta(cache)
meta$nnzh; meta$irng
#> [1] 3
#> [1] 1 2
nlp <- NLPModelsAdaptor(cache, meta, Counters())
NLPModels$grad(nlp, c(0, 0))
#> [1] -2 -4
NLPModels$hess_coord(nlp, c(0, 0))
#> [1] 1.998156 0.000000 2.003078