Path forecasts¶
Inspect the forecasts used for selected paths. The tracer takes a snapshot at the beginning of each retained sample and averages the forecast tables across samples.
Collect the data¶
Load the 3MKT demo and attach the tracer before running it:
import passengersim as pax
from passengersim.tracers.forecasts import PathForecastTracer
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()
cfg.carriers.AL1.rm_system = "P"
with pax.Simulation(cfg) as sim:
PathForecastTracer(path_ids=[1, 5]).attach(sim)
summary = sim.run()
table = summary.callback_data["selected_path_forecasts"]
To enable the same tracer in YAML:
callbacks:
selected_path_forecasts:
parameters:
path_ids: [1, 5]
Read the results¶
Use the dashboard to explore the forecasts by booking class and data collection point (DCP). It shows forecast demand and its spread, expected demand within each timeframe, and sales and closure history where available.
table.xs(1, level="path_id")["mean_to_departure"].head()
| booking_class | Y0 | Y1 | Y2 | Y3 | Y4 | Y5 |
|---|---|---|---|---|---|---|
| days_prior | ||||||
| 63 | 2.443996 | 10.160591 | 5.465180 | 1.824164 | 12.094415 | 6.214151 |
| 56 | 2.303894 | 9.595360 | 5.148410 | 1.747805 | 9.745749 | 4.768604 |
| 49 | 2.201740 | 9.157001 | 4.876462 | 1.701651 | 8.643954 | 4.077328 |
| 42 | 2.113227 | 8.757258 | 4.638308 | 1.656010 | 7.341597 | 3.308366 |
| 35 | 2.003022 | 8.304694 | 4.345897 | 1.611497 | 6.002781 | 2.470615 |
from passengersim.tracers.forecasts import fig_path_forecast_dashboard
fig_path_forecast_dashboard(summary, path_id=1)
The dashboard also shows adjusted fares by booking class and timeframe. An unadjusted fare appears at its ordinary price, and a class closed by its advance-purchase restriction has a missing value. The snapshot reflects fares at the start of the sample; later changes by a custom RM step are outside that snapshot. See the forecast summary tables.