benchmarking.functions namespace

Submodules

benchmarking.functions.BenchmarkingFunction module

class benchmarking.functions.BenchmarkingFunction.BenchmarkingFunction[source]

Bases: ABC

add_bound(bound: List[float]) None[source]
add_maximum(inputs: List[float], outputs: float, local: bool = False) None[source]
add_minimum(inputs: List[float], outputs: float, local: bool = False) None[source]
property bounds: List[List[float]]

Suggested boundaries to use.

property extrema: List[Optimum]

List of all extrema.

property global_extrema: List[Optimum]

List of global extrema.

property global_maxima: List[Optimum]

List of global maxima.

property global_minima: List[Optimum]

List of global minima.

property max: float | None

Get the value of the global maximum. Returns ‘None’ if there are no maxima listed for the function.

property maxima: List[Optimum]

List of all maxima.

property metadata: dict

Dictionary containing metadata about benchmarking function.

property min: float | None

Get the value of the global minimum. Returns ‘None’ if there are no minima listed for the function.

property minima: List[Optimum]

List of all minima.

property nmax: int

Number of global maxima.

property nmin: int

Number of global minima.

set_function(foo: Callable) None[source]

benchmarking.functions.Optimum module

class benchmarking.functions.Optimum.Optimum(coordinates: List[float], value: float)[source]

Bases: object

property coordinates: List[float]

Coordinates of the optimum.

property ndim: int

Number of dimensions (length of coordinates).

property value: float

Value of the optimum.

benchmarking.functions.beale module

class benchmarking.functions.beale.Beale[source]

Bases: BenchmarkingFunction

benchmarking.functions.beale.beale(xs: List[float]) float[source]

Beale optimization test function.

Beale function from https://www.sfu.ca/~ssurjano/beale.html.

Input domain: 2D square \(x_i = [-4.5, 4.5]\) for all i = 1, 2.

Function in LaTeX format:

\[f(x) = (1.5 - x_1 + x_1 x_2)^2 + (2.25 - x_1 + x_1 x_2^2)^2 + (2.625 - x_1 + x_1 x_2^3)^2\]
Parameters:

xs (List[float]) – Parameter list

Returns:

Result of calculation

Return type:

float

benchmarking.functions.booth module

class benchmarking.functions.booth.Booth[source]

Bases: BenchmarkingFunction

benchmarking.functions.booth.booth(xs: List[float]) float[source]

Booth optimization test function.

Booth function from https://www.sfu.ca/~ssurjano/booth.html.

Input domain: 2D square with bounds [-10, 10].

Function in LaTeX format:

\[f(x) = (x_1 + 2x_2 - 7)^2 + (2x_1 + x_2 - 5)^2\]
Parameters:

xs (List[float]) – Parameter list

Returns:

Result of calculation

Return type:

float

benchmarking.functions.branin module

class benchmarking.functions.branin.Branin[source]

Bases: BenchmarkingFunction

benchmarking.functions.branin.branin(xs: List[float], a: float = 1, b: float = 0.12918450914398066, c: float = 1.5915494309189535, r: float = 6, s: float = 10, t: float = 0.039788735772973836) float[source]

Branin, or Branin-Hoo, optimization test function.

Branin function with (by default) values of a, b, c, r, s, t: a = 1, b = 5.1 / (4 * pi^2), c = 5 / pi, r = 6, s = 10 and t = 1 / (8 * pi) from https://www.sfu.ca/~ssurjano/branin.html.

Function in LaTeX format:

\[f(x) = a(x_2 - bx_1^2 + cx_1 - r)^2 + s(1-t)cos(x_1) + s\]
Parameters:
  • xs (List[float]) – Input ‘x’ values.

  • a (float, optional) – ‘a’ parameter, defaults to 1

  • b (float, optional) – ‘b’ parameter, defaults to 5.1/(4 * np.pi**2)

  • c (float, optional) – ‘c’ parameter, defaults to 5/np.pi

  • r (float, optional) – ‘r’ parameter, defaults to 6

  • s (float, optional) – ‘s’ parameter, defaults to 10

  • t (float, optional) – ‘t’ parameter, defaults to 1/(8 * np.pi)

Returns:

Result of calculation.

Return type:

float

benchmarking.functions.bukin_n6 module

class benchmarking.functions.bukin_n6.BukinN6[source]

