Skip to main content

Predictor

Trait Predictor 

Source
pub trait Predictor: Send {
    // Required methods
    fn update(&mut self, sym: bool);
    fn revert(&mut self);
    fn predict_prob(&mut self, sym: bool) -> f64;
    fn model_name(&self) -> String;
    fn boxed_clone(&self) -> Box<dyn Predictor>;

    // Provided methods
    fn commit_update(&mut self, sym: bool) { ... }
    fn update_history(&mut self, sym: bool) { ... }
    fn commit_update_history(&mut self, sym: bool) { ... }
    fn pop_history(&mut self) { ... }
    fn begin_rollback_scope(&mut self) { ... }
    fn rollback_scope(&mut self) -> bool { ... }
    fn predict_one(&mut self) -> f64 { ... }
}
Expand description

Interface for an AIXI world model.

Predictors are mutated behind &mut self and cloned per worker during parallel MCTS. They only need Send, not Sync, which avoids unsound thread-sharing requirements for backends with thread-confined internals.

Required Methods§

Source

fn update(&mut self, sym: bool)

Incorporates a new symbol into the model’s training history.

Source

fn revert(&mut self)

Reverts the model to its state before the last update.

Source

fn predict_prob(&mut self, sym: bool) -> f64

Predicts the probability of the next symbol being sym.

Source

fn model_name(&self) -> String

Returns a human-readable name of the predictive model.

Source

fn boxed_clone(&self) -> Box<dyn Predictor>

Creates a boxed clone of this predictor.

Provided Methods§

Source

fn commit_update(&mut self, sym: bool)

Incorporates a new symbol as committed training history without retaining rollback state when the predictor supports that optimization.

Source

fn update_history(&mut self, sym: bool)

Appends a symbol to the model’s interaction history without necessarily updating the training counts immediately (backend dependent).

Source

fn commit_update_history(&mut self, sym: bool)

Appends a symbol as committed interaction history without retaining rollback state when the predictor supports that optimization.

Source

fn pop_history(&mut self)

Reverts the model to its state before the last update_history.

Source

fn begin_rollback_scope(&mut self)

Begins an optional coarse rollback scope for simulation-heavy callers.

Predictors that support this can avoid retaining per-symbol rollback state until the matching rollback_scope call.

Source

fn rollback_scope(&mut self) -> bool

Rolls back to the last scope opened with begin_rollback_scope.

Returns true when a scope rollback was performed, allowing callers to skip per-symbol revert loops.

Source

fn predict_one(&mut self) -> f64

Shorthand for predict_prob(true).

Implementors§

Source§

impl Predictor for CtwPredictor

Source§

impl Predictor for FacCtwPredictor

Source§

impl Predictor for MambaPredictor

Available on crate feature backend-mamba only.
Source§

impl Predictor for RateBackendBitPredictor

Source§

impl Predictor for RosaPredictor

Source§

impl Predictor for RwkvPredictor

Available on crate feature backend-rwkv only.
Source§

impl Predictor for ZpaqPredictor