optimpv.optimizers.axBOtorch package

Submodules

optimpv.optimizers.axBOtorch.EGBO module

Evolution-Guided Bayesian Optimization (EGBO) Acquisition Function for Ax-Botorch Modular Framework.

class optimpv.optimizers.axBOtorch.EGBO.EGBOAcquisition(surrogate: Surrogate, search_space_digest: SearchSpaceDigest, torch_opt_config: TorchOptConfig, botorch_acqf_class: type[AcquisitionFunction], botorch_acqf_options: dict[str, Any], botorch_acqf_classes_with_options: list[tuple[type[AcquisitionFunction], dict[str, Any]]] | None = None, n: int | None = None, options: dict[str, Any] | None = None, pop_size: int = 256, EA_algo: str = 'UNSGA3')[source]

Bases: Acquisition

Implement the acquisition function of Evolution-Guided Bayesian Optimization (EGBO).

Based on the following paper: Low, A.K.Y., Mekki-Berrada, F., Gupta, A. et al. Evolution-guided Bayesian optimization for constrained multi-objective optimization in self-driving labs. npj Comput Mater 10, 104 (2024). https://doi.org/10.1038/s41524-024-01274-x

Code inspired the repository: https://github.com/andrelowky/CMOO-Algorithm-Development/

optimize(n: int, search_space_digest: SearchSpaceDigest, inequality_constraints: list[tuple[Tensor, Tensor, float]] | None = None, fixed_features: dict[int, float] | None = None, rounding_func: Callable[[Tensor], Tensor] | None = None, optimizer_options: dict[str, Any] | None = None) tuple[Tensor, Tensor, Tensor][source]

Generate a set of candidates via multi-start optimization. Obtains candidates and their associated acquisition function values.

Parameters:
  • n – The number of candidates to generate.

  • search_space_digest – A SearchSpaceDigest object containing search space properties, e.g. bounds for optimization.

  • inequality_constraints – A list of tuples (indices, coefficients, rhs), with each tuple encoding an inequality constraint of the form sum_i (X[indices[i]] * coefficients[i]) >= rhs.

  • fixed_features – A map {feature_index: value} for features that should be fixed to a particular value during generation.

  • rounding_func – A function that post-processes an optimization result appropriately (i.e., according to round-trip transformations).

  • optimizer_options – Options for the optimizer function, e.g. sequential or raw_samples.

Returns:

A three-element tuple containing an n x d-dim tensor of generated candidates, a tensor with the associated acquisition values, and a tensor with the weight for each candidate.

optimpv.optimizers.axBOtorch.axBOtorchOptimizer module

optimpv.optimizers.axBOtorch.axUtils module

Utility functions for the Ax/Botorch library

optimpv.optimizers.axBOtorch.axUtils.ConvertParamsAx(params)[source]

Convert the params to the format required by the Ax/Botorch library

Parameters:

params (list of Fitparam() objects) – list of Fitparam() objects

Returns:

list of dictionaries with the following keys:

’name’: string: the name of the parameter ‘type’: string: ‘range’ or ‘fixed’ ‘bounds’: list of float: the lower and upper bounds of the parameter

Return type:

list of dict

optimpv.optimizers.axBOtorch.axUtils.CreateObjectiveFromAgent(agent)[source]

Create the objective function from the agent

Parameters:

agent (Agent() object) – the agent object

Returns:

the objective function

Return type:

function

optimpv.optimizers.axBOtorch.axUtils.get_VMLC_default_model_kwargs_list(num_free_params, use_CENTER=False, is_MOO=False, has_categorical=False)[source]

Get the default model kwargs list that VMLC-PV likes to use. This includes the use of log transforms, standardization of the outputs, and an ARD 5/2 Matern kernel. We also use the qLogNoisyExpectedImprovement acquisition function for single objective optimization and the qLogExpectedHypervolumeImprovement for multi-objective optimization.

Parameters:
  • num_free_params (int) – Number of free parameters in the model.

  • use_CENTER (bool, optional) – Whether to use the CENTER model configuration, by default False

  • is_MOO (bool, optional) – Whether the model is for multi-objective optimization, by default False

Returns:

List of model kwargs dictionaries for the Ax/Botorch library.

Return type:

list of dict

optimpv.optimizers.axBOtorch.axUtils.get_df_ax_client_metrics(params, ax_client, all_metrics)[source]

Get the dataframe from the ax client and rescale the parameters to their true scale. The dataframe contains the parameters and the objective values. The parameters are rescaled to their true scale. The objective values are the mean of the objective values. The dataframe is returned as a pandas dataframe.

Parameters:
  • params (list of FitParam() objects) – List of Fitparam() objects.

  • ax_client (object) – Ax client object.

  • all_metrics (list of str) – List of objective names.

Returns:

Dataframe containing the parameters and the objective values.

Return type:

pd.DataFrame

Raises:

ValueError – trying to rescale a parameter that is not int or float

optimpv.optimizers.axBOtorch.axUtils.get_df_from_ax(params, optimizer)[source]

Get the dataframe from the ax client and rescale the parameters to their true scale. The dataframe contains the parameters and the objective values. The parameters are rescaled to their true scale. The objective values are the mean of the objective values. The dataframe is returned as a pandas dataframe.

Parameters:
  • params (list of FitParam() objects) – List of Fitparam() objects.

  • optimizer (object) – Optimizer object from optimpv.axBOtorch.axBOtorch The optimizer object contains the ax client and the experiment.

Returns:

Dataframe containing the parameters and the objective values.

Return type:

pd.DataFrame

Raises:

ValueError – trying to rescale a parameter that is not int or float

Module contents