BookingCurve¶
- class passengersim.core.BookingCurve¶
Bases:
objectBooking curve for modeling time-based passenger booking patterns.
A booking curve represents the cumulative distribution function (CDF) of passenger bookings over time, specified as days prior to departure (DCP).
Methods
__init__(*args, **kwargs)Add a days-prior-to-departure (DCP) point to the booking curve.
Get the booking curve as a dictionary.
Draw a random arrival time from the booking curve.
Verify that the booking curve percentages are monotonically increasing.
Attributes
Name of the booking curve.
Random number generator used for sampling from the booking curve.
- add_dcp()¶
Add a days-prior-to-departure (DCP) point to the booking curve.
- Parameters:
- days_prior : int
Number of days prior to departure.
- pct : float
Cumulative percentage of bookings expected by this DCP.
- get_curve()¶
Get the booking curve as a dictionary.
- Returns:
dict[int, float] – Dictionary mapping days prior to departure (DCP) to cumulative booking percentages.
- get_days_prior()¶
Draw a random arrival time from the booking curve.
The booking curve is treated as a piecewise-linear cumulative distribution function. A weighted roulette wheel selects the timeframe between two DCPs, and linear interpolation places the draw within that timeframe. Any fraction of arrivals at or before the first DCP is placed exactly at that DCP. The curve’s
random_generatoris used for the uniform draw.- Returns:
float – Days prior to departure of the sampled arrival; larger values are earlier arrivals.
- Raises:
ValueError – If the booking curve has no DCP points.
- name¶
Name of the booking curve.
- Returns:
str – The booking curve name.
- random_generator¶
Random number generator used for sampling from the booking curve.
- Returns:
Generator – The random number generator instance.
- verify_curve()¶
Verify that the booking curve percentages are monotonically increasing.
- Returns:
bool – True if the curve percentages are valid (monotonically increasing), False otherwise.