Benchmarks

This module contains benchmark functions for optimization problems and to benchmark machine learning algorithms to get a baseline of the performance of some algorithms before developing.

Machine learning benchmarks

Optimization benchmarks

mango.benchmark.optimization.ackley.ackley(x: ndarray) float

General Ackley function.

The Ackley function is widely used for testing optimization algorithms.

In its two-dimensional form, it is characterized by a nearly flat outer region, and a large hole at the centre. The function poses a risk for optimization algorithms, particularly hillclimbing algorithms, to be trapped in one of its many local minima.

The global minimum point of the function is: f(x) = 0, at x = (0, …, 0)

Parameters:

x (numpy.ndarray) – numpy array of floats. The values are evaluated in the range [-32.768, 32.768]

Returns:

the value of the function

Return type:

float

Doc-author:

baobab soluciones

mango.benchmark.optimization.ackley.inverted_ackley(x: ndarray) float

Inverted Ackley function.

Some description of the function.

Parameters:

x (numpy.ndarray) – numpy array of floats

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.bukin.bukin_function_6(x: array) float

Bukin function N. 6.

The sixth Bukin function has many local minima, all of which lie in a ridge.

The global minima is at (-10, 1) with a value of 0.

Parameters:

x (numpy.ndarray) – array of floats. Values are between [-15, 5] for x1 and [-3, 3] for x2

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.bukin.inverted_bukin_function_6(x: array) float

Inverted Bukin function N. 6.

Parameters:

x (numpy.ndarray) – array of floats. Values are between [-15, 5] for x1 and [-3, 3] for x2

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.cross_in_tray.cross_in_tray(x: array) float

Cross-in-tray function.

The Cross-in-tray function has many widespread local minima, which are regularly distributed

The function is usually evaluated on the square xi ∈ [-10, 10], for all i = 1, 2. The global mínima is located at x = (1.34941, 1.34941), (-1.34941, 1.34941), (1.34941, -1.34941) and (-1.34941, -1.34941) with a value of -2.06261

Parameters:

x (numpy.ndarray) – array of floats

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.cross_in_tray.inverted_cross_in_tray(x: array) float

Inverted Cross-in-tray function.

The Cross-in-tray function has many widespread local minima, which are regularly distributed This implementation inverts the function to test out the maximization

Parameters:

x (numpy.ndarray) – array of floats

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.dolan.dolan_function_no2(x: array) float

Dolan function No 2.

The global minima is at [8.39045925, 4.81424707, 7.34574133, 68.88246895, 3.85470806] with a value of 10^-5

Parameters:

x (numpy.ndarray) – array of floats. Values are evaluated between [-100, 100]

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.dolan.inverted_dolan_function_no2(x: array) float

Inverted Dolan function No 2.

Parameters:

x (numpy.ndarray) – array of floats. Values are evaluated between [-100, 100]

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.drop_wave.drop_wave(x: array) float

Drop-Wave function.

The Drop-Wave function has a unique global minimum. It is multimodal, but the minima are regularly distributed.

The global minima is located at x = (0, 0) with a value of -1

Parameters:

x (numpy.ndarray) – array of floats. Values usually are between -5.12 and 5.12.

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.drop_wave.inverted_drop_wave(x: array) float

Inverted Drop-Wave function.

The Drop-Wave function has a unique global minimum. It is multimodal, but the minima are regularly distributed. This implementation inverts the function to test out the maximization

The global minima is located at x = (0, 0) with a value of -1

Parameters:

x (numpy.ndarray) – array of floats. Values usually are between -5.12 and 5.12.

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.egg_holder.egg_holder(x: array) float

Egg-holder function.

The Egg-holder function has many widespread local minima, which are regularly distributed

The function is usually evaluated on the square xi ∈ [-512, 512], for all i = 1, 2. The global mínima is located at x = (512, 404.2319) with a value of -959.6407

Parameters:

x (numpy.ndarray) – array of floats

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.egg_holder.inverted_egg_holder(x: array) float

Inverted Egg-holder function.

The Egg-holder function has many widespread local minima, which are regularly distributed This implementation inverts the function to test out the maximization

Parameters:

