Test function module#

References

Parent class#

class nubo.test_functions.test_functions.TestFunction[source]#

Bases: object

Parent class for all test functions.

Methods

__call__(x)

Call eval method of the test function.

Ackley function#

class nubo.test_functions.ackley.Ackley(dims: int, noise_std: float | None = 0.0, minimise: bool | None = True)[source]#

Bases: TestFunction

\(d\)-dimensional Ackley function.

The Ackley function has many local minima and one global minimum \(f(\boldsymbol x^*) = 0\) at \(\boldsymbol x^* = (0, ..., 0)\). It is usually evaluated on the hypercube \(\boldsymbol x \in [-32.768, 32.768]^d\).

\[f(\boldsymbol x) = -a \exp \left(-b \sqrt{\frac{1}{d} \sum^d_{i=1} x^2_i}\right) - \exp \left( \frac{1}{d} \sum^d_{i=1} \cos(c x_i)\right) + a + \exp(1),\]

where \(a = 20\), \(b = 0.2\), and \(c = 2\pi\).

Attributes:
dimsint

Number of input dimensions.

noise_stdfloat

Standard deviation of Gaussian noise.

minimisebool

Minimisation problem if true, maximisation problem if false.

boundstorch.Tensor

(size 2 x dims) Bounds of input space.

optimumdict

Contains inputs and output of global maximum.

afloat

Function parameter.

bfloat

Function parameter.

cfloat

Function parameter.

Methods

eval(x)

Compute output of Ackley function for some test points x.

eval(x: Tensor) Tensor[source]#

Compute output of Ackley function for some test points x.

Parameters:
xtorch.Tensor

(size n x dims) Test points.

Dixon-Price function#

class nubo.test_functions.dixonprice.DixonPrice(dims: int, noise_std: float | None = 0.0, minimise: bool | None = True)[source]#

Bases: TestFunction

\(d\)-dimensional Dixon-Price function.

The Dixon-Price function is valley-shaped and has one global minimum \(f(\boldsymbol x^*) = 0\) at \(x^*_i = 2^{-\frac{2^i-2}{2^i}}\), for all \(i = 1, ..., d\). It is usually evaluated on the hypercube \(\boldsymbol x \in [-10, 10]^d\).

\[f(\boldsymbol x) = (x_1 - 1)^2 + \sum_{i=2}^d i (2x_i^2 - x_{i-1})^2.\]
Attributes:
dimsint

Number of input dimensions.

noise_stdfloat

Standard deviation of Gaussian noise.

minimisebool

Minimisation problem if true, maximisation problem if false.

boundstorch.Tensor

(size 2 x dims) Bounds of input space.

optimumdict

Contains inputs and output of global maximum.

Methods

eval(x)

Compute output of Dixon-Price function for some test points x.

eval(x: Tensor) Tensor[source]#

Compute output of Dixon-Price function for some test points x.

Parameters:
xtorch.Tensor

(size n x dims) Test points.

Griewank function#

class nubo.test_functions.griewank.Griewank(dims: int, noise_std: float | None = 0.0, minimise: bool | None = True)[source]#

Bases: TestFunction

\(d\)-dimensional Griewank function.

The Griewank function has many local minima and one global minimum \(f(\boldsymbol x^*) = 0\) at \(\boldsymbol x^* = (0, ..., 0)\). It is usually evaluated on the hypercube \(\boldsymbol x \in [-600, 600]^d\).

\[f(\boldsymbol x) = \sum_{i=1}^d \frac{x_i^2}{4000} - \prod_{i=1}^d \cos \left( \frac{x_i}{\sqrt{i}} \right) + 1.\]
Attributes:
dimsint

Number of input dimensions.

noise_stdfloat

Standard deviation of Gaussian noise.

minimisebool

Minimisation problem if true, maximisation problem if false.

boundstorch.Tensor

(size 2 x dims) Bounds of input space.

optimumdict

Contains inputs and output of global maximum.

Methods

eval(x)

Compute output of Griewank function for some test points x.

eval(x: Tensor) Tensor[source]#

