Skip to main content

Reproducible

Trait Reproducible 

Source
pub trait Reproducible {
    // Required methods
    fn set_seed(&mut self, seed: u64);
    fn rng_state(&self) -> [u8; 32];
    fn restore_rng_state(&mut self, state: &[u8; 32]);
    fn current_seed(&self) -> u64;
}
Expand description

Reproducibility trait for deterministic simulation.

Implements EDD-03: Deterministic Reproducibility.

§Guarantee

For all runs r1, r2 with identical seeds:

S(I, σ) → R₁ ∧ S(I, σ) → R₂ ⟹ R₁ ≡ R₂

§Example

impl Reproducible for MySimulation {
    fn set_seed(&mut self, seed: u64) {
        self.rng = StdRng::seed_from_u64(seed);
    }

    fn rng_state(&self) -> [u8; 32] {
        // Serialize RNG state for checkpointing
    }

    fn restore_rng_state(&mut self, state: &[u8; 32]) {
        // Restore RNG state from checkpoint
    }
}

Required Methods§

Source

fn set_seed(&mut self, seed: u64)

Set the master seed for all RNG operations.

Source

fn rng_state(&self) -> [u8; 32]

Get current RNG state for checkpointing.

Returns a 32-byte array representing the complete RNG state that can be used to restore the simulation to this exact point.

Source

fn restore_rng_state(&mut self, state: &[u8; 32])

Restore RNG state from a checkpoint.

§Arguments
  • state - A 32-byte array previously returned by rng_state()
Source

fn current_seed(&self) -> u64

Get the current seed value.

Implementors§