Carrier

class passengersim.core.Carrier

Bases: object

Carrier object representing an airline with revenue management controls.

Represents an airline carrier with counters for tracking sales, revenue, and bookings, along with configuration for revenue management systems, pricing strategies, and forecasting.

Methods

__init__(*args, **kwargs)

add_ancillary

Add an ancillary (code & price).

add_carrier_history

Add an item to the carrier history.

add_customer_model

Add a customer model to the Carrier

add_frat5_mkt

Specify Frat5 for an O&D market.

get_ancillary_by_index

Get ancillary by index.

get_ancillary_price

Get the price for an ancillary, by code.

get_ancillary_sold

Get the sold for an ancillary, by code.

get_carrier_history

Return carrier history.

get_forecast_accuracy

Return forecast accuracy.

get_frat5_mkt

Get Frat5 for an O&D market.

get_history_def

Get the history definition.

get_spill_counters

Return spill counters.

raw_bid_price_trace

Raw bid price trace.

raw_bookings_by_day

Raw bookings by fare class by days prior to departure.

raw_bookings_by_segment_fare_dcp

Raw bookings by segment, fare class, and DCP.

raw_displacement_cost_trace

Raw displacement cost trace.

raw_fare_class_distribution

Raw fare class distribution.

raw_load_factor_distribution

Raw load factor distribution.

raw_revenue_by_segment_fare_dcp

Raw revenue by segment, fare class, and DCP.

reset_bid_price_trace

Reset bid price trace.

reset_displacement_cost_trace

Reset displacement cost trace.

Attributes

ancillaries

List of ancillaries that this airline will offer

brand_preference

An array of Brand Preference information

cabin_ordering

Ordering of cabin types on this carrier, from best to worst.

control

RM control technique, such as 'leg', 'bp', 'bp_loose', 'vn', 'classless'

cp_algorithm

Algorithm to use for Continuous Pricing, defaults to 'none'

cp_elasticity

For Continuous Pricing, estimate customer price elasticity

cp_quantize

For Contrinuous Pricing, round the value to this.

cp_record

For Continuous Pricing, do we record in the highest_closed class or the lowest_open?

cp_record_highest_closed_as_open

For continuous pricing, do we record the highest closed class as open in the pathclass history?

cp_scale

Scale the Contuous Pricing modifier.

current_tf_index

Current timeframe index

dcp_days_prior

Days prior for DCPs (i.e. the start time of each timeframe).

default_booking_classes

Default booking classes for legs and paths on this carrier.

frat5

Default Frat5 curve to use for this Carrier

gt_available_seat_miles

Grand total ASM, gets updated outside the burn period and is not reset by the reset methods

gt_cp_revenue

Grand total Continuous Pricing revenue, gets updated outside the burn period and is not reset by the reset methods

gt_cp_sold

Grand total Continuous Pricing sales, gets updated outside the burn period and is not reset by the reset methods

gt_demand

Grand total generated demand, gets updated outside the burn period and is not reset by the reset methods

gt_revenue

Grand total revenue, gets updated outside the burn period and is not reset by the reset methods

gt_revenue_passenger_miles

Grand total RPM, gets updated outside the burn period and is not reset by the reset methods

gt_sold

Grand total sold, gets updated outside the burn period and is not reset by the reset methods

history_length

History length

load_factor_curve

Load Factor curve, was an experiment in used this type of RM control.

metadata

A dictionary for storing arbitrary metadata on the Carrier object

name

Name is usually the code, such as 'AL1' or 'DL'

num_objects

Number of Carrier objects allocated, was used for memory leak detection

proration_rule

How do we prorate revenue between legs on connecting paths?

revenue

Revenue total, reset after each sample

rm_sys

The RM system used by this carrier.

sold

Number sold, reset after each sample

sold_priceable

Number sold priceable, reset after each sample

store_q_history

Whether to store the Q history

truncation_rule

Do we mark a TimeFrame as closed if it's closed at the start, end, or both

add_ancillary()

Add an ancillary (code & price).

Parameters:
anc : Ancillary

The ancillary item to add.

Returns:

int – Returns 0 on success.

add_carrier_history()

Add an item to the carrier history.

ONLY USED FOR UNIT TESTING.

Parameters:
trial : int

Trial number.

sample : int

Sample number.

sold : int

Number sold.

sold_priceable : int

Number sold priceable.

revenue : float

Revenue amount.

Returns:

int – Returns 0 on success.

add_customer_model()

Add a customer model to the Carrier

Parameters:
customer_model : CustomerModel

The CustomerModel to use.

add_frat5_mkt()

Specify Frat5 for an O&D market.

Parameters:
orig : str

Origin airport code.

dest : str

Destination airport code.

frat5 : Frat5

The Frat5 curve to use for this market.

ancillaries

List of ancillaries that this airline will offer

brand_preference

An array of Brand Preference information

cabin_ordering

Ordering of cabin types on this carrier, from best to worst.

For any leg that has multiple cabins, all cabin names must appear in this list. The cabins are strictly ordered such that any customer can be accommodated in the cabin for the ticket they purchased or any better cabin.

Returns:

list[str] – List of cabin name strings ordered from best to worst.

control

RM control technique, such as ‘leg’, ‘bp’, ‘bp_loose’, ‘vn’, ‘classless’

cp_algorithm

Algorithm to use for Continuous Pricing, defaults to ‘none’

cp_elasticity

For Continuous Pricing, estimate customer price elasticity

cp_quantize

For Contrinuous Pricing, round the value to this. i.e. 10 will result in allprices being a multiple of 10

cp_record

For Continuous Pricing, do we record in the highest_closed class or the lowest_open?

cp_record_highest_closed_as_open

For continuous pricing, do we record the highest closed class as open in the pathclass history?