Compute output of Griewank function for some test points x.

Parameters:
xtorch.Tensor

(size n x dims) Test points.

Hartmann function#

class nubo.test_functions.hartmann.Hartmann3D(noise_std: float | None = 0.0, minimise: bool | None = True)[source]#

Bases: TestFunction

3-dimensional Hartmann function.

The 3-dimensional Hartmann function has four local minima and one global minimum \(f(\boldsymbol x^*) = -3.86278\) at \(\boldsymbol x^* = (0.114614, 0.555649, 0.852547)\). It is usually evaluated on the hypercube \(\boldsymbol x \in (0, 1)^3\).

\[f(\boldsymbol x) = - \sum_{i=1}^4 \alpha_i \exp \left( - \sum_{j=1}^3 A_{ij} (x_j - P_{ij})^2 \right),\]

where

\[\alpha = (1.0, 1.2, 3.0, 3.2)^T,\]
\[\begin{split}\boldsymbol A = \begin{pmatrix} 3.0 & 10.0 & 30.0 \\ 0.1 & 10.0 & 35.0 \\ 3.0 & 10.0 & 30.0 \\ 0.1 & 10.0 & 35.0 \end{pmatrix},\end{split}\]
\[\begin{split}\text{and } \boldsymbol P = 10^{-4} \begin{pmatrix} 3689 & 1170 & 2673 \\ 4699 & 4387 & 7470 \\ 1091 & 8732 & 5547 \\ 381 & 5743 & 8828 \end{pmatrix}.\end{split}\]
Attributes:
dimsint

Number of input dimensions.

noise_stdfloat

Standard deviation of Gaussian noise.

minimisebool

Minimisation problem if true, maximisation problem if false.

boundstorch.Tensor

(size 2 x dims) Bounds of input space.

optimumdict

Contains inputs and output of global maximum.

atorch.Tensor

(size 4 x 1) Function parameters.

Atorch.Tensor

(size 4 x 3) Function parameters.

Ptorch.Tensor

(size 4 x 3) Function parameters.

Methods

eval(x)

Compute output of Hartmann function for some test points x.

eval(x: Tensor) Tensor[source]#

Compute output of Hartmann function for some test points x.

Parameters:
xtorch.Tensor

(size n x dims) Test points.

class nubo.test_functions.hartmann.Hartmann6D(noise_std: float | None = 0.0, minimise: bool | None = True)[source]#

Bases: TestFunction

6-dimensional Hartmann function.

The 6-dimensional Hartmann function has six local minima and one global minimum \(f(\boldsymbol x^*) = -3.32237\) at \(\boldsymbol x^* = (0.20169, 0.150011, 0.476874, 0.275332, 0.311652, 0.6573)\). It is usually evaluated on the hypercube \(\boldsymbol x \in (0, 1)^6\).

\[f(\boldsymbol x) = - \sum_{i=1}^4 \alpha_i \exp \left( - \sum_{j=1}^6 A_{ij} (x_j - P_{ij})^2 \right),\]

where

\[\alpha = (1.0, 1.2, 3.0, 3.2)^T,\]
\[\begin{split}\boldsymbol A = \begin{pmatrix} 10.00 & 3.00 & 17.00 & 3.50 & 1.70 & 8.00 \\ 0.05 & 10.00 & 17.00 & 0.10 & 8.00 & 14.00 \\ 3.00 & 3.50 & 1.70 & 10.00 & 17.00 & 8.00 \\ 17.00 & 8.00 & 0.05 & 10.00 & 0.10 & 14.00 \end{pmatrix},\end{split}\]
\[\begin{split}\text{and } \boldsymbol P = 10^{-4} \begin{pmatrix} 1312 & 1696 & 5569 & 124 & 8283 & 5886 \\ 2329 & 4135 & 8307 & 3736 & 1004 & 9991 \\ 2348 & 1451 & 3522 & 2883 & 3047 & 6650 \\ 4047 & 8828 & 8732 & 5743 & 1091 & 381 \end{pmatrix}.\end{split}\]
Attributes:
dimsint

