from spotoptim.function import rosenbrock
import numpy as np
X = np.array([1.0, 1.0])
rosenbrock(X)array([0.])
N-dimensional Rosenbrock function.
The Rosenbrock function is a classic test function for optimization algorithms. It is characterized by a long, narrow, parabolic-shaped valley. The global minimum is inside the valley and is hard to find for many algorithms.
f(x, y) = (1 - x)^2 + 100 * (y - x2)2
f(X) = sum_{i=1}^{N-1} [100 * (x_{i+1} - x_i2)2 + (1 - x_i)^2]
| 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 |
| Name | Type | Description |
|---|---|---|
| np.ndarray | np.ndarray: Function values at the input points with shape (n_samples,). |
| Name | Type | Description |
|---|---|---|
| ValueError | If X has fewer than 2 dimensions. |
Single point evaluation:
array([0.])
Multiple points evaluation:
Rosenbrock, H.H. (1960). “An automatic method for finding the greatest or least value of a function”. The Computer Journal. 3 (3): 175–184.