Skip to content

Simulation Engine

Attributes

base_time instance-attribute

base_time: int

The base time of the simulation.

bucketnames instance-attribute

bucketnames: Sequence[str]

buckets instance-attribute

buckets: Sequence[Bucket]

burn_samples instance-attribute

burn_samples: int

carriers instance-attribute

carriers: Sequence[Carrier]

choice_set_sampling_probability instance-attribute

choice_set_sampling_probability: float

Used to randomly sample the choice set, especially useful for large networks

config instance-attribute

config: Config | None

demands instance-attribute

demands: Sequence[Demand]

disable_ap instance-attribute

disable_ap: bool

dwm_lite instance-attribute

dwm_lite: bool

fares instance-attribute

fares: Sequence[Fare]

iteration instance-attribute

iteration: int

last_dcp instance-attribute

last_dcp: int

last_dcp_index instance-attribute

last_dcp_index: int

last_event_time instance-attribute

last_event_time: int

legs instance-attribute

legs: LegIterator

manual_paths instance-attribute

manual_paths: bool

markets instance-attribute

markets: Mapping[str, Market]

max_connect_time instance-attribute

max_connect_time: int

mkt_k_factor instance-attribute

mkt_k_factor: float

name instance-attribute

name: str

num_dcps instance-attribute

num_dcps: int

num_samples instance-attribute

num_samples: int

num_trials instance-attribute

num_trials: int

num_trials_completed instance-attribute

num_trials_completed: int

Number of trials actually completed with this simulation.

When multiprocessing, this typically will be just 1, as each process will complete only one trial.

pathclasses instance-attribute

pathclasses: Sequence[PathClass]

paths instance-attribute

paths: PathIterator

pax_type_k_factor instance-attribute

pax_type_k_factor: float

prorate_revenue instance-attribute

prorate_revenue: bool

When set to True, O&D revenue is prorated by mileage to the leg level

random_generator instance-attribute

random_generator: Generator

revenue instance-attribute

revenue: float

rm_start_sample instance-attribute

rm_start_sample: int

sample instance-attribute

sample: int

save_timeframe_details instance-attribute

save_timeframe_details: bool

snapshot_filters instance-attribute

snapshot_filters: list[SnapshotFilter] | None

sys_k_factor instance-attribute

sys_k_factor: float

tf_k_factor instance-attribute

tf_k_factor: float

Timeframe k-factor, controls variance in the passenger arrival curves

tf_z_factor instance-attribute

tf_z_factor: float

trial instance-attribute

trial: int

Functions

__init__

__init__(name: str = 'Incognito', random_generator=None)

_book_offer

_book_offer(
    dmd: Demand, offer: Offer, num_pax: int = 1
) -> None

Exercise the bookOffer method in CoreSim, this is ONLY for unit testing !!!

Trying to do anything else with this method may result in pain, mental anguish and gnashing of teeth

_get_event

_get_event() -> float

Pop the next event from the queue and return the timestamp.

Only used for unit testing.

add_airport

add_airport(airport: Airport) -> None

Add an Airport to the simulation

add_carrier

add_carrier(carrier: Carrier) -> None

Add a Carrier to the simulation

add_dcp

add_dcp(dcp_index: int, days_prior: int) -> None

Add dcp_index and days_prior. Must be added in ascending order of dcp_index

add_demand

add_demand(dmd: Demand) -> None

Add a Market Segment demand to the simulation.

add_event

add_event(e: Event) -> None

Add a user Event to the simulation.

add_fare

add_fare(fare: Fare) -> None

Add a Fare to the simulation.

add_frat5

add_frat5(frat5: Frat5) -> None

Add a Frat5 curve to the simulation.

add_leg

add_leg(leg: Leg) -> None

Add a Leg to the simulation.

add_path

add_path(path: Path) -> None

Add a Path to the simulation.

additional_settings

additional_settings(**kwargs) -> None

Set additional settings for the simulation.

allocate_demand_to_tf

allocate_demand_to_tf(
    dmd: Demand,
    num_pax: int,
    tf_k_factor: float,
    endTS: int,
    debug: bool = False,
) -> tuple[int]

Generate events for a single demand

Parameters:

  • dmd (Demand) –
  • num_pax (int) –
  • tf_k_factor (float) –
  • endTS (int) –
  • debug (bool, default: False ) –

Returns:

  • int

    Number of events allocated.

