The {optimizeR} package provides an object-oriented framework for
optimizer functions in R and adds convenience features for minimization
and maximization.
You probably do not need this package if you…
- already know which optimizer you want to use and are comfortable with its constraints, such as minimization only over the first function argument;
- want to compare optimizers that are already covered by
{optimx}, a framework for comparing about 30 optimizers; - are searching for new optimization algorithms, because this package does not implement optimizer functions itself.
You might find the package useful if you want to…
- compare optimizer functions not covered by
{optimx}or other frameworks (see the CRAN Task View: Optimization and Mathematical Programming for an overview); - have consistently named inputs and outputs across different optimizers;
- view optimizers as objects, which can help when implementing packages that depend on optimization;
- use optimizers for both minimization and maximization,
- optimize over more than one function argument,
- measure computation time or set a time limit for long optimization tasks.
How to use the package?
The following demo is a bit artificial, but it showcases the package purpose. Assume we want to
- maximize a function over two of its arguments,
- interrupt optimization if it exceeds 10 seconds,
- compare the performance of
stats::nlmandpracma::nelder_mead.
We can do this task with {optimizeR}. You can install the released
package version from CRAN with:
install.packages("optimizeR")Then load the package via library("optimizeR").
1. Define the objective function
Let