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.51.dev12+gb8c884e passengersim.core 0.51.dev2+g02d3ce20
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()
Task Completed after 4.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()
Task Completed after 5.60 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()
Task Completed after 4.86 seconds
InĀ [27]:
Copied!
summary3.fig_carrier_revenues()
summary3.fig_carrier_revenues()
Out[27]:
InĀ [28]:
Copied!
summary3.fig_carrier_load_factors()
summary3.fig_carrier_load_factors()
Out[28]:
InĀ [29]:
Copied!
summary3.fig_carrier_rasm()
summary3.fig_carrier_rasm()
Out[29]:
InĀ [30]:
Copied!
summary3.fig_fare_class_mix()
summary3.fig_fare_class_mix()
Out[30]:
InĀ [31]:
Copied!
summary3.fig_carrier_head_to_head_revenue("AL1", "AL2")
summary3.fig_carrier_head_to_head_revenue("AL1", "AL2")
Out[31]: