Leg

class passengersim.config.Leg[source]

Bases: BaseModel

Configuration for a single leg in the simulated network.

Attributes:

leg_id

A unique identifier for this leg.

carrier

The carrier name for this leg.

fltno

A flight number identifier for this leg.

orig

Origination location for this leg.

orig_timezone

Timezone name for the origination location for this leg.

dest

Destination location for this leg.

dest_timezone

Timezone name for the destination location for this leg.

date

Departure date for this leg.

arr_day

If the arrival time is on a different day, this is offset in days.

dep_time

Departure time for this leg in Unix time.

dep_time_offset

dep_localtime

Departure time for this leg in local time at the origin.

arr_time

Arrival time for this leg in Unix time.

arr_time_offset

arr_localtime

Arrival time for this leg in local time at the destination.

time_adjusted

duration_minutes

Duration of this leg in minutes, or None if dep_time or arr_time is not set.

capacity

The capacity of this leg.

total_capacity

The total capacity of this leg across all cabins.

distance

tags

Optional dictionary of tags associated with this leg.

Methods:

serialize_leg(nxt, info)

leg_id : int | None

A unique identifier for this leg.

Each leg in a network should have a globally unique identifier (i.e. even if the carrier is different, leg_id values should be unique. Note this is not the same as the fltno, which is a label analogous to flight numbers in practice, which don’t need to be unique. If the leg_id is not provided, the fltno is used, unless the simulation already has a leg with that leg_id, in which case a new unique leg_id will be generated.

carrier : str

The carrier name for this leg.

fltno : int

A flight number identifier for this leg.

Flight numbers do not need to be unique.

orig : str

Origination location for this leg.

orig_timezone : str | None

Timezone name for the origination location for this leg.

dest : str

Destination location for this leg.

dest_timezone : str | None

Timezone name for the destination location for this leg.

date : datetime

Departure date for this leg.

This should be the date of the departure, in local time at the origin (not the UTC date). When the dep_time is specified as a string in the format “HH:MM”, the date is used in conjunction with this time to create the preferred dep_time in Unix time.

arr_day : int

If the arrival time is on a different day, this is offset in days.

This is based on the local time at the destination. For example, if a flight departs on March 1st in the late evening from New York and arrives in London in the early morning of March 2nd, the arr_day would be +1, even though if you look only at UTC, the departure and arrival might be on the same day. This should correspond to the number of days (plus or minus) that would typically be shown the a customer booking on this leg.

This will usually be zero (arrival date is same as departure date) but will sometimes be 1 (arrives next day) or in a few pathological cases -1 or +2 (for travel across the international dateline).

dep_time : int

Departure time for this leg in Unix time.

In input files, this can be specified as a string in the format “HH:MM”, with the hour in 24-hour format, and given in local time at the origin. The date field is used in conjunction with this time to create the preferred dep_time in Unix time.

Unix time is the number of seconds since 00:00:00 UTC on 1 Jan 1970.

dep_time_offset : int
property dep_localtime : datetime

Departure time for this leg in local time at the origin.

arr_time : int

Arrival time for this leg in Unix time.

In input files, this can be specified as a string in the format “HH:MM”, with the hour in 24-hour format.

Unix time is the number of seconds since 00:00:00 UTC on 1 Jan 1970.

arr_time_offset : int
property arr_localtime : datetime

Arrival time for this leg in local time at the destination.

time_adjusted : bool
property duration_minutes : int | None

Duration of this leg in minutes, or None if dep_time or arr_time is not set.

capacity : int | dict[str, int]

The capacity of this leg.

If provided as an int, the leg is assumed to have a single cabin with that many seats. If provided as a dict, the keys are cabin names and the values are the number of seats in each cabin. For example, {“Y”: 150, “J”: 8} would indicate 150 Y-cabin seats and 20 J-cabin seats.

property total_capacity : int

The total capacity of this leg across all cabins.

distance : float | None
tags : dict[str, str]

Optional dictionary of tags associated with this leg.

Tags can be used to store arbitrary key-value pairs of information related to this leg. This may be useful for categorization, filtering, or adding metadata. Tags can also be used in RM actions to apply different strategies based on leg characteristics. For example, a tag could indicate whether a leg is a “short-haul” or “long-haul” flight, allowing RM actions to adjust their behavior accordingly.

serialize_leg(nxt: SerializerFunctionWrapHandler, info: SerializationInfo) dict[source]