Learn R Programming

NMOF (version 0.20-0)

testFunctions: Classical Test Functions for Unconstrained Optimisation

Description

A number of functions that have been suggested in the literature as benchmarks for unconstrained optimisation.

Usage

tfAckley(x)
tfGriewank(x)
tfRastrigin(x)
tfRosenbrock(x)
tfSchwefel(x)
tfTrefethen(x)

Arguments

x
a numeric vector of arguments. See Details.

Value

  • The objective function evaluated at x (a numeric vector of length one).

concept

Test functions for global optimisation

Warning

These test functions are artificial problems. It is typically not too helpful to fine-tune a method on such functions. (This would be like memorising all the answers for a particular multiple-choice test.) The functions' main purpose is checking the numerical implementation of algorithms.

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 $$\exp(1) + 20 -20 \exp{\left(-0.2 \sqrt{\frac{1}{n}\sum_{i=1}^n x_i^2}\right)} - \exp{\left(\frac{1}{n}\sum_{i=1}^n \cos(2 \pi x_i)\right)}\,.$$ The minimum function value is zero; reached at $x=0$. The Griewank function is given by $$1+\frac{1}{4000} \sum^n_{i=1} x_i^2 - \prod_{i=1}^n \cos \left(\frac{x_i}{\sqrt{i}}\right)\,.$$ The function is minimised at $x=0$; its minimum value is zero. The Rastrigin function: $$10n + \sum_{i=1}^n \left(x_i^2 -10\cos(2\pi x_i)\right)\,.$$ The minimum function value is zero; reached at $x=0$. The Rosenbrock (or banana) function: $$\sum_{i=1}^{n-1}\left(100 (x_{i+1}-x_i^2)^2 + (1-x_i)^2\right)\,.$$ The minimum function value is zero; reached at $x=1$. The Schwefel function: $$\sum_{i=1}^n \left(-x_i \sin\left(\sqrt{|x_i|}\right)\right)\,.$$ The minimum function value (to about 8 digits) is $-418.9829n$; reached at $x = 420.9687$. Trefethen's function takes a two-dimensional x (here written as $x$ and $y$); it is defined as $$\exp(\sin(50x)) + \sin(60 e^y) + \sin(70 \sin(x)) + \sin(\sin(80y)) - \sin(10(x+y)) + \frac{1}{4}(x^2+y^2)\,.$$ The minimum function value is -3.3069; reached at c(-0.0244, 0.2106).

References

Gilli, M., Maringer, D. and Schumann, E. (2011) Numerical Methods and Optimization in Finance. Elsevier. http://www.elsevierdirect.com/product.jsp?isbn=9780123756626 (Chapter 10)

See Also

DEopt, PSopt

Examples

Run this code
## 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 1L:n) for (j in 1L: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 1L:n) for (j in 1L: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)

Run the code above in your browser using DataLab