Common Queries
_leg_bucket_trace
_leg_bucket_trace(
target_cols: str,
cnx: Database,
scenario: str | None = None,
burn_samples: int = 100,
carrier: str | None = None,
leg_id: int | None = None,
booking_class: str | None = None,
days_prior: int | None = None,
) -> DataFrame
Recorded forecast of demand by leg.
This query requires that the simulation was run while recording leg bucket
details (i.e. with the bucket
flag set on Config.db.write_items
). This
function is provided primarily for testing and debugging purposes.
Parameters:
-
cnx
(Database
) – -
scenario
(str
, default:None
) – -
burn_samples
(int
, default:100
) –The forecasts will be analyzed ignoring this many samples from the beginning of each trial.
-
carrier
(str
, default:None
) –If provided, only return forecasts for this carrier.
-
leg_id
(int
, default:None
) –If provided, only return forecasts for this leg.
-
booking_class
(str
, default:None
) –If provided, only return forecasts for this booking class.
-
days_prior
(int
, default:None
) –If provided, only return forecasts for this many days prior to departure.
Returns:
-
DataFrame
–The resulting dataframe is indexed by any of
carrier
,leg_id
,booking_class
, and/ordays_prior
that were not filtered, and has these columns: -forecast_mean
: Forecast mean (mu). -forecast_stdev
: Forecast standard deviation (sigma). -forecast_closed_in_tf
: Fraction of time the timeframe was closed in the data used to make a forecast. -forecast_closed_in_tf
: Fraction of time any future timeframe was closed in the data used to make a forecast.
Source code in passengersim/database/common_queries.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
|
bid_price_history
bid_price_history(
cnx: Database,
scenario: str,
burn_samples: int = 100,
weighting: Literal["equal", "capacity"] = "equal",
) -> DataFrame
Compute average bid price history over all legs for each carrier.
This query requires that the simulation was run while recording leg
details (i.e. with the leg
flag set on Config.db.write_items
),
including bid prices.
Parameters:
-
cnx
(Database
) – -
scenario
(str
) – -
burn_samples
(int
, default:100
) –The bid prices will be analyzed ignoring this many samples from the beginning of each trial.
-
weighting
((equal, capacity)
, default:'equal'
) –How to weight the bid prices. If 'equal', then each leg is weighted equally. If 'capacity', then each leg is weighted by its total capacity.
Returns:
-
DataFrame
–The resulting dataframe is indexed by
carrier
anddays_prior
, and has these columns:bid_price_mean
: Average bid price across all samples and all legsbid_price_stdev
: Sample standard deviation of bid prices across all samples and all legsfraction_some_cap
: Fraction of all legs across all samples that have non-zero capacity available for sale.fraction_zero_cap
: Fraction of all legs across all samples that have zero capacity available for sale. Bid prices are computed for these legs but are not really meaningful.some_cap_bid_price_mean
: Average bid price across all samples and all legs conditional on the leg having non-zero capacity.some_cap_bid_price_stdev
: Sample standard deviation of bid prices across all samples and all legs conditional on the leg having non-zero capacity.
Source code in passengersim/database/common_queries.py
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 |
|
bookings_by_timeframe
bookings_by_timeframe(
cnx: Database,
scenario: str,
from_fare_detail: bool = False,
burn_samples: int = 100,
) -> DataFrame
Average bookings and revenue by carrier, booking class, and timeframe.
This query requires that the simulation was run while recording supporting
details (i.e. with the bookings
or fare
flags set on Config.db.write_items
).
Parameters:
-
cnx
(Database
) – -
scenario
(str
) – -
from_fare_detail
(bool
, default:False
) –Reconstruct this table from the
fare_detail
table. This is generally slower than accessing thebookings
table directly, and also requires substantially more data to have been saved into the database by setting thefare
flag onConfig.db.write_items
-
burn_samples
(int
, default:100
) –The bookings will be computed ignoring this many samples from the beginning of each trial. This argument is nominally ignored by this query unless
from_fare_detail
is true, although the simulator will have already ignored the burned samples when storing the data in the bookings table.
Returns:
-
DataFrame
–The resulting dataframe is indexed by
trial
,carrier
,class
, anddays_prior
, and has these columns:avg_sold
: Average number of sales.avg_business
: Average number of sales to passengers in the business segment.avg_leisure
: Average number of sales to leisure passengers.avg_revenue
: Average total revenue earned from customers booking in this booking class in this time period.avg_price
: Average price per ticket from customers booking in this booking class in this time period
Source code in passengersim/database/common_queries.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
|
carrier_history
carrier_history(
cnx: Database,
*,
scenario: str = None,
burn_samples: int = 100,
) -> DataFrame
Sample-level details of carrier-level measures.
This query delivers sample-by-sample aggregated summary results for the
various carriers in the simulation. It requires that the simulation was
run while recording leg bucket details (i.e. with the bucket
flag set
on Config.db.write_items
).
Parameters:
-
cnx
(Database
) – -
scenario
(str
, default:None
) – -
burn_samples
(int
, default:100
) –The history will be returned ignoring this many samples from the beginning of each trial.
Returns:
-
DataFrame
–The resulting dataframe is indexed by
iteration
,trial
andsample
, and columns defined with a two-level MultiIndex. The second level of the columns MultiIndex represents the carriers, while the top level includes these columns:forecast_mean
: Forecast mean (mu) at the beginning of the booking curve, summed over all this carrier's legs in this sample.forecast_stdev
: Forecast standard deviation (sigma) at the beginning of the booking curve, aggregated over all this carrier's legs in this sample.sold
: Total bookings accepted by this carrier in this sample.revenue
: Total revenue for this carrier in this sample.
Source code in passengersim/database/common_queries.py
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 |
|
demand_to_come
demand_to_come(
cnx: Database,
*,
scenario: str = None,
burn_samples: int = 100,
) -> DataFrame
Demand by market and timeframe across each sample.
This query delivers sample-by-sample timeframe demand results for the
various markets (origin, destination, passenger type) in the simulation.
It requires that the simulation was run while recording demand details
(i.e. with the demand
flag set on Config.db.write_items
).
Parameters:
-
cnx
(Database
) – -
scenario
(str
, default:None
) – -
burn_samples
(int
, default:100
) –The demand will be returned ignoring this many samples from the beginning of each trial.
Returns:
-
DataFrame
–The resulting dataframe is indexed by
iteration
,trial
,sample
,segment
,orig
, anddest
; and has columns defined by the DCPs. The values stored are the total remaining demand to come at each DCP.
Source code in passengersim/database/common_queries.py
demand_to_come_summary
demand_to_come_summary(
cnx: Database, scenario: str, burn_samples: int = 100
) -> DataFrame
Demand by market and timeframe across each sample.
This query delivers sample-by-sample timeframe demand results for the
various markets (origin, destination, passenger type) in the simulation.
It requires that the simulation was run while recording demand details
(i.e. with the demand
flag set on Config.db.write_items
).
Parameters:
-
cnx
(Database
) – -
scenario
(str
) – -
burn_samples
(int
, default:100
) –The demand will be returned ignoring this many samples from the beginning of each trial.
Returns:
-
DataFrame
–The resulting dataframe is indexed by
iteration
,trial
,sample
,segment
,orig
, anddest
; and has columns defined by the DCPs. The values stored are the total remaining demand to come at each DCP.
Source code in passengersim/database/common_queries.py
displacement_history
displacement_history(
cnx: Database, scenario: str, burn_samples: int = 100
) -> DataFrame
Compute average displacement cost history over all legs for each carrier.
This query requires that the simulation was run while recording leg
details (i.e. with the leg
flag set on Config.db.write_items
),
including displacement costs.
Parameters:
-
cnx
(Database
) – -
scenario
(str
) – -
burn_samples
(int
, default:100
) –The bid prices will be analyzed ignoring this many samples from the beginning of each trial.
Returns:
-
DataFrame
–The resulting dataframe is indexed by
carrier
anddays_prior
, and has these columns:displacement_mean
: Average displacement cost across all samples and all legsdisplacement_stdev
: Sample standard deviation of displacement cost across all samples and all legs
Source code in passengersim/database/common_queries.py
1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 |
|
edgar
edgar(
cnx: Database,
*,
scenario: str = None,
burn_samples: int = 100,
) -> DataFrame
Forecast accuracy information.
Parameters:
-
cnx
(Database
) – -
scenario
(str
, default:None
) – -
burn_samples
(int
, default:100
) –The demand will be returned ignoring this many samples from the beginning of each trial.
Returns:
-
DataFrame
–The resulting dataframe is indexed by
iteration
,trial
,sample
,segment
,orig
, anddest
; and has columns defined by the DCPs. The values stored are the total remaining demand to come at each DCP.
Source code in passengersim/database/common_queries.py
fare_class_mix
fare_class_mix(
cnx: Database, scenario: str, burn_samples: int = 100
) -> DataFrame
Fare class mix by carrier.
This query requires that the simulation was run while recording final fare
details (i.e. with the fare
or fare_final
flags set on Config.db.write_items
).
Parameters:
-
cnx
(Database
) – -
scenario
(str
) – -
burn_samples
(int
, default:100
) –The average total demand will be computed ignoring this many samples from the beginning of each trial.
Returns:
-
DataFrame
–The resulting dataframe is indexed by
carrier
andbooking_class
, and has these columns:avg_sold
: Average number of sales in this booking class.avg_revenue
: Average total revenue earned from customers booking in this booking class.avg_price
: Average price per ticket from customers booking in this booking class.
Source code in passengersim/database/common_queries.py
leg_forecast_trace
leg_forecast_trace(
cnx: Database,
scenario: str | None = None,
burn_samples: int = 100,
carrier: str | None = None,
leg_id: int | None = None,
booking_class: str | None = None,
days_prior: int | None = None,
) -> DataFrame
Recorded forecast of demand by leg.
This query requires that the simulation was run while recording leg bucket
details (i.e. with the bucket
flag set on Config.db.write_items
). This
function is provided primarily for testing and debugging purposes.
Parameters:
-
cnx
(Database
) – -
scenario
(str
, default:None
) – -
burn_samples
(int
, default:100
) –The forecasts will be analyzed ignoring this many samples from the beginning of each trial.
-
carrier
(str
, default:None
) –If provided, only return forecasts for this carrier.
-
leg_id
(int
, default:None
) –If provided, only return forecasts for this leg.
-
booking_class
(str
, default:None
) –If provided, only return forecasts for this booking class.
-
days_prior
(int
, default:None
) –If provided, only return forecasts for this many days prior to departure.
Returns:
-
DataFrame
–The resulting dataframe is indexed by any of
carrier
,leg_id
,booking_class
, and/ordays_prior
that were not filtered, and has these columns: -forecast_mean
: Forecast mean (mu). -forecast_stdev
: Forecast standard deviation (sigma). -forecast_closed_in_tf
: Fraction of time the timeframe was closed in the data used to make a forecast. -forecast_closed_in_tf
: Fraction of time any future timeframe was closed in the data used to make a forecast.
Source code in passengersim/database/common_queries.py
leg_forecasts
leg_forecasts(
cnx: Database,
*,
scenario: str = None,
burn_samples: int = 100,
) -> DataFrame
Average forecasts of demand by leg, bucket, and days to departure.
This query requires that the simulation was run while recording leg bucket
details (i.e. with the bucket
flag set on Config.db.write_items
).
Parameters:
-
cnx
(Database
) – -
scenario
(str
, default:None
) – -
burn_samples
(int
, default:100
) –The forecasts will be analyzed ignoring this many samples from the beginning of each trial.
Returns:
-
DataFrame
–The resulting dataframe is indexed by
carrier
,leg_id
,bucket_number
,booking_class
anddays_prior
, and has these columns:forecast_mean
: Average forecast mean (mu).forecast_stdev
: Average forecast standard deviation (sigma).forecast_closed_in_tf
: Average fraction of time the timeframe was closed in the data used to make a forecast.forecast_closed_in_tf
: Average fraction of time any future timeframe was closed in the data used to make a forecast.
Source code in passengersim/database/common_queries.py
leg_local_and_flow_by_class
leg_local_and_flow_by_class(
cnx: Database, scenario: str, burn_samples: int = 100
) -> DataFrame
Source code in passengersim/database/common_queries.py
1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 |
|
leg_sales_trace
leg_sales_trace(
cnx: Database,
scenario: str | None = None,
burn_samples: int = 100,
carrier: str | None = None,
leg_id: int | None = None,
booking_class: str | None = None,
days_prior: int | None = None,
) -> DataFrame
Recorded forecast of demand by leg.
This query requires that the simulation was run while recording leg bucket
details (i.e. with the bucket
flag set on Config.db.write_items
). This
function is provided primarily for testing and debugging purposes.
Parameters:
-
cnx
(Database
) – -
scenario
(str
, default:None
) – -
burn_samples
(int
, default:100
) –The forecasts will be analyzed ignoring this many samples from the beginning of each trial.
-
carrier
(str
, default:None
) –If provided, only return forecasts for this carrier.
-
leg_id
(int
, default:None
) –If provided, only return forecasts for this leg.
-
booking_class
(str
, default:None
) –If provided, only return forecasts for this booking class.
-
days_prior
(int
, default:None
) –If provided, only return forecasts for this many days prior to departure.
Returns:
-
DataFrame
–The resulting dataframe is indexed by any of
carrier
,leg_id
,booking_class
, and/ordays_prior
that were not filtered, and has these columns:sold
,revenue
,auth
Source code in passengersim/database/common_queries.py
load_factor_distribution
load_factor_distribution(
cnx: Database,
scenario: str,
burn_samples: int = 100,
cutoffs=(0.5, 0.6, 0.7, 0.8, 0.85, 0.9, 0.95),
) -> DataFrame
Source code in passengersim/database/common_queries.py
load_factors
load_factors(
cnx: Database, scenario: str, burn_samples: int = 100
) -> DataFrame
Source code in passengersim/database/common_queries.py
local_and_flow_yields
local_and_flow_yields(
cnx: Database,
*,
scenario: str = None,
burn_samples: int = 100,
) -> DataFrame
Compute yields for local (nonstop) and flow (connecting) passengers.
This query requires that the simulation was run while recording path class
details (i.e. with the pathclass
or pathclass_final
flags set on
Config.db.write_items
).
Parameters:
-
cnx
(Database
) – -
scenario
(str
, default:None
) – -
burn_samples
(int
, default:100
) –The yields will be computed ignoring this many samples from the beginning of each trial.
Returns:
-
DataFrame
–
Source code in passengersim/database/common_queries.py
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 |
|
od_fare_class_mix
od_fare_class_mix(
cnx: Database,
orig: str,
dest: str,
scenario: str,
burn_samples: int = 100,
) -> DataFrame
Fare class mix by carrier for a particular origin-destination market.
This query requires that the simulation was run while recording final fare
details (i.e. with the fare
or fare_final
flags set on Config.db.write_items
).
Parameters:
-
cnx
(Database
) – -
orig
(str
) –Origin and destination to query.
-
dest
(str
) –Origin and destination to query.
-
scenario
(str
) – -
burn_samples
(int
, default:100
) –The average total demand will be computed ignoring this many samples from the beginning of each trial.
Returns:
-
DataFrame
–The resulting dataframe is indexed by
carrier
andbooking_class
, and has these columns:avg_sold
: Average number of sales in this booking class.avg_revenue
: Average total revenue earned from customers booking in this booking class.avg_price
: Average price per ticket from customers booking in this booking class.
Source code in passengersim/database/common_queries.py
path_forecasts
path_forecasts(
cnx: Database,
*,
scenario: str = None,
burn_samples: int = 100,
) -> DataFrame
Average forecasts of demand by path, class, and days to departure.
This query requires that the simulation was run while recording path-class
details (i.e. with the pathclass
flag set on Config.db.write_items
).
Parameters:
-
cnx
(Database
) – -
scenario
(str
, default:None
) – -
burn_samples
(int
, default:100
) –The forecasts will be analyzed ignoring this many samples from the beginning of each trial.
Returns:
-
DataFrame
–The resulting dataframe is indexed by
path_id
,booking_class
anddays_prior
, and has these columns:forecast_mean
: Average forecast mean (mu).forecast_stdev
: Average forecast standard deviation (sigma).forecast_closed_in_tf
: Average fraction of time the timeframe was closed in the data used to make a forecast.forecast_closed_in_tf
: Average fraction of time any future timeframe was closed in the data used to make a forecast.
Source code in passengersim/database/common_queries.py
total_demand
total_demand(
cnx: Database, scenario: str, burn_samples: int = 100
) -> float
Average total demand.
This query requires that the simulation was run while recording final demand
details (i.e. with the demand
or demand_final
flags set on
Config.db.write_items
).
Parameters:
-
cnx
(Database
) – -
scenario
(str
) – -
burn_samples
(int
, default:100
) –The average total demand will be computed ignoring this many samples from the beginning of each trial.
Returns:
-
float
–