default_circuity_function¶
-
passengersim.connection_builder.circuity.default_circuity_function(places: dict[str, Airport], legs: tuple[Leg, ...], dest: str | None =
None, iteration: int =0) bool[source]¶ Decide if the path is allowable.
- Parameters:
- places : dict[str, Airport]¶
A dictionary mapping airport codes to Airport objects containing their location information.
- legs : tuple[Leg,...]¶
A tuple of Leg objects representing the sequence of legs in the path.
- dest : str | None, optional¶
The code of the destination airport, if available. Defaults to the dest attribute of the last leg in legs if not provided. When building 3+ leg paths, the destination may be different from the final leg’s destination, in which case this function is evaluating not whether the proposed path is acceptable (it isn’t) but whether the proposed path could be the beginning of an acceptable path.
- iteration : int, optional¶
The current iteration of the connection builder. This can be used to allow for different circuity rules in different iterations, for example to allow more circuitous paths in later iterations when not enough valid paths were created in earlier iterations. Defaults to 0.
- Returns:
bool – True if the path is allowable, False if it should be disallowed.
- Raises:
ValueError – If legs is empty, or if orig or dest is not found in places.
StopIteration – If the iteration number is large enough that further iterations are no longer going to produce newly acceptable paths.
Notes
This function should evaluate the directness of the path given by the sequence of legs, and False if the path should be disallowed (e.g. if it is too circuitous). The determination of “too circuitous” is up to the user, and can be based on the total distance traveled, the ratio of total distance to great circle distance, or any other metric derived from the legs and the places. This means you can allow special rules for certain airports, airports in certain states or countries, individual carriers, or any other available static criteria.
This default function can be replaced in the connection builder by any user-defined function with the same signature.