testFunctions: Classical Test Functions for Unconstrained Optimisation

Description Usage Arguments Details Value Warning Author(s) References See Also Examples

Description

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

Usage

1
2
3
4
5
6
7

Arguments

x

a numeric vector of arguments. See Details.

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(-0.2 * sqrt(sum(x^2)/n)) - exp(sum(cos(2 * pi * x))/n)

The minimum function value is zero; reached at x = 0.

The Eggholder takes a two-dimensional x, here written as x and y. It is defined as

-(y + 47) * sin(sqrt(abs(y + x/2 + 47))) - x * sin(sqrt(abs(x - (y + 47))))

The minimum function value is -959.6407; reached at c(512, 404.2319).

The Griewank function is given by

sum(x^2)/4000 - prod(cos(x/sqrt(1:n))) + 1

The function is minimised at x = 0; its minimum value is zero.

The Rastrigin function:

10*n + sum(x^2 - 10 * cos(2 * pi * x))

The minimum function value is zero; reached at x = 0.

The Rosenbrock (or banana) function:

sum(100*(x[2:n] - x[1:(n - 1)]^2)^2 + (1 - x[1:(n - 1)])^2)

The minimum function value is zero; reached at x = 1.

The Schwefel function:

sum(-x * sin(sqrt(abs(x))))

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(50 * x)) + sin(60 * exp(y)) + sin(70 * sin(x)) + sin(sin(80 * y)) - sin(10 * (x + y)) + (x^2 + y^2)/4

The minimum function value is -3.3069; reached at c(-0.0244, 0.2106).

Value

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

Warning

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.

Author(s)

Enrico Schumann

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)

Schumann, E. (2016) Financial Optimisation with R (NMOF Manual). http://enricoschumann.net/NMOF.htm#NMOFmanual

See Also

DEopt, PSopt

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## 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)

enricoschumann/NMOF documentation built on June 5, 2019, 8:56 a.m.