ConnectionBuilderSettings

class passengersim.config.simulation_controls.ConnectionBuilderSettings[source]

Bases: PrettyModel

Settings for the automatic connection builder.

This tool generates connections in the simulation, converting legs into paths.

Attributes:

max_legs

The maximum number of legs to include in any generated path.

max_legs_if_nonstop_exists

The maximum number of legs to include in any generated path if a nonstop path exists in that market.

existing_paths

What to do with existing paths when generating new ones.

circuity_function

The function to use when deciding if a path is allowable due to circuity.

nonstop_leg_path_id_alignment

Whether to align path IDs with leg IDs for nonstop paths.

verbosity

The level of detail to include in connection builder logging.

min_paths_per_market

The minimum number of paths to generate for each market.

extra_max_connect_time_per_iteration

Extra time added to all maximum connection times at each iteration.

max_legs : Annotated[int, Field(ge=1, le=6)]

The maximum number of legs to include in any generated path.

max_legs_if_nonstop_exists : Annotated[int, Field(ge=1, le=6)]

The maximum number of legs to include in any generated path if a nonstop path exists in that market.

The nonstop path can be on any carrier.

existing_paths : Literal['keep', 'replace', 'required', 'none']

What to do with existing paths when generating new ones.

The default value is “keep”, which means that for any market where paths already exist they will be used, and no new paths will be generated. For markets where no paths exist, new paths will be generated as normal. Alternatively, set this to “none”, which has the same behavior as “keep” but will raise an error if the configuration includes any defined paths.

Other options are “replace”, which will remove all existing paths and then generating new ones for all markets, and “required”, which will prevent the generation of any new paths. If set to “required”, the connection builder will only serve as a check that all markets have paths, and will raise an error if any market is missing paths.

circuity_function : str

The function to use when deciding if a path is allowable due to circuity.

Circuity is the ratio of the total distance of the path to the direct distance between the origin and destination. The default function disallows paths that are excessively circuitous, with thresholds that vary based on the direct distance. Users can provide their own function with the same signature to implement custom circuity rules.

The circuity function is specified by name here and should be a registered circuity function. See passengersim.connection_builder.circuity for more details on circuity functions and how to register custom ones.

nonstop_leg_path_id_alignment : bool

Whether to align path IDs with leg IDs for nonstop paths.

By default, this is set to True, which means that any nonstop path (corresponds to a single leg) will be assigned the same ID as that leg by the path building algorithm. This can make it easier to identify and analyze nonstop paths in the simulation results. If set to False, nonstop paths will be assigned unique IDs that do not necessarily align with leg IDs. This generally corresponds to the behavior of the previous path building algorithm, and may be desirable in cases where there are existing results to compare against.

verbosity : int

The level of detail to include in connection builder logging.

min_paths_per_market : int

The minimum number of paths to generate for each market.

This is not a hard minimum, but the connection builder will make an effort to generate at least this many paths for each market, if possible given the other settings. This could be by progressively relaxing circuity rules, maximum connection times, or other tweaks. If the connection builder is unable to generate at least this many paths for a market, it will log a warning.

extra_max_connect_time_per_iteration : int

Extra time added to all maximum connection times at each iteration.

The connection builder iterates when the min_paths_per_market value is not met, potentially relaxing circuity rules at each iteration. This setting also allows for the relaxation of maximum connect times, by adding this many minutes to all maximum connection times at each iteration.