The {ino}
package provides tools for the analysis of the
initialization for numerical optimization in R. For detailed examples
and usage instructions, please refer to the
vignettes accompanying the
package.
You can install the released version from CRAN with:
install.packages("ino")
And the development version from GitHub with:
# install.packages("devtools")
devtools::install_github("loelschlaeger/ino")
The Ackley function has multiple local minima and one global minimum in the origin.
f_ackley <- function(x) {
stopifnot(is.numeric(x), length(x) == 2)
-20 * exp(-0.2 * sqrt(0.5 * (x[1]^2 + x[2]^2))) -
exp(0.5 * (cos(2 * pi * x[1]) + cos(2 * pi * x[2]))) + exp(1) + 20
}
f_ackley(c(0, 0))
#> [1] 0
The optimization result depends on the initial value:
library("ino")
Nop$new(f = f_ackley, npar = 2)$
set_optimizer(optimizer_nlm())$
optimize(initial = "random", runs = 100, verbose = FALSE)$
optima()
#> value frequency
#> 1 0 39
#> 2 2.58 34
#> 3 3.57 12
#> 4 5.38 6
#> 5 4.88 5
#> 6 6.56 2
#> 7 6.88 2
Have a question, found a bug, request a feature, want to contribute? Please file an issue.