BaseSimulation

class passengersim.driver.BaseSimulation(config: Config, output_dir: Path | None = None)[source]

Bases: ABC

Initialize a BaseSimulation instance.

Parameters:
config : Config

The simulation configuration object.

output_dir : pathlib.Path or None, optional

Directory for output files. If None, a temporary directory will be created automatically.

Methods

__init__(config[, output_dir])

Initialize a BaseSimulation instance.

from_yaml(filenames[, output_dir])

Create a Simulation object from a YAML file.

path_names()

Get a mapping of path IDs to path names.

pathclasses_for_carrier(carrier)

Generator of all path classes for a given carrier.

Attributes

demands

Generator of all demands in the simulation.

fares

Generator of all fares in the simulation.

markets

Access markets in the simulation.

pathclasses

Generator of all path classes in the simulation.

paths

Generator of all paths in the simulation.

classmethod from_yaml(filenames: Path | list[Path], output_dir: Path | None = None)[source]

Create a Simulation object from a YAML file.

Parameters:
filenames : pathlib.Path | list[pathlib.Path]

output_dir : pathlib.Path | None, optional

Returns:

Simulation

__init__(config: Config, output_dir: Path | None = None)[source]

Initialize a BaseSimulation instance.

Parameters:
config : Config

The simulation configuration object.

output_dir : pathlib.Path or None, optional

Directory for output files. If None, a temporary directory will be created automatically.

path_names()[source]

Get a mapping of path IDs to path names.

Returns:

dict – Dictionary mapping path IDs to string representations of paths.

property markets : Mapping[str, Market]

Access markets in the simulation.

Returns:

Mapping[str, Market] – A mapping of market names to Market objects.

property paths

Generator of all paths in the simulation.

Returns:

generator – Generator yielding path objects from the simulation.

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)[source]

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 demands

Generator of all demands in the simulation.

Returns:

DemandIterator – Iterator object for accessing demand data.

property fares

Generator of all fares in the simulation.

Returns:

FareIterator – Iterator object for accessing fare data.