Skip to content

Booking Curves

BookingCurve

Bases: Named

A mathematical description of the relative arrival rate of customers over time.

Source code in passengersim/config/booking_curves.py
class BookingCurve(Named, extra="forbid"):
    """
    A mathematical description of the relative arrival rate of customers over time.
    """

    curve: dict[int, float]
    """Define a booking curve.

    For a given customer type, the booking curve gives the cumulative fraction
    of those customers who are expected to have already "arrived" at any given
    data collection point (DCP).  An "arriving" customer is one who is interested
    in booking, but may or may not actually purchase a travel product from one
    of the carriers, depending on the availability of products at the time of their
    arrival.

    The values (cumulative fraction of customers arriving) should increase
    monotonically as the keys (DCPs, e.g. days to departure) decrease.

    Example
    -------
    ```{yaml}
    - name: business
      curve:
        63: 0.01
        56: 0.02
        49: 0.05
        42: 0.13
        35: 0.19
        31: 0.23
        28: 0.29
        24: 0.35
        21: 0.45
        17: 0.54
        14: 0.67
        10: 0.79
        7: 0.86
        5: 0.91
        3: 0.96
        1: 1.0
    ```
    """

    @field_validator("curve")
    def _booking_curves_accumulate(cls, v: dict[int, float], info: ValidationInfo):
        """Check that all curve values do not decrease as DCP keys decrease."""
        sorted_dcps = reversed(sorted(v.keys()))
        i = 0
        for dcp in sorted_dcps:
            assert (
                v[dcp] >= i
            ), f"booking curve {info.data['name']} moves backwards at dcp {dcp}"
            i = v[dcp]
        return v

curve instance-attribute

curve: dict[int, float]

Define a booking curve.

For a given customer type, the booking curve gives the cumulative fraction of those customers who are expected to have already "arrived" at any given data collection point (DCP). An "arriving" customer is one who is interested in booking, but may or may not actually purchase a travel product from one of the carriers, depending on the availability of products at the time of their arrival.

The values (cumulative fraction of customers arriving) should increase monotonically as the keys (DCPs, e.g. days to departure) decrease.

Example
- name: business
  curve:
    63: 0.01
    56: 0.02
    49: 0.05
    42: 0.13
    35: 0.19
    31: 0.23
    28: 0.29
    24: 0.35
    21: 0.45
    17: 0.54
    14: 0.67
    10: 0.79
    7: 0.86
    5: 0.91
    3: 0.96
    1: 1.0