Skip to content

Path

adjusted_at instance-attribute

adjusted_at: int

carrier instance-attribute

carrier: Carrier

carrier_name instance-attribute

carrier_name: str

dest instance-attribute

dest: str

duration instance-attribute

duration: float

fcst_mean instance-attribute

fcst_mean: float

fcst_std_dev instance-attribute

fcst_std_dev: float

first_flight instance-attribute

first_flight: bool

gt_revenue instance-attribute

gt_revenue: float

gt_sold instance-attribute

gt_sold: int

gt_sold_priceable instance-attribute

gt_sold_priceable: int

last_fcst_ts instance-attribute

last_fcst_ts: int

last_flight instance-attribute

last_flight: bool

market instance-attribute

market: Market

minimum_conect_time instance-attribute

minimum_conect_time: int

orig instance-attribute

orig: str

path_quality_index instance-attribute

path_quality_index: float

pathclasses instance-attribute

pathclasses: Iterator[PathClass]

price instance-attribute

price: float

q_forecast instance-attribute

q_forecast: Forecast

The Q-Forecast object for this Path.

revenue instance-attribute

revenue: float

sold instance-attribute

sold: int

sold_priceable instance-attribute

sold_priceable: int

__init__

__init__(
    orig: str,
    dest: str,
    price: float,
    carrier: Carrier | None = None,
)

accumulate_forecasts

accumulate_forecasts(dcpIndex: int)

Adds the path fcst to each leg / bucket

accumulate_forecasts_vn

accumulate_forecasts_vn()

Adds the path fcst to each leg / bucket, using the Virtual Nesting mapping

add_booking_class

add_booking_class(booking_class: str)

Add a booking class to this Path

add_carrier

add_carrier(carrier: Carrier) -> None

Add a Carrier to this Path.

add_leg

add_leg(leg: Leg) -> None

Add a leg to this Path.

add_path_class

add_path_class(path_class: PathClass)

Add a path class to this Path

adjust_forecasts

adjust_forecasts(
    algorithm: str,
    current_tf_index: int,
    current_tf_begin_time: int,
    current_time: int,
    current_tf_end_time: int,
    departure_time: int = 0,
    snapshot_instruction: SnapshotInstruction | None = None,
) -> None

Adjust the forecast for this path and any path-class items it has, using in daily reoptimization

allocate_q_demand

allocate_q_demand(
    frat5: Frat5, dcp_index: int, debug: bool
) -> float

First step in Q-forecasting

capture_dcp

capture_dcp(
    dcp_index: int, frat5=None, snapshot_instruction=None
)

Save relevant information for this DCP

check_avail

check_avail(fare: Fare, num_pax: int, debug: bool | None)

Is this fare available on the Path? Used for unit testing

compute_fare_adjustments

compute_fare_adjustments(
    dcp_index: int,
    algorithm: Literal["mr", "ki"],
    frat5: Frat5,
    scale_factor: float = 1.0,
    snapshot_instruction: SnapshotInstruction | None = None,
    *,
    sort_pathclasses: bool = True,
) -> None

Compute the fare adjustment for this path and its path-class items.

Parameters:

  • dcp_index (int) –

    Compute fare adjustments from this DCP to departure.

  • algorithm (('mr', 'ki'), default: 'mr' ) –

    The algorithm to use for fare adjustment.

  • frat5 (Frat5) –

    Frat5 object to use for Q-forecasting.

  • scale_factor (float, default: 1.0 ) –

    Scale factor to apply to fare adjustments. This overrides the scale factor set in the Frat5 object, which is deprecated.

  • snapshot_instruction (SnapshotInstruction, default: None ) –

    If not None, a snapshot of the forecast will be written based on these instructions.

  • sort_pathclasses (bool, default: True ) –

    If True, sort the pathclasses by fare before adjustment. If the pathclasses are already sorted, this can be set to False to save time.

compute_forecasts

compute_forecasts(
    dcp_index: int,
    algorithm: str = None,
    snapshot_instruction: SnapshotInstruction | None = None,
    recompute: bool = True,
    *,
    alpha: float = 0.15,
    event_time: int | None = None,
) -> None

Run the standard forecast models for this Path and its PathClass items.

Parameters:

  • dcp_index (int) –

    The index of the DCP to compute the forecasts for. This is used to limit the computation to only the relevant data; if the DCP index is greater than zero then the forecast is only computed for the DCP(s) at and after this index.

  • algorithm (str, default: None ) –

    The name of the forecast algorithm to use. This must be provided if recompute is True, otherwise it is ignored.

  • snapshot_instruction (SnapshotInstruction, default: None ) –

    If given, this is a snapshot instruction to use for the forecast.

  • recompute (bool, default: True ) –

    If True, recompute the forecast, otherwise use the existing forecast and simply update cached values on the Leg and its buckets to reflect the dcp_index.

  • alpha (float, default: 0.15 ) –

    The alpha value to use for exponential smoothing, this is ignored if algorithm is not 'exp_smoothing'.

  • event_time (int, default: None ) –

    The time of the event that triggered the forecast computation. This is used to when adjusting forecasts within a DCP.

