Glossary
Terms are defined as the home chapter uses them.
- active callsign groups
-
Three sets on
HEMSAvailability(callsign groups, registrations, callsigns) that record which resources are claimed by an in-flight allocation, so the same crew or vehicle cannot be allocated twice. Entries are added on claim and discarded byreturn_resource. Chapter 6 - activity time
-
A sampled duration for a job stage (for example
time_mobile), drawn byUtils.activity_time(vehicle_type, time_type)from a fitted distribution and redrawn until it falls inside the bounds for thattime_type. Chapter 3 - actual_data folder
-
The CSVs the model reads for rotas, callsign lookup, servicing, school holidays and time bounds, which the app overwrites from uploads, scenarios or manual edits. Each file has a
_DEFAULTtwin that the app never writes to. Chapter 1 - ad hoc unavailability
-
Unplanned unavailability of a helicopter, sampled by
Utils.sample_ad_hoc_reasonfrom per-registration, six-hour-band and per-quarter probabilities. Every degraded lookup path falls back to"available". Chapter 3 - Ambulance
-
The thin base class from which
HEMSinherits, added as the generic responder. Chapter 5 - AMPDS card
-
The dispatch-code category of the 999 call, sampled for each patient by
ampds_code_selection, conditioned on the hour of day. It drives the sampled care category. Chapter 4 - best-fit distribution
-
The result of
getBestFit:Fittertries each name insim_tools_distr_plus, ranks them, andget_best()returns a one-entry dict of scipy distribution name to parameters. An empty series yields{}. Chapter 8 - call generator
-
DES_HEMS.generate_calls(), the single long-lived SimPy process that decides each day’s call count, places calls within each hour, spawns agenerate_patientprocess per call and yields on the daily servicing check. Chapter 4 - calls per day
-
The number of calls generated for a simulated day: a draw from
Utils.inc_per_day_samples, multiplied bydemand_increase_percentand truncated withint(). Chapter 4 - callsign
-
The identifier of a crewed unit (for example H70), carried on each
HEMSobject. Theg-daanaircraft switches between H70 and H71 depending on whetherg-daasis in service. Chapter 5 - callsign group
-
The grouping of callsigns that share a group number (for example 70 or 71), held on each
HEMSobject and used in allocation to select a preferred unit and to find a secondary. Chapter 5 - care category
-
The patient’s required level of care: CC (critical care), EC (enhanced care) or REG (regular). Sampled per patient conditioned on the AMPDS card. CC and EC patients may take the
allocate_resourcepath; all others useallocate_regular_resource. Chapter 4 - fitter (package)
-
The third-party Python package providing
Fitterandget_common_distributions, imported at the top ofdistribution_fit_utils.py. Chapter 8 - g-daan / g-daas swap
-
The service has two helicopters but wants the callsign H70 always crewed. When H70’s usual aircraft
g-daasis in the workshop,g-daanflies as H70 instead of its usual H71. Hard-coded by registration string. Chapter 5 - DEFAULT parameter files
-
The
*_DEFAULT.csvfiles beside each working CSV inactual_data/.reset_to_defaults()copies each over its working twin; the app never writes to them. Chapter 1 - distribution fitting pipeline
-
The offline batch run of
DistributionFitUtils(entry pointrun_dist_fit_utils.py) that reads a job-level CSV, emptiesdistribution_data/andhistorical_data/, then writes the fitted distributions, probability tables and historical aggregates. It is not part of a simulation run. Chapter 8 - distribution_data folder
-
The folder of fitted distributions and probability tables that
Utils.__init__loads once per run; written byDistributionFitUtils. Chapter 3 - DistributionFitUtils
-
The class implementing the fitting pipeline. Its output filenames and column layouts are an API, because
Utilsand the results classes read them by name. Chapter 8 - event log
-
The list of dicts built by
add_patient_result_row()and converted toresults_dfat the end ofrun(). Each dict is one row ofrun_results.csv; no row is stored beforewarm_up_duration. Chapter 4 - event_type
-
The kind of an event-log row (
arrival_departure,queue,resource_use,resource_use_endand thepatient_*andresource_*descriptors). Downstream code filters on these strings, so they form an implicit schema. Chapter 4 - FilterStore
-
The SimPy store type holding
HEMSobjects.HEMSAvailabilitykeeps two,storefor idle resources andserviceStorefor those in the workshop, and takes items out with lambda filters. Chapter 5 - graceful_methods
-
A class decorator that rebinds every non-dunder callable so that any exception becomes an
st.erroror aprintand the method returnsNone. It is applied toSimulationInputs,TrialResultsandHistoricResults, not to__init__. Chapter 7 - helicopter benefit
-
A per-patient flag, sampled for HEMS cases, that records whether a helicopter would benefit the patient. For any patient on the regular allocation path (REG, and CC/EC patients who did not take
allocate_resource) with a benefit,PROB_HELI_BENEFIT_KNOWNdetermines whether it is known at allocation, which restricts the choice to helicopters. Chapter 4 - HEMS resource
-
A helicopter or car, modelled as a
HEMSobject carrying callsign, callsign group, registration, vehicle type, category, shift hours and a pre-computed servicing schedule. Chapter 5 - HEMS result
- The outcome of the HEMS attendance (for example Stand Down, or Treated not conveyed, meaning the patient was treated but nobody was taken to hospital by HEMS), sampled after allocation conditioned on patient outcome, quarter, vehicle type, callsign group and hour. It determines which later journey stages are skipped. Chapter 4
- HEMS rota
-
HEMS_ROTA.csvinactual_data/, with one row per callsign, category and shift pattern.prep_HEMS_resourcesturns each row into oneHEMSobject. Chapter 5 - historical aggregates
-
The
historical_*outputs ofDistributionFitUtils: observed totals written tohistorical_data/, whichTrialResultsandHistoricResultsplot against simulated output. Chapter 8 - historical_data folder
-
The folder of aggregated observed data loaded by
HistoricResults, plus acalculated/subfolder holding the simulated historical baseline. Chapter 7 - HistoricResults
-
The class that loads the files in
historical_data/and the simulated baseline, to be passed intoTrialResultsplot methods for comparison.TrialResultsdoes not import it. Chapter 7 - hourly arrival profile
-
The per-quarter table of hourly proportions used by
calls_per_hourto draw one hour per call and return{hour: count}. Chapter 4 - ia_dict
-
The
{hour: count}dictionary returned bycalls_per_hour, set once per day ingenerate_calls()and consumed hour by hour. Chapter 4 - incidents per day samples
-
An empirical list of daily call counts per season and per quarter (
Q1toQ4), written byincidents_per_day_samples()and resampled at run time byUtils.inc_per_day_samples. Chapter 8 - master seed
-
The single seed given to
parallelProcessJoblib;SeedSequence(master_seed).spawn(total_runs)derives one per-run seed from it, independent ofn_cores. Chapter 2 - missed call
-
A patient for whom allocation returned
Noneas the primary resource. The model still runs apatient_journey, but no HEMS resource is used. Chapter 6 - missed jobs
-
Calls counted from
resource_request_outcomeevents whosetime_typeis"No Resource Available", reported byTrialResultsincluding an annualised normalised string. Chapter 7 - named random stream
-
A dedicated numpy
Generatorper sampling purpose, held inUtils.rngs, so drawing more or fewer values for one purpose does not change the numbers any other purpose sees. Chapter 3 - parameter template
-
The Excel workbook (
app/inputs/parameter_template.xlsx) whose sheets the setup page reads intoactual_data/CSVs and, via itsadditional_parameterssheet, into session-state scalars. Chapter 1 - Patient
-
A plain attribute bag in
class_patient.pywith defaults and no behaviour;generate_patient()populates it by sampling. Chapter 4 - patient journey
-
The
DES_HEMS.patient_journey()generator: stagestime_allocation,time_mobile,time_to_scene,time_on_scene,time_to_hospitalandtime_to_clear, some skipped depending on the HEMS result, ending in adepartrow. Resources are returned in afinallyblock. Chapter 4 - patient outcome
- The outcome sampled for each patient, conditioned on care category and quarter. It later conditions the HEMS result. Chapter 4
- per-run seed
-
The integer seed for one replication, derived from the master seed and run index and passed to
runSimasrandom_seed.DES_HEMSwraps it in a furtherSeedSequence. Chapter 2 - predefined scenario
-
A filled-in parameter template stored in
scenarios/and offered as a choice on the setup page. It needs a unique name inscenario_details. Chapter 1 - preferred callsign group
-
The callsign group sampled for a HEMS patient and used by
allocate_regular_resourceandpreferred_regular_group_availableto select the unit to send. Chapter 6 - preferred vehicle type
-
The vehicle type (
helicopterorcar) sampled for a HEMS patient and used, with the preferred callsign group, in the REG allocation path. Chapter 6 - primary and secondary resource
-
The first and third elements of the list
[primary, reason_text, secondary]that allocation returns. The secondary is a secondHEMSfrom the same callsign group orNone; as written, it is alwaysNone. Chapter 6 - quarter (qtr)
- Q1 to Q4 of the calendar year, used to stratify most probability tables. Chapter 3
- registration
-
The aircraft or vehicle registration (for example
g-daan), used as the key for servicing schedules and in the active sets. Chapter 5 - RWC
-
Appears in
make_RWC_utilisation_dataframeandPLOT_RWC_utilisation. Not expanded in the code; it presumably means “real-world comparison”, i.e. utilisation built from historic rotas. Chapter 7 - replication
- One independently seeded run of the whole model. Results are only meaningful as a set of replications. Chapter 2
- reset to defaults
-
reset_to_defaults(), which rewrites session state fromDEFAULT_INPUTSand, whenreset_csvsis set, copies each*_DEFAULT.csvover its working CSV. Chapter 1 - resource allocation
-
The part of
HEMSAvailabilitythat returns, per patient,[primary, reason_text, secondary]as a SimPy event, viaallocate_resource(CC and EC) orallocate_regular_resource(everyone else). Chapter 6 - ResourceAllocationReason
-
An
IntEnumwhose values indexHEMSAvailability.LOOKUP_LIST. The enum and the list must be kept in step by hand. Chapter 6 - results collation
-
collateRunResults, which globsoutput_run_*.csvin the results folder, concatenates them intorun_results.csvand deletes the per-run files. CallremoveExistingResultsbefore a fresh batch. Chapter 2 - run_params_used.csv
-
The file of parameters recorded by
write_run_params, written once by run 0 whensave_params_csvis set. Nothing links it to the results by identifier. Chapter 2 - run_results.csv
-
The combined event log across all replications, produced by collation and read by
TrialResults. Each row carries arun_number. Chapter 2 - SR NOTE
-
A code-comment convention in this repo (a maintainer’s note-to-self) used to flag a caveat, for example in
write_run_paramsand above therun == 0check inrunSim. Chapter 2 - school holidays
-
The date ranges in
school_holidays.csv, parsed byparse_school_holidays(which raisesValueErrorif a holiday ends before it starts) and avoided when scheduling aircraft servicing. Chapter 5 - SeededDistribution
-
A pair of a frozen scipy distribution and its own numpy generator, held in a dictionary keyed by
(vehicle_type, time_type). Chapter 3 - SeedSequence spawning
-
The use of
SeedSequence.spawnto derive child sequences: one perUtils, 22 named generators insetup_seeds, then one per activity-time fit. Children are numbered by position, so inserting a stream key shifts later streams. Chapter 3 - service store
-
The second
FilterStore(serviceStore) holding resources currently in the workshop. The daily servicing check moves items between it andstore. Chapter 5 - servicing schedule
-
The pre-computed service windows for each aircraft, built by
prep_HEMS_resourcesfrom service intervals, last service dates and the callsign lookup. Windows avoid school holidays and each other, and only ever move earlier than due. Chapter 5 - session state defaults
-
DEFAULT_INPUTSinapp/_state_control.py, the flat dict of scalar parameters.setup_state()fills only missing keys, so it is idempotent. Chapter 1 - SimPy environment
-
The single
simpy.Environmentowned by eachDES_HEMSrun, advanced untilsim_duration + warm_up_duration. Chapter 4 - simulated historical baseline
-
Output of
run_sim_on_historical_params: 30 replications of two simulated years using historic rotas fromtests/rotas_historic, summarised intohistorical_data/calculated/. It estimates quantities that cannot be observed directly. Chapter 8 - simulation time in minutes
-
The model’s unit of time. Durations and
warm_up_timeare passed in minutes; the app converts days by24 * 60and hours by60. Chapter 2 - SimulationInputs
-
A holder of five DataFrames: run parameters and service dates from the run’s data folder, and rota, callsign lookup and rota month bounds from
actual_data/. Chapter 7 - Stand Down
- A HEMS result meaning the crew was cancelled before reaching the scene; the later journey stages are skipped. Chapter 4
- Streamlit app
-
The multipage app in
app/. It holds scalar parameters inst.session_state, tabular parameters as CSVs inactual_data/, and callsrunSimorparallelProcessJoblib. Chapter 1 - summer and winter shift hours
-
The two sets of shift hours carried by each
HEMS.hems_resource_on_shiftpicks between them by month, using the bounds inrota_start_end_months.csv. Chapter 5 - theoretical available hours
-
The utilisation denominator: rostered minutes per day from
warm_up_end_datetosim_end_date, computed bycalculate_available_hoursfrom the rota alone. Servicing is not subtracted. Chapter 7 - time_type
- The “what” of an event-log row: a stage name, a callsign or a number of minutes. Chapter 4
- TrialResults
-
The class that takes
run_results.csvand derives its metric DataFrames in the constructor, exposingPLOT_*,get_*anddisplay_*methods. Nothing it computes feeds back into the simulation. Chapter 7 - upper allowable time bounds
-
Per-
time_typeminimum and maximum durations fromupper_allowable_time_bounds.csv, used byUtils.activity_timeto reject out-of-range draws and byDistributionFitUtilsto filter data before fitting. Shared across vehicle types. Chapter 3 - utilisation
- Time in use divided by theoretical available hours, per callsign. Per-run durations are summed over runs, divided by the number of runs, then divided by single-run availability. Chapter 7
- Utils
-
The sampling layer in
air_ambulance_des/utils.py. It loads the fitted inputs, builds the named random streams insetup_seeds()and exposes selection methods that each return one sampled value. Chapter 3 - vehicle type
-
helicopterorcar, an attribute of eachHEMSobject. Allocation hard-codes these two values. Chapter 5 - warm-up period
-
Simulated minutes at the start of a run whose events are simulated but not recorded, enforced only in
add_patient_result_row. The recorded window starts atwarm_up_durationand lastssim_duration. Chapter 2