Benchmarks

This module contains a comprehensive collection of benchmark functions for optimization problems. These functions are commonly used to test and evaluate the performance of optimization algorithms, including genetic algorithms, particle swarm optimization, and other metaheuristic methods.

The benchmark functions include:

  • Unimodal functions: Functions with a single global optimum (e.g., Rosenbrock, Sphere)

  • Multimodal functions: Functions with multiple local optima (e.g., Rastrigin, Ackley, Griewank)

  • Composition functions: Complex functions combining multiple sub-functions

  • Real-world inspired functions: Functions modeling practical optimization problems

Each function is provided in both standard and inverted versions, allowing for both minimization and maximization testing scenarios. These benchmarks serve as a standardized test suite for comparing algorithm performance and establishing baseline metrics before developing new optimization approaches.

Optimization benchmarks

Ackley Function

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

Compute the Ackley function value for optimization benchmarking.

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) – Input vector as numpy array. Values should be in range [-32.768, 32.768]

Returns:

Function value at the given point

Return type:

float

Raises:

ValueError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([0.0, 0.0])
>>> result = ackley(x)
>>> print(f"{result:.6f}")
0.000000
mango.benchmark.optimization.ackley.inverted_ackley(x: numpy.ndarray) float

Compute the inverted Ackley function value for maximization problems.

This function returns the negative of the standard Ackley function, effectively converting the minimization problem into a maximization problem. The global maximum point is: f(x) = 0, at x = (0, …, 0).

Parameters:

x (numpy.ndarray) – Input vector as numpy array. Values should be in range [-32.768, 32.768]

Returns:

Negative function value at the given point

Return type:

float

Raises:

ValueError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([0.0, 0.0])
>>> result = inverted_ackley(x)
>>> print(f"{result:.6f}")
0.000000

Bukin Function

mango.benchmark.optimization.bukin.bukin_function_6(x: numpy.ndarray) float

Compute the Bukin function N. 6 value for optimization benchmarking.

The sixth Bukin function has many local minima, all of which lie in a ridge. This function is particularly challenging for optimization algorithms due to its complex landscape with multiple local optima.

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

Parameters:

x (numpy.ndarray) – Input vector with 2 elements. x[0] in range [-15, 5], x[1] in range [-3, 3]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input array doesn’t have exactly 2 elements

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([-10.0, 1.0])
>>> result = bukin_function_6(x)
>>> print(f"{result:.6f}")
0.000000
mango.benchmark.optimization.bukin.inverted_bukin_function_6(x: numpy.ndarray) float

Compute the inverted Bukin function N. 6 value for maximization problems.

This function returns the negative of the standard Bukin function N. 6, effectively converting the minimization problem into a maximization problem. The global maximum is at (-10, 1) with a value of 0.

Parameters:

x (numpy.ndarray) – Input vector with 2 elements. x[0] in range [-15, 5], x[1] in range [-3, 3]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input array doesn’t have exactly 2 elements

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([-10.0, 1.0])
>>> result = inverted_bukin_function_6(x)
>>> print(f"{result:.6f}")
0.000000

Cross-in-Tray Function

mango.benchmark.optimization.cross_in_tray.cross_in_tray(x: numpy.ndarray) float

Compute the Cross-in-tray function value for optimization benchmarking.

The Cross-in-tray function has many widespread local minima, which are regularly distributed. This function is particularly challenging for optimization algorithms due to its complex landscape with multiple global minima.

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

Parameters:

x (numpy.ndarray) – Input vector with 2 elements. Both elements in range [-10, 10]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input array doesn’t have exactly 2 elements

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([1.34941, 1.34941])
>>> result = cross_in_tray(x)
>>> print(f"{result:.6f}")
-2.062612
mango.benchmark.optimization.cross_in_tray.inverted_cross_in_tray(x: numpy.ndarray) float

Compute the inverted Cross-in-tray function value for maximization problems.

This function returns the negative of the standard Cross-in-tray function, effectively converting the minimization problem into a maximization problem. The global maxima are located at the same points as the original function’s minima, but with positive values.

Parameters:

x (numpy.ndarray) – Input vector with 2 elements. Both elements in range [-10, 10]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input array doesn’t have exactly 2 elements

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([1.34941, 1.34941])
>>> result = inverted_cross_in_tray(x)
>>> print(f"{result:.6f}")
2.062612

Dolan Function

mango.benchmark.optimization.dolan.dolan_function_no2(x: numpy.ndarray) float

Compute the Dolan function No. 2 value for optimization benchmarking.

The Dolan function No. 2 is a 5-dimensional optimization test function with complex interactions between variables. It features trigonometric and polynomial terms that create a challenging landscape for optimization algorithms.

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

