strategies.api
strategies.api
Classes
| Name | Description |
|---|---|
| Strategy | Base class for all strategies |
| RandomStrategy | Strategy for randomly selecting new candidates. |
| DoEStrategy | Strategy for design of experiments. This strategy is used to generate a set of |
| FractionalFactorialStrategy | |
| SoboStrategy | |
| AdditiveSoboStrategy | |
| MultiplicativeSoboStrategy | |
| CustomSoboStrategy | |
| QparegoStrategy | |
| MoboStrategy | |
| BotorchStrategy | |
| EntingStrategy | Strategy for selecting new candidates using ENTMOOT |
| MultiFidelityStrategy | |
| ActiveLearningStrategy | ActiveLearningStrategy that uses an acquisition function which focuses on |
| ShortestPathStrategy | |
| StepwiseStrategy |
Strategy
strategies.api.Strategy(data_model)Base class for all strategies
Attributes:
Attributes
| Name | Description |
|---|---|
| candidates | Returns the (pending) candidates of the strategy. |
| domain | Returns the domain of the strategy. |
| experiments | Returns the experiments of the strategy. |
| inputs | Shortcut to access the inputs of the strategy’s domain. |
| num_candidates | Returns number of (pending) candidates |
| num_experiments | Returns number of experiments |
| outputs | Shortcut to access the outputs of the strategy’s domain. |
| seed | Returns the seed of the strategy. |
Methods
| Name | Description |
|---|---|
| add_candidates | Add pending candidates to the strategy. Appends to existing ones. |
| add_experiments | Add experiments to the strategy. Appends to existing ones. |
| ask | Function to generate new candidates. |
| from_spec | Used by the mapper to map from data model to functional strategy. |
| has_sufficient_experiments | Abstract method to check if sufficient experiments are available. |
| postprocess_candidates | Method to allow for postprocessing of candidates. |
| reset_candidates | Resets the pending candidates of the strategy. |
| set_candidates | Set pending candidates of the strategy. Overwrites existing ones. |
| set_experiments | Set experiments of the strategy. Overwrites existing ones. |
| tell | This function passes new experimental data to the optimizer |
| to_candidates | Transform candiadtes dataframe to a list of Candidate objects. |
add_candidates
strategies.api.Strategy.add_candidates(candidates)Add pending candidates to the strategy. Appends to existing ones.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| experiments | pd.DataFrame | Dataframe with candidates. | required |
add_experiments
strategies.api.Strategy.add_experiments(experiments)Add experiments to the strategy. Appends to existing ones.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| experiments | pd.DataFrame | Dataframe with experiments. | required |
ask
strategies.api.Strategy.ask(
candidate_count=None,
add_pending=False,
raise_validation_error=True,
)Function to generate new candidates.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| candidate_count | PositiveInt | Number of candidates to be generated. If not provided, the number of candidates is determined automatically. Defaults to None. | None |
| add_pending | bool | If true the proposed candidates are added to the set of pending experiments. Defaults to False. | False |
| raise_validation_error | bool | If true an error will be raised if candidates violate constraints, otherwise only a warning will be displayed. Defaults to True. | True |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | if candidate count is smaller than 1 | |
| ValueError | if not enough experiments are available to execute the strategy | |
| ValueError | if the number of generated candidates does not match the requested number |
Returns
| Name | Type | Description |
|---|---|---|
| pd.DataFrame | pd.DataFrame: DataFrame with candidates (proposed experiments) |
from_spec
strategies.api.Strategy.from_spec(data_model)Used by the mapper to map from data model to functional strategy.
has_sufficient_experiments
strategies.api.Strategy.has_sufficient_experiments()Abstract method to check if sufficient experiments are available.
Returns
| Name | Type | Description |
|---|---|---|
| bool | bool | True if number of passed experiments is sufficient, False otherwise |
postprocess_candidates
strategies.api.Strategy.postprocess_candidates(candidates)Method to allow for postprocessing of candidates.
By default this methods applies the stepsize of continuous features if applicable.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| candidates | pd.DataFrame | DataFrame with candidates. | required |
Returns: DataFrame with postprocessed candidates.
reset_candidates
strategies.api.Strategy.reset_candidates()Resets the pending candidates of the strategy.
set_candidates
strategies.api.Strategy.set_candidates(candidates)Set pending candidates of the strategy. Overwrites existing ones.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| experiments | pd.DataFrame | Dataframe with candidates. | required |
set_experiments
strategies.api.Strategy.set_experiments(experiments)Set experiments of the strategy. Overwrites existing ones.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| experiments | pd.DataFrame | Dataframe with experiments. | required |
tell
strategies.api.Strategy.tell(experiments, replace=False)This function passes new experimental data to the optimizer
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| experiments | pd.DataFrame | DataFrame with experimental data | required |
| replace | bool | Boolean to decide if the experimental data should replace the former DataFrame or if the new experiments should be attached. Defaults to False. | False |
to_candidates
strategies.api.Strategy.to_candidates(candidates)Transform candiadtes dataframe to a list of Candidate objects.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| candidates | pd.DataFrame | candidates formatted as dataframe | required |
Returns: List[Candidate]: candidates formatted as list of Candidate objects.
RandomStrategy
strategies.api.RandomStrategy(data_model, **kwargs)Strategy for randomly selecting new candidates.
This strategy generates candidate samples using the random strategy. It first checks if the domain is compatible with polytope sampling. If so, it uses polytope sampling to generate candidate samples. If not, it performs rejection sampling by repeatedly generating candidates with polytope sampling until the desired number of valid samples is obtained.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| data_model | data_models.RandomStrategy | The data model for the random strategy. | required |
| **kwargs | Additional keyword arguments. | {} |
Methods
| Name | Description |
|---|---|
| has_sufficient_experiments | Check if there are sufficient experiments for the strategy. |
| make | Create a new instance of the RandomStrategy class. |
has_sufficient_experiments
strategies.api.RandomStrategy.has_sufficient_experiments()Check if there are sufficient experiments for the strategy.
Returns
| Name | Type | Description |
|---|---|---|
| bool | bool | True if there are sufficient experiments, False otherwise. |
make
strategies.api.RandomStrategy.make(
domain,
fallback_sampling_method=None,
n_burnin=None,
n_thinning=None,
num_base_samples=None,
max_iters=None,
seed=None,
)Create a new instance of the RandomStrategy class. Args: domain: The domain we randomly sample from. fallback_sampling_method: The fallback sampling method to use when the domain has no constraints. n_burnin: The number of burn-in samples for the polytope sampler. n_thinning: The thinning factor for the polytope sampler. num_base_samples: The number of base samples for rejection sampling. max_iters: The maximum number of iterations for rejection sampling. seed: The seed value for random number generation. Returns: RandomStrategy: A new instance of the RandomStrategy class.
DoEStrategy
strategies.api.DoEStrategy(data_model, **kwargs)Strategy for design of experiments. This strategy is used to generate a set of experiments for a given domain. The experiments are generated via minimization of a user defined optimality criterion.
Methods
| Name | Description |
|---|---|
| has_sufficient_experiments | Abstract method to check if sufficient experiments are available. |
| make | Create a new design of experimence strategy instance. |
has_sufficient_experiments
strategies.api.DoEStrategy.has_sufficient_experiments()Abstract method to check if sufficient experiments are available.
Returns
| Name | Type | Description |
|---|---|---|
| bool | bool | True if number of passed experiments is sufficient, False otherwise |
make
strategies.api.DoEStrategy.make(
domain,
seed=None,
criterion=None,
verbose=None,
ipopt_options=None,
scip_params=None,
use_hessian=None,
use_cyipopt=None,
sampling=None,
return_fixed_candidates=None,
)Create a new design of experimence strategy instance. Args: domain: The domain for the strategy. seed: Random seed for reproducibility. criterion: Optimality criterion for the strategy. Default is d-optimality. verbose: Verbosity level. ipopt_options: Options for IPOPT solver. IPOPT is used to minize the optimality criterion. scip_params: Parameters for SCIP solver. SCIP is used to for backprojection of discrete and categorical variables. use_hessian: Whether to use Hessian information. use_cyipopt: Whether to use cyipopt. sampling: Initial points for the strategy. return_fixed_candidates: Whether to return fixed candidates. Returns: DoEStrategy: A new instance of the DoEStrategy class.
FractionalFactorialStrategy
strategies.api.FractionalFactorialStrategy(data_model, **kwargs)Methods
| Name | Description |
|---|---|
| make | Create a new instance of the strategy with the given parameters. This method will create the datamodel |
| randomize_design | Randomize the run order of the design if self.randomize_runorder is True. |
make
strategies.api.FractionalFactorialStrategy.make(
domain,
n_repetitions=None,
n_center=None,
block_feature_key=None,
generator=None,
n_generators=None,
randomize_runorder=None,
seed=None,
)Create a new instance of the strategy with the given parameters. This method will create the datamodel under the hood and pass it to the constructor of the strategy. Args: domain: The domain of the strategy. n_repetitions: The number of repetitions of the continuous part of the design. n_center: The number of center points in the continuous part of the design per block. block_feature_key: The feature key to use for blocking the design. generator: The generator for the continuous part of the design. n_generators: The number of reducing factors. randomize_runorder: If true, the run order is randomized, else it is deterministic. seed: The seed for the random number generator.
randomize_design
strategies.api.FractionalFactorialStrategy.randomize_design(design)Randomize the run order of the design if self.randomize_runorder is True.
SoboStrategy
strategies.api.SoboStrategy(data_model, **kwargs)Methods
| Name | Description |
|---|---|
| make | Creates a single objective Bayesian optimization strategy. |
make
strategies.api.SoboStrategy.make(
domain,
acquisition_function=None,
acquisition_optimizer=None,
surrogate_specs=None,
outlier_detection_specs=None,
min_experiments_before_outlier_check=None,
frequency_check=None,
frequency_hyperopt=None,
folds=None,
seed=None,
include_infeasible_exps_in_acqf_calc=False,
)Creates a single objective Bayesian optimization strategy. Args: domain: The optimization domain of the strategy. acquisition_function: The acquisition function to use. acquisition_optimizer: The optimizer to use for the acquisition function. surrogate_specs: The specifications for the surrogate model. outlier_detection_specs: The specifications for the outlier detection. min_experiments_before_outlier_check: The minimum number of experiments before checking for outliers. frequency_check: The frequency of checking for outliers. frequency_hyperopt: The frequency of hyperparameter optimization. folds: The number of folds for cross-validation. seed: The random seed to use. include_infeasible_exps_in_acqf_calc: Whether infeasible experiments should be included in the set of experiments used to compute the acquisition function.
AdditiveSoboStrategy
strategies.api.AdditiveSoboStrategy(data_model, **kwargs)Methods
| Name | Description |
|---|---|
| make | Creates a Bayesian optimization strategy that adds multiple objectives. |
make
strategies.api.AdditiveSoboStrategy.make(
domain,
use_output_constraints=None,
acquisition_function=None,
acquisition_optimizer=None,
surrogate_specs=None,
outlier_detection_specs=None,
min_experiments_before_outlier_check=None,
frequency_check=None,
frequency_hyperopt=None,
folds=None,
seed=None,
include_infeasible_exps_in_acqf_calc=False,
)Creates a Bayesian optimization strategy that adds multiple objectives. The weights of the objectives are defines in the outputs of the domain. Args: domain: The optimization domain of the strategy. use_output_constraints: Whether to use output constraints. acquisition_function: The acquisition function to use. acquisition_optimizer: The optimizer to use for the acquisition function. surrogate_specs: The specifications for the surrogate model. outlier_detection_specs: The specifications for the outlier detection. min_experiments_before_outlier_check: The minimum number of experiments before checking for outliers. frequency_check: The frequency of checking for outliers. frequency_hyperopt: The frequency of hyperparameter optimization. folds: The number of folds for cross-validation for hyperparameter optimization. seed: The random seed to use. include_infeasible_exps_in_acqf_calc: Whether infeasible experiments should be included in the set of experiments used to compute the acquisition function.
MultiplicativeSoboStrategy
strategies.api.MultiplicativeSoboStrategy(data_model, **kwargs)Methods
| Name | Description |
|---|---|
| make | Creates Bayesian optimization strategy that multiplies multiple objectives. The weights of |
make
strategies.api.MultiplicativeSoboStrategy.make(
domain,
acquisition_function=None,
acquisition_optimizer=None,
surrogate_specs=None,
outlier_detection_specs=None,
min_experiments_before_outlier_check=None,
frequency_check=None,
frequency_hyperopt=None,
folds=None,
seed=None,
include_infeasible_exps_in_acqf_calc=False,
)Creates Bayesian optimization strategy that multiplies multiple objectives. The weights of the objectives are defines in the outputs of the domain. Args: domain: The optimization domain of the strategy. acquisition_function: The acquisition function to use. acquisition_optimizer: The optimizer to use for the acquisition function. surrogate_specs: The specifications for the surrogate model. outlier_detection_specs: The specifications for the outlier detection. min_experiments_before_outlier_check: The minimum number of experiments before checking for outliers. frequency_check: The frequency of checking for outliers. frequency_hyperopt: The frequency of hyperparameter optimization. folds: The number of folds for cross-validation for hyperparameter optimization. seed: The random seed to use. include_infeasible_exps_in_acqf_calc: Whether infeasible experiments should be included in the set of experiments used to compute the acquisition function.
CustomSoboStrategy
strategies.api.CustomSoboStrategy(data_model, **kwargs)Methods
| Name | Description |
|---|---|
| dumps | Dumps the function to a string via pickle as this is not directly json serializable. |
| loads | Loads the function from a base64 encoded pickle bytes object and writes it to the model attribute. |
| make | The CustomSoboStrategy can be used to design custom objectives or objective combinations for optimizations. |
dumps
strategies.api.CustomSoboStrategy.dumps()Dumps the function to a string via pickle as this is not directly json serializable.
loads
strategies.api.CustomSoboStrategy.loads(data)Loads the function from a base64 encoded pickle bytes object and writes it to the model attribute.
make
strategies.api.CustomSoboStrategy.make(
domain,
use_output_constraints=None,
dump=None,
acquisition_function=None,
acquisition_optimizer=None,
surrogate_specs=None,
outlier_detection_specs=None,
min_experiments_before_outlier_check=None,
frequency_check=None,
frequency_hyperopt=None,
folds=None,
seed=None,
include_infeasible_exps_in_acqf_calc=False,
)The CustomSoboStrategy can be used to design custom objectives or objective combinations for optimizations. In this tutorial notebook, it is shown how to use it to optimize a quantity that depends on a combination of an inferred quantity and one of the inputs. See tutorials/advanced_examples/custom_sobo.ipynb.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| domain | Domain | The optimization domain of the strategy. | required |
| use_output_constraints | bool | None | Whether to use output constraints. | None |
| dump | str | None | The function to use for the optimization. | None |
| acquisition_function | AnySingleObjectiveAcquisitionFunction | None | The acquisition function to use. | None |
| acquisition_optimizer | AnyAcqfOptimizer | None | The optimizer to use for the acquisition function. | None |
| surrogate_specs | BotorchSurrogates | None | The specifications for the surrogate model. | None |
| outlier_detection_specs | OutlierDetections | None | The specifications for the outlier detection. | None |
| min_experiments_before_outlier_check | PositiveInt | None | The minimum number of experiments before checking for outliers. | None |
| frequency_check | PositiveInt | None | The frequency of checking for outliers. | None |
| frequency_hyperopt | int | None | The frequency of hyperparameter optimization. | None |
| folds | int | None | The number of folds for cross-validation. | None |
| seed | int | None | The random seed to use. | None |
| include_infeasible_exps_in_acqf_calc | bool | None | Whether infeasible experiments should be included in the set of experiments used to compute the acquisition function. | False |
QparegoStrategy
strategies.api.QparegoStrategy(data_model, **kwargs)Methods
| Name | Description |
|---|---|
| make | Creates an instance of the multi-objective strategy ParEGO using the provided configuration parameters. |
make
strategies.api.QparegoStrategy.make(
domain,
acquisition_function=None,
acquisition_optimizer=None,
surrogate_specs=None,
outlier_detection_specs=None,
min_experiments_before_outlier_check=None,
frequency_check=None,
frequency_hyperopt=None,
folds=None,
seed=None,
include_infeasible_exps_in_acqf_calc=False,
)Creates an instance of the multi-objective strategy ParEGO using the provided configuration parameters.
J. Knowles. Parego: a hybrid algorithm with on-line landscape approximation for expensive multiobjective optimization problems. IEEE Transactions on Evolutionary Computation, 10(1):50-66, 2006
S. Daulton, M. Balandat, and E. Bakshy. Differentiable Expected Hypervolume Improvement for Parallel Multi-Objective Bayesian Optimization. Advances in Neural Information Processing Systems 33, 2020.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| domain | Domain | The optimization domain of the strategy. | required |
| acquisition_function | qEI | qLogEI | qLogNEI | qNEI | None | The acquisition function to use. | None |
| acquisition_optimizer | AnyAcqfOptimizer | None | The optimizer for the acquisition function. | None |
| surrogate_specs | BotorchSurrogates | None | Specifications for the surrogate model. | None |
| outlier_detection_specs | OutlierDetections | None | Specifications for outlier detection. | None |
| min_experiments_before_outlier_check | PositiveInt | None | Minimum number of experiments before checking for outliers. | None |
| frequency_check | PositiveInt | None | Frequency of outlier checks. | None |
| frequency_hyperopt | int | None | Frequency of hyperparameter optimization. | None |
| folds | int | None | Number of folds for cross-validation for hyperparameter optimization. | None |
| seed | int | None | Random seed for reproducibility. | None |
| include_infeasible_exps_in_acqf_calc | bool | None | Whether infeasible experiments should be included in the set of experiments used to compute the acquisition function. | False |
Returns: An instance of the strategy configured with the provided parameters.
MoboStrategy
strategies.api.MoboStrategy(data_model, **kwargs)Methods
| Name | Description |
|---|---|
| make | Creates an instance of a multi-objective strategy based on expected hypervolume improvement. |
make
strategies.api.MoboStrategy.make(
domain,
ref_point=None,
acquisition_function=None,
acquisition_optimizer=None,
surrogate_specs=None,
outlier_detection_specs=None,
min_experiments_before_outlier_check=None,
frequency_check=None,
frequency_hyperopt=None,
folds=None,
seed=None,
include_infeasible_exps_in_acqf_calc=False,
)Creates an instance of a multi-objective strategy based on expected hypervolume improvement.
S. Daulton, M. Balandat, and E. Bakshy. Parallel Bayesian Optimization of Multiple Noisy Objectives with Expected Hypervolume Improvement. Advances in Neural Information Processing Systems 34, 2021.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| domain | Domain | The domain specifying the search space. | required |
| ref_point | ExplicitReferencePoint | Dict[str, float] | None | Reference point for hypervolume computation. | None |
| acquisition_function | AnyMultiObjectiveAcquisitionFunction | None | Acquisition function. | None |
| acquisition_optimizer | AnyAcqfOptimizer | None | Optimizer for the acquisition function. | None |
| surrogate_specs | BotorchSurrogates | None | Surrogate model specifications. | None |
| outlier_detection_specs | OutlierDetections | None | Outlier detection configuration. | None |
| min_experiments_before_outlier_check | PositiveInt | None | Minimum number of experiments before performing outlier detection. | None |
| frequency_check | PositiveInt | None | Frequency at which to perform outlier checks. | None |
| frequency_hyperopt | int | None | Frequency at which to perform hyperparameter optimization. | None |
| folds | int | None | Number of folds for cross-validation for hyperparameter optimization. | None |
| seed | int | None | Random seed for reproducibility. | None |
| include_infeasible_exps_in_acqf_calc | bool | None | Whether infeasible experiments should be included in the set of experiments used to compute the acquisition function. | False |
Returns: An instance of the strategy configured with the specified parameters.
BotorchStrategy
strategies.api.BotorchStrategy(data_model, **kwargs)Methods
| Name | Description |
|---|---|
| calc_acquisition | Calculate the acquisition value for a set of experiments. |
| get_acqf_input_tensors |
calc_acquisition
strategies.api.BotorchStrategy.calc_acquisition(candidates, combined=False)Calculate the acquisition value for a set of experiments.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| candidates | pd.DataFrame | Dataframe with experimentes for which the acqf value should be calculated. | required |
| combined | bool | If combined an acquisition value for the whole batch is calculated, else individual ones. Defaults to False. | False |
Returns
| Name | Type | Description |
|---|---|---|
| np.ndarray | np.ndarray: Dataframe with the acquisition values. |
get_acqf_input_tensors
strategies.api.BotorchStrategy.get_acqf_input_tensors()Returns
| Name | Type | Description |
|---|---|---|
| X_train | Tensor | Tensor of shape (n, d) with n training points and d input dimensions. |
| X_pending | Tensor | None | Tensor of shape (m, d) with m pending points |
EntingStrategy
strategies.api.EntingStrategy(data_model, **kwargs)Strategy for selecting new candidates using ENTMOOT
Methods
| Name | Description |
|---|---|
| make | Create an enting strategy instance with the specified parameters. |
make
strategies.api.EntingStrategy.make(
domain,
beta=None,
bound_coeff=None,
acq_sense=None,
dist_trafo=None,
dist_metric=None,
cat_metric=None,
kappa_fantasy=None,
num_boost_round=None,
max_depth=None,
min_data_in_leaf=None,
min_data_per_group=None,
verbose=None,
solver_name=None,
solver_verbose=None,
solver_params=None,
seed=None,
)Create an enting strategy instance with the specified parameters.
https://github.com/cog-imperial/entmoot
ENTMOOT: A Framework for Optimization over Ensemble Tree Models A. Thebelt, J. Kronqvist, M. Mistry, R. Lee, N. Sudermann-Merx, R. Misener Computers & Chemical Engineering, 2021
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| domain | Domain | The domain object defining the problem space. | required |
| beta | PositiveFloat | None | Parameter controlling the trade-off in acquisition. | None |
| bound_coeff | PositiveFloat | None | Coefficient for bounding constraints. | None |
| acq_sense | Literal['exploration', 'penalty'] | None | Acquisition sense, either “exploration” or “penalty”. | None |
| dist_trafo | Literal['normal', 'standard'] | None | Transformation applied to distances, either “normal” or “standard”. | None |
| dist_metric | Literal['euclidean_squared', 'l1', 'l2'] | None | Metric used for distance calculations, e.g., “euclidean_squared”, “l1”, or “l2”. | None |
| cat_metric | Literal['overlap', 'of', 'goodall4'] | None | Metric for categorical variables, e.g., “overlap”, “of”, or “goodall4”. | None |
| kappa_fantasy | float | None | Kappa parameter for fantasy strategy for batch proposals. | None |
| num_boost_round | PositiveInt | None | Number of boosting rounds for the model. | None |
| max_depth | PositiveInt | None | Maximum depth of the model. | None |
| min_data_in_leaf | PositiveInt | None | Minimum data points required in a leaf. | None |
| min_data_per_group | PositiveInt | None | Minimum data points required per group. | None |
| verbose | Literal[-1, 0, 1, 2] | None | Verbosity level of the process. | None |
| solver_name | str | None | Name of the solver to be used. | None |
| solver_verbose | bool | None | Whether to enable verbose output for the solver. | None |
| solver_params | Dict[str, Any] | None | Additional parameters for the solver. | None |
| seed | int | None | Random seed for reproducibility. | None |
Returns: A strategy instance configured with the provided parameters.
MultiFidelityStrategy
strategies.api.MultiFidelityStrategy(data_model, **kwargs)Methods
| Name | Description |
|---|---|
| make | Create a new instance of the multi-fidelity optimization strategy with the given parameters. This strategy |
make
strategies.api.MultiFidelityStrategy.make(
domain,
fidelity_thresholds=None,
acquisition_function=None,
acquisition_optimizer=None,
surrogate_specs=None,
outlier_detection_specs=None,
min_experiments_before_outlier_check=None,
frequency_check=None,
frequency_hyperopt=None,
folds=None,
seed=None,
include_infeasible_exps_in_acqf_calc=False,
)Create a new instance of the multi-fidelity optimization strategy with the given parameters. This strategy is useful if you have different measurement fidelities that measure the same thing with different cost and accuracy. As an example, you can have a simulation that is fast but inaccurate and the real experiment that is slow and expensive, but more accurate.
K. Kandasamy, G. Dasarathy, J. B. Oliva, J. Schneider, B. Póczos. Gaussian Process Bandit Optimisation with Multi-fidelity Evaluations. Advances in Neural Information Processing Systems, 29, 2016.
Jose Pablo Folch, Robert M Lee, Behrang Shafei, David Walz, Calvin Tsay, Mark van der Wilk, Ruth Misener. Combining Multi-Fidelity Modelling and Asynchronous Batch Bayesian Optimization. Computers & Chemical Engineering Volume 172, 2023.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| domain | Domain | The optimization domain of the strategy. | required |
| fidelity_thresholds | List[float] | float | None | The thresholds for the fidelity. If a single value is provided, it will be used for all fidelities. | None |
| acquisition_function | AnySingleObjectiveAcquisitionFunction | None | The acquisition function to use. | None |
| acquisition_optimizer | AnyAcqfOptimizer | None | The acquisition optimizer to use. | None |
| surrogate_specs | BotorchSurrogates | None | The specifications for the surrogate model. | None |
| outlier_detection_specs | OutlierDetections | None | The specifications for the outlier detection. | None |
| min_experiments_before_outlier_check | PositiveInt | None | The minimum number of experiments before checking for outliers. | None |
| frequency_check | PositiveInt | None | The frequency of outlier checks. | None |
| frequency_hyperopt | int | None | The frequency of hyperparameter optimization. | None |
| folds | int | None | The number of folds for cross-validation. | None |
| seed | int | None | The random seed to use. | None |
| include_infeasible_exps_in_acqf_calc | bool | None | Whether infeasible experiments should be included in the set of experiments used to compute the acquisition function. | False |
ActiveLearningStrategy
strategies.api.ActiveLearningStrategy(data_model, **kwargs)ActiveLearningStrategy that uses an acquisition function which focuses on pure exploration of the objective function only. Can be used for single and multi-objective functions.
Methods
| Name | Description |
|---|---|
| make | Creates an ActiveLearningStrategy instance. ActiveLearningStrategy that uses an acquisition function which focuses on |
make
strategies.api.ActiveLearningStrategy.make(
domain,
acquisition_optimizer=None,
surrogate_specs=None,
outlier_detection_specs=None,
min_experiments_before_outlier_check=None,
frequency_check=None,
frequency_hyperopt=None,
folds=None,
acquisition_function=None,
seed=None,
include_infeasible_exps_in_acqf_calc=False,
)Creates an ActiveLearningStrategy instance. ActiveLearningStrategy that uses an acquisition function which focuses on pure exploration of the objective function only. Can be used for single and multi-objective functions. Args: domain: Domain of the strategy. acquisition_optimizer: Acquisition optimizer to use. surrogate_specs: Surrogate specifications. outlier_detection_specs: Outlier detection specifications. min_experiments_before_outlier_check: Minimum number of experiments before checking for outliers. frequency_check: Frequency of outlier checks. frequency_hyperopt: Frequency of hyperparameter optimization. folds: Number of folds for cross-validation in hyperparameter optimization. acquisition_function: Acquisition function to use. seed: Seed for the random number generator. include_infeasible_exps_in_acqf_calc: Whether infeasible experiments should be included in the set of experiments used to compute the acquisition function. Returns: ActiveLearningStrategy: An instance of the ActiveLearningStrategy class.
ShortestPathStrategy
strategies.api.ShortestPathStrategy(data_model, **kwargs)Attributes
| Name | Description |
|---|---|
| continuous_inputs | Returns the continuous inputs from the domain. |
Methods
| Name | Description |
|---|---|
| get_linear_constraints | Returns the linear constraints in the form of matrices A and b, where Ax = b for |
| has_sufficient_experiments | Checks if there are sufficient experiments available. |
| make | Represents a strategy for finding the shortest path between two points |
| step | Takes a starting point and returns the next step in the shortest path. |
get_linear_constraints
strategies.api.ShortestPathStrategy.get_linear_constraints(constraints)Returns the linear constraints in the form of matrices A and b, where Ax = b for equality constraints and Ax <= b for inequality constraints.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| constraints | Constraints | The Constraints object containing the linear constraints. |
required |
Returns
| Name | Type | Description |
|---|---|---|
| Tuple[np.ndarray, np.ndarray] | Tuple[np.ndarray, np.ndarray]: A tuple containing the matrices A and b. |
has_sufficient_experiments
strategies.api.ShortestPathStrategy.has_sufficient_experiments()Checks if there are sufficient experiments available.
Returns
| Name | Type | Description |
|---|---|---|
| bool | bool | True if there are sufficient experiments, False otherwise. |
make
strategies.api.ShortestPathStrategy.make(
domain,
start=None,
end=None,
atol=None,
seed=None,
)Represents a strategy for finding the shortest path between two points Args: start: The starting point of the path. end: The ending point of the path. atol: The absolute tolerance used for numerical comparisons.
step
strategies.api.ShortestPathStrategy.step(start)Takes a starting point and returns the next step in the shortest path.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| start | pd.Series | The starting point for the shortest path. | required |
Returns
| Name | Type | Description |
|---|---|---|
| pd.Series | pd.Series: The next step in the shortest path. |
StepwiseStrategy
strategies.api.StepwiseStrategy(data_model, **kwargs)Methods
| Name | Description |
|---|---|
| get_step | Returns the strategy at the current step and the corresponding transform if given. |
| make | Create a StepwiseStrategy from a list of steps. Each step is a strategy the runs until a |
get_step
strategies.api.StepwiseStrategy.get_step()Returns the strategy at the current step and the corresponding transform if given.
make
strategies.api.StepwiseStrategy.make(domain, steps=None, seed=None)Create a StepwiseStrategy from a list of steps. Each step is a strategy the runs until a condition is satisfied. One example of a stepwise strategy is is to start with a few random samples to gather initial data for subsequent Bayesian optimization. An example steps-list for two random experiments followed by a SoboStrategy is:
from bofire.data_models.strategies.api import (
Step,
RandomStrategy,
SoboStrategy,
NumberOfExperimentsCondition,
AlwaysTrueCondition
)
from bofire.stratgies.api import StepwiseStrategy
steps = [
Step(
strategy_data=RandomStrategy(domain=domain),
condition=NumberOfExperimentsCondition(n_experiments=2),
),
Step(
strategy_data=SoboStrategy(domain=domain), condition=AlwaysTrueCondition()
)
]
stepwise_strategy = StepwiseStrategy.make(domain, steps)All passed domains need to compatible, i.e.,
- they have the same number of features,
- the same feature keys and
- the features with the same key have the same type and categories.
- The bounds and allowed categories of the features can vary.
Further, the data and domain are passed to the next step. They can also be transformed before being passed to the next step. Args: steps: List of steps to be used in the strategy. seed: Seed for random number generation.