trieste.acquisition.function.continuous_thompson_sampling#

This module contains acquisition function builders for continuous Thompson sampling.

Module Contents#

class GreedyContinuousThompsonSampling(select_output: Callable[[trieste.types.TensorType], trieste.types.TensorType] = select_nth_output)[source]#

Bases: trieste.acquisition.interface.SingleModelGreedyAcquisitionBuilder[trieste.models.interfaces.HasTrajectorySampler]

Acquisition function builder for performing greedy continuous Thompson sampling. This builder return acquisition functions that are the negatives of approximate samples from the given ProbabilisticModel, as provided by the model’s get_trajectory() method. A set of such samples are to be maximized in a sequential greedy manner to provide the next recommended query points. Note that we actually return the negative of the trajectory, so that our acquisition optimizers (which are all maximizers) can be used to extract the minimisers of trajectories.

For more details about trajectory-based Thompson sampling see [HernandezLRPKAG17] and [WBT+20].

Parameters

select_output – A method that returns the desired trajectory from a trajectory sampler with shape […, B], where B is a batch dimension. Defaults to the :func:~`trieste.acquisition.utils.select_nth_output` function with output dimension 0.

prepare_acquisition_function(model: trieste.models.interfaces.HasTrajectorySampler, dataset: Optional[trieste.data.Dataset] = None, pending_points: Optional[trieste.types.TensorType] = None)trieste.models.interfaces.TrajectoryFunction[source]#
Parameters
  • model – The model.

  • dataset – The data from the observer (not used).

  • pending_points – The points already in the current batch (not used).

Returns

A negated trajectory sampled from the model.

update_acquisition_function(function: trieste.models.interfaces.TrajectoryFunction, model: trieste.models.interfaces.HasTrajectorySampler, dataset: Optional[trieste.data.Dataset] = None, pending_points: Optional[trieste.types.TensorType] = None, new_optimization_step: bool = True)trieste.models.interfaces.TrajectoryFunction[source]#
Parameters
  • function – The trajectory function to update.

  • model – The model.

  • dataset – The data from the observer (not used).

  • pending_points – The points already in the current batch (not used).

  • new_optimization_step – Indicates whether this call to update_acquisition_function is to start of a new optimization step, of to continue collecting batch of points for the current step. Defaults to True.

Returns

A new trajectory sampled from the model.

class ParallelContinuousThompsonSampling(select_output: Callable[[trieste.types.TensorType], trieste.types.TensorType] = select_nth_output)[source]#

Bases: trieste.acquisition.interface.SingleModelVectorizedAcquisitionBuilder[trieste.models.interfaces.HasTrajectorySampler]

Acquisition function builder for performing parallel continuous Thompson sampling.

This builder provides broadly the same behavior as our GreedyContinuousThompsonSampler however optimizes trajectory samples in parallel rather than sequentially. Consequently, ParallelContinuousThompsonSampling can choose query points faster than GreedyContinuousThompsonSampler however it has much larger memory usage.

For a convenient way to control the total memory usage of this acquisition function, see our split_acquisition_function_calls wrapper.

Parameters

select_output – A method that returns the desired trajectory from a trajectory sampler with shape […, B], where B is a batch dimension. Defaults to the :func:~`trieste.acquisition.utils.select_nth_output` function with output dimension 0.

prepare_acquisition_function(model: trieste.models.interfaces.HasTrajectorySampler, dataset: Optional[trieste.data.Dataset] = None)trieste.models.interfaces.TrajectoryFunction[source]#
Parameters
  • model – The model.

  • dataset – The data from the observer (not used).

Returns

A negated trajectory sampled from the model.

update_acquisition_function(function: trieste.models.interfaces.TrajectoryFunction, model: trieste.models.interfaces.HasTrajectorySampler, dataset: Optional[trieste.data.Dataset] = None)trieste.models.interfaces.TrajectoryFunction[source]#
Parameters
  • function – The trajectory function to update.

  • model – The model.

  • dataset – The data from the observer (not used).

Returns

A new trajectory sampled from the model.

class _DummyTrajectoryFunctionClass[source]#

Bases: trieste.models.interfaces.TrajectoryFunctionClass

An TrajectoryFunctionClass is a trajectory function represented using a class rather than as a standalone function. Using a class to represent a trajectory function makes it easier to update and resample without having to retrace the function.

__call__(x: trieste.types.TensorType)trieste.types.TensorType[source]#

Call trajectory function.

negate_trajectory_function(function: trieste.models.interfaces.TrajectoryFunction, select_output: Optional[Callable[[trieste.types.TensorType], trieste.types.TensorType]] = None, function_type: Optional[Type[trieste.models.interfaces.TrajectoryFunction]] = None)trieste.models.interfaces.TrajectoryFunction[source]#

Return the negative of trajectories and select the output to form the acquisition function, so that our acquisition optimizers (which are all maximizers) can be used to extract the minimizers of trajectories.

We negate the trajectory function object’s call method, as it may have e.g. update and resample methods, and select the output we wish to use.