Parameters:

x (numpy.ndarray) – Input vector with 5 elements. All elements in range [-100, 100]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input array doesn’t have exactly 5 elements

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([8.39045925, 4.81424707, 7.34574133, 68.88246895, 3.85470806])
>>> result = dolan_function_no2(x)
>>> print(f"{result:.2e}")
1.00e-05
mango.benchmark.optimization.dolan.inverted_dolan_function_no2(x: numpy.ndarray) float

Compute the inverted Dolan function No. 2 value for maximization problems.

This function returns the negative of the standard Dolan function No. 2, effectively converting the minimization problem into a maximization problem. The global maximum is at the same point as the original function’s minimum, but with a positive value.

Parameters:

x (numpy.ndarray) – Input vector with 5 elements. All elements in range [-100, 100]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input array doesn’t have exactly 5 elements

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([8.39045925, 4.81424707, 7.34574133, 68.88246895, 3.85470806])
>>> result = inverted_dolan_function_no2(x)
>>> print(f"{result:.2e}")
-1.00e-05

Drop-Wave Function

mango.benchmark.optimization.drop_wave.drop_wave(x: numpy.ndarray) float

Compute the Drop-Wave function value for optimization benchmarking.

The Drop-Wave function has a unique global minimum. It is multimodal, but the minima are regularly distributed. This function features a distinctive “drop” shape with oscillatory behavior that creates multiple local minima.

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

Parameters:

x (numpy.ndarray) – Input vector with 2 elements. Values usually in range [-5.12, 5.12]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input array doesn’t have exactly 2 elements

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([0.0, 0.0])
>>> result = drop_wave(x)
>>> print(f"{result:.6f}")
-1.000000
mango.benchmark.optimization.drop_wave.inverted_drop_wave(x: numpy.ndarray) float

Compute the inverted Drop-Wave function value for maximization problems.

This function returns the negative of the standard Drop-Wave function, effectively converting the minimization problem into a maximization problem. The global maximum is at the same point as the original function’s minimum, but with a positive value.

Parameters:

x (numpy.ndarray) – Input vector with 2 elements. Values usually in range [-5.12, 5.12]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input array doesn’t have exactly 2 elements

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([0.0, 0.0])
>>> result = inverted_drop_wave(x)
>>> print(f"{result:.6f}")
1.000000

Egg-Holder Function

mango.benchmark.optimization.egg_holder.egg_holder(x: numpy.ndarray) float

Compute the Egg-holder function value for optimization benchmarking.

The Egg-holder function has many widespread local minima, which are regularly distributed. This function is particularly challenging for optimization algorithms due to its complex landscape with numerous local optima and steep gradients.

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

Parameters:

x (numpy.ndarray) – Input vector with 2 elements. Both elements in range [-512, 512]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input array doesn’t have exactly 2 elements

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([512.0, 404.2319])
>>> result = egg_holder(x)
>>> print(f"{result:.4f}")
-959.6407
mango.benchmark.optimization.egg_holder.inverted_egg_holder(x: numpy.ndarray) float

Compute the inverted Egg-holder function value for maximization problems.

This function returns the negative of the standard Egg-holder function, effectively converting the minimization problem into a maximization problem. The global maximum is at the same point as the original function’s minimum, but with a positive value.

Parameters:

x (numpy.ndarray) – Input vector with 2 elements. Both elements in range [-512, 512]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input array doesn’t have exactly 2 elements

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([512.0, 404.2319])
>>> result = inverted_egg_holder(x)
>>> print(f"{result:.4f}")
959.6407

Gramacy & Lee Function

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

Compute the Gramacy & Lee function value for optimization benchmarking.

This function is multimodal, with a number of local minima. It features oscillatory behavior combined with polynomial terms, creating a challenging landscape for optimization algorithms. The function is typically used for one-dimensional optimization problems.

The global minimum is at x = 0.54.

Parameters:

x (Union[numpy.ndarray, list, float]) – Input value as numpy array, list, or float. Value usually in range [-0.5, 2.5]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input is empty or invalid

  • IndexError – If input array/list is empty

Example:
>>> import numpy as np
>>> result = gramacy_lee(0.54)
>>> print(f"{result:.6f}")
-0.869011
>>> result = gramacy_lee([0.54])
>>> print(f"{result:.6f}")
-0.869011
mango.benchmark.optimization.gramacy_lee.inverted_gramacy_lee(x: numpy.ndarray | list | float) float

Compute the inverted Gramacy & Lee function value for maximization problems.

