Common Queries
bid_price_history
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.
Returns:
-
DataFrame
–The resulting dataframe is indexed by
carrier
andrrd
, 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
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 |
|
bookings_by_timeframe
bookings_by_timeframe(
cnx: Database,
scenario: str,
from_fare_detail: bool = False,
burn_samples: int = 100,
) -> pd.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
, andrrd
, 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
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 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 |
|
carrier_history
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
) – -
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
demand_to_come
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
fare_class_mix
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_forecasts
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
) – -
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
,flt_no
,bucket_number
,booking_class
andrrd
, 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
load_factors
Source code in passengersim/database/common_queries.py
local_and_flow_yields
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
) – -
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
611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 |
|
od_fare_class_mix
od_fare_class_mix(
cnx: Database,
orig: str,
dest: str,
scenario: str,
burn_samples: int = 100,
) -> pd.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
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
) – -
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
andrrd
, 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
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
–