kumulant

Snapshotable

interface Snapshotable<S>(source)

Snapshot, merge, and replica creation for bandits, independent of their input shape.

S is the snapshot type. PerArmBandit uses List<R> with one Result per arm, including com.eignex.kumulant.bandit.univariate.Exp3Bandit's exponential weights. Workers can send snapshots to a coordinator without sharing live accumulators. Each implementation documents merge approximations and state omitted from its snapshots.

Inheritors

Functions

create

abstract fun create(random: Random): Snapshotable<S>(source)

Spawn a fresh bandit with the same configuration; state resets to the prior seed. The random source is replaced; pass the source you want the new bandit to use for exploration (which is independent of merging in another snapshot's state).

Useful when a worker accepts a stream of snapshots to apply sequentially: create(random).also { it.merge(snapshot) }.

merge

abstract fun merge(other: S)(source)

Fold another replica's other state into this bandit. Most families merge exactly via the underlying stat's parallel-merge formula; SGD- based contextual bandits merge approximately. Each concrete bandit's KDoc documents its merge semantics.

snapshot

abstract fun snapshot(): S(source)

Return the current state without adding observations or choosing an arm. Consistency follows the implementation's concurrency contract; a snapshot of independently updated cells need not represent a single instant.