from spotoptim.function import michalewicz
import numpy as np
X = np.array([2.20, 1.57])
result = michalewicz(X)
result[0] # Should be close to -1.8013np.float64(-1.801140718473825)
N-dimensional Michalewicz function.
The Michalewicz function is a multimodal test function with steep ridges and valleys. The parameter m defines the steepness of the valleys and ridges. Larger values of m result in more difficult search problems. The number of local minima increases exponentially with the dimension.
f(X) = -sum_{i=1}^{n} sin(x_i) * [sin(i * x_i^2 / π)]^(2m)
| Name | Type | Description | Default |
|---|---|---|---|
| X | array - like |
Input points with shape (n_samples, n_features) or (n_features,). Can be a 1D array for a single point or 2D array for multiple points. | required |
| m | int | Steepness parameter. Higher values make the function more difficult to optimize. Defaults to 10. | 10 |
| Name | Type | Description |
|---|---|---|
| np.ndarray | np.ndarray: Function values at the input points with shape (n_samples,). |
Single point evaluation:
np.float64(-1.801140718473825)
Multiple points evaluation:
array([-1.80114072e+00, -2.55738728e-05])
Using different steepness parameter:
Michalewicz, Z. (1996). “Genetic Algorithms + Data Structures = Evolution Programs”. Springer-Verlag.