Optimize niche model using a compiled XPtr backend
Source:R/optimize_niche_xptr.R
optimize_niche_xptr.RdRuns ucminfcpp::ucminf_xptr() over a compiled C++ objective function created by create_niche_obj_ptr(). Supports single-start and multi-start optimization. Ensures that all starting vectors are numeric doubles and finite.
Usage
optimize_niche_xptr(
start = NULL,
xptr,
control = ucminfcpp::ucminf_control(grad = "central", gradstep = c(1e-06, 1e-08),
maxeval = 200),
multi_start = FALSE
)Value
A list with:
par — best parameter vector
value — negative log-likelihood
conv — convergence code
all_results — (multi-start only) table of all runs
Examples
# \donttest{
## optimize_niche() uses optimize_niche_xptr() internally;
## call it directly for full control over each optimization run:
fit <- optimize_niche(
env_occ = example_env_occ_3d,
env_m = example_env_m_3d,
num_starts = 3L,
likelihood = "ip_weighted"
)
fit$best$value
#> NULL
# }