soogo.model.base module
Surrogate model abstract base class.
- class soogo.model.base.Surrogate
Bases:
ABC
Abstract base class for surrogate models.
This class provides a common interface for different types of surrogate models such as Gaussian Processes and Radial Basis Function models. All surrogate models should inherit from this class and implement the abstract methods.
The interface is designed to support optimization algorithms that use surrogate models for approximating expensive objective functions.
- abstract property X: ndarray
Get the training input points.
- Returns:
m-by-d matrix with m training points in a d-dimensional space.
- abstract property Y: ndarray
Get the training output values.
- Returns:
m-by-n matrix with m training points and n target dimensions.
- abstractmethod __call__(x: ndarray, i: int = -1, **kwargs) ndarray | Tuple[ndarray, ...]
Evaluate the surrogate model at given points.
- Parameters:
x (
ndarray
) – m-by-d matrix with m point coordinates in a d-dimensional space.i (
int
) – Index of the target dimension to evaluate. If -1, evaluate all. (default:-1
)
- Return type:
Union
[ndarray
,Tuple
[ndarray
,...
]]- Returns:
Model predictions at the input points. Some models may return additional information such as uncertainty estimates.
- abstractmethod check_initial_design(sample: ndarray) bool
Check if the sample is able to generate a valid surrogate.
- Parameters:
sample (
ndarray
) – m-by-d matrix with m training points in a d-dimensional space.- Return type:
bool
- Returns:
True if the sample is valid for building the surrogate model.
- property dim: int
Get the dimension (d) of the input space.
- Returns:
Dimension of the input space.
- abstractmethod eval_kernel(x: ndarray, y: ndarray | None = None) ndarray
Evaluate the kernel function at a pair (x,y).
The structure of the kernel is the same as the one passed as parameter but with optimized hyperparameters.
- Parameters:
x (
ndarray
) – First entry in the tuple (x,y).y (
Optional
[ndarray
]) – Second entry in the tuple (x,y). If None, use x. (default:None
)
- Return type:
ndarray
- Returns:
Kernel evaluation result.
- abstract property iindex: tuple[int, ...]
Return the indices of integer variables in the feature space.
- Returns:
Tuple with indices of integer variables.
- abstractmethod min_design_space_size(dim: int) int
Return the minimum design space size for a given space dimension.
- Parameters:
dim (
int
) – Dimension of the space.- Return type:
int
- Returns:
Minimum number of points needed to build the surrogate model.
- property ntarget: int
Get the dimension (n) of the target space.
- Returns:
Dimension of the target space.
- property ntrain: int
Get the number of training points (m).
- Returns:
Number of training points.
- abstractmethod reserve(n: int, dim: int, ntarget: int = 1) None
Reserve space for training data.
- Parameters:
n (
int
) – Number of training points to reserve.dim (
int
) – Dimension of the input space.ntarget (
int
) – Dimension of the target space. (default:1
)
- Return type:
None
- abstractmethod reset_data() None
Reset the surrogate model training data.
This method is used to clear the training data of the surrogate model, allowing it to be reused for a new optimization run.
- Return type:
None
- abstractmethod update(x: ndarray, y: ndarray) None
Update the surrogate model with new training data.
- Parameters:
x (
ndarray
) – m-by-d matrix with m new point coordinates in a d-dimensional space.y (
ndarray
) – m-by-n matrix with m new function values and n target dimensions.
- Return type:
None