x (numpy.ndarray) – array of floats

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.gramacy_lee.gramacy_lee(x: array | list | float) float

Gramacy & Lee function.

This function is multimodal, with a number of local minima. The global minimum is at x = 0.54.

Parameters:

x (numpy.array, list or float) – array or list with the value or the value itself. Each value is usually between -0.5 and 2.5.

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.gramacy_lee.inverted_gramacy_lee(x: array | list | float) float

Inverted Gramacy & Lee function.

This function is multimodal, with a number of local minima. The global minimum is at x = 0.54.

Parameters:

x (numpy.array, list or float) – array or list with the value or the value itself. Each value is usually between -0.5 and 2.5.

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.griewank.griewank(x: array) float

Griewank function.

The Griewank function has many widespread local minima, which are regularly distributed

The global minima is located at [0, 0, …, 0] with a value of 0

Parameters:

x (numpy.ndarray) – array of floats

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.griewank.inverted_griewank(x: array) float

Inverted Griewank function.

The Griewank function has many widespread local minima, which are regularly distributed This implementation inverts the function to test out the maximization

Parameters:

x (numpy.ndarray) – array of floats

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.holder_table.holder_table(x: array | list) float

Holder function.

This function is multimodal, with a number of local minima. The global minima is at (8.05502, 9.66459), (-8.05502, 9.66459), (8.05502, -9.66459) and (-8.05502, -9.66459) with a value of -19.2085.

Parameters:

x (numpy.array or list) – array or list of floats. Each value is usually between -10 and 10.

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.holder_table.inverted_holder_table(x: array | list) float

Inverted Holder function.

This function is multimodal, with a number of local minima. This inverted version is used for testin maximization

The global maxima is at (8.05502, 9.66459), (-8.05502, 9.66459), (8.05502, -9.66459) and (-8.05502, -9.66459) with a value of 19.2085.

Parameters:

x (numpy.array or list) – list of floats. Each value is usually between -10 and 10.

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.langermann.langermann(x: array | list) float

Langermann function.

The Langermann function is a multimodal problem. It has a fairly large number of local minima, widely separated and regularly distributed.

This implementation is only for the two dimension version of the function using the values for a, c and m proposed by Molga & Smutnicki (2005) [2].

Parameters:

x (numpy.array or list) – array or list of floats. Each value is usually between 0 and 10.

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.langermann.inverted_langermann(x: array | list) float

Inverted Langermann function.

The Langermann function is a multimodal problem. It has a fairly large number of local minima, widely separated and regularly distributed. This implementation inverts the function to test out the maximization

Parameters:

x (numpy.array or list) – array or list of floats. Each value is usually between 0 and 10.

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.levy.levy(x: array) float

Levy function.

The global minima is at x = [1, 1, 1, …, 1] and the function value is 0.

Parameters:

x (numpy.array) – array of floats. Each value is usually between -10 and 10.

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.levy.inverted_levy(x: array) float

Inverted Levy function.

Parameters:

x (numpy.array) – array of floats. Each value is usually between -10 and 10.

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.levy.levy_function_no13(x: array | list) float

Levy function N. 13.

The global minima is at x = [1, 1] and the function value is 0.

Parameters:

x (numpy.array or list) – array or list of floats. Each value is usually between -10 and 10.

Returns:

the value of the function

Return type:

float

Doc-author:

baobab soluciones

mango.benchmark.optimization.levy.inverted_levy_no13(x: array | list) float

Inverted Levy function N. 13.

The global minima is at x = [1, 1] and the function value is 0.

Parameters:

x (numpy.array or list) – list of floats. Each value is usually between -10 and 10.

Returns:

the value of the function

Return type:

float

Doc-author:

baobab soluciones

mango.benchmark.optimization.rastrigin.rastrigin(x: array) float

Rastrigin function.

The Rastrigin function has several local minima. It is highly multimodal, but locations of the minima are regularly distributed.

The global minima is at [0, 0, …, 0] with a value of 0

Parameters:

x (npumpy.array) – array of floats. Values usually are between -5.12 and 5.12.

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.rastrigin.inverted_rastrigin(x: array) float

Inverted Rastrigin function.