This function returns the negative of the standard Gramacy & Lee function, effectively converting the minimization problem into a maximization problem. The global maximum is at the same point as the original function’s minimum, but with a positive value.

Parameters:

x (Union[numpy.ndarray, list, float]) – Input value as numpy array, list, or float. Value usually in range [-0.5, 2.5]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input is empty or invalid

  • IndexError – If input array/list is empty

Example:
>>> import numpy as np
>>> result = inverted_gramacy_lee(0.54)
>>> print(f"{result:.6f}")
0.869011
>>> result = inverted_gramacy_lee([0.54])
>>> print(f"{result:.6f}")
0.869011

Griewank Function

mango.benchmark.optimization.griewank.griewank(x: numpy.ndarray) float

Compute the Griewank function value for optimization benchmarking.

The Griewank function has many widespread local minima, which are regularly distributed. This function combines a quadratic term with a product of cosine terms, creating a complex landscape with numerous local optima. The function becomes more challenging as the dimensionality increases.

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

Parameters:

x (numpy.ndarray) – Input vector with n elements. Values usually in range [-600, 600]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input array is empty

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([0.0, 0.0])
>>> result = griewank(x)
>>> print(f"{result:.6f}")
0.000000
mango.benchmark.optimization.griewank.inverted_griewank(x: numpy.ndarray) float

Compute the inverted Griewank function value for maximization problems.

This function returns the negative of the standard Griewank function, effectively converting the minimization problem into a maximization problem. The global maximum is at the same point as the original function’s minimum, but with a positive value.

Parameters:

x (numpy.ndarray) – Input vector with n elements. Values usually in range [-600, 600]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input array is empty

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([0.0, 0.0])
>>> result = inverted_griewank(x)
>>> print(f"{result:.6f}")
0.000000

Holder Table Function

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

Compute the Holder Table function value for optimization benchmarking.

This function is multimodal, with a number of local minima. It features trigonometric and exponential terms that create a complex landscape with multiple global minima. The function is particularly challenging due to its oscillatory behavior and multiple optimal solutions.

The global minima are located at: - (8.05502, 9.66459) - (-8.05502, 9.66459) - (8.05502, -9.66459) - (-8.05502, -9.66459) All with a value of -19.2085.

Parameters:

x (Union[numpy.ndarray, list]) – Input vector with 2 elements. Both elements usually in range [-10, 10]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input doesn’t have exactly 2 elements

  • IndexError – If input is empty

Example:
>>> import numpy as np
>>> x = np.array([8.05502, 9.66459])
>>> result = holder_table(x)
>>> print(f"{result:.4f}")
-19.2085
mango.benchmark.optimization.holder_table.inverted_holder_table(x: numpy.ndarray | list) float

Compute the inverted Holder Table function value for maximization problems.

This function returns the negative of the standard Holder Table function, effectively converting the minimization problem into a maximization problem. The global maxima are at the same points as the original function’s minima, but with positive values.

Parameters:

x (Union[numpy.ndarray, list]) – Input vector with 2 elements. Both elements usually in range [-10, 10]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input doesn’t have exactly 2 elements

  • IndexError – If input is empty

Example:
>>> import numpy as np
>>> x = np.array([8.05502, 9.66459])
>>> result = inverted_holder_table(x)
>>> print(f"{result:.4f}")
19.2085

Langermann Function

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

Compute the Langermann function value for optimization benchmarking.

The Langermann function is a multimodal problem. It has a fairly large number of local minima, widely separated and regularly distributed. This function combines exponential and cosine terms to create a complex landscape with multiple local optima.

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).

Parameters:

x (Union[numpy.ndarray, list]) – Input vector with 2 elements. Both elements usually in range [0, 10]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input doesn’t have exactly 2 elements

  • IndexError – If input is empty

Example:
>>> import numpy as np
>>> x = np.array([2.0, 3.0])
>>> result = langermann(x)
>>> print(f"{result:.6f}")
1.000000
mango.benchmark.optimization.langermann.inverted_langermann(x: numpy.ndarray | list) float

Compute the inverted Langermann function value for maximization problems.

This function returns the negative of the standard Langermann function, effectively converting the minimization problem into a maximization problem. The global maximum is at the same point as the original function’s minimum, but with a positive value.

Parameters:

x (Union[numpy.ndarray, list]) – Input vector with 2 elements. Both elements usually in range [0, 10]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input doesn’t have exactly 2 elements

  • IndexError – If input is empty

Example:
>>> import numpy as np
>>> x = np.array([2.0, 3.0])
>>> result = inverted_langermann(x)
>>> print(f"{result:.6f}")
-1.000000

Levy Function

