Leg
__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,
)
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:
-
Bucket–
capture_dcp
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.
forecast
forecast(
dcp_index: int,
algorithm: str,
snapshot_instruction: SnapshotInstruction | None = None,
)
get_bucket_auth
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 the forecast demand for a bucket, either by class name (string) or index (int)
get_bucket_fcst_revenue
Get the forecast revenue for a bucket, either by class name (string) or index (int)
get_bucket_fcst_std_dev
Get the forecast demand std. dev. for a bucket, either by class name (string) or index (int)
get_bucket_revenue
Get the revenue for a bucket, either by class name (string) or index (int)
get_bucket_sold
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–
littlewood
set_bucket_auth
Set the authorization for a bucket, either by class name (string) or index (int)
set_bucket_fcst_mean
Set the forecast demand for a bucket, either by class name (string) or index (int)
set_bucket_fcst_revenue
Set the revenue forecast for a bucket, either by class name (string) or index (int)
set_bucket_fcst_std_dev
Set the forecast demand std. dev. for a bucket, either by class name (string) or index (int)
set_bucket_revenue
Set the revenue for a bucket, either by class name (string) or index (int)
set_bucket_sold
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.