The Rastrigin function has several local minima. It is highly multimodal, but locations of the minima are regularly distributed. This implementation inverts the function to test out the maximization

Parameters:

x (npumpy.array) – array of floats. Values usually are between -5.12 and 5.12.

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.rosenbrock.rosenbrock(x: array) float

Rosenbrock function.

The Rosenbrock function, also referred to as the Valley or Banana function, is a popular test problem for gradient-based optimization algorithms.

The function is unimodal, and the global minimum lies in a narrow, parabolic valley. However, even though this valley is easy to find, convergence to the minimum is difficult (Picheny et al., 2012).

The global minima is at [1, 1, …, 1] with a value of 0

Parameters:

x (numpy.array) – array of floats. Values usually are between -5 and 10

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.rosenbrock.inverted_rosenbrock(x: array) float

Inverted Rosenbrock function.

The Rosenbrock function, also referred to as the Valley or Banana function, is a popular test problem for gradient-based optimization algorithms.

The function is unimodal, and the global minimum lies in a narrow, parabolic valley. However, even though this valley is easy to find, convergence to the minimum is difficult (Picheny et al., 2012).

Parameters:

x (numpy.array) – array of floats. Values ussually are between -5 and 10

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.schaffer.schaffer_function_no2(x: array | list) float

Schaffer function N. 2.

\[f(x) = 0.5 + \frac{\sin^2(x_1^2 - x_2^2) - 0.5}{[1 + 0.001(x_1^2 + x_2^2)]^2}\]

The global minima is at x [0, 0] with value 0

Parameters:

x (numpy.array or list) – A list of values. Values are evaluated between [-100, 100]

Returns:

The value of the Schaffer function N. 2.

Return type:

float

mango.benchmark.optimization.schaffer.inverted_schaffer_function_no2(x: array | list) float

Inverted Schaffer function N. 2.

This inverted version is used for maximization.

\[f(x) = -0.5 - \frac{\sin^2(x_1^2 - x_2^2) - 0.5}{[1 + 0.001(x_1^2 + x_2^2)]^2}\]

The global maxima is at x [0, 0] with value 0

Parameters:

x (numpy.array or list) – A list of values. Values are evaluated between [-100, 100]

Returns:

The value of the Inverted Schaffer function N. 2.

Return type:

float

mango.benchmark.optimization.schaffer.schaffer_function_no4(x: array | list) float

Schaffer function N. 4.

\[f(x) = 0.5 + \frac{\cos^2(\sin(|x_1^2 - x_2^2|)) - 0.5}{[1 + 0.001(x_1^2 + x_2^2)]^2}\]

The global minima is at x [0, 1.253115] with value 0.292579

Parameters:

x (numpy.array or list) – array or list of values. Values are evaluated between [-100, 100]

Returns:

The value of the Schaffer function N. 4.

Return type:

float

mango.benchmark.optimization.schaffer.inverted_schaffer_function_no4(x: array | list) float

Inverted Schaffer function N. 4.

This inverted version is used for maximization.

\[f(x) = -0.5 - \frac{\cos^2(\sin(|x_1^2 - x_2^2|)) - 0.5}{[1 + 0.001(x_1^2 + x_2^2)]^2}\]

The global maxima is at x [0, 1.253115] with value -0.292579

Parameters:

x (numpy.array or list) – array or list of values. Values are evaluated between [-100, 100]

Returns:

The value of the Inverted Schaffer function N. 4.

Return type:

float

mango.benchmark.optimization.schwefel.schwefel(x: array) float

Schwefel function

The Schwefel function is complex, with many local minima.

The global minima is located at [420,9687, …, 420,9687] with a value of 0

Parameters:

x (numpy.array) – input vector. The function is usually evaluated between [500, 500]

Returns:

the value of the function

Return type:

float

mango.benchmark.optimization.schwefel.inverted_schwefel(x: array) float

Inverted Schwefel function

The Schwefel function is complex, with many local maxima. This version is used to test maximization.

The global minima is located at [420,9687, …, 420,9687] with a value of 0

Parameters:

x (numpy.array) – input vector. The function is usually evaluated between [500, 500]

Returns:

the value of the function

Return type:

float