pub struct Simulation {
pub nodes: Vec<GossipNode>,
pub loss_rate: f64,
/* private fields */
}Expand description
The simulation environment.
Fields§
§nodes: Vec<GossipNode>Nodes in the simulation.
loss_rate: f64Message loss rate (0.0 = no loss, 1.0 = all lost).
Implementations§
Source§impl Simulation
impl Simulation
Sourcepub fn with_loss_rate(self, rate: f64) -> Self
pub fn with_loss_rate(self, rate: f64) -> Self
Set message loss rate.
Sourcepub fn run_until_converged(&mut self, max_rounds: u64) -> Option<u64>
pub fn run_until_converged(&mut self, max_rounds: u64) -> Option<u64>
Run simulation until convergence or max rounds. Returns the round at which convergence was reached, or None.
Sourcepub fn add_constraint(&mut self, node_idx: usize, constraint: &str)
pub fn add_constraint(&mut self, node_idx: usize, constraint: &str)
Add constraints to a specific node (simulate local operation).
Sourcepub fn record_satisfied(&mut self, node_idx: usize, count: u64)
pub fn record_satisfied(&mut self, node_idx: usize, count: u64)
Record satisfied constraints on a specific node.
Sourcepub fn is_converged(&self) -> bool
pub fn is_converged(&self) -> bool
Check if all nodes have converged to the same state.
Auto Trait Implementations§
impl Freeze for Simulation
impl RefUnwindSafe for Simulation
impl Send for Simulation
impl Sync for Simulation
impl Unpin for Simulation
impl UnsafeUnpin for Simulation
impl UnwindSafe for Simulation
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