src.environment.problem.SOO.COCO_BBOB.bbob_surrogate¶
Problem Difficulty Classification¶
Difficulty Mode |
Training Set |
Testing Set |
|---|---|---|
easy |
Easy problems (see dimension-specific splits below) |
Difficult problems |
difficult |
Difficult problems |
Easy problems |
Dimension-specific classifications:
2D: Easy: 1-6, 8-15, 20, 22 | Difficult: 7, 16-19, 21, 23, 24
5D: Easy: 1-15, 20 | Difficult: 16-19, 21-24
10D: Easy: 1-15, 20 | Difficult: 16-19, 21-24
Note: When difficulty is ‘all’, both training and testing sets contain all functions (1-24).
Module Contents¶
Classes¶
Introduction¶BBOB-Surrogate investigates the integration of surrogate modeling techniques into MetaBBO , enabling data-driven approximation of expensive objective functions while maintaining optimization fidelity. |
|
Introduction¶BBOB-Surrogate investigates the integration of surrogate modeling techniques into MetaBBO , enabling data-driven approximation of expensive objective functions while maintaining optimization fidelity. |
API¶
- class src.environment.problem.SOO.COCO_BBOB.bbob_surrogate.MLP(input_dim)[source]¶
Bases:
torch.nn.ModuleInitialization
- class src.environment.problem.SOO.COCO_BBOB.bbob_surrogate.bbob_surrogate_model(dim, func_id, lb, ub, shift, rotate, bias, config)[source]¶
Bases:
src.environment.problem.SOO.COCO_BBOB.bbob_numpy.Basic_ProblemIntroduction¶
BBOB-Surrogate investigates the integration of surrogate modeling techniques into MetaBBO , enabling data-driven approximation of expensive objective functions while maintaining optimization fidelity.
Original paper¶
“Surrogate Learning in Meta-Black-Box Optimization: A Preliminary Study.” arXiv preprint arXiv:2503.18060 (2025).
Official Implementation¶
Initialization
Introduction¶
Initializes the surrogate model for a BBOB (Black-Box Optimization Benchmarking) function with a specified dimension, function ID, and transformation parameters. Depending on the function ID and dimension, loads either a KAN or MLP surrogate model from the appropriate directory and prepares it for evaluation on the specified device.
Args:¶
dim (int): The dimensionality of the optimization problem.
func_id (int): The ID of the BBOB function to be modeled.
lb (float or np.ndarray): The lower bound(s) of the search space.
ub (float or np.ndarray): The upper bound(s) of the search space.
shift (np.ndarray): The shift vector applied to the function.
rotate (np.ndarray): The rotation matrix applied to the function.
bias (float): The bias added to the function value.
config (object): Configuration object containing device information.
Attributes:¶
dim (int): Problem dimensionality.
func_id (int): BBOB function ID.
instance (object): Instantiated BBOB function with transformations.
device (str or torch.device): Device for model computation.
optimum (None): Placeholder for the optimum value.
model (KAN or MLP): Loaded surrogate model for the function.
ub (float or np.ndarray): Upper bound(s) of the search space.
lb (float or np.ndarray): Lower bound(s) of the search space.
Raises:¶
ValueError: If the specified dimension is not supported for training.
- func(x)[source]¶
Introduction¶
Evaluates the surrogate model on the given input
x, normalizing it to the model’s expected input range, and returns the model’s output.Args:¶
x (np.ndarray or torch.Tensor): The input vector(s) to evaluate. Can be a NumPy array or a PyTorch tensor.
Returns:¶
np.ndarray: If
xis a NumPy array, returns the model output as a flattened NumPy array.torch.Tensor: If
xis a PyTorch tensor, returns the model output as a tensor.
Notes:¶
The input is normalized using the lower (
self.lb) and upper (self.ub) bounds before being passed to the model.The computation is performed without tracking gradients.
- eval(x)[source]¶
Introduction¶
Evaluates the objective function for a given input, supporting both single individuals and populations. Measures and accumulates the evaluation time.
Args:¶
x (np.ndarray): Input array representing either a single individual (1D) or a population (2D or higher).
Built-in Attribute:¶
self.func: The objective function to be evaluated.
self.T1: Accumulates the total evaluation time in milliseconds.
Returns:¶
float or np.ndarray: The evaluated objective value(s) for the input individual or population.
Raises:¶
ValueError: If the input array
xdoes not have at least one dimension.
- class src.environment.problem.SOO.COCO_BBOB.bbob_surrogate.bbob_surrogate_Dataset(data, batch_size=1)[source]¶
Bases:
torch.utils.data.DatasetIntroduction¶
BBOB-Surrogate investigates the integration of surrogate modeling techniques into MetaBBO , enabling data-driven approximation of expensive objective functions while maintaining optimization fidelity.
Original paper¶
“Surrogate Learning in Meta-Black-Box Optimization: A Preliminary Study.” arXiv preprint arXiv:2503.18060 (2025).
Official Implementation¶
Initialization
Initializes the object with provided data and batch size, and computes relevant attributes.
Args:¶
data (list): A list of data items, each expected to have a
dimattribute.batch_size (int, optional): The number of items per batch. Defaults to 1.
Attributes:¶
data (list): Stores the input data.
batch_size (int): Stores the batch size.
N (int): The total number of data items.
ptr (list): List of starting indices for each batch.
index (np.ndarray): Array of indices for the data.
maxdim (int): The maximum
dimvalue among all data items.
- static get_datasets(version='torch', suit='bbob-surrogate-10D', train_batch_size=1, test_batch_size=1, difficulty='easy', user_train_list=None, user_test_list=None, seed=3849, shifted=True, biased=True, rotated=True, config=None, upperbound=5)[source]¶
Introduction¶
Generates training and testing datasets for BBOB surrogate benchmark problems, supporting different dimensions, difficulty levels, and custom configurations. The function creates surrogate and true BBOB function instances with optional shifting, rotation, and bias, and returns them as datasets suitable for machine learning workflows.
Args:¶
version (str, optional): Dataset version, default is ‘torch’.
suit (str, optional): Benchmark suite, one of ‘bbob-surrogate-10D’, ‘bbob-surrogate-5D’, or ‘bbob-surrogate-2D’. Default is ‘bbob-surrogate-10D’.
train_batch_size (int, optional): Batch size for the training dataset. Default is 1.
test_batch_size (int, optional): Batch size for the testing dataset. Default is 1.
difficulty (str or None, optional): Difficulty level of the problem. One of ‘easy’, ‘difficult’, ‘all’, or None. Default is ‘easy’.
user_train_list (list or None, optional): Custom list of function IDs for the training set. Default is None.
user_test_list (list or None, optional): Custom list of function IDs for the testing set. Default is None.
seed (int, optional): Random seed for reproducibility. Default is 3849.
shifted (bool, optional): Whether to apply a random shift to the functions. Default is True.
biased (bool, optional): Whether to add a random bias to the functions. Default is True.
rotated (bool, optional): Whether to apply a random rotation to the functions. Default is True.
config (object or None, optional): Configuration object to set additional parameters (e.g., dimension). Default is None.
upperbound (float, optional): Upper bound for the function domain. Default is 5.
Returns:¶
bbob_surrogate_Dataset: Training dataset containing surrogate function instances.
bbob_surrogate_Dataset: Testing dataset containing true BBOB function instances.
Raises:¶
ValueError: If the difficulty or suite is invalid, or if required arguments are missing or inconsistent.
- __len__()[source]¶
Introduction¶
Returns the number of elements or items in the object.
Built-in Attribute:¶
len is a special method used by Python’s built-in len() function.
Returns:¶
int: The number of elements contained in the object, as defined by the attribute
self.N.
- __getitem__(item)[source]¶
Introduction¶
Retrieves a batch of data items corresponding to the given index or slice.
Args:¶
item (int or slice): The index or slice specifying which batch to retrieve.
Built-in Attribute:¶
self.ptr (list or array-like): Pointer(s) to the start of each batch.
self.index (list or array-like): Indices mapping to the data storage.
self.batch_size (int): The size of each batch.
self.N (int): The total number of data items.
self.data (list or array-like): The data storage from which items are retrieved.
Returns:¶
list: A list containing the data items for the specified batch.
Raises:¶
IndexError: If the provided index is out of range.
- __add__(other: src.environment.problem.SOO.COCO_BBOB.bbob_surrogate.bbob_surrogate_Dataset)[source]¶
Introduction¶
Implements the addition operator for
bbob_surrogate_Datasetobjects, allowing two datasets to be combined.Args:¶
other (bbob_surrogate_Dataset): Another dataset to add to the current instance.
Returns:¶
bbob_surrogate_Dataset: A new dataset containing the combined data from both datasets, using the batch size of the current instance.
Raises:¶
AttributeError: If
otherdoes not have adataattribute.
- shuffle()[source]¶
Introduction¶
Randomly shuffles the indices of the dataset and updates the
indexattribute with a new random permutation.Built-in Attribute:¶
self.N (int): The total number of elements to shuffle.
self.index (torch.Tensor): Stores the shuffled indices.
Returns:¶
None
Notes:¶
Uses
torch.randpermto generate a random permutation of indices for the dataset.