pub struct ThompsonSamplingTuner { /* private fields */ }Expand description
Thompson-sampling multi-armed-bandit tuner over GA operator parameters.
Each parameter (BanditParameter) is discretized into arms; every generation
select_all Thompson-samples one arm per parameter, whose
value the caller applies to its operators, and observe
credits every parameter’s selected arm with each improvement event. Distinct
parameters keep independent arms and posteriors, so (unlike the previous
learner) mutation-rate and crossover-probability posteriors are free to diverge.
Implementations§
Source§impl ThompsonSamplingTuner
impl ThompsonSamplingTuner
Sourcepub fn new(parameters: Vec<BanditParameter>) -> Self
pub fn new(parameters: Vec<BanditParameter>) -> Self
Create a tuner from an explicit set of parameters.
Sourcepub fn from_config(cfg: &ThompsonConfig) -> Self
pub fn from_config(cfg: &ThompsonConfig) -> Self
Build a tuner from a ThompsonConfig.
Sourcepub fn with_history(self, on: bool) -> Self
pub fn with_history(self, on: bool) -> Self
Enable or disable per-generation snapshot recording.
Sourcepub fn parameters(&self) -> &[BanditParameter]
pub fn parameters(&self) -> &[BanditParameter]
All tuned parameters.
Sourcepub fn parameter(&self, name: &str) -> Option<&BanditParameter>
pub fn parameter(&self, name: &str) -> Option<&BanditParameter>
Look up a parameter by name.
Sourcepub fn parameter_mut(&mut self, name: &str) -> Option<&mut BanditParameter>
pub fn parameter_mut(&mut self, name: &str) -> Option<&mut BanditParameter>
Look up a parameter by name (mutable).
Sourcepub fn select_all<R: Rng>(&mut self, rng: &mut R)
pub fn select_all<R: Rng>(&mut self, rng: &mut R)
Thompson-sample one arm per parameter for the coming generation.
Sourcepub fn selected(&self, name: &str) -> Option<f64>
pub fn selected(&self, name: &str) -> Option<f64>
Value selected for name at the most recent select_all.
Sourcepub fn observe(&mut self, improved: bool)
pub fn observe(&mut self, improved: bool)
Credit every parameter’s currently selected arm with one improvement event.
Sourcepub fn total_observations(&self) -> u64
pub fn total_observations(&self) -> u64
Total number of improvement events fed back to the tuner.
Sourcepub fn snapshot(&mut self, generation: usize)
pub fn snapshot(&mut self, generation: usize)
Record a snapshot of the current posteriors (no-op unless history is enabled).
Sourcepub fn history(&self) -> &[TunerSnapshot]
pub fn history(&self) -> &[TunerSnapshot]
Recorded per-generation snapshots (empty unless history is enabled).
Trait Implementations§
Source§impl Clone for ThompsonSamplingTuner
impl Clone for ThompsonSamplingTuner
Source§fn clone(&self) -> ThompsonSamplingTuner
fn clone(&self) -> ThompsonSamplingTuner
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for ThompsonSamplingTuner
impl RefUnwindSafe for ThompsonSamplingTuner
impl Send for ThompsonSamplingTuner
impl Sync for ThompsonSamplingTuner
impl Unpin for ThompsonSamplingTuner
impl UnsafeUnpin for ThompsonSamplingTuner
impl UnwindSafe for ThompsonSamplingTuner
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.