Cabin¶
- class passengersim.core.Cabin¶
Bases:
objectCabin inventory control container.
A Cabin represents a physical cabin class (e.g., F, C, Y) on an aircraft, with capacity and sales tracking capabilities.
Methods
__init__(*args, **kwargs)Add inventory control bucket(s) to the Cabin.
Capture the cabin history and store it in the internal structure.
Return cabin data as a list of dictionaries.
Attributes
Index for the bid price vector, gets moved along each day prior to departure
Iterator that returns the Bucket items for this Cabin.
Capacity of this Cabin, must be >= 0.
Cabin name, arbitrary string, but F/C/Y would be typical values.
Iterator to return PathClass objects in this cabin
Revenue in this Cabin, reset after each sample.
Number sold in this Cabin, reset after each sample.
- add_bucket()¶
Add inventory control bucket(s) to the Cabin.
- Parameters:
- *args : Bucket
One or more Bucket objects to add to this Cabin.
- Returns:
str – Confirmation message indicating bucket(s) were added.
- bp_index¶
Index for the bid price vector, gets moved along each day prior to departure
- Returns:
int – Index values.
- buckets¶
Iterator that returns the Bucket items for this Cabin.
- Returns:
Iterator[Bucket] – Iterator over the buckets in this cabin.
- capacity¶
Capacity of this Cabin, must be >= 0.
- Returns:
int – The maximum capacity of the cabin.
- capture_cabin_history()¶
Capture the cabin history and store it in the internal structure.
- Parameters:
- trial : int
Trial number for the current simulation run.
- sample : int
Sample number for the current simulation run.
- distance : float
Distance for the current flight segment in nautical miles. Used to calculate yield (revenue per passenger-mile).
- Returns:
int – Returns 0 on success.
- get_cabin_data()¶
Return cabin data as a list of dictionaries.
- Parameters:
- carrier_code : str
Carrier code identifier.
- flt_no : int
Flight number.
- Returns:
list[dict] – List of dictionaries containing cabin history data for each sample. Each dictionary contains keys: trial, sample, carrier, flt_no, cabin, capacity, distance, sold, sold_priceable, revenue, sold_cp, revenue_cp.
The distance field (in nautical miles) enables yield calculation: yield = revenue / (sold × distance), which measures revenue per passenger-mile.
The sold_cp and revenue_cp fields track sales and revenue specifically from Continuous Pricing (CP) fare adjustments, where prices are dynamically adjusted based on demand and availability.
- name¶
Cabin name, arbitrary string, but F/C/Y would be typical values.
- Returns:
str – The name of the cabin.
- pathclass_identifiers¶
Iterator to return PathClass objects in this cabin
- Returns:
iterator – Iterator for PathClass objects.
- revenue¶
Revenue in this Cabin, reset after each sample.
Revenue is the sum of allocated revenue per passenger sold in this cabin during the current sample (departure). Note that this is NOT simply price × sold, because:
Revenue is prorated across legs: When passengers book multi-leg itineraries, the total fare they pay is allocated (prorated) across the different legs and cabins they use. Each cabin receives its portion of the total fare.
Example: A passenger pays $500 for a two-leg journey (BOS-ORD-LAX). The first leg’s cabin might be allocated $300 of revenue, while the second leg’s cabin gets $200, even though both cabins show “1 sold”.
Multiple fares can use the same cabin: Different fare products with different prices might all book into the same cabin, contributing different amounts of revenue per seat.
Reset after each sample: The revenue counter is reset to zero at the start of each sample (departure) and accumulates bookings during that sample. After the sample completes, it resets for the next departure.
- Returns:
float – The total revenue generated.
- sold¶
Number sold in this Cabin, reset after each sample.
Counts the number of seats sold in this cabin for the current sample. Note that this is a per-leg counter: if one passenger books a 2-leg itinerary, each leg’s cabin will increment sold by 1, resulting in a total of 2 across both legs.
- Returns:
int – The number of seats sold.