Number of input dimensions.

noise_stdfloat

Standard deviation of Gaussian noise.

minimisebool

Minimisation problem if true, maximisation problem if false.

boundstorch.Tensor

(size 2 x dims) Bounds of input space.

optimumdict

Contains inputs and output of global maximum.

atorch.Tensor

(size 4 x 1) Function parameters.

Atorch.Tensor

(size 4 x 6) Function parameters.

Ptorch.Tensor

(size 4 x 6) Function parameters.

Methods

eval(x)

Compute output of Hartmann function for some test points x.

eval(x: Tensor) Tensor[source]#

Compute output of Hartmann function for some test points x.

Parameters:
xtorch.Tensor

(size n x dims) Test points.

Levy function#

class nubo.test_functions.levy.Levy(dims: int, noise_std: float | None = 0.0, minimise: bool | None = True)[source]#

Bases: TestFunction

\(d\)-dimensional Levy function.

The Levy function has many local minima and one global minimum \(f(\boldsymbol x^*) = 0\) at \(\boldsymbol x^* = (1, ..., 1)\). It is usually evaluated on the hypercube \(\boldsymbol x \in [-10, 10]^d\).

\[f(\boldsymbol x) = \sin^2 (\pi w_1) + \sum_{i=1}^{d-1} (w_i - 1)^2 [1 + 10 \sin^2 (\pi w_i + 1)] + (w_d - 1)^2 [1 + \sin^2(2\pi w_d)],\]

where \(w_i = 1 + \frac{x_i - 1}{4}\), for all \(i = 1, ..., d\).

Attributes:
dimsint

Number of input dimensions.

noise_stdfloat

Standard deviation of Gaussian noise.

minimisebool

Minimisation problem if true, maximisation problem if false.

boundstorch.Tensor

(size 2 x dims) Bounds of input space.

optimumdict

Contains inputs and output of global maximum.

Methods

eval(x)

Compute output of Levy function for some test points x.

eval(x: Tensor) Tensor[source]#

Compute output of Levy function for some test points x.

Parameters:
xtorch.Tensor

(size n x dims) Test points.

Rastrigin function#

class nubo.test_functions.rastrigin.Rastrigin(dims: int, noise_std: float | None = 0.0, minimise: bool | None = True)[source]#

Bases: TestFunction

\(d\)-dimensional Rastrigin function.

The Rastrigin function has many local minima and one global minimum \(f(\boldsymbol x^*) = 0\) at \(\boldsymbol x^* = (0, ..., 0)\). It is usually evaluated on the hypercube \(\boldsymbol x \in [-5.12, 5.12]^d\).

\[f(\boldsymbol x) = 10d + \sum_{i-1}^d [x_i^2 - 10 \cos(2 \pi x_i)].\]
Attributes:
dimsint

Number of input dimensions.

noise_stdfloat

Standard deviation of Gaussian noise.

minimisebool

Minimisation problem if true, maximisation problem if false.

boundstorch.Tensor

(size 2 x dims) Bounds of input space.

optimumdict

Contains inputs and output of global maximum.

Methods

eval(x)

Compute output of Rastrigin function for some test points x.

eval(x: Tensor) Tensor[source]#

Compute output of Rastrigin function for some test points x.

Parameters:
xtorch.Tensor

(size n x dims) Test points.

Schwefel function#

class nubo.test_functions.schwefel.Schwefel(dims: int, noise_std: float | None = 0.0, minimise: bool | None = True)[source]#

Bases: TestFunction

\(d\)-dimensional Schwefel function.

The Schwefel function has many local minima and one global minimum \(f(\boldsymbol x^*) = 0\) at \(\boldsymbol x^* = (420.9687, ..., 420.9687)\). It is usually evaluated on the hypercube \(\boldsymbol x \in [-500, 500]^d\).

\[f(\boldsymbol x) = 418.9829 d - \sum_{i=1}^d x_i \sin (\sqrt{\lvert x_i \rvert}).\]
Attributes:
dimsint

Number of input dimensions.