Bases: BenchmarkingFunction

benchmarking.functions.bukin_n6.bukin_n6(xs: List[float]) float[source]

Sixth Bukin function optimization test function.

Sixth Bukin function from https://www.sfu.ca/~ssurjano/bukin6.html.

Input domain: 2D rectangle \(x_1 = [-15, -5], x_2 = [-3, 3]\).

Function in LaTeX format:

\[f(x) = 100 \sqrt{|x_2 - 0.01 x_1^2|} + 0.01 |x_1 + 10|\]
Parameters:

xs (List[float]) – Parameter list

Returns:

Result of calculation

Return type:

float

benchmarking.functions.eggholder module

class benchmarking.functions.eggholder.Eggholder[source]

Bases: BenchmarkingFunction

benchmarking.functions.eggholder.eggholder(xs: List[float]) float[source]

Eggholder function optimization test function.

Eggholder function from https://www.sfu.ca/~ssurjano/egg.html.

Input domain: 2D square \(x_i = [-512, 512]\) for all i = 1, 2.

Function in LaTeX format:

\[f(x) = -(x_2 + 47) \sin{(\sqrt{|x_2 + \dfrac{x_1}{2} + 47|})} - x_1 \sin{(\sqrt{|x_1 - (x_2 + 47)|})}\]
Parameters:

xs (List[float]) – Parameter list

Returns:

Result of calculation

Return type:

float

benchmarking.functions.goldstein_price module

class benchmarking.functions.goldstein_price.GoldsteinPrice[source]

Bases: BenchmarkingFunction

benchmarking.functions.goldstein_price.goldstein_price(xs: List[float]) float[source]

Goldstein-Price optimization test function.

Goldstein-Price function from https://www.sfu.ca/~ssurjano/goldpr.html.

Function in LaTeX format:

\[f(x) = [1 + (x_1 + x_2 + 1)^2 (19 - 14 x_1 + 3 x_1^2 - 14 x_2 + 6 x_1 x_2 + 3 x_2^2)] \times [30 + (2 x_1 - 3 x_2)^2 (18 - 32 x_1 + 12 x_1^2 + 48 x_2 - 36 x_1 x_2 + 27 x_2^2)]\]
Parameters:

xs (List[float]) – Parameter list

Returns:

Result of calculation

Return type:

float

benchmarking.functions.hartmann module

class benchmarking.functions.hartmann.Hartmann3D[source]

Bases: BenchmarkingFunction

Hartmann 3-Dimensional Function

Source: https://www.sfu.ca/~ssurjano/hart3.html

class benchmarking.functions.hartmann.Hartmann6D[source]

Bases: BenchmarkingFunction

Hartmann 6-Dimensional Function

Source: https://www.sfu.ca/~ssurjano/hart6.html

benchmarking.functions.hartmann.hartmann(xs: List[float], alpha: ndarray = None, A: ndarray = None, P: ndarray = None) float[source]

Hartmann n-Dimensional optimization test function. This function supports 3 or 6 dimensions, and dimensions are inferred by the length of the xs parameter list.

Hartmann nD function with (by default) values of \(\alpha\), A, and P from https://www.sfu.ca/~ssurjano/hart3.html.

Function in LaTeX format:

\[f(x) = -\sum_{i=1}^{4} \alpha_i \exp{\bigg(-\sum_{j=1}^n A_{ij}(x_j - P_{ij})^2\bigg)}\]
Parameters:
  • xs (List[float]) – Input parameters

  • alpha (np.ndarray, optional) – Alpha array, leave as ‘None’ to get default for given dimension count, defaults to None

  • A (np.ndarray, optional) – ‘A’ array, leave as ‘None’ to get default for given dimension count, defaults to None

  • P (np.ndarray, optional) – ‘P’ array, leave as ‘None’ to get default for given dimension count, defaults to None

Raises:

ValueError – Invalid dimension count.

Returns:

Result of calculation.

Return type:

float

benchmarking.functions.himmelblau module

class benchmarking.functions.himmelblau.Himmelblau[source]

Bases: BenchmarkingFunction

benchmarking.functions.himmelblau.himmelblau(xs: List[float]) float[source]

Himmelblau’s optimization test function.

Himmelblau’s function from https://en.wikipedia.org/wiki/Himmelblau’s_function.

Input domain: Unknown.

Function in LaTeX format:

