Daily leg bid prices

Track the mean and standard deviation of the current bid price for selected legs on each day before departure. Choose the leg bid-price detail tracer if you need individual observations or percentiles.

Collect the data

Load the europa/upe demo and attach the tracer before running it:

import passengersim as pax
from passengersim.tracers.bid_price import LegBidPriceTracer

cfg = pax.Config.from_yaml(pax.demo_network("europa/upe"))
cfg.simulation_controls.num_trials = 1
cfg.simulation_controls.num_samples = 800
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.Simulation(cfg) as sim:
    LegBidPriceTracer(leg_ids=[211]).attach(sim)
    summary = sim.run()
table = summary.callback_data["leg_bid_prices"]
   ╭─────────────────────────────────────╮                                                                         
   │ licensed for jpn                    │                                                                         
   │ until 2036-11-17 20:12:20+00:00 UTC │                                                                         
   │ maximum 42000 legs in network       │                                                                         
   ╰─────────────────────────────────────╯                                                                         

To enable the same tracer in YAML:

callbacks:
  leg_bid_prices:
    parameters:
      leg_ids: [211]

Read the results

The columns identify legs. The statistic index level contains the mean (mean), sample standard deviation (std_dev), and observation count (n). A single observation has an undefined sample standard deviation. Statistics pool observations across samples, trials, and workers. The optional priority (default 1) controls the timing of the daily observation.

table.xs("std_dev", level="statistic").head()
leg_id 211
days_prior
63 25.703031
62 25.743040
61 25.187360
60 25.474175
59 25.768529
from passengersim.tracers.bid_price import fig_leg_bid_prices

fig_leg_bid_prices(summary)

Pass std_dev=False for means alone, or raw_df=True for the plotted data.

Note

Results saved by earlier versions of PassengerSim have no n row, and their standard deviation is the average of each trial’s standard deviation, which leaves out the variation between trials. Combining such a result with a new one gives trial-weighted averages without an n row. If the standard deviation matters to you, re-run the simulation. The tracers’ options_version has changed, so a configuration that requires the old version reports an error instead of mixing the two.

Native daily leg bid-price history

The native summary covering every leg is enabled by default.

After running, access summary.leg_bid_price_history. It is indexed by (leg_id, days_prior) and contains:

Column

Meaning

bid_price_mean

Mean bid price across retained samples and trials

bid_price_std_dev

Pooled sample standard deviation

n_observations

Number of retained observations for that leg and day

daily_prices = summary.leg_bid_price_history
daily_prices.xs(211, level="leg_id").head()
bid_price_mean bid_price_std_dev n_observations
days_prior
0 307.015572 493.182692 750
1 262.471093 475.658276 750
2 271.392372 476.554814 750
3 277.552664 469.776351 750
4 272.466854 462.194783 750

Collection includes each integer day from the earliest configured DCP through departure day, excludes burn-in, and works with cfg.db = None. It is on by default; the table is None when collection is disabled. Set collect_leg_bid_prices: false before the next run to turn it off. The option always collects all legs; filtering the resulting table does not reduce collection. A cell with no observations has a missing mean and standard deviation; a single observation has a missing standard deviation. The native collector stores online statistics rather than individual sample observations, and saved PXSIM and pickle results retain the information needed to combine summaries correctly.

Native collection follows core daily-statistics timing and the existing leg reporting-price convention, including sold-out legs. For positive days_prior, recording occurs at the core daily or DCP event; later callbacks can subsequently change prices. At days_prior == 0, recording occurs at the end of the sample, after the event queue finishes. The native collector has no callback priority setting, so a Python tracer may observe different prices if callbacks change them between these times. Multi-cabin legs record their leg-level reporting price without selecting a cabin or applying cabin capacity-sharing rules.

Each row pools individual observations across retained samples, trials, and workers. The standard deviation is the sample standard deviation of those observations (ddof=1), including variation between trials. It is not the average of trial standard deviations. Rerunning a simulation starts a fresh history; saved summaries retain their previous results. This table requires no database report selection.

You can use native collection alongside LegBidPriceTracer. Use this tracer when selecting only some legs or developing custom collection behavior. It pools its statistics across trials and workers in the same way. Cabin-level collection is not yet enabled by this option.