Leg bid-price arrays¶
See the entire bid-price schedule available at the beginning of a sample as an array. This array stores the bid price at each combination of seats sold and days before departure. The tracer averages these opening schedules across retained samples.
This complete array may not be available, depending on the RM system a carrier uses; generally a
DP-based algorithm solves for this entire array, while ProBP or SubPB algorithms only solve for the
current bid price. You can see this in the example below, where leg 311 (on Brat, using the U RM
system) has a complete array, while leg 211 (on Stroop, using the P RM system) only has one
column’s worth of data.
To see changes made later in the sample, use the daily vector tracer, which records the vector of active bid prices at each day, instead of the complete array of bid prices at the beginning of the sample. This will reveal a slightly different picture of the bid-price schedule, as the RM system may change the bid prices during the sample. The vector of bid prices actually used 3 days prior to departure (revealed by the daily vector tracer) may not be the same as the expected vector of bid prices 3 days prior to departure when that expectation is computed at the beginning of the sample (this tracer).
See also the other bid-price figures.
Collect the data¶
Flights 211 and 311 in the Europa UPE demo uses bid prices. Flight 111 does not use bid prices; it can be included in the list of legs, but it will not contribute any observations.
Attach the tracer before running the network:
import passengersim as pax
from passengersim.tracers.bid_price import LegBidPriceArrayTracer
cfg = pax.Config.from_yaml(pax.demo_network("europa/upe"))
cfg.simulation_controls.num_trials = 3
cfg.simulation_controls.num_samples = 300
cfg.simulation_controls.burn_samples = 50
cfg.simulation_controls.show_progress_bar = False
cfg.db = None
cfg.outputs.reports.clear()
cfg.outputs._write_no_files()
with pax.MultiSimulation(cfg) as sim:
LegBidPriceArrayTracer(leg_ids=[111, 211, 311]).attach(sim)
summary = sim.run()
table = summary.callback_data["leg_bid_price_arrays"].sort_index(axis=1)
╭─────────────────────────────────────╮ │ licensed for jpn │ │ until 2036-11-17 20:12:20+00:00 UTC │ │ maximum 42000 legs in network │ ╰─────────────────────────────────────╯
╭───────────────── Summary revenue statistics · Europa ─────────────────╮ │ Brat Stroop Tapas │ │ Run Samples Mean ~95% CI Mean ~95% CI Mean ~95% CI │ │ Europa 750 972K ±8,871 939.4K ±9,037 291K ±2,381 │ │ Post-burn-in only · Approx. 95% CI for mean │ ╰───────────────────────────────────────────────────────────────────────╯
To enable the same tracer in YAML:
callbacks:
leg_bid_price_arrays:
parameters:
leg_ids: [111, 211, 311]
Read the results¶
The table has one row per leg and seats-sold level, and one column per day before departure. In the table below, you can see that leg 211 has only one column of data, the rest are missing data.
table.head()
| DaysPrior | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ... | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| leg_id | SeatsSold | |||||||||||||||||||||
| 211 | 0 | 312.930092 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
| 1 | 315.240991 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | |
| 2 | 317.962503 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | |
| 3 | 320.483404 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | |
| 4 | 323.090995 | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | ... | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN | NaN |
5 rows × 63 columns
The bottom of the table shows leg 311, which has a complete array of bid prices.
table.tail()
| DaysPrior | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | ... | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| leg_id | SeatsSold | |||||||||||||||||||||
| 311 | 146 | 2.912438 | 67.537230 | 183.422365 | 310.438823 | 399.801403 | 456.118702 | 496.863435 | 516.986788 | 529.661174 | 541.453871 | ... | 574.204122 | 574.204122 | 574.204122 | 574.204122 | 574.204122 | 574.204122 | 574.204122 | 574.204122 | 574.204122 | 574.204122 |
| 147 | 29.056690 | 196.585873 | 334.683284 | 430.035623 | 487.678789 | 527.675217 | 557.387416 | 573.661183 | 585.203219 | 595.920939 | ... | 624.614421 | 624.614421 | 624.614421 | 624.614421 | 624.614421 | 624.614421 | 624.614421 | 624.614421 | 624.614421 | 624.614421 | |
| 148 | 137.539061 | 395.294983 | 514.974548 | 563.271983 | 592.400001 | 615.796686 | 636.203643 | 650.556319 | 662.311468 | 673.360024 | ... | 699.398760 | 699.398760 | 699.398760 | 699.398760 | 699.398760 | 699.398760 | 699.398760 | 699.398760 | 699.398760 | 699.398760 | |
| 149 | 417.348872 | 617.270828 | 680.685734 | 708.748705 | 728.821640 | 746.761958 | 763.196705 | 774.806055 | 784.001044 | 792.236330 | ... | 804.114590 | 804.114590 | 804.114590 | 804.114590 | 804.114590 | 804.114590 | 804.114590 | 804.114590 | 804.114590 | 804.114590 | |
| 150 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | ... | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 | 0.000000 |
5 rows × 63 columns
Use a leg whose revenue-management system produces bid-price arrays. A leg without an array contributes no observations. To plot the mean prices as a heatmap, choose a collected leg:
from passengersim.tracers.bid_price import fig_leg_bid_price_array
fig_leg_bid_price_array(summary, leg_id=311)
The same figures work for a leg with only one column of data, but the heatmap will be less interesting:
fig_leg_bid_price_array(summary, leg_id=211)
While there won’t be an error from trying to collect a leg without bid prices, the resulting table won’t include it and trying to plot a figure for it will fail.
try:
fig_leg_bid_price_array(summary, leg_id=111)
except KeyError as e:
print(f"Leg 111 has no bid-price array: {e} ")
Leg 111 has no bid-price array: nan