compute_hybrid_forecasts

compute_hybrid_forecasts(
    dcp_index: int,
    algorithm: str,
    frat5: Frat5,
    snapshot_instruction: SnapshotInstruction | None = None,
    recompute: bool = True,
    pods_init: bool = False,
    *,
    alpha: float = 0.15,
) -> float

Run the hybrid forecast models for this path and its path-class items.

Parameters:

  • dcp_index (int) –

    Only compute forecasts only from this DCP to departure.

  • algorithm (('exp_smoothing', 'additive_pickup'), default: 'exp_smoothing' ) –

    Forecasting algorithm to use.

  • frat5 (Frat5) –

    Frat5 object to use for Q-forecasting.

  • snapshot_instruction (SnapshotInstruction, default: None ) –

    If not None, a snapshot of the forecast will be written based on these instructions.

  • max_cap (float, default: 10.0 ) –

    Maximum capacity inflation for Q-forecasting.

  • pods_init (bool, default: False ) –
  • alpha (float, default: 0.15 ) –

    Smoothing factor for exponential smoothing. This is a keyword-only argument.

compute_q_equivalent

compute_q_equivalent(
    frat5: Frat5,
    dcp_index: int,
    max_cap: float = 10.0,
    snapshot_instruction: SnapshotInstruction | None = None,
) -> float

First step in Q-forecasting

get_class_decision_fare

get_class_decision_fare(pc_index: int | str) -> float

Get the decision fare amount for a class, either by class name (string) or index (int)

get_class_fcst_mean

get_class_fcst_mean(pc_index: int | str) -> float

Get the demand forecast for a class, either by class name (string) or index (int)

get_class_sold

get_class_sold(pc_index: int | str) -> int

Get the number sold for a class, either by class name (string) or index (int)

get_class_std_dev

get_class_std_dev(pc_index: int | str) -> float

Get the demand forecast std. dev. for a class, either by class name (string) or index (int)

get_leg_bid_price

get_leg_bid_price(n: int) -> float

Get the bid price on the n-th leg.

get_leg_carrier

get_leg_carrier(n: int) -> str

Get the carrier code for the n-th leg.

get_leg_dep_time

get_leg_dep_time(n: int) -> int

Get the departure timestamp code for the n-th leg.

get_leg_dest

get_leg_dest(n: int) -> str

Get the destination airport for the n-th leg.

get_leg_equipment

get_leg_equipment(n: int) -> str

Get the equipment code for the n-th leg.

get_leg_fltno

get_leg_fltno(n: int) -> int

Get the flight number for the n-th leg.

get_leg_orig

get_leg_orig(n: int) -> str

Get the origin airport for the n-th leg.

get_total_bid_price

get_total_bid_price() -> float

Get the total of bid prices on all legs

get_total_distance

get_total_distance() -> float

Get the total of distances on all legs

num_classes

num_classes() -> int

Return the number of booking classes that are tracked for this Path

num_deps

num_deps() -> int

How many historical departures are on this path?

num_legs

num_legs() -> int

How many legs are on this path?

print_class_history

print_class_history(path_class_index: int) -> str

Print some historical data to stdout, mostly for debugging

reset_counters

reset_counters() -> None

Reset the sold, revenue, and forecast counters for this path and any path-class items it has

set_class_decision_fare

set_class_decision_fare(pc_index: int | str, fcst: float)

Set the decision fare amount for a class, either by class name (string) or index (int)

set_class_fcst_mean

set_class_fcst_mean(pc_index: int | str, fcst: float)

Set the demand forecast for a class, either by class name (string) or index (int)

set_class_sold

set_class_sold(pc_index: int | str, sold: int)

Set the number sold for a class, either by class name (string) or index (int)

set_class_std_dev

set_class_std_dev(pc_index: int | str, fcst: float)

Set the demand forecast std. dev.for a class, either by class name (string) or index (int)

untruncate_demand

untruncate_demand(
    dcp_index: int,
    algorithm: str,
    debug: SnapshotInstruction | None = None,
    maxiter: int = 20,
    tolerance: float = 0.01,
    pods_initialization: bool = False,
    minimum_mu: float = 0.01,
    minimum_sigma: float = 0.1,
)

Run the demand untruncation models for this path and any path-class items it has