\[f(x) = (x_1^2 + x_2 - 11)^2 + (x_1 + x_2^2 - 7)^2\]
Parameters:

xs (List[float]) – Parameter list

Returns:

Result of calculation

Return type:

float

benchmarking.functions.holder_table module

class benchmarking.functions.holder_table.HolderTable[source]

Bases: BenchmarkingFunction

benchmarking.functions.holder_table.holder_table(xs: List[float]) float[source]

Holder Table function optimization test function.

Holder Table function from https://www.sfu.ca/~ssurjano/holder.html.

Input domain: 2D square \(x_i = [-10, 10]\) for all i = 1, 2.

Function in LaTeX format:

\[f(x) = -|\sin{(x_1)} \cos{(x_2)} \exp{(|1 - \frac{\sqrt{x_1^2 + x_2^2}}{\pi}|)}|\]
Parameters:

xs (List[float]) – Parameter list

Returns:

Result of calculation

Return type:

float

benchmarking.functions.matyas module

class benchmarking.functions.matyas.Matyas[source]

Bases: BenchmarkingFunction

benchmarking.functions.matyas.matyas(xs: List[float]) float[source]

Matyas optimization test function.

Matyas function from https://www.sfu.ca/~ssurjano/matya.html.

Input domain: 2D square with bounds [-10, 10].

Function in LaTeX format:

\[f(x) = 0.26 (x_1^2 + x_2^2) - 0.48 x_1 x_2\]
Parameters:

xs (List[float]) – Parameter list

Returns:

Result of calculation

Return type:

float

benchmarking.functions.rosenbrock module

class benchmarking.functions.rosenbrock.Rosenbrock(dim: int = 4)[source]

Bases: BenchmarkingFunction

benchmarking.functions.rosenbrock.rosenbrock(xs: List[float]) float[source]

Rosenbrock nD optimization test function. Dimensions are inferred from the length of the input paremeter list, xs.

Rosenbrock nD function from https://www.sfu.ca/~ssurjano/rosen.html.

Function in LaTeX format:

\[f(x) = \sum_{i=1}^{d-1} [100(x_{i+1} - x_i^2)^2 + (x_i - 1)^2]\]
Parameters:

xs (List[float]) – List of input parameters

Returns:

Result of calculation

Return type:

float

benchmarking.functions.schwefel module

class benchmarking.functions.schwefel.Schwefel(dim: int = 4)[source]

Bases: BenchmarkingFunction

benchmarking.functions.schwefel.schwefel(xs: List[float]) float[source]

Schwefel optimization test function.

Schwefel function from https://www.sfu.ca/~ssurjano/schwef.html.

Input domain: Hypercube \(x_i = [-500, 500]\), for all i=1, …, d.

Function in LaTeX format:

\[f(x) = 418.9829 d - \sum_{i = 1}^d x_i \sin{(\sqrt{|x_i|})}\]
Parameters:

xs (List[float]) – Parameter list

Returns:

Result of calculation

Return type:

float

benchmarking.functions.shekel module

class benchmarking.functions.shekel.Shekel(m: int = 5)[source]

Bases: BenchmarkingFunction

benchmarking.functions.shekel.shekel(xs: List[float], m: int = 10, C: ndarray = array([[4., 1., 8., 6., 3., 2., 5., 8., 6., 7.], [4., 1., 8., 6., 7., 9., 3., 1., 2., 3.6], [4., 1., 8., 6., 3., 2., 5., 8., 6., 7.], [4., 1., 8., 6., 7., 9., 3., 1., 2., 3.6]]), beta: List[float] = [0.1, 0.2, 0.2, 0.4, 0.4, 0.6, 0.3, 0.7, 0.5, 0.5]) float[source]

Shekel 4D optimization test function.

Shekel 4D function with (by default) values of \(\beta\) and C from https://www.sfu.ca/~ssurjano/shekel.html. Does not support m > 10 without a new C provided.

Function in LaTeX format:

