pub struct ProbSessionScheduler { /* private fields */ }Expand description
A Markov-chain protocol simulator: makes probabilistic choices at each
Choice node according to supplied weights.
Implementations§
Source§impl ProbSessionScheduler
impl ProbSessionScheduler
Sourcepub fn new(branches: Vec<ProbBranch>) -> Self
pub fn new(branches: Vec<ProbBranch>) -> Self
Create a new scheduler with the given branches.
Sourcepub fn probabilities(&self) -> Vec<f64>
pub fn probabilities(&self) -> Vec<f64>
Normalise the weights to proper probabilities that sum to 1.
Sourcepub fn greedy_choice(&self) -> Option<usize>
pub fn greedy_choice(&self) -> Option<usize>
Sample a branch index deterministically by taking the one with the highest weight (useful for testing without a random source).
Sourcepub fn expected_rounds(&self) -> f64
pub fn expected_rounds(&self) -> f64
Expected number of rounds: sum of (prob × cost) for each branch, where cost is approximated as 1 for non-End, 0 for End.
Auto Trait Implementations§
impl Freeze for ProbSessionScheduler
impl RefUnwindSafe for ProbSessionScheduler
impl Send for ProbSessionScheduler
impl Sync for ProbSessionScheduler
impl Unpin for ProbSessionScheduler
impl UnsafeUnpin for ProbSessionScheduler
impl UnwindSafe for ProbSessionScheduler
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
Mutably borrows from an owned value. Read more