Classical Test Functions for Unconstrained Optimisation
A number of functions that have been suggested in the literature as benchmarks for unconstrained optimisation.
tfAckley(x) tfEggholder(x) tfGriewank(x) tfRastrigin(x) tfRosenbrock(x) tfSchwefel(x) tfTrefethen(x)
x
: a numeric vector of arguments. See Details.All functions take as argument only one variable, a numeric vector x
whose length determines the dimensionality of the problem.
The Ackley function is implemented as
The minimum function value is zero; reached at .
The Eggholder takes a two-dimensional x
, here written as and . It is defined as
The minimum function value is -959.6407; reached at c(512, 404.2319)
.
The Griewank function is given by
The function is minimised at ; its minimum value is zero.
The Rastrigin function:
The minimum function value is zero; reached at .
The Rosenbrock (or banana) function:
The minimum function value is zero; reached at .
The Schwefel function:
The minimum function value (to about 8 digits) is ; reached at .
Trefethen's function takes a two-dimensional x
(here written as and ); it is defined as
The minimum function value is -3.3069; reached at c(-0.0244, 0.2106)
.
The objective function evaluated at x
(a numeric vector of length one).
Gilli, M., Maringer, D. and Schumann, E. (2019) Numerical Methods and Optimization in Finance. 2nd edition. Elsevier. tools:::Rd_expr_doi("10.1016/C2017-0-01621-X")
Schumann, E. (2023) Financial Optimisation with R (NMOF
Manual). https://enricoschumann.net/NMOF.htm#NMOFmanual
Enrico Schumann
These test functions represent artificial problems. It is practically not too helpful to fine-tune a method on such functions. (That would be like memorising all the answers to a particular multiple-choice test.) The functions' main purpose is checking the numerical implementation of algorithms.
DEopt
, PSopt
## persp for two-dimensional x ## Ackley n <- 100L; surf <- matrix(NA, n, n) x1 <- seq(from = -2, to = 2, length.out = n) for (i in 1:n) for (j in 1:n) surf[i, j] <- tfAckley(c(x1[i], x1[j])) persp(x1, x1, -surf, phi = 30, theta = 30, expand = 0.5, col = "goldenrod1", shade = 0.2, ticktype = "detailed", xlab = "x1", ylab = "x2", zlab = "-f", main = "Ackley (-f)", border = NA) ## Trefethen n <- 100L; surf <- matrix(NA, n, n) x1 <- seq(from = -10, to = 10, length.out = n) for (i in 1:n) for (j in 1:n) surf[i, j] <- tfTrefethen(c(x1[i], x1[j])) persp(x1, x1, -surf, phi = 30, theta = 30, expand = 0.5, col = "goldenrod1", shade = 0.2, ticktype = "detailed", xlab = "x1", ylab = "x2", zlab = "-f", main = "Trefethen (-f)", border = NA)
Useful links