physbo.test_functions.single_objective module
- class physbo.test_functions.single_objective.Ackley(dim: int = 2, a: float = 20.0, b: float = 0.2, min_X: ndarray | list[float] | float = -32.768, max_X: ndarray | list[float] | float = 32.768, test_maximizer: bool = True)[source]
Bases:
SingleTestFunctionAckley function.
\[\text{Minimize}\quad f(\boldsymbol{x}) = -a \exp \left( -b \sqrt{\frac{1}{n} \sum_{i=1}^n x_i^2} \right) - \exp \left( \frac{1}{n} \sum_{i=1}^n \cos(c x_i) \right) + a + \exp(1)\]Global minimum: \(f(\boldsymbol{0}) = 0\).
- Parameters:
dim (int, default=2) – Number of dimensions \(n\).
a (float, default=20.0) – First parameter.
b (float, default=0.2) – Second parameter.
min_X (np.ndarray | list[float] | float, default=-32.768) – Minimum value of search space for each dimension.
max_X (np.ndarray | list[float] | float, default=32.768) – Maximum value of search space for each dimension.
test_maximizer (bool, default=True) – If True, the test function is negated for testing a maximization problem solver.
References
Ackley, D. H. (1987) “A connectionist machine for genetic hillclimbing”, Kluwer Academic Publishers, Boston MA. p. 13-14.
- f(x: ndarray) ndarray[source]
Evaluate the test function at the given point.
- Parameters:
x (np.ndarray) – The point at which to evaluate the test function. x is a numpy array of shape (n, d), where n is the number of points and d is the dimension of the input space.
- Returns:
f – The value of the test function at the given point. The output value is a numpy array of shape (n, k), where k is the number of objectives.
- Return type:
np.ndarray
- class physbo.test_functions.single_objective.Beale(min_X: ndarray | list[float] | float = -4.5, max_X: ndarray | list[float] | float = 4.5, test_maximizer: bool = True)[source]
Bases:
SingleTestFunctionBeale function.
\[\text{Minimize}\quad f(\boldsymbol{x}) = (1.5 - x_1 + x_1 x_2)^2 + (2.25 - x_1 + x_1 x_2^2)^2 + (2.625 - x_1 + x_1 x_2^3)^2\]Global minimum: \(f(3, 0.5) = 0\).
- Parameters:
min_X (np.ndarray | list[float] | float, default=-4.5) – Minimum value of search space for each dimension.
max_X (np.ndarray | list[float] | float, default=4.5) – Maximum value of search space for each dimension.
test_maximizer (bool, default=True) – If True, the test function is negated for testing a maximization problem solver.
- f(x: ndarray) ndarray[source]
Evaluate the test function at the given point.
- Parameters:
x (np.ndarray) – The point at which to evaluate the test function. x is a numpy array of shape (n, d), where n is the number of points and d is the dimension of the input space.
- Returns:
f – The value of the test function at the given point. The output value is a numpy array of shape (n, k), where k is the number of objectives.
- Return type:
np.ndarray
- class physbo.test_functions.single_objective.Booth(min_X: ndarray | list[float] | float = -10.0, max_X: ndarray | list[float] | float = 10.0, test_maximizer: bool = True)[source]
Bases:
SingleTestFunctionBooth function.
\[\text{Minimize}\quad f(\boldsymbol{x}) = (x_1 + 2 x_2 - 7)^2 + (2 x_1 + x_2 - 5)^2\]Global minimum: \(f(1, 3) = 0\).
- Parameters:
min_X (np.ndarray | list[float] | float, default=-10.0) – Minimum value of search space for each dimension.
max_X (np.ndarray | list[float] | float, default=10.0) – Maximum value of search space for each dimension.
test_maximizer (bool, default=True) – If True, the test function is negated for testing a maximization problem solver.
- f(x: ndarray) ndarray[source]
Evaluate the test function at the given point.
- Parameters:
x (np.ndarray) – The point at which to evaluate the test function. x is a numpy array of shape (n, d), where n is the number of points and d is the dimension of the input space.
- Returns:
f – The value of the test function at the given point. The output value is a numpy array of shape (n, k), where k is the number of objectives.
- Return type:
np.ndarray
- class physbo.test_functions.single_objective.Easom(min_X: ndarray | list[float] | float = -100.0, max_X: ndarray | list[float] | float = 100.0, test_maximizer: bool = True)[source]
Bases:
SingleTestFunctionEasom function.
\[\text{Minimize}\quad f(\boldsymbol{x}) = -\cos(x_1) \cos(x_2) \exp \left( -((x_1 - \pi)^2 + (x_2 - \pi)^2) \right) + 1\]Global minimum: \(f(\pi, \pi) = 0\).
- Parameters:
min_X (np.ndarray | list[float] | float, default=-100.0) – Minimum value of search space for each dimension.
max_X (np.ndarray | list[float] | float, default=100.0) – Maximum value of search space for each dimension.
test_maximizer (bool, default=True) – If True, the test function is negated for testing a maximization problem solver.
- f(x: ndarray) ndarray[source]
Evaluate the test function at the given point.
- Parameters:
x (np.ndarray) – The point at which to evaluate the test function. x is a numpy array of shape (n, d), where n is the number of points and d is the dimension of the input space.
- Returns:
f – The value of the test function at the given point. The output value is a numpy array of shape (n, k), where k is the number of objectives.
- Return type:
np.ndarray
- class physbo.test_functions.single_objective.Himmelblau(min_X: ndarray | list[float] | float = -5.0, max_X: ndarray | list[float] | float = 5.0, test_maximizer: bool = True)[source]
Bases:
SingleTestFunctionHimmelblau’s function.
\[\text{Minimize}\quad f(\boldsymbol{x}) = (x_1^2 + x_2 - 11)^2 + (x_1 + x_2^2 - 7)^2\]Global minimum: \(f(3, 2) = f(-2.805118, 3.131312) = f(-3.779310, -3.283186) = f(3.584428, -1.848126) = 0\).
- Parameters:
min_X (np.ndarray | list[float] | float, default=-5.0) – Minimum value of search space for each dimension.
max_X (np.ndarray | list[float] | float, default=5.0) – Maximum value of search space for each dimension.
test_maximizer (bool, default=True) – If True, the test function is negated for testing a maximization problem solver.
References
Himmelblau, D. (1972). Applied Nonlinear Programming. McGraw-Hill.
- f(x: ndarray) ndarray[source]
Evaluate the test function at the given point.
- Parameters:
x (np.ndarray) – The point at which to evaluate the test function. x is a numpy array of shape (n, d), where n is the number of points and d is the dimension of the input space.
- Returns:
f – The value of the test function at the given point. The output value is a numpy array of shape (n, k), where k is the number of objectives.
- Return type:
np.ndarray
- class physbo.test_functions.single_objective.Matyas(min_X: ndarray | list[float] | float = -10.0, max_X: ndarray | list[float] | float = 10.0, test_maximizer: bool = True)[source]
Bases:
SingleTestFunctionMatyas function.
\[\text{Minimize}\quad f(\boldsymbol{x}) = 0.26 (x_1^2 + x_2^2) - 0.48 x_1 x_2\]Global minimum: \(f(0, 0) = 0\).
- Parameters:
min_X (np.ndarray | list[float] | float, default=-10.0) – Minimum value of search space for each dimension.
max_X (np.ndarray | list[float] | float, default=10.0) – Maximum value of search space for each dimension.
test_maximizer (bool, default=True) – If True, the test function is negated for testing a maximization problem solver.
- f(x: ndarray) ndarray[source]
Evaluate the test function at the given point.
- Parameters:
x (np.ndarray) – The point at which to evaluate the test function. x is a numpy array of shape (n, d), where n is the number of points and d is the dimension of the input space.
- Returns:
f – The value of the test function at the given point. The output value is a numpy array of shape (n, k), where k is the number of objectives.
- Return type:
np.ndarray
- class physbo.test_functions.single_objective.Rastrigin(dim: int = 2, A: float = 10.0, min_X: ndarray | list[float] | float = -5.12, max_X: ndarray | list[float] | float = 5.12, test_maximizer: bool = True)[source]
Bases:
SingleTestFunctionRastrigin function.
\[\text{Minimize}\quad f(\boldsymbol{x}) = A n + \sum_{i=1}^n (x_i^2 - A \cos(2 \pi x_i))\]Global minimum: \(f(\boldsymbol{0}) = 0\).
- Parameters:
dim (int, default=2) – Number of dimensions \(n\).
A (float, default=10.0) – Amplitude parameter.
min_X (np.ndarray | list[float] | float, default=-5.12) – Minimum value of search space for each dimension.
max_X (np.ndarray | list[float] | float, default=5.12) – Maximum value of search space for each dimension.
test_maximizer (bool, default=True) – If True, the test function is negated for testing a maximization problem solver.
References
Rastrigin, L. A. “Systems of extremal control.” Mir, Moscow (1974).
- f(x: ndarray) ndarray[source]
Evaluate the test function at the given point.
- Parameters:
x (np.ndarray) – The point at which to evaluate the test function. x is a numpy array of shape (n, d), where n is the number of points and d is the dimension of the input space.
- Returns:
f – The value of the test function at the given point. The output value is a numpy array of shape (n, k), where k is the number of objectives.
- Return type:
np.ndarray
- class physbo.test_functions.single_objective.Rosenbrock(dim: int = 2, a: float = 100.0, min_X: ndarray | list[float] | float = -5.0, max_X: ndarray | list[float] | float = 10.0, test_maximizer: bool = True)[source]
Bases:
SingleTestFunctionRosenbrock function.
\[\text{Minimize}\quad f(\boldsymbol{x}) = \sum_{i=1}^{n-1} \left( a (x_{i+1} - x_i^2)^2 + (1 - x_i)^2 \right)\]Global minimum: \(f(1, \dots, 1) = 0\).
- Parameters:
dim (int, default=2) – Number of dimensions \(n\). Must be >= 2.
a (float, default=100.0) – Amplitude parameter.
min_X (np.ndarray | list[float] | float, default=-5.0) – Minimum value of search space for each dimension.
max_X (np.ndarray | list[float] | float, default=10.0) – Maximum value of search space for each dimension.
test_maximizer (bool, default=True) – If True, the test function is negated for testing a maximization problem solver.
References
Rosenbrock, H.H. (1960). “An automatic method for finding the greatest or least value of a function”. The Computer Journal. 3 (3): 175-184. https://doi.org/10.1093/comjnl/3.3.175
- f(x: ndarray) ndarray[source]
Evaluate the test function at the given point.
- Parameters:
x (np.ndarray) – The point at which to evaluate the test function. x is a numpy array of shape (n, d), where n is the number of points and d is the dimension of the input space.
- Returns:
f – The value of the test function at the given point. The output value is a numpy array of shape (n, k), where k is the number of objectives.
- Return type:
np.ndarray
- class physbo.test_functions.single_objective.Schaffer2(min_X: ndarray | list[float] | float = -100.0, max_X: ndarray | list[float] | float = 100.0, test_maximizer: bool = True)[source]
Bases:
SingleTestFunctionSchaffer’s second function.
\[\text{Minimize}\quad f(\boldsymbol{x}) = 0.5 + \frac{\sin^2(x_1^2 - x_2^2) - 0.5}{(1 + 0.001 (x_1^2 + x_2^2))^2}\]Global minimum: \(f(0, 0) = 0\).
- Parameters:
min_X (np.ndarray | list[float] | float, default=-100.0) – Minimum value of search space for each dimension.
max_X (np.ndarray | list[float] | float, default=100.0) – Maximum value of search space for each dimension.
test_maximizer (bool, default=True) – If True, the test function is negated for testing a maximization problem solver.
- f(x: ndarray) ndarray[source]
Evaluate the test function at the given point.
- Parameters:
x (np.ndarray) – The point at which to evaluate the test function. x is a numpy array of shape (n, d), where n is the number of points and d is the dimension of the input space.
- Returns:
f – The value of the test function at the given point. The output value is a numpy array of shape (n, k), where k is the number of objectives.
- Return type:
np.ndarray
- class physbo.test_functions.single_objective.SingleTestFunction(dim: int, min_X: ndarray | list[float] | float, max_X: ndarray | list[float] | float, test_maximizer: bool)[source]
Bases:
TestFunctionInitialize the test function.
- Parameters:
nobj (int) – Number of objectives.
dim (int) – Number of dimensions.
min_X (np.ndarray | list[float] | float) – Minimum value of search space for each dimension.
max_X (np.ndarray | list[float] | float) – Maximum value of search space for each dimension.
test_maximizer (bool, default=True) – If True, the test function is negated for testing a maximization problem solver.
- class physbo.test_functions.single_objective.Sphere(dim: int = 2, min_X: ndarray | list[float] | float = -5.0, max_X: ndarray | list[float] | float = 5.0, test_maximizer: bool = True)[source]
Bases:
SingleTestFunctionSphere function.
\[\text{Minimize}\quad f(\boldsymbol{x}) = \sum_{i=1}^d x_i^2\]Global minimum: \(f(\boldsymbol{0}) = 0\).
- Parameters:
dim (int, default=2) – Number of dimensions.
min_X (np.ndarray | list[float] | float) – Minimum value of search space for each dimension.
max_X (np.ndarray | list[float] | float) – Maximum value of search space for each dimension.
test_maximizer (bool, default=True) – If True, the test function is negated for testing a maximization problem solver.
- f(x: ndarray) ndarray[source]
Evaluate the test function at the given point.
- Parameters:
x (np.ndarray) – The point at which to evaluate the test function. x is a numpy array of shape (n, d), where n is the number of points and d is the dimension of the input space.
- Returns:
f – The value of the test function at the given point. The output value is a numpy array of shape (n, k), where k is the number of objectives.
- Return type:
np.ndarray
- class physbo.test_functions.single_objective.StyblinskiTang(dim: int = 2, min_X: ndarray | list[float] | float = -5.0, max_X: ndarray | list[float] | float = 5.0, test_maximizer: bool = True)[source]
Bases:
SingleTestFunctionStyblinski-Tang function.
\[\text{Minimize}\quad f(\boldsymbol{x}) = \sum_{i=1}^n \left( \frac{x_i^4 - 16 x_i^2 + 5 x_i}{2} \right)\]Global minimum: \(f(-2.903534, \dots, -2.903534) \approx -39.16617 n\).
- Parameters:
dim (int, default=2) – Number of dimensions.
min_X (np.ndarray | list[float] | float, default=-5.0) – Minimum value of search space for each dimension.
max_X (np.ndarray | list[float] | float, default=5.0) – Maximum value of search space for each dimension.
test_maximizer (bool, default=True) – If True, the test function is negated for testing a maximization problem solver.
- f(x: ndarray) ndarray[source]
Evaluate the test function at the given point.
- Parameters:
x (np.ndarray) – The point at which to evaluate the test function. x is a numpy array of shape (n, d), where n is the number of points and d is the dimension of the input space.
- Returns:
f – The value of the test function at the given point. The output value is a numpy array of shape (n, k), where k is the number of objectives.
- Return type:
np.ndarray
- class physbo.test_functions.single_objective.ThreeHumpCamel(min_X: ndarray | list[float] | float = -5.0, max_X: ndarray | list[float] | float = 5.0, test_maximizer: bool = True)[source]
Bases:
SingleTestFunctionThree-hump camel function.
\[\text{Minimize}\quad f(\boldsymbol{x}) = 2 x_1^2 - 1.05 x_1^4 + x_1^6 / 6 + x_1 x_2 + x_2^2\]Global minimum: \(f(0, 0) = 0\).
- Parameters:
min_X (np.ndarray | list[float] | float, default=-5.0) – Minimum value of search space for each dimension.
max_X (np.ndarray | list[float] | float, default=5.0) – Maximum value of search space for each dimension.
test_maximizer (bool, default=True) – If True, the test function is negated for testing a maximization problem solver.
- f(x: ndarray) ndarray[source]
Evaluate the test function at the given point.
- Parameters:
x (np.ndarray) – The point at which to evaluate the test function. x is a numpy array of shape (n, d), where n is the number of points and d is the dimension of the input space.
- Returns:
f – The value of the test function at the given point. The output value is a numpy array of shape (n, k), where k is the number of objectives.
- Return type:
np.ndarray