MultiSimulation¶
-
class passengersim.driver.MultiSimulation(config: Config, output_dir: Path | None =
None)[source]¶ Bases:
BaseSimulation,CallbackMixinInitialize a BaseSimulation instance.
- Parameters:
Methods
__init__(config[, output_dir])Initialize a BaseSimulation instance.
Add callback events to the simulation event queue.
begin_sample_callback(callback)Register a function to be triggered at the beginning of each sample.
Get all callback functions.
daily_callback(callback)Register a function to be triggered each day during a sample.
end_sample_callback(callback)Register a function to be triggered at the end of each sample.
from_yaml(filenames[, output_dir])Create a Simulation object from a YAML file.
Get a mapping of path IDs to path names.
pathclasses_for_carrier(carrier)Generator of all path classes for a given carrier.
run(*[, summarizer, output_dir, ...])sequential_run(*[, summarizer])Adopt all globally registered callbacks.
Attributes
Generator of all demands in the simulation.
Generator of all fares in the simulation.
Access markets in the simulation.
Generator of all path classes in the simulation.
Generator of all paths in the simulation.
- sequential_run(*, summarizer=<class 'passengersim.summaries.SimulationTables'>)[source]¶
-
run(*, summarizer: type[SimulationTablesT] | SimulationTablesT | None =
None, output_dir: pathlib.Path | None =None, max_processes: int | None =None, fail_fast: bool =True, rich_progress: Progress | None =None)[source]¶
- add_callback_events()¶
Add callback events to the simulation event queue.
- apply_callback_functions(sim: CallbackMixin)¶
- begin_sample_callback(callback: Callable[[CallbackMixin], dict | None] | GenericTracer)¶
Register a function to be triggered at the beginning of each sample.
The callback function will be triggered after initial setup including all RM steps for the initial DCP, but before any customers can arrive.
- Parameters:
- callback : Callable[[Simulation], dict | None]¶
The callback function to register. It should accept a single argument, which will be the Simulation object, and return a dictionary of interesting things to store, or nothing.
- callback_functions() dict[str, list[Callable]]¶
Get all callback functions.
- daily_callback(callback: collections.abc.Callable[[CallbackMixin, int], dict | None] | GenericTracer | RmSys)¶
Register a function to be triggered each day during a sample.
The callback function will be triggered after all RM steps when the day coincides with a DCP.
- Parameters:
- callback : Callable[[Simulation, int], dict | None]¶
The callback function to register. It should accept two arguments, which will be the Simulation object and the days_prior, and return None.
- property demands¶
Generator of all demands in the simulation.
- Returns:
DemandIterator – Iterator object for accessing demand data.
- end_sample_callback(callback: Callable[[CallbackMixin], dict | None] | GenericTracer)¶
Register a function to be triggered at the end of each sample.
The callback function will be triggered before counters are reset or history buffers are rolled over.
- Parameters:
- callback : Callable[[Simulation], None]¶
The callback function to register. It should accept a single argument, which will be the Simulation object, and return a dictionary of interesting things to store, or nothing.
- property fares¶
Generator of all fares in the simulation.
- Returns:
FareIterator – Iterator object for accessing fare data.
-
classmethod from_yaml(filenames: Path | list[Path], output_dir: Path | None =
None)¶ Create a Simulation object from a YAML file.
- property markets : Mapping[str, Market]¶
Access markets in the simulation.
- Returns:
Mapping[str, Market] – A mapping of market names to Market objects.
- path_names()¶
Get a mapping of path IDs to path names.
- Returns:
dict – Dictionary mapping path IDs to string representations of paths.
- property pathclasses¶
Generator of all path classes in the simulation.
- Yields:
pathclass – Path class objects from all paths in the simulation.
- pathclasses_for_carrier(carrier: str)¶
Generator of all path classes for a given carrier.
- Parameters:
- carrier : str¶
The carrier name to filter path classes by.
- Yields:
pathclass – Path class objects for the specified carrier.
- property paths¶
Generator of all paths in the simulation.
- Returns:
generator – Generator yielding path objects from the simulation.
- use_registered_callbacks()¶
Adopt all globally registered callbacks.