\[f(x) = -\sum_{i=1}^m \bigg(\sum_{j=1}^4(x_j - C_{ji})^2 + \beta_i\bigg)^{-1}\]
Parameters:
  • xs (List[float]) – List of input parameters

  • m (int, optional) – ‘m’ parameter, defaults to 10

  • C (np.ndarray, optional) –

    ‘C’ array, defaults to:

    np.array([[4.0, 1.0, 8.0, 6.0, 3.0, 2.0, 5.0, 8.0, 6.0, 7.0],
              [4.0, 1.0, 8.0, 6.0, 7.0, 9.0, 3.0, 1.0, 2.0, 3.6],
              [4.0, 1.0, 8.0, 6.0, 3.0, 2.0, 5.0, 8.0, 6.0, 7.0],
              [4.0, 1.0, 8.0, 6.0, 7.0, 9.0, 3.0, 1.0, 2.0, 3.6]])
    

  • beta (List[float], optional) –

    ‘beta’ list, defaults to

    [ 0.1, 0.2, 0.2, 0.4, 0.4, 0.6, 0.3, 0.7, 0.5, 0.5 ]
    

Returns:

Result of calculation

Return type:

float

benchmarking.functions.shubert module

class benchmarking.functions.shubert.Shubert[source]

Bases: BenchmarkingFunction

Shubert Function

Source: https://www.sfu.ca/~ssurjano/shubert.html

benchmarking.functions.shubert.shubert(xs: List[float]) float[source]

Shubert optimization test function.

Shubert function from https://www.sfu.ca/~ssurjano/shubert.html.

Function in LaTeX format:

\[f(x) = \big(\sum_{i=5}^5 i cos((i + 1)x_1 + i)\big) \times \big(\sum_{i=5}^5 i cos((i + 1)x_2 + i)\big)\]
Parameters:

xs (List[float]) – Parameter list

Returns:

Result of calculation

Return type:

float

benchmarking.functions.six_hump_camel module

class benchmarking.functions.six_hump_camel.SixHumpCamel[source]

Bases: BenchmarkingFunction

benchmarking.functions.six_hump_camel.six_hump_camel(xs: List[float]) float[source]

Six-hump camel optimization test function.

Six-hump camel function from https://www.sfu.ca/~ssurjano/camel6.html.

Function in LaTeX format:

\[f(x) = (4 - 2.1 x_1^2 + \frac{x_1^4}{3}) x_1^2 + x_1 x_2 + (-4 + 4 x_2^2) x_2^2\]
Parameters:

xs (float) – Parameter list

Returns:

Result of calculation

Return type:

float

benchmarking.functions.sphere module

class benchmarking.functions.sphere.Sphere(dim: int = 4)[source]

Bases: BenchmarkingFunction

benchmarking.functions.sphere.sphere(xs: List[float]) float[source]

Sphere optimization test function.

Sphere function from https://www.sfu.ca/~ssurjano/spheref.html.

Input domain: Hypercube \(x_i = [-5.12, 5.12]\) for all i=1, …, d.

Function in LaTeX format:

\[f(x) = \sum_{i=1}^d x_i^2\]
Parameters:

xs (List[float]) – Parameter list

Returns:

Result of calculation

Return type:

float

benchmarking.functions.styblinski_tang module

class benchmarking.functions.styblinski_tang.StyblinskiTang(dim: int = 4)[source]

Bases: BenchmarkingFunction

benchmarking.functions.styblinski_tang.styblinski_tang(xs: List[float]) float[source]

Styblinski-Tang optimization test function.

Styblinski-Tang function from https://www.sfu.ca/~ssurjano/stybtang.html.

Input domain: Hypercube \(x_i = [-5, 5]\) for all i=1, …, d.

Function in LaTeX format:

\[f(x) = \dfrac{1}{2} \sum_{i = 1}^d (x_i^4 - 16 x_i^2 + 5 x_i)\]
Parameters:

xs (List[float]) – Parameter list

Returns:

Result of calculation

Return type:

float

benchmarking.functions.three_hump_camel module

class benchmarking.functions.three_hump_camel.ThreeHumpCamel[source]

Bases: BenchmarkingFunction

benchmarking.functions.three_hump_camel.three_hump_camel(xs: List[float]) float[source]

Three-hump camel optimization test function.

Three-hump camel function from https://www.sfu.ca/~ssurjano/camel3.html.

Input domain: 2D square \(x_i = [-5, 5]\) for all i = 1, 2.

Function in LaTeX format:

\[f(x) = 2 x_1^2 - 1.05 x_1^4 + \dfrac{x_1^6}{6} + x_1 x_2 + x_2^2\]
Parameters:

xs (float) – Parameter list

Returns:

Result of calculation

Return type:

float