noise_stdfloat

Standard deviation of Gaussian noise.

minimisebool

Minimisation problem if true, maximisation problem if false.

boundstorch.Tensor

(size 2 x dims) Bounds of input space.

optimumdict

Contains inputs and output of global maximum.

Methods

eval(x)

Compute output of Schwefel function for some test points x.

eval(x: Tensor) Tensor[source]#

Compute output of Schwefel function for some test points x.

Parameters:
xtorch.Tensor

(size n x dims) Test points.

Sphere function#

class nubo.test_functions.sphere.Sphere(dims: int, noise_std: float | None = 0.0, minimise: bool | None = True)[source]#

Bases: TestFunction

\(d\)-dimensional Sphere function.

The Sphere function is bowl-shaped and has one global minimum \(f(\boldsymbol x^*) = 0\) at \(\boldsymbol x^* = (0, ..., 0)\). It is usually evaluated on the hypercube \(\boldsymbol x \in [-5.12, 5.12]^d\).

\[f(\boldsymbol x) = \sum_{i=1}^d x_i^2.\]
Attributes:
dimsint

Number of input dimensions.

noise_stdfloat

Standard deviation of Gaussian noise.

minimisebool

Minimisation problem if true, maximisation problem if false.

boundstorch.Tensor

(size 2 x dims) Bounds of input space.

optimumdict

Contains inputs and output of global maximum.

Methods

eval(x)

Compute output of Sphere function for some test points x.

eval(x: Tensor) Tensor[source]#

Compute output of Sphere function for some test points x.

Parameters:
xtorch.Tensor

(size n x dims) Test points.

Sum Squares function#

class nubo.test_functions.sumsquares.SumSquares(dims: int, noise_std: float | None = 0.0, minimise: bool | None = True)[source]#

Bases: TestFunction

\(d\)-dimensional Sum Squares function.

The Sum Squares function is bowl-shaped and has one global minimum \(f(\boldsymbol x^*) = 0\) at \(\boldsymbol x^* = (0, ..., 0)\). It is usually evaluated on the hypercube \(\boldsymbol x \in [-10, 10]^d\).

\[f(\boldsymbol x) = \sum_{i=1}^d i x_i^2.\]
Attributes:
dimsint

Number of input dimensions.

noise_stdfloat

Standard deviation of Gaussian noise.

minimisebool

Minimisation problem if true, maximisation problem if false.

boundstorch.Tensor

(size 2 x dims) Bounds of input space.

optimumdict

Contains inputs and output of global maximum.

Methods

eval(x)

Compute output of Sum-of-Squares function for some test points x.

eval(x: Tensor) Tensor[source]#

Compute output of Sum-of-Squares function for some test points x.

Parameters:
xtorch.Tensor

(size n x dims) Test points.

Zakharov function#

class nubo.test_functions.zakharov.Zakharov(dims: int, noise_std: float | None = 0.0, minimise: bool | None = True)[source]#

Bases: TestFunction

\(d\)-dimensional Zakharov function.

The Zakharov function is plate-shaped and has one global minimum \(f(\boldsymbol x^*) = 0\) at \(\boldsymbol x^* = (0, ..., 0)\). It is usually evaluated on the hypercube \(\boldsymbol x \in [-5, 10]^d\).

\[f(\boldsymbol x) = \sum_{i=1}^d x_i^2 + \left( \sum_{i=1}^d 0.5 i x_i \right)^2 + \left( \sum_{i=1}^d 0.5 i x_i \right)^4.\]
Attributes:
dimsint

Number of input dimensions.

noise_stdfloat

Standard deviation of Gaussian noise.

minimisebool

Minimisation problem if true, maximisation problem if false.

boundstorch.Tensor

(size 2 x dims) Bounds of input space.

optimumdict

Contains inputs and output of global maximum.

Methods

eval(x)

Compute output of Zakharov function for some test points x.

eval(x: Tensor) Tensor[source]#

Compute output of Zakharov function for some test points x.

Parameters:
xtorch.Tensor

(size n x dims) Test points.