Unconstrained numerical optimization algorithms implemented in R.
mize can be used as a standalone optimizer like stats::optim(), or it can
be integrated into other packages by creating a stateful optimizer and handling
iterations, convergence, and logging externally.
mize includes Broyden-Fletcher-Goldfarb-Shanno (BFGS), limited-memory BFGS
(L-BFGS), conjugate gradient (CG), Nesterov accelerated gradient (NAG),
momentum-based methods, and related line searches.
Installation
install.packages("mize")Install the development version from GitHub with:
# install.packages("pak") pak::pak("jlmelville/mize")
Quick Start
library(mize) rosenbrock_fg <- list( fn = function(x) { 100 * (x[2] - x[1] * x[1])^2 + (1 - x[1])^2 }, gr = function(x) { c( -400 * x[1] * (x[2] - x[1] * x[1]) - 2 * (1 - x[1]), 200 * (x[2] - x[1] * x[1]) ) } ) res <- mize(c(-1.2, 1), rosenbrock_fg, method = "L-BFGS") res$par res$f
For stateful optimization, create an optimizer and call mize_step() manually:
opt <- make_mize(method = "L-BFGS", par = c(-1.2, 1), fg = rosenbrock_fg) par <- c(-1.2, 1) for (i in seq_len(30)) { step <- mize_step(opt, par, rosenbrock_fg) par <- step$par opt <- step$opt }
Documentation
The package website is https://jlmelville.github.io/mize/.
Start with:
The CRAN package also includes the main vignettes.
See Also
The Wolfe line searches use conversions of Mark Schmidt's minFunc routines, Carl Edward Rasmussen's Matlab code, and Dianne O'Leary's Matlab translation of the More-Thuente line search algorithm from MINPACK.
I also maintain the funconstrain package, which contains test problems for numerical optimization.
License
Acknowledgments
I am grateful to Hans Werner Borchers, who provided assistance and encouragement in getting mize onto CRAN.