Has no effect unless cp_record is set to highest_closed

cp_scale

Scale the Contuous Pricing modifier. Example, 0.5 will add 50% of the modifier to the bid price

current_tf_index

Current timeframe index

dcp_days_prior

Days prior for DCPs (i.e. the start time of each timeframe)

default_booking_classes

Default booking classes for legs and paths on this carrier.

Each entry is a pair (booking_class, lowest_cabin) where booking_class is the name of the booking class and lowest_cabin is the lowest cabin type where customers who purchase this booking class may be accommodated. When setting, each item may be a plain string (stored with an empty lowest_cabin) or a (str, str) pair.

Returns:

list[tuple[str, str]] – List of (booking_class, lowest_cabin) pairs.

frat5

Default Frat5 curve to use for this Carrier

get_ancillary_by_index()

Get ancillary by index.

ONLY USED FOR DEBUGGING.

Parameters:
index : int

The index of the ancillary to retrieve.

Returns:

Ancillary – The ancillary at the specified index.

get_ancillary_price()

Get the price for an ancillary, by code.

Parameters:
name : str

The ancillary code to look up.

Returns:

float – The price of the ancillary.

get_ancillary_sold()

Get the sold for an ancillary, by code.

Parameters:
name : str

The ancillary code to look up.

Returns:

int – The number sold of the ancillary.

get_carrier_history()

Return carrier history.

Returns carrier history as a list of dictionaries, with one item for each sample.

Returns:

list[dict] – List of dictionaries containing carrier history data with keys: ‘trial’, ‘sample’, ‘carrier’, ‘sold’, ‘sold_priceable’, ‘revenue’.

get_forecast_accuracy()

Return forecast accuracy.

Returns forecast accuracy as a list of dictionaries.

Returns:

list[dict] – List of dictionaries containing forecast accuracy data with keys: ‘trial’, ‘sample’, ‘carrier’, ‘booking_class’, ‘timeframe’, ‘num_zero_displacement’, ‘num_obs’, ‘sold’, ‘sold_priceable’, ‘fcst_mean’, ‘fcst_variance’.

get_frat5_mkt()

Get Frat5 for an O&D market.

Parameters:
orig : str

Origin airport code.

dest : str

Destination airport code.

Returns:

Frat5 or None – The Frat5 curve for the specified market, or None if not found.

get_history_def()

Get the history definition.

Returns the history definition used to initialize the history for this carrier’s buckets and pathclasses.

Returns:

dict – Dictionary with keys: - ‘num_departures’ : int - Number of samples in carrier history - ‘num_timeframes’ : int - Number of timeframes in carrier history - ‘store_priceable’ : bool - Whether carrier has a Frat5 curve

get_spill_counters()

Return spill counters.

Returns spill counters as a list of dictionaries.

gt_available_seat_miles

Grand total ASM, gets updated outside the burn period and is not reset by the reset methods

gt_cp_revenue

Grand total Continuous Pricing revenue, gets updated outside the burn period and is not reset by the reset methods

gt_cp_sold

Grand total Continuous Pricing sales, gets updated outside the burn period and is not reset by the reset methods

gt_demand

Grand total generated demand, gets updated outside the burn period and is not reset by the reset methods

gt_revenue

Grand total revenue, gets updated outside the burn period and is not reset by the reset methods

gt_revenue_passenger_miles

Grand total RPM, gets updated outside the burn period and is not reset by the reset methods

gt_sold

Grand total sold, gets updated outside the burn period and is not reset by the reset methods

history_length

History length

load_factor_curve

Load Factor curve, was an experiment in used this type of RM control. (deprecated)

metadata

A dictionary for storing arbitrary metadata on the Carrier object

name

Name is usually the code, such as ‘AL1’ or ‘DL’

num_objects

Number of Carrier objects allocated, was used for memory leak detection

proration_rule

How do we prorate revenue between legs on connecting paths?

raw_bid_price_trace()

Raw bid price trace.

Returns:

dict – Dictionary with DCP keys and values containing bid price statistics.

raw_bookings_by_day()

Raw bookings by fare class by days prior to departure.

Returns:

dict – Dictionary with fare class keys and booking data by days prior.

raw_bookings_by_segment_fare_dcp()

Raw bookings by segment, fare class, and DCP.

Returns:

dict – Dictionary with segment keys, then fare class keys, then DCP keys with booking counts.

raw_displacement_cost_trace()

Raw displacement cost trace.

Returns:

dict – Dictionary with DCP keys and values containing displacement cost statistics.

raw_fare_class_distribution()

Raw fare class distribution.

Returns:

dict – Dictionary with fare class keys and values containing ‘sold’ and ‘revenue’ keys.

raw_load_factor_distribution()

Raw load factor distribution.

Returns:

numpy.ndarray – Array of load factor distribution data.

raw_revenue_by_segment_fare_dcp()

Raw revenue by segment, fare class, and DCP.

Returns:

dict – Dictionary with segment keys, then fare class keys, then DCP keys with revenue values.

reset_bid_price_trace()

Reset bid price trace.

Clears the accumulated bid price trace data.

Returns:

None

reset_displacement_cost_trace()

Reset displacement cost trace.

Clears the accumulated displacement cost trace data.

Returns:

None

revenue

Revenue total, reset after each sample

rm_sys

The RM system used by this carrier.

This RM system should be a daily callback that implements the RM system for this carrier. It should also be attached to the Simulation as a daily callback and is triggered via the regular callback process. This attribute is provided for convenience so that the RM system can be easily accessed if needed.

Type:

RmSys

sold

Number sold, reset after each sample

sold_priceable

Number sold priceable, reset after each sample

store_q_history

Whether to store the Q history

truncation_rule

Do we mark a TimeFrame as closed if it’s closed at the start, end, or both