Skip to main content

LinUcbFast

Struct LinUcbFast 

Source
pub struct LinUcbFast { /* private fields */ }
Available on crate feature bandit only.
Expand description

Preview high-performance LinUCB implementation.

LinUcbFast maintains A^-1 directly with the Sherman-Morrison rank-one update. Selection and update are O(arm_count * d^2) and O(d^2) respectively. Its serde state is Preview and is not part of the frozen LinUcb state schema.

Implementations§

Source§

impl LinUcbFast

Source

pub fn new(config: LinUcbConfig) -> Result<Self, RillError>

Create an empty fast LinUCB from the same configuration as LinUcb.

Source

pub fn from_linucb(source: &LinUcb) -> Result<Self, RillError>

Convert a stable LinUCB state into the Preview fast representation.

Source

pub fn inverse_matrix(&self, arm: usize) -> Result<&[Vec<f64>], RillError>

Borrow one cached inverse matrix.

Source

pub const fn state_f64_count(&self) -> usize

Number of stored f64 values, excluding allocator metadata.

Source

pub fn score_arm( &self, arm: usize, context: &[f64], ) -> Result<LinUcbArmScore, RillError>

Explain one arm score in O(d^2).

Source

pub fn score_all( &self, context: &[f64], ) -> Result<Vec<LinUcbArmScore>, RillError>

Explain all arm scores in O(arm_count * d^2).

Source

pub fn select_deterministic(&self, context: &[f64]) -> Result<usize, RillError>

Deterministic lowest-index tie-break for replay and audit.

Source

pub fn validate(&self) -> Result<(), RillError>

Validate dimensions, finite values, symmetry and positive definiteness.

Trait Implementations§

Source§

impl Clone for LinUcbFast

Source§

fn clone(&self) -> LinUcbFast

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl ContextualBandit for LinUcbFast

Source§

fn arm_count(&self) -> usize

The number of arms (actions) available.
Source§

fn feature_count(&self) -> usize

The number of features in the context vector.
Source§

fn samples_seen(&self) -> u64

How many total samples the bandit has observed.
Source§

fn select( &self, context: &[f64], rng: &mut impl Rng, ) -> Result<usize, RillError>

Select an arm given the context vector, using the provided RNG. Read more
Source§

fn update( &mut self, arm: usize, context: &[f64], reward: f64, ) -> Result<(), RillError>

Update the bandit with the observed reward for a previously selected arm.
Source§

fn reset(&mut self)

Reset the bandit to its initial (no-data) state.
Source§

impl Debug for LinUcbFast

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl ValidateState for LinUcbFast

Source§

fn validate_state(&self) -> Result<(), RillError>

Validate the in-memory state of this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V