University of Alberta, Amii and SODALab · 2022 to 2024

Bandits and Online Algorithms

The question

A bandit algorithm picks one of several options each round and sees the reward of only the one it picked. It has to balance trying options it knows little about against using the best one so far. Regret measures what that costs against the best choice in hindsight. Online algorithms have a related problem. They make each decision before the rest of the input arrives, and they can use a machine-learned prediction of what’s coming.

What I studied

Over two years I worked through bandits in five settings, from random rewards to an adversary that chooses them, and online algorithms that use predictions. I presented each topic as a seminar deck and wrote the derivations up in a report. The original code was lost with an old computer, so I rebuilt it from those notes and tested every algorithm against its proven guarantee.

Settings and algorithms
SettingAlgorithms
StochasticExplore-then-commit, UCB1, ε-greedy
BayesianThompson sampling, the Gittins index
AdversarialHedge, Exp3, Exp3-IX
ContextualExp4, LinUCB
RestlessThe Whittle index
Online, with predictionsConversion, ski rental, knapsack, matching

Random rewards

With random rewards, UCB1 plays the arm whose average plus a confidence bonus is highest, so every arm gets tried until the data rules it out. Explore-then-commit pays its whole exploration cost up front. ε-greedy never stops exploring, so its regret keeps growing.

Regret after 10,000 rounds five Gaussian arms, mean of 200 runs
UCB1
208
Explore-then-commit
436
ε-greedy
480
Lower is better. Explore-then-commit spends 400 of its 436 on exploration.

With a prior over the arms, Thompson sampling did better still, ending at regret 8 where UCB1 reached 76 on three Bernoulli arms. For discounted rewards the Gittins index is the optimal rule. I computed it with the report’s dynamic program, and it matches a published table in all 64 cells.

An adversary

An adversary that pays only the arm the learner is least likely to pull can hold a deterministic rule like UCB1 at zero reward. Exp3 picks arms at random from a weighted distribution and estimates every arm’s reward from the one it sees, which keeps its regret under a bound that holds for any reward sequence.

Regret against an adaptive adversary 10,000 rounds, five arms
UCB1
8,000
Exp3-IX
357
Exp3
351
Exp3’s bound here is 401. UCB1’s regret grows in a straight line.

Exp3’s bound holds in expectation. On a table whose best arm switches, 8.8 percent of its runs ended above it. Exp3-IX adds implicit exploration, which caps what one unlucky round can cost an arm, and none of its runs crossed the bound.

Context and restless arms

When each round comes with a context, such as a user’s features, the right arm depends on it. Scored offline on logged news recommendations with every parameter fixed in advance, LinUCB, which fits a model of clicks per article, earned twice the click rate of the best single article.

Click rate on logged news data replay evaluation, 20 orderings
LinUCB
0.533
Best single article
0.268
ε-greedy
0.214
UCB
0.162
Random
0.104

Restless arms change state whether they are pulled or not, like machines that wear out when worked and recover when rested. Exact planning there is intractable, and the Whittle index splits the problem into one arm at a time. On ten such arms it reached 98 to 99 percent of the best achievable reward when most arms could be worked each round, against 86 to 90 percent for a myopic rule.

Online algorithms with predictions

The learning-augmented algorithms take a trust parameter. It trades consistency, how well they do with a perfect prediction, against robustness, their worst case with any prediction. In every case below, the measured ratio matched the proven bound.

Measured ratios against the optimum trust parameter 0.5 where it applies
ProblemPerfect predictionAny predictionWithout predictions
One-way trading1.033.361.72
Ski rental1.282.551.59
Each ratio compares the algorithm with the offline optimum, so 1 is perfect and higher is worse. One-way trading uses Sun et al. (2021) with a price range ratio of 5; ski rental uses the primal-dual method of Bamas et al. (2020).

The classical primal-dual algorithms reach their guarantees too. The knapsack threshold rule meets its bound of 1 + ln θ where greedy can be a thousand times worse than the optimum, and water-filling matching reaches 1 − 1/e on the hard instance where greedy falls to one half.