EM UntruncationĀ¶
In this example, we include product and advance purchase (AP) restrictions in the simulation, and have each airline use the leg-based EMSR-B algorithm to manage revenue. Additionally, the EM algorithm is employed to detruncate censored demand. Demand is simulated at normal levels.
InĀ [1]:
Copied!
import passengersim as pax
pax.versions()
import passengersim as pax
pax.versions()
passengersim 0.18.1 passengersim.core 0.18.1
InĀ [2]:
Copied!
from passengersim.utils.codeview import show_file
from passengersim.utils.codeview import show_file
InĀ [3]:
Copied!
show_file("network/08-untrunc-em.yaml")
show_file("network/08-untrunc-em.yaml")
include: - 01-base.yaml - 02-buyup.yaml - 03-ap.yaml simulation_controls: demand_multiplier: 1.0 rm_systems: rm_test1: availability_control: leg processes: DCP: - step_type: untruncation name: untruncation algorithm: em kind: leg - step_type: forecast name: forecast algorithm: additive_pickup alpha: 0.15 kind: leg - step_type: emsr name: optimization algorithm: emsrb kind: leg airlines: - name: AL1 rm_system: rm_test1 - name: AL2 rm_system: rm_test1
InĀ [4]:
Copied!
cfg = pax.Config.from_yaml([
"network/08-untrunc-em.yaml",
])
cfg = pax.Config.from_yaml([
"network/08-untrunc-em.yaml",
])
InĀ [5]:
Copied!
cfg.simulation_controls.num_trials = 6
cfg.simulation_controls.num_trials = 6
InĀ [6]:
Copied!
cfg.outputs.reports.add("local_and_flow_yields")
cfg.outputs.reports.add("local_and_flow_yields")
InĀ [7]:
Copied!
sim = pax.Simulation(cfg)
sim = pax.Simulation(cfg)
InĀ [8]:
Copied!
summary = sim.run()
summary = sim.run()
Task Completed after 13.59 seconds
InĀ [9]:
Copied!
summary.fig_carrier_revenues()
summary.fig_carrier_revenues()
Out[9]:
InĀ [10]:
Copied!
summary.fig_carrier_load_factors()
summary.fig_carrier_load_factors()
Out[10]:
InĀ [11]:
Copied!
summary.fig_fare_class_mix()
summary.fig_fare_class_mix()
Out[11]:
InĀ [12]:
Copied!
summary.fig_bookings_by_timeframe()
summary.fig_bookings_by_timeframe()
Out[12]:
InĀ [13]:
Copied!
summary.local_and_flow_yields
summary.local_and_flow_yields
Out[13]:
flt_no | carrier | orig | dest | capacity | distance | local_yield | local_fraction | flow_yield | |
---|---|---|---|---|---|---|---|---|---|
0 | 101 | AL1 | BOS | ORD | 100 | 863.753282 | 0.228168 | 0.419748 | 0.160276 |
1 | 102 | AL1 | BOS | ORD | 100 | 863.753282 | 0.227869 | 0.416923 | 0.161073 |
2 | 111 | AL1 | ORD | LAX | 120 | 1739.799337 | 0.175814 | 0.545423 | 0.160276 |
3 | 112 | AL1 | ORD | LAX | 120 | 1739.799337 | 0.175983 | 0.546765 | 0.161073 |
4 | 201 | AL2 | BOS | ORD | 100 | 863.753282 | 0.228095 | 0.419208 | 0.161365 |
5 | 202 | AL2 | BOS | ORD | 100 | 863.753282 | 0.228021 | 0.420197 | 0.161306 |
6 | 211 | AL2 | ORD | LAX | 120 | 1739.799337 | 0.176204 | 0.545464 | 0.161365 |
7 | 212 | AL2 | ORD | LAX | 120 | 1739.799337 | 0.176278 | 0.547227 | 0.161306 |
InĀ [14]:
Copied!
summary.to_xlsx("outputs/3mkt-08.xlsx")
summary.to_xlsx("outputs/3mkt-08.xlsx")
Comparing against TargetsĀ¶
InĀ [15]:
Copied!
import targets
target = targets.load(8, cfg)
import targets
target = targets.load(8, cfg)
InĀ [16]:
Copied!
from passengersim import contrast
from passengersim import contrast
InĀ [17]:
Copied!
comps = contrast.Contrast({
"simulation": summary,
"target": target,
})
comps = contrast.Contrast({
"simulation": summary,
"target": target,
})
InĀ [18]:
Copied!
comps.fig_demand_to_come("mean")
comps.fig_demand_to_come("mean")
Out[18]:
InĀ [19]:
Copied!
comps.fig_demand_to_come("std")
comps.fig_demand_to_come("std")
Out[19]:
InĀ [20]:
Copied!
comps.apply(
lambda s: (
s.aggregate_demand_history(by_segment=True).unstack("segment").cov()
)
)
comps.apply(
lambda s: (
s.aggregate_demand_history(by_segment=True).unstack("segment").cov()
)
)
Out[20]:
segment | business | leisure | |
---|---|---|---|
source | segment | ||
simulation | business | 3263.099012 | 1976.758878 |
leisure | 1976.758878 | 5291.913397 | |
target | business | 3249.598992 | 1955.419868 |
leisure | 1955.419868 | 5359.555328 |
InĀ [21]:
Copied!
contrast.fig_bookings_by_timeframe(comps, by_carrier="AL1", by_class=True)
contrast.fig_bookings_by_timeframe(comps, by_carrier="AL1", by_class=True)
Out[21]:
InĀ [22]:
Copied!
comps.fig_carrier_revenues()
comps.fig_carrier_revenues()
Out[22]:
InĀ [23]:
Copied!
comps.fig_carrier_load_factors()
comps.fig_carrier_load_factors()
Out[23]:
InĀ [24]:
Copied!
comps.fig_fare_class_mix()
comps.fig_fare_class_mix()
Out[24]:
InĀ [25]:
Copied!
comps.fig_bookings_by_timeframe(by_carrier="AL1", by_class=True)
comps.fig_bookings_by_timeframe(by_carrier="AL1", by_class=True)
Out[25]:
InĀ [26]:
Copied!
comps.fig_leg_forecasts(by_flt_no=101, of=["mu", "sigma"])
comps.fig_leg_forecasts(by_flt_no=101, of=["mu", "sigma"])
Out[26]:
InĀ [27]:
Copied!
comps.fig_leg_forecasts(by_flt_no=101, of=["mu", "sigma"])
comps.fig_leg_forecasts(by_flt_no=101, of=["mu", "sigma"])
Out[27]:
InĀ [28]:
Copied!
comps.fig_leg_forecasts(by_flt_no=111, of=["mu", "sigma"])
comps.fig_leg_forecasts(by_flt_no=111, of=["mu", "sigma"])
Out[28]: