explore function

void explore(
  1. FutureOr<void> body(
    1. Simulation sim
    ), {
  2. int seeds = 100,
  3. int firstSeed = 0,
  4. FaultPolicy? faults,
  5. ActorSystemConfig config()?,
  6. int maxSteps = 100000,
  7. Duration maxTime = const Duration(hours: 1),
})

Runs body under seeds different seeds, starting at firstSeed, and stops at the first one it fails under.

The failure is rethrown as a SimulationFailure that names the seed and shows the last scheduling steps. Pass that seed to simulate to get the same run again.

Implementation

void explore(
  FutureOr<void> Function(Simulation sim) body, {
  int seeds = 100,
  int firstSeed = 0,
  FaultPolicy? faults,
  ActorSystemConfig Function()? config,
  int maxSteps = 100000,
  Duration maxTime = const Duration(hours: 1),
}) {
  for (var seed = firstSeed; seed < firstSeed + seeds; seed++) {
    final sim = Simulation._(seed, faults, maxSteps, maxTime);
    try {
      sim._run(body, config?.call());
    } catch (e, s) {
      throw SimulationFailure(seed, e, s, sim._trace);
    }
  }
}