pub struct BanditParameter {
pub name: String,
/* private fields */
}Expand description
A single tunable parameter, discretized into arms and tuned by Thompson sampling over each arm’s Beta posterior.
Fields§
§name: StringHuman-readable parameter name (e.g. "mutation_rate").
Implementations§
Source§impl BanditParameter
impl BanditParameter
Sourcepub fn new(name: impl Into<String>, values: Vec<f64>) -> Self
pub fn new(name: impl Into<String>, values: Vec<f64>) -> Self
Create a parameter with the given candidate values and a uniform prior.
Sourcepub fn with_prior(
name: impl Into<String>,
values: Vec<f64>,
prior: BetaPosterior,
) -> Self
pub fn with_prior( name: impl Into<String>, values: Vec<f64>, prior: BetaPosterior, ) -> Self
Create a parameter with the given candidate values and a shared Beta prior.
Sourcepub fn select<R: Rng>(&mut self, rng: &mut R) -> f64
pub fn select<R: Rng>(&mut self, rng: &mut R) -> f64
Thompson-sample an arm and return its parameter value.
Draws one probability from each arm’s Beta posterior and selects the arm with the highest draw. The draw is used only to choose the arm; the returned value is the arm’s concrete parameter value.
Sourcepub fn observe(&mut self, improved: bool)
pub fn observe(&mut self, improved: bool)
Credit the most recently selected arm with an improvement outcome.
Sourcepub fn posterior_means(&self) -> Vec<f64>
pub fn posterior_means(&self) -> Vec<f64>
Posterior mean of P(improvement) for each arm, in arm order.
Sourcepub fn selection_counts(&self) -> Vec<u64>
pub fn selection_counts(&self) -> Vec<u64>
Selection (pull) count for each arm, in arm order.
Sourcepub fn selected_value(&self) -> Option<f64>
pub fn selected_value(&self) -> Option<f64>
Value chosen at the most recent select, if any.
Sourcepub fn selected_index(&self) -> Option<usize>
pub fn selected_index(&self) -> Option<usize>
Arm index chosen at the most recent select, if any.
Sourcepub fn best_index(&self) -> usize
pub fn best_index(&self) -> usize
Index of the arm with the highest posterior mean of P(improvement).
Sourcepub fn best_value(&self) -> f64
pub fn best_value(&self) -> f64
Value of the arm with the highest posterior mean of P(improvement).
Sourcepub fn total_observations(&self) -> f64
pub fn total_observations(&self) -> f64
Total number of improvement events credited across all arms.
Trait Implementations§
Source§impl Clone for BanditParameter
impl Clone for BanditParameter
Source§fn clone(&self) -> BanditParameter
fn clone(&self) -> BanditParameter
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 BanditParameter
impl RefUnwindSafe for BanditParameter
impl Send for BanditParameter
impl Sync for BanditParameter
impl Unpin for BanditParameter
impl UnsafeUnpin for BanditParameter
impl UnwindSafe for BanditParameter
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.