Leg booking detail

Record the cumulative seats sold for selected legs each day in every retained sample. Use this tracer when you want to inspect an individual sample or see the distribution across samples.

Collect the data

Load the 3MKT demo and attach the tracer before running it:

import passengersim as pax
from passengersim.callbacks.booking_detail import LegBookingDetailTracer

cfg = pax.Config.from_yaml(pax.demo_network("3MKT"))
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:
    LegBookingDetailTracer(leg_ids=[101, 111]).attach(sim)
    summary = sim.run()
table = summary.callback_data["leg_booking_detail"]

To enable the same tracer in YAML:

callbacks:
  leg_booking_detail:
    parameters:
      leg_ids: [101, 111]

Read the results

Rows identify the trial, sample, and days before departure. Columns are leg IDs. The optional priority (default 1) sets the timing of the daily observation.

table.head()
leg_id 101 111
trial sample days_prior
0 50 63 0.0 0.0
62 0.0 2.0
61 0.0 3.0
60 6.0 13.0
59 8.0 17.0
summary.leg_booking_detail.xs(101, level="leg_id").head()
metric mean q10 q25 q50 q75 q90
days_prior
0 83.546667 63.0 73.00 85.0 98.0 100.0
1 82.284000 62.0 72.00 84.0 96.0 100.0
2 80.064000 60.0 69.25 81.5 93.0 99.0
3 77.540000 58.0 67.00 79.0 90.0 95.0
4 75.666667 56.0 65.00 77.0 88.0 93.0
summary.fig_leg_booking_detail_rake(leg_id=101)

The summary property reports the mean and the 10th, 25th, 50th, 75th, and 90th percentiles for each leg and day. Missing observations are skipped; all six statistics are missing when a leg has no observations that day. The rake chart shows the median and percentile bands. See the leg visualization guide for a worked example.