DatasetGenerator

class DatasetGenerator

Bases: object

A generator of (random) input-output pairs of black-box function(s) as initial data for black-box optimization.

Methods

__init__

Initialize the generator.

generate

Generate a dataset consisting multiple unique input-output pairs.

__init__(
objective: BlackBoxFuncBase | list[BlackBoxFuncBase],
meet_constraints: bool = True,
seed: int = 0,
) None

Initialize the generator.

For multiple-objective optimization, you can:

  1. Specify multiple black-box function class instances in a list. By doing so, the generated dataset for each black-box objective function satisfies all the user-defined constraints for variables across all black-box opbjective functions as well.

  2. Create and execute DatasetGenerator.generate for each of black-box objective function classes independently. You can set different number of samples in the dataset for different objective function class instances. This method is useful when you have training datasets for some of the objective functions, and only need to generate datasets for the rest of the objective functions. The drawback of this method is that if there are constraints that considers variables appearing different objective functions, the following meet_constraints has to be False, meaning such constraints are not considered in the initial dataset. If all constraints are about variables only used within the same objective function, such constraints can be considered here.

Parameters:
  • objective (BlackBoxFuncBase) – A black-box function class instance for single objective optimization, or a list of multiple objective function class instances for multi-objectives.

  • meet_constraints (bool, optional) – True if generated input vectors must meet the constraints. Defaults to True.

  • seed (int, optional) – A random seed. Defaults to 0.

generate(num_samples: int, method: str = 'random') Any

Generate a dataset consisting multiple unique input-output pairs. These inputs also satisfy all user-defined constraints if meet_constraints = True in DatasetGenerator.__init__.

Parameters:
  • num_samples (int) – A number of input-output pairs to generate.

  • method (str, optional) – A generation method. Defaults to “random”.

Returns:

The generated dataset with multiple input-output pairs. If multiple objective functions in a list are passed in DatasetGenerator.__init__, return multiple datasets in a tuple, each corresponds to one of the objective functions in a respective order.

Return type:

DataList | tuple[DataList, …]

__dict__ = mappingproxy({'__module__': 'amplify_bbopt.data_gen', '__doc__': 'A generator of (random) input-output pairs of black-box function(s) as initial data for black-box optimization.', '__init__': <function DatasetGenerator.__init__>, '_gen_input': <function DatasetGenerator._gen_input>, '_generate_input_constrained': <function DatasetGenerator._generate_input_constrained>, '_generate_inputs': <function DatasetGenerator._generate_inputs>, 'generate': <function DatasetGenerator.generate>, '__dict__': <attribute '__dict__' of 'DatasetGenerator' objects>, '__weakref__': <attribute '__weakref__' of 'DatasetGenerator' objects>, '__annotations__': {}})
__weakref__

list of weak references to the object (if defined)