Path
accumulate_forecasts_vn
Adds the path fcst to each leg / bucket, using the Virtual Nesting mapping
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
First step in Q-forecasting
capture_dcp
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 the decision fare amount for a class, either by class name (string) or index (int)
get_class_fcst_mean
Get the demand forecast for a class, either by class name (string) or index (int)
get_class_sold
Get the number sold for a class, either by class name (string) or index (int)
get_class_std_dev
Get the demand forecast std. dev. for a class, either by class name (string) or index (int)
num_classes
Return the number of booking classes that are tracked for this Path
print_class_history
Print some historical data to stdout, mostly for debugging
reset_counters
Reset the sold, revenue, and forecast counters for this path and any path-class items it has
set_class_decision_fare
Set the decision fare amount for a class, either by class name (string) or index (int)
set_class_fcst_mean
Set the demand forecast for a class, either by class name (string) or index (int)
set_class_sold
Set the number sold for a class, either by class name (string) or index (int)
set_class_std_dev
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