Thompson Sampling

Thompson Sampling is a probabilistic acquisition function that samples from the posterior distribution of the surrogate model. It naturally balances exploration and exploitation by selecting candidates according to their probability of being optimal.

class alf_tools.optimizer.acquisition_functions.thompson_sampling.ThompsonSampling(seed=0)[source]

Bases: AcquisitionFunction

Thompson Sampling acquisition function.

A generalisation of Thompson Sampling to the case where batch size > num posterior samples.

For an ensemble surrogate (empirical_dist), each point is scored by its maximum rank under any ensemble member, when predictions are sorted in ascending order. (Higher predictions correspond to higher ranks.) We return the maximum rank for each candidate as an acquisition value, so that higher is better.

For a Gaussian-process surrogate (per-candidate means/variances but no empirical_dist), we draw one posterior sample per candidate from N(mean, std) and use the sample as the acquisition value (higher is better). The sampling RNG is seeded by combining the seed argument with the round, so seed replications decorrelate while staying reproducible.

This is a maximising acquisition function.