mcframework.backends.SequentialBackend#
- class mcframework.backends.SequentialBackend[source]#
Bases:
objectSequential (single-threaded) execution backend.
Executes simulation draws one at a time on the main thread. Suitable for small simulations or debugging.
Examples
>>> backend = SequentialBackend() >>> results = backend.run(sim, n_simulations=1000, seed_seq=None, progress_callback=None)
Methods
Run simulations sequentially on a single thread.
- run(sim: MonteCarloSimulation, n_simulations: int, seed_seq: np.random.SeedSequence | None, progress_callback: Callable[[int, int], None] | None, **simulation_kwargs: Any) np.ndarray[source]#
Run simulations sequentially on a single thread.
- Parameters:
- sim
MonteCarloSimulation The simulation instance to run.
- n_simulations
int Number of simulation draws to perform.
- seed_seq
SeedSequenceorNone Seed sequence for creating a deterministic RNG stream. When provided, a dedicated RNG is spawned and passed to each
single_simulationcall via the_rngkeyword, matching the reproducibility semantics of parallel backends.- progress_callback
callable()orNone Optional callback
f(completed, total)for progress reporting.- **simulation_kwargs
Any Additional keyword arguments passed to
single_simulation.
- sim
- Returns:
np.ndarrayArray of simulation results with shape
(n_simulations,).
- classmethod __new__(*args, **kwargs)#
- __init__(*args, **kwargs)#