mango.benchmark.optimization.levy.levy(x: numpy.ndarray) float

Compute the Levy function value for optimization benchmarking.

The Levy function is a multimodal optimization test function with complex oscillatory behavior. It features trigonometric terms that create numerous local minima, making it challenging for optimization algorithms.

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

Parameters:

x (numpy.ndarray) – Input vector with n elements. Each element usually in range [-10, 10]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input array is empty

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([1.0, 1.0, 1.0])
>>> result = levy(x)
>>> print(f"{result:.6f}")
0.000000
mango.benchmark.optimization.levy.inverted_levy(x: numpy.ndarray) float

Compute the inverted Levy function value for maximization problems.

This function returns the negative of the standard Levy function, effectively converting the minimization problem into a maximization problem. The global maximum is at the same point as the original function’s minimum, but with a positive value.

Parameters:

x (numpy.ndarray) – Input vector with n elements. Each element usually in range [-10, 10]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input array is empty

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([1.0, 1.0, 1.0])
>>> result = inverted_levy(x)
>>> print(f"{result:.6f}")
0.000000
mango.benchmark.optimization.levy.levy_function_no13(x: numpy.ndarray | list) float

Compute the Levy function N. 13 value for optimization benchmarking.

This is a 2D variant of the Levy function with specific trigonometric terms. It features oscillatory behavior that creates multiple local minima, making it challenging for optimization algorithms.

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

Parameters:

x (Union[numpy.ndarray, list]) – Input vector with 2 elements. Both elements usually in range [-10, 10]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input doesn’t have exactly 2 elements

  • IndexError – If input is empty

Example:
>>> import numpy as np
>>> x = np.array([1.0, 1.0])
>>> result = levy_function_no13(x)
>>> print(f"{result:.6f}")
0.000000
mango.benchmark.optimization.levy.inverted_levy_no13(x: numpy.ndarray | list) float

Compute the inverted Levy function N. 13 value for maximization problems.

This function returns the negative of the standard Levy function N. 13, effectively converting the minimization problem into a maximization problem. The global maximum is at the same point as the original function’s minimum, but with a positive value.

Parameters:

x (Union[numpy.ndarray, list]) – Input vector with 2 elements. Both elements usually in range [-10, 10]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input doesn’t have exactly 2 elements

  • IndexError – If input is empty

Example:
>>> import numpy as np
>>> x = np.array([1.0, 1.0])
>>> result = inverted_levy_no13(x)
>>> print(f"{result:.6f}")
0.000000

Rastrigin Function

mango.benchmark.optimization.rastrigin.rastrigin(x: numpy.ndarray) float

Compute the Rastrigin function value for optimization benchmarking.

The Rastrigin function has several local minima. It is highly multimodal, but locations of the minima are regularly distributed. This function combines a quadratic term with cosine oscillations, creating a complex landscape with numerous local optima.

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

Parameters:

x (numpy.ndarray) – Input vector with n elements. Values usually in range [-5.12, 5.12]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input array is empty

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([0.0, 0.0, 0.0])
>>> result = rastrigin(x)
>>> print(f"{result:.6f}")
0.000000
mango.benchmark.optimization.rastrigin.inverted_rastrigin(x: numpy.ndarray) float

Compute the inverted Rastrigin function value for maximization problems.

This function returns the negative of the standard Rastrigin function, effectively converting the minimization problem into a maximization problem. The global maximum is at the same point as the original function’s minimum, but with a positive value.

Parameters:

x (numpy.ndarray) – Input vector with n elements. Values usually in range [-5.12, 5.12]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input array is empty

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([0.0, 0.0, 0.0])
>>> result = inverted_rastrigin(x)
>>> print(f"{result:.6f}")
0.000000

Rosenbrock Function

mango.benchmark.optimization.rosenbrock.rosenbrock(x: numpy.ndarray) float

Compute the Rosenbrock function value for optimization benchmarking.

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 minimum is at [1, 1, …, 1] with a value of 0.

Parameters:

x (numpy.ndarray) – Input vector with n elements. Values usually in range [-5, 10]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input array is empty

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([1.0, 1.0, 1.0])
>>> result = rosenbrock(x)
>>> print(f"{result:.6f}")
0.000000
mango.benchmark.optimization.rosenbrock.inverted_rosenbrock(x: numpy.ndarray) float

Compute the inverted Rosenbrock function value for maximization problems.

This function returns the negative of the standard Rosenbrock function, effectively converting the minimization problem into a maximization problem. The global maximum is at the same point as the original function’s minimum, but with a positive value.

Parameters:

