pub struct Streams { /* private fields */ }Expand description
The run’s seed and seeding: hands out the random stream for each evaluation.
Model checking (TLC’s RandomEnumerableValues, TLCStateRandom):
Streams::startupis one stream, used in order by the constant definitions TLC evaluates at start-up, theASSUMEs, and the initial predicate, including invariants checked on initial states. In TLC this is the main thread’s generator:new Random(seed), never reseeded.Streams::stateis the stream for everything evaluated while expanding one state: its next-state relation (all actions, in order), and the checks on the successors. TLC reseeds the worker’s generator tofingerprint(state) ^ seedon the first draw for each newly expanded state, and keeps drawing from it for the rest of that expansion.- Trace reconstruction replays with the same streams:
Streams::startupfor the initial states, thenStreams::stateper predecessor (TLC resets the generator,ConcurrentTLCTrace.getTrace). In TLC the reset stream does not replay draws made by start-up definitions andASSUMEs beforeInit, so a violation that depends on them can lose its counterexample.
Simulation (TLC’s Simulator, SimulationWorker, DefaultRandom):
Streams::startupserves constants,ASSUMEs and the initial states, as above.- Each worker chooses initial states, actions and successors with its own
generator, seeded from
Streams::tlc_simulation_worker_seeds. - Each worker evaluates
RandomElementand friends withStreams::tlc_simulation_values,new Random(seed)per worker thread, never reseeded; so in TLC every worker draws the same value sequence.
In RandomMode::Dive, Streams::simulation_trace replaces both per-worker
generators with one stream per trace number, so traces are reproducible whatever
worker runs them.
Implementations§
Source§impl Streams
impl Streams
Sourcepub const fn new(seed: i64, mode: RandomMode) -> Self
pub const fn new(seed: i64, mode: RandomMode) -> Self
The streams of a run with seed (always reported) in mode.
Sourcepub const fn mode(&self) -> RandomMode
pub const fn mode(&self) -> RandomMode
The seeding mode.
Sourcepub const fn startup(&self) -> Stream
pub const fn startup(&self) -> Stream
The start-up stream: constant definitions, ASSUMEs and Init, in TLC’s
evaluation order.
Sourcepub const fn state(&self, fp: u64) -> Stream
pub const fn state(&self, fp: u64) -> Stream
The stream for expanding the state with fingerprint fp: under
RandomMode::Tlc TLC’s state fingerprint (TLCState.fingerPrint), seeding
new Random(fp ^ seed) (RandomEnumerableValues.TLCStateRandom).
Sourcepub fn tlc_simulation_worker_seeds(&self, aril: u64, workers: usize) -> Vec<i64>
pub fn tlc_simulation_worker_seeds(&self, aril: u64, workers: usize) -> Vec<i64>
TLC simulation: the seeds of the workers simulation workers’ generators,
rng.nextLong() each in worker order after rng.setSeed(seed, aril)
(TLC.process, Simulator constructor). With TLC’s default (no -seed) the
seed itself came from an unseeded generator and aril is ignored; pass 0.
Sourcepub const fn tlc_simulation_values(&self) -> JavaRandom
pub const fn tlc_simulation_values(&self) -> JavaRandom
TLC simulation: a worker thread’s generator for RandomElement and the
Randomization operators (RandomEnumerableValues.DefaultRandom).
Sourcepub const fn simulation_trace(&self, trace: u64) -> Stream
pub const fn simulation_trace(&self, trace: u64) -> Stream
dive simulation: the single stream of trace number trace (0-based, in the
order traces are numbered, not the order workers finish them). It drives the
choice of initial state, actions and successors, and the operators’ draws.