kumulant

SampleCountingPolicy

abstract class SampleCountingPolicy<R : Result>(sampleWeight: (R) -> Double) : BanditPolicy<R> (source)

Base for policies whose score depends on the population's total sample weight (the UCB family and annealed epsilon-greedy). Tracks that total and the arm count through update, addArm and removeArm; sampleWeight reads an arm snapshot's share of the total.

The counters are shared across arms, so concurrent updates use atomic cells.

Inheritors

Constructors

SampleCountingPolicy

constructor(sampleWeight: (R) -> Double)(source)

Properties

Link copied to clipboard
abstract val arm: Arm<R>

Per-arm cumulator spec; determines the prior pseudo-counts, value encoding, and result shape that evaluate consumes.

Functions

addArm

open override fun addArm(snapshot: R)(source)

Hook called when a new arm joins the population. Lets stateful policies fold the new arm's snapshot into their global counters (UCB's total-samples). Default no-op.

removeArm

open override fun removeArm(snapshot: R)(source)

Hook called when an arm leaves the population. Inverse of addArm; lets stateful policies remove the departing arm's contribution from their global counters. Default no-op.

update

open override fun update(stat: SeriesStat<R>, value: Double, weight: Double = 1.0)(source)

Fold an observed reward value (with optional weight) into the per-arm stat. Default applies arm.encode first; policies with global counters (UCB families) override to update their counter alongside the stat update.

Link copied to clipboard
open fun createArm(concurrency: Concurrency = Concurrency.None): SeriesStat<R>

Allocate a fresh per-arm accumulator from the arm spec with the given concurrency. Default delegates to arm.createStat(concurrency); override only if the policy needs a non-standard variant.

Link copied to clipboard

Fresh policy carrying the same configuration but no accumulated global state. A replica bandit must not share counters with the bandit it was created from, so any policy holding mutable state has to override this; the default returns this because a stateless policy is safe to share.

Link copied to clipboard
abstract fun evaluate(snapshot: R, step: Long, rng: Random): Double

Score an arm given its current snapshot. Higher scores are preferred by the bandit. step is the global update count (for time-dependent exploration schedules); rng is the bandit's shared com.eignex.kumulant.bandit.Bandit.random (consumed by sampling policies).