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§
Sourcefn rng_state(&self) -> [u8; 32]
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.
Sourcefn restore_rng_state(&mut self, state: &[u8; 32])
fn restore_rng_state(&mut self, state: &[u8; 32])
Restore RNG state from a checkpoint.
§Arguments
state- A 32-byte array previously returned byrng_state()
Sourcefn current_seed(&self) -> u64
fn current_seed(&self) -> u64
Get the current seed value.