x (numpy.ndarray) – Input vector with n elements. Values usually in range [-5, 10]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input array is empty

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([1.0, 1.0, 1.0])
>>> result = inverted_rosenbrock(x)
>>> print(f"{result:.6f}")
0.000000

Schaffer Function

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

Compute the Schaffer function N. 2 value for optimization benchmarking.

This function features trigonometric terms that create a complex landscape with oscillatory behavior. It is particularly challenging for optimization algorithms due to its multimodal nature.

\[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 minimum is at x = [0, 0] with value 0.

Parameters:

x (Union[numpy.ndarray, list]) – Input vector with 2 elements. Values usually in range [-100, 100]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input doesn’t have exactly 2 elements

  • IndexError – If input is empty

Example:
>>> import numpy as np
>>> x = np.array([0.0, 0.0])
>>> result = schaffer_function_no2(x)
>>> print(f"{result:.6f}")
0.000000
mango.benchmark.optimization.schaffer.inverted_schaffer_function_no2(x: numpy.ndarray | list) float

Compute the inverted Schaffer function N. 2 value for maximization problems.

This function returns the negative of the standard Schaffer function N. 2, effectively converting the minimization problem into a maximization problem. The global maximum is at the same point as the original function’s minimum, but with a positive value.

Parameters:

x (Union[numpy.ndarray, list]) – Input vector with 2 elements. Values usually in range [-100, 100]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input doesn’t have exactly 2 elements

  • IndexError – If input is empty

Example:
>>> import numpy as np
>>> x = np.array([0.0, 0.0])
>>> result = inverted_schaffer_function_no2(x)
>>> print(f"{result:.6f}")
0.000000
mango.benchmark.optimization.schaffer.schaffer_function_no4(x: numpy.ndarray | list) float

Compute the Schaffer function N. 4 value for optimization benchmarking.

This function features nested trigonometric terms that create a complex landscape with oscillatory behavior. It is particularly challenging for optimization algorithms due to its multimodal nature and asymmetric global minimum.

\[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 minimum is at x = [0, 1.253115] with value 0.292579.

Parameters:

x (Union[numpy.ndarray, list]) – Input vector with 2 elements. Values usually in range [-100, 100]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input doesn’t have exactly 2 elements

  • IndexError – If input is empty

Example:
>>> import numpy as np
>>> x = np.array([0.0, 1.253115])
>>> result = schaffer_function_no4(x)
>>> print(f"{result:.6f}")
0.292579
mango.benchmark.optimization.schaffer.inverted_schaffer_function_no4(x: numpy.ndarray | list) float

Compute the inverted Schaffer function N. 4 value for maximization problems.

This function returns the negative of the standard Schaffer function N. 4, effectively converting the minimization problem into a maximization problem. The global maximum is at the same point as the original function’s minimum, but with a positive value.

Parameters:

x (Union[numpy.ndarray, list]) – Input vector with 2 elements. Values usually in range [-100, 100]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input doesn’t have exactly 2 elements

  • IndexError – If input is empty

Example:
>>> import numpy as np
>>> x = np.array([0.0, 1.253115])
>>> result = inverted_schaffer_function_no4(x)
>>> print(f"{result:.6f}")
-0.292579

Schwefel Function

mango.benchmark.optimization.schwefel.schwefel(x: numpy.ndarray) float

Compute the Schwefel function value for optimization benchmarking.

The Schwefel function is complex, with many local minima. It features trigonometric terms that create a challenging landscape for optimization algorithms. The function becomes more difficult as dimensionality increases.

The global minimum is located at [420.9687, …, 420.9687] with a value of 0.

Parameters:

x (numpy.ndarray) – Input vector with n elements. Values usually in range [-500, 500]

Returns:

Function value at the given point

Return type:

float

Raises:
  • ValueError – If input array is empty

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([420.9687, 420.9687])
>>> result = schwefel(x)
>>> print(f"{result:.6f}")
0.000000
mango.benchmark.optimization.schwefel.inverted_schwefel(x: numpy.ndarray) float

Compute the inverted Schwefel function value for maximization problems.

This function returns the negative of the standard Schwefel function, effectively converting the minimization problem into a maximization problem. The global maximum is at the same point as the original function’s minimum, but with a positive value.

Parameters:

x (numpy.ndarray) – Input vector with n elements. Values usually in range [-500, 500]

Returns:

Negative function value at the given point

Return type:

float

Raises:
  • ValueError – If input array is empty

  • IndexError – If input array is empty

Example:
>>> import numpy as np
>>> x = np.array([420.9687, 420.9687])
>>> result = inverted_schwefel(x)
>>> print(f"{result:.6f}")
0.000000