Mathematical test functions
This library contains a number of mathematical test functions to test the convergence of optimization algorithms. The functions are taken from the following sources:
simone fraser university http://www.sfu.ca/~ssurjano/optimization.html [1]
Algorithms for Optimization by Mykel J. Kochenderfer & Tim A. Wheeler [2]
Certified global minima for a benchmark of difficult optimization problems [3]
The functions are implemented in the test_functions module.
- 1
Fraser, “Test functions for optimization algorithms,” 2013.
- 2
Kochenderfer & T. A. Wheeler, “Algorithms for Optimization,” 2013.
- 3
“Certified global minima for a benchmark of difficult optimization problems,” 2013.
Functions
1-d functions
tfx
- test_functions.tfx(x)
1-d Parabolic test function.
- Parameters
x (np.ndarray or list[float]) – Input value
- Returns
Value f(x1, x2, ….), real float
- Return type
np.ndarray or float
2-d functions
wheelers ridge
- test_functions.wheelers_ridge(x: Union[np.ndarray, list], a: float = 1.5)
2-d Wheelers ridge test function.
- Parameters
x (np.ndarray or list[float]) – Input value
- Returns
Value f(x1, x2), real float
- Return type
np.ndarray or float
booths function
- dfmcontrol.test_functions.t_functions.tfx(x)
2-d Booths function test function.
- Parameters
x (np.ndarray or list[float]) – Input value
- Returns
TValue f(x1, x2), real float
- Return type
np.ndarray or float
n-d functions
michealewicz
- test_functions.michealewicz(x: list, m: float = 10.0) float:
n-d test function with many local minima.
- Parameters
x (np.ndarray or list[float]) – List of x inputs, where N-dimensions = len(x)
m (float) – Steepness parameter, typically m=10
- Returns
Value f(x1, x2, ….), real float
- Return type
np.ndarray or float
Ackley
- test_functions.ackley(x: list, a: float = 20.0, b: float = 0.2, c: float = 2.0 * np.pi) float:
n-d test function with a single global minimum.
- Parameters
x (np.ndarray or list[float]) – List of x inputs, where N-dimensions = len(x)
a (float) – Steepness parameter, typically a=20
b (float) – Steepness parameter, typically b=0.2
c (float) – Steepness parameter, typically c=2*pi
- Returns
Value f(x1, x2, ….), real float
- Return type
np.ndarray or float
Styblinski Tang
- test_functions.styblinski_tang(x: list) float:
n-d test function 3 local minima and a global minimum.
- Parameters
x (np.ndarray or list[float]) – List of x inputs, where N-dimensions = len(x)
- Returns
Value f(x1, x2, ….), real float
- Return type
np.ndarray or float
Decorator function
- dfmcontrol.Mathematical_functions.t_functions.tfx_decorator(func: Callable = None, ndim: int = 1, cores: int = 1, compute_analytical: bool = False, **kwargs)
Decorator for creating a TFx object.
- Parameters
func – Callable function to be decorated.
ndim – int, dimension of the function.
cores – int, number of cores to use for the calculation of the optima and minima.
compute_analytical – bool, whether to compute the analytical optima and minima.
kwargs – minima: {“x”: [x1, x2, … , xn], “fx”: []}, optima: {“x”: [x1, x2, … , xn], “fx”: []}
- Returns
TFx object