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, name: str | None = None)[ソース]
ベースクラス:
ABCAbstract class for test functions.
Test functions are used to evaluate the performance of the optimization algorithms.
Note
Each test function is implemented in the same sense (minimization or maximization) as in the reference it follows, so that
fand the docstring can be compared with the literature directly. A subclass declares its sense by the class attribute_is_maximization(Falseby default, i.e., minimization).test_maximizerselects the sense of the returned values: withtest_maximizer=True(the default) the values returned by__call__and the reference box always describe a maximization problem (as PHYSBO maximizes objectives), and withtest_maximizer=Falsethey always describe a minimization problem. The sign is flipped only when the declared sense and the requested sense differ.- パラメータ:
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 returned values describe a maximization problem (for testing a maximization problem solver such as PHYSBO). If False, they describe a minimization problem.
name (str | None, default=None) -- Name of the test function. If None, the class name is used.
- constraint(x: ndarray) ndarray[ソース]
Evaluate the constraint function at the given point.
- パラメータ:
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.
- 戻り値:
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.
- 戻り値の型:
np.ndarray
- property dim: int
Get the number of dimensions of the test function.
- 戻り値:
The number of dimensions of the test function d.
- 戻り値の型:
int
- abstractmethod f(x: ndarray) ndarray[ソース]
Evaluate the test function at the given point.
fis written in the sense of the reference (see_is_maximization); the conversion to the requested sense is done by__call__.- パラメータ:
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.
- 戻り値:
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.
- 戻り値の型:
np.ndarray
- property is_maximization: bool
Whether the test function is defined as a maximization problem in its reference.
This describes how
fis written, not the sense of the returned values (which is selected bytest_maximizer).- 戻り値:
True if the original problem is a maximization problem.
- 戻り値の型:
bool
- make_grid(num_X: int | list[int] | ndarray) ndarray[ソース]
Make a grid of points in the search space.
- パラメータ:
num_X (int | list[int] | np.ndarray) -- Number of points in each dimension.
- 戻り値:
The grid of points in the search space. The output is a numpy array of shape (N, d), where N is the number of points and d is the dimension of the search space.
- 戻り値の型:
np.ndarray
- property max_X: ndarray
Get the maximum values of the search space of the test function.
- 戻り値:
The maximum value of the test function for each dimension.
- 戻り値の型:
np.ndarray
- property min_X: ndarray
Get the minimum values of the search space of the test function.
- 戻り値:
The minimum value of the test function for each dimension.
- 戻り値の型:
np.ndarray
- property name: str
Get the name of the test function.
- 戻り値:
The name of the test function.
- 戻り値の型:
str
- property nobj: int
Get the number of objectives of the test function.
- 戻り値:
The number of objectives of the test function k.
- 戻り値の型:
int
- set_name(name: str)[ソース]
Set the name of the test function.
- パラメータ:
name (str) -- The name of the test function.
- property test_maximizer: bool
Whether the returned values describe a maximization problem.
- 戻り値:
True if
__call__returns values of a maximization problem.- 戻り値の型:
bool