trieste.ask_tell_optimization#

This module contains the Ask/Tell API for users of Trieste who would like to perform Bayesian Optimization with external control of the optimization loop.

Module Contents#

StateType[source]#

Unbound type variable.

SearchSpaceType[source]#

Type variable bound to SearchSpace.

TrainableProbabilisticModelType[source]#

Contravariant type variable bound to TrainableProbabilisticModel.

class AskTellOptimizer(search_space: SearchSpaceType, datasets: Mapping[trieste.types.Tag, trieste.data.Dataset], models: Mapping[trieste.types.Tag, TrainableProbabilisticModelType], *, fit_model: bool = True)           AskTellOptimizer(search_space: SearchSpaceType, datasets: Mapping[trieste.types.Tag, trieste.data.Dataset], models: Mapping[trieste.types.Tag, TrainableProbabilisticModelType], acquisition_rule: trieste.acquisition.rule.AcquisitionRule[trieste.types.TensorType, SearchSpaceType, TrainableProbabilisticModelType], *, fit_model: bool = True)           AskTellOptimizer(search_space: SearchSpaceType, datasets: Mapping[trieste.types.Tag, trieste.data.Dataset], models: Mapping[trieste.types.Tag, TrainableProbabilisticModelType], acquisition_rule: trieste.acquisition.rule.AcquisitionRule[trieste.types.State[StateType | None, trieste.types.TensorType], SearchSpaceType, TrainableProbabilisticModelType], acquisition_state: StateType | None, *, fit_model: bool = True)           AskTellOptimizer(search_space: SearchSpaceType, datasets: trieste.data.Dataset, models: TrainableProbabilisticModelType, *, fit_model: bool = True)           AskTellOptimizer(search_space: SearchSpaceType, datasets: trieste.data.Dataset, models: TrainableProbabilisticModelType, acquisition_rule: trieste.acquisition.rule.AcquisitionRule[trieste.types.TensorType, SearchSpaceType, TrainableProbabilisticModelType], *, fit_model: bool = True)           AskTellOptimizer(search_space: SearchSpaceType, datasets: trieste.data.Dataset, models: TrainableProbabilisticModelType, acquisition_rule: trieste.acquisition.rule.AcquisitionRule[trieste.types.State[StateType | None, trieste.types.TensorType], SearchSpaceType, TrainableProbabilisticModelType], acquisition_state: StateType | None = None, *, fit_model: bool = True)[source]#

Bases: Generic[SearchSpaceType, TrainableProbabilisticModelType]

This class provides Ask/Tell optimization interface. It is designed for those use cases when control of the optimization loop by Trieste is impossible or not desirable. For more details about the Bayesian Optimization routine, refer to BayesianOptimizer.

Parameters
  • search_space – The space over which to search for the next query point.

  • datasets – Already observed input-output pairs for each tag.

  • models – The model to use for each Dataset in datasets.

  • acquisition_rule – The acquisition rule, which defines how to search for a new point on each optimization step. Defaults to EfficientGlobalOptimization with default arguments. Note that if the default is used, this implies the tags must be OBJECTIVE and the search space can be any SearchSpace.

  • acquisition_state – The optional acquisition state for stateful acquisitions.

  • fit_model – If True (default), models passed in will be optimized on the given data. If False, the models are assumed to be optimized already.

Raises

ValueError – If any of the following are true: - the keys in datasets and models do not match - datasets or models are empty - default acquisition is used but incompatible with other inputs

__repr__()str[source]#

Print-friendly string representation

property datasetsMapping[trieste.types.Tag, trieste.data.Dataset][source]#

The current datasets.

property datasettrieste.data.Dataset[source]#

The current dataset when there is just one dataset.

property modelsMapping[trieste.types.Tag, TrainableProbabilisticModelType][source]#

The current models.

property modeltrieste.models.TrainableProbabilisticModel[source]#

The current model when there is just one model.

property acquisition_stateStateType | None[source]#

The current acquisition state.

classmethod from_record(record: Record[StateType] | FrozenRecord[StateType], search_space: SearchSpaceType, acquisition_rule: AcquisitionRule[TensorType | State[StateType | None, TensorType], SearchSpaceType, TrainableProbabilisticModelType] | None = None)AskTellOptimizer[SearchSpaceType, TrainableProbabilisticModelType][source]#

Creates new AskTellOptimizer instance from provided optimization state. Model training isn’t triggered upon creation of the instance.

Parameters
  • record – Optimization state record.

  • search_space – The space over which to search for the next query point.

  • acquisition_rule – The acquisition rule, which defines how to search for a new point on each optimization step. Defaults to EfficientGlobalOptimization with default arguments.

Returns

New instance of AskTellOptimizer.

to_record(copy: bool = True)trieste.bayesian_optimizer.Record[StateType][source]#

Collects the current state of the optimization, which includes datasets, models and acquisition state (if applicable).

Parameters

copy – Whether to return a copy of the current state or the original. Copying is not supported for all model types. However, continuing the optimization will modify the original state.

Returns

An optimization state record.

to_result(copy: bool = True)trieste.bayesian_optimizer.OptimizationResult[StateType][source]#

Converts current state of the optimization into a OptimizationResult object.

Parameters

copy – Whether to return a copy of the current state or the original. Copying is not supported for all model types. However, continuing the optimization will modify the original state.

Returns

A OptimizationResult object.

ask()trieste.types.TensorType[source]#

Suggests a point (or points in batch mode) to observe by optimizing the acquisition function. If the acquisition is stateful, its state is saved.

Returns

A TensorType instance representing suggested point(s).

tell(new_data: Mapping[Tag, Dataset] | Dataset)None[source]#

Updates optimizer state with new data.

Parameters

new_data – New observed data.

Raises

ValueError – If keys in new_data do not match those in already built dataset.