Skip to content

Leg

action_state instance-attribute

action_state: str

action_timestamp instance-attribute

action_timestamp: float

arr_time instance-attribute

arr_time: int

arr_time_offset instance-attribute

arr_time_offset: int

bid_price instance-attribute

bid_price: float

bid_price_gradient instance-attribute

bid_price_gradient: float

buckets instance-attribute

buckets: Iterator[Bucket]

cabins instance-attribute

cabins: Iterator[Cabin]

capacity instance-attribute

capacity: int

carrier instance-attribute

carrier: Carrier | None

dep_time instance-attribute

dep_time: int

dep_time_offset instance-attribute

dep_time_offset: int

dest instance-attribute

dest: str

displacement instance-attribute

displacement: float

distance instance-attribute

distance: float

duration instance-attribute

duration: float

equipment instance-attribute

equipment: str

fcst_mean instance-attribute

fcst_mean: float

fcst_std_dev instance-attribute

fcst_std_dev: float

flt_no instance-attribute

flt_no: int

gt_capacity instance-attribute

gt_capacity: int

gt_revenue instance-attribute

gt_revenue: float

gt_sold instance-attribute

gt_sold: int

info instance-attribute

info: Any

leg_id instance-attribute

leg_id: int

orig instance-attribute

orig: str

pathclass_identifiers instance-attribute

pathclass_identifiers: Iterator[str]

q_demand instance-attribute

q_demand: float

revenue instance-attribute

revenue: float

sold instance-attribute

sold: float

__init__

__init__(
    leg_id: int,
    carrier: Carrier | None,
    flt_no: int,
    orig: str,
    dest: str,
    capacity: int = 0,
    sold: int = 0,
    duration: int = 0,
    equipment: str = None,
    info: Any = None,
)

add_bucket

add_bucket(*args: Bucket)

Add an inventory control bucket to the Leg.

add_cabin

add_cabin(*args: Cabin)

Add a Cabin to the Leg.

bucket_number

bucket_number(i: int | str) -> Bucket

Get the bucket from the leg.

Parameters:

  • i (int or str) –

    If an integer, returns the bucket at this index position from the list of buckets attached to this Leg. If given as a str, returns the bucket with the indicated booking class.

Returns:

capture_dcp

capture_dcp(i: int) -> None

Grab a snapshot of important variables.

Parameters:

  • i (int) –

    The index of the DCP to capture.

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,
    return_vectors: bool = False,
) -> None | dict[str, ForecastVectors]

Compute forecasts for the leg and its buckets.

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.

  • event_time (int, default: None ) –

    The time of the event that triggered the forecast computation.

  • return_vectors (bool, default: False ) –

    If True, return a dictionary of forecast vectors for each bucket. Primarily used for debugging and testing.

emsrb

emsrb(debug: bool | None)

forecast

forecast(
    dcp_index: int,
    algorithm: str,
    snapshot_instruction: SnapshotInstruction | None = None,
)

get_bid_price_array

get_bid_price_array() -> ndarray

Get a copy of the bid price array for the leg.

get_bucket_auth

get_bucket_auth(i: int | str) -> int

Get the authorization for a bucket attached to this leg.

Parameters:

  • i (int or str) –

    If an integer, returns the auth of the bucket at this index position from the list of buckets attached to this Leg. If given as a str, returns the auth of the bucket with the indicated booking class.

Returns:

  • int

get_bucket_fcst_mean

get_bucket_fcst_mean(bkt_ref: int | str) -> float

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

get_bucket_fcst_revenue

get_bucket_fcst_revenue(bkt_ref: int | str) -> float

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

get_bucket_fcst_std_dev

get_bucket_fcst_std_dev(bkt_ref: int | str) -> float

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

get_bucket_revenue

get_bucket_revenue(bkt_ref: int | str) -> float

Get the revenue for a bucket, either by class name (string) or index (int)

get_bucket_sold

get_bucket_sold(i: int | str) -> int

Get the number of seats sold for a bucket attached to this leg.

Parameters:

  • i (int or str) –

    If an integer, returns the number of seats sold for the bucket at this index position from the list of buckets attached to this Leg. If given as a str, returns the number of seats sold for the bucket with the indicated booking class.

Returns:

  • int

get_cabin

get_cabin(i: int) -> Cabin

Get Cabin by index

get_num_buckets

get_num_buckets() -> int

Get the number of buckets attached to this leg.

get_num_cabins

get_num_cabins() -> int

Get the number of cabins attached to this leg.

littlewood

littlewood(
    mu: float,
    sigma: float,
    rev_hi: float,
    rev_lo: float,
    cv100: float,
) -> float

print_bucket_detail

print_bucket_detail() -> None

Print a bunch of debugging info

print_bucket_history

print_bucket_history()

Print a bunch of debugging info

set_bucket_auth

set_bucket_auth(bkt_ref: int | str, auth: int)

Set the authorization for a bucket, either by class name (string) or index (int)

set_bucket_fcst_mean

set_bucket_fcst_mean(bkt_ref: int | str, auth: int)

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

set_bucket_fcst_revenue

set_bucket_fcst_revenue(bkt_ref: int | str, auth: int)

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

set_bucket_fcst_std_dev

set_bucket_fcst_std_dev(bkt_ref: int | str, auth: int)

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

set_bucket_revenue

set_bucket_revenue(bkt_ref: int | str, auth: int)

Set the revenue for a bucket, either by class name (string) or index (int)

set_bucket_sold

set_bucket_sold(bkt_ref: int | str, sold: int)

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

untruncate_demand

untruncate_demand(
    dcp_index: int,
    algorithm: str,
    snapshot_instruction: 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 leg and its buckets.

Parameters:

  • dcp_index (int) –

    The index of the DCP to run the untruncation models for.

  • algorithm (str) –

    The name of the untruncation algorithm to use.

  • snapshot_instruction (SnapshotInstruction, default: None ) –

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

Returns:

  • None or str

write_to_sqlite

write_to_sqlite(
    sqlite_pointer: Connection,
    sim: SimulationEngine,
    dcp: int,
)

Write to leg_bucket_detail.