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.
- 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)#