allocate_demand_to_tf_pods

allocate_demand_to_tf_pods(
    dmd: Demand,
    num_pax: int,
    tf_k_factor: float,
    endTS: int,
) -> tuple[int]

Generate events for a single demand (used to simulate PODS processing)

Parameters:

  • dmd (Demand) –
  • num_pax (int) –
  • tf_k_factor (float) –
  • endTS (int) –
  • debug (bool, default: False ) –

Returns:

  • tuple[int]

    Number of events allocated by DCP.

build_connections

build_connections(
    dmd: Demand, debug: bool | None = False
) -> None

Build connections for the demands.

This will create Path objects for each demand, if the network is given only by the Leg objects.

build_expiration

build_expiration() -> datetime

Get the expiration time for this build.

capture_forecast_accuracy

capture_forecast_accuracy() -> None

Capture EDGAR-like forecast accuracy data

choice_set_columns

choice_set_columns() -> list

Return a list of column names for the choice set

clear_choice_set

clear_choice_set() -> None

Delete the choice set data that is stored in memory

compute_hhi

compute_hhi(debug: bool | None = False)

distribution_local_leg_passengers

distribution_local_leg_passengers(carrier: str) -> ndarray

Return the distribution of percent local passengers by leg for this carrier.

final_write_to_sqlite

final_write_to_sqlite(cnx: Connection)

Write final summary details to sqlite

fraction_local_by_carrier_and_place

fraction_local_by_carrier_and_place(
    carrier: str,
) -> dict[str, float]

Return the fraction of local passengers by place for this carrier.

get_airport_carrier_share

get_airport_carrier_share(
    selfself, airport: str, carrier: str
) -> float

Get the seat share for this carrier at the specified airport

get_choice_set

get_choice_set(carrier: str | None) -> list

Get the choice set for the all, or subset for the specified carrier

get_days_prior

get_days_prior(dcp_index: int) -> int

Get days_prior for this dcp_index

get_preferred_carrier

get_preferred_carrier(
    dmd: Demand, z_val: float, debug: bool
)

Calls the code to set preferred carrier. This is for unit tests

go

go() -> Any

Run the simulation.

license_info

license_info(user_cert=None) -> str

Access license info as a human-readable string.

Parameters:

  • user_cert (Certificate, default: None ) –

    The license.

Returns:

  • str

num_events

num_events() -> int

Return the number of events currently on the event queue.

path_2_leg

path_2_leg(carrier: str, dcp_index: int) -> None

Aggregate PathClass forecasts to Leg/Bucket

The dcp_index is used to adjust forecast revenues when fare adjustment is used.

record_daily_statistics

record_daily_statistics(days_prior: int) -> int

Record daily statistics.

Parameters:

  • days_prior (int) –

    The current number of days prior to departure.

Returns:

  • int

    1 if statistics were recorded (i.e. the sample is after the burn period), or 0 otherwise.

record_dcp_statistics

record_dcp_statistics(days_prior: int) -> int

Record DCP statistics.

Parameters:

  • days_prior (int) –

    The current number of days prior to departure.

Returns:

  • int

    1 if statistics were recorded (i.e. the sample is after the burn period), or 0 otherwise.

record_departure_statistics

record_departure_statistics() -> int

Record departure statistics.

Returns:

  • int

    1 if statistics were recorded (i.e. the sample is after the burn period), or 0 otherwise.

reset_counters

reset_counters() -> None

Reset counters for sold & revenue, for demands and legs.

set_parm

set_parm(name: str, value: float) -> None

Set a simulation parameter by name and value

shop

shop(orig: str, dest: str) -> list[tuple]

Shop all carriers for this O-D pair, return a list of (carrier, price)

update_db_write_flags

update_db_write_flags()

Update database writing flags based on config.

validate_license

validate_license(user_cert=None, future: int = 0) -> None

Validate a user's license certificate.

Parameters:

  • user_cert (Certificate, default: None ) –

    The license.

  • future (int, default: 0 ) –

    Validate as if it is this many days in the future. This is primarily used for debugging and testing. This is treated as an unsigned integer internally, so negative values will not go back in time.

Raises:

  • RuntimeError

    If the license certificate is not valid.

write_to_sqlite

write_to_sqlite(
    cnx: Connection,
    dcp: int,
    store_bid_prices: bool = True,
    intermediate_day: bool = False,
    store_displacements: bool = True,
)

Write details to sqlite