physbo.test_functions.base module

class physbo.test_functions.base.TestFunction(nobj: int, dim: int, min_X: ndarray | list[float] | float, max_X: ndarray | list[float] | float, test_maximizer: bool = True)[source]

Bases: ABC

Abstract class for test functions.

Test functions are used to evaluate the performance of the optimization algorithms.

Note

The test function f should be defined as a minimization problem.

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

constraint(x: ndarray) ndarray[source]

Evaluate the constraint function at the given point.

Parameters:

x (np.ndarray) – The point at which to evaluate the constraint 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:

The boolean values indicating whether the point is valid or not. The output value is a numpy array of shape (n,), where n is the number of points.

Return type:

np.ndarray

property dim: int

Get the number of dimensions of the test function.

Returns:

The number of dimensions of the test function d.

Return type:

int

abstractmethod 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

property max_X: ndarray

Get the maximum values of the search space of the test function.

Returns:

The maximum value of the test function for each dimension.

Return type:

np.ndarray

property min_X: ndarray

Get the minimum values of the search space of the test function.

Returns:

The minimum value of the test function for each dimension.

Return type:

np.ndarray

property nobj: int

Get the number of objectives of the test function.

Returns:

The number of objectives of the test function k.

Return type:

int