Q Forecasting¶
In [1]:
Copied!
from textwrap import fill
import numpy as np
import pandas as pd
import passengersim as pax
pax.versions()
from textwrap import fill
import numpy as np
import pandas as pd
import passengersim as pax
pax.versions()
passengersim 0.57.dev4+g8e386693f passengersim.core 0.57.dev0+g85ef573c.d20251014
In [2]:
Copied!
cfg = pax.Config.from_yaml(pax.demo_network("3MKT"))
cfg = pax.Config.from_yaml(pax.demo_network("3MKT"))
In this example, we will work with a completely fenceless marketplace. To convert the typical 3MKT network into a restriction-free network, we can use a tool to strip the restrictions.
In [3]:
Copied!
from passengersim.config.manipulate import strip_all_restrictions
cfg = strip_all_restrictions(cfg)
from passengersim.config.manipulate import strip_all_restrictions
cfg = strip_all_restrictions(cfg)
In [4]:
Copied!
cfg.carriers.AL1.rm_system = "Q"
cfg.carriers.AL2.rm_system = "C"
cfg.carriers.AL1.rm_system = "Q"
cfg.carriers.AL2.rm_system = "C"
We need to revalidate the congfiguration to be able to view or modify the RM system definitions prior to initializing the simulation.
In [5]:
Copied!
cfg = cfg.model_revalidate()
cfg = cfg.model_revalidate()
In [6]:
Copied!
print(fill(cfg.rm_systems.Q.description))
print(fill(cfg.rm_systems.Q.description))
Path-based additive pickup PODS-style Q-hybrid forecast (with no fare restrictions this becomes Q-only), EM detruncation of priceable and yieldable demand (separately), ProBP optimization.
In [7]:
Copied!
print(fill(cfg.rm_systems.C.description))
print(fill(cfg.rm_systems.C.description))
Path-based additive pickup conditional forecast, EM detruncation of yieldable demand, ProBP optimization.
In [8]:
Copied!
cfg.simulation_controls.num_trials = 1
cfg.simulation_controls.num_samples = 600
cfg.simulation_controls.num_trials = 1
cfg.simulation_controls.num_samples = 600
In [9]:
Copied!
sim = pax.Simulation(cfg)
summary = sim.run()
sim = pax.Simulation(cfg)
summary = sim.run()
Output()
Task Completed after 12.83 seconds
In [10]:
Copied!
summary.fig_carrier_revenues()
summary.fig_carrier_revenues()
Out[10]:
In [11]:
Copied!
summary.fig_carrier_load_factors()
summary.fig_carrier_load_factors()
Out[11]:
In [12]:
Copied!
summary.fig_carrier_rasm()
summary.fig_carrier_rasm()
Out[12]:
In [13]:
Copied!
summary.fig_fare_class_mix()
summary.fig_fare_class_mix()
Out[13]:
In [14]:
Copied!
summary.fig_carrier_head_to_head_revenue("AL1", "AL2")
summary.fig_carrier_head_to_head_revenue("AL1", "AL2")
Out[14]:
Without Priceable Detruncation¶
We can remove the detruncation of priceable demand from the Q system, and re-evaluate to see the difference.
In [15]:
Copied!
cfg2 = cfg.model_copy(deep=True)
del cfg2.rm_systems.Q.processes.dcp.q_untruncation
cfg2 = cfg.model_copy(deep=True)
del cfg2.rm_systems.Q.processes.dcp.q_untruncation
In [16]:
Copied!
summary2 = pax.Simulation(cfg2).run()
summary2 = pax.Simulation(cfg2).run()
Output()
Task Completed after 11.53 seconds
In [17]:
Copied!
summary2.fig_carrier_revenues()
summary2.fig_carrier_revenues()
Out[17]:
In [18]:
Copied!
summary2.fig_carrier_load_factors()
summary2.fig_carrier_load_factors()
Out[18]:
In [19]:
Copied!
summary2.fig_carrier_rasm()
summary2.fig_carrier_rasm()
Out[19]:
In [20]:
Copied!
summary2.fig_fare_class_mix()
summary2.fig_fare_class_mix()
Out[20]:
In [21]:
Copied!
summary2.fig_carrier_head_to_head_revenue("AL1", "AL2")
summary2.fig_carrier_head_to_head_revenue("AL1", "AL2")
Out[21]:
Applying Fare Adjustment¶
In [22]:
Copied!
cfg3 = cfg.model_copy(deep=True)
cfg3.carriers.AL1.rm_system = "F"
cfg3.carriers.AL2.rm_system = "M"
cfg3 = cfg.model_copy(deep=True)
cfg3.carriers.AL1.rm_system = "F"
cfg3.carriers.AL2.rm_system = "M"
In [23]:
Copied!
cfg3 = cfg3.model_revalidate()
cfg3 = cfg3.model_revalidate()
In [24]:
Copied!
print(fill(cfg3.rm_systems.F.description))
print(fill(cfg3.rm_systems.F.description))
Path-based additive pickup PODS-style Q-hybrid forecast (with no fare restrictions this becomes Q-only), EM detruncation of priceable and yieldable demand (separately), MR fare adjustment with 25% scaling, ProBP optimization.
In [25]:
Copied!
print(fill(cfg3.rm_systems.M.description))
print(fill(cfg3.rm_systems.M.description))
Path-based additive pickup conditional forecast, EM detruncation of yieldable demand, MR fare adjustment with 25% scaling, ProBP optimization.
In [26]:
Copied!
sim3 = pax.Simulation(cfg3)
summary3 = sim3.run()
sim3 = pax.Simulation(cfg3)
summary3 = sim3.run()
Output()
Task Completed after 11.90 seconds
In [ ]:
Copied!
summary3.fig_carrier_revenues()
summary3.fig_carrier_revenues()
In [ ]:
Copied!
summary3.fig_carrier_load_factors()
summary3.fig_carrier_load_factors()
In [ ]:
Copied!
summary3.fig_carrier_rasm()
summary3.fig_carrier_rasm()
In [ ]:
Copied!
summary3.fig_fare_class_mix()
summary3.fig_fare_class_mix()
In [ ]:
Copied!
summary3.fig_carrier_head_to_head_revenue("AL1", "AL2")
summary3.fig_carrier_head_to_head_revenue("AL1", "AL2")