Author-reviewedEvidence: highv1.0.0

Event Queue

An event queue is the time-ordered collection of pending events that a discrete-event simulation processes to advance its clock and update system states.

Last reviewed byDr Darrin Baines

Concept Architecture

Event Queue: Concept Architecture

Orientation and learning roadmap

The page follows the event calendar that moves a discrete-event simulation through time. It explains how events are scheduled and ordered, then works through a health-care pathway in which clinical and resource events interact. The final sections show how that calendar supports economic outcomes and what must be checked when events coincide or become invalid.

Keep future events separate from waiting patients

An event queue holds scheduled changes to the simulated system, such as an arrival, test result, treatment start, recurrence, or death. Each entry identifies when a change is due and what the model should do when it occurs; the simulation clock advances to the earliest valid entry. By contrast, a patient waiting line holds people seeking a limited resource, often with its own priority or first-come-first-served rule.

ObjectContentsGoverning order
Event queue or future-event listScheduled events for all relevant entities.Earliest simulation time first, with a specified rule for ties.
Resource waiting queuePatients waiting for a bed, scanner, appointment, or staff member.The resource's access, triage, or priority discipline.
Event logEvents that have already occurred.Recorded history for validation and output calculation.

A patient can be in a resource waiting queue while the event calendar also contains a future deterioration or abandonment event for that patient. The two structures answer different questions, so the implementation must keep them distinct. A scheduling decision can add, reschedule, or invalidate a future event.

Schedule and execute the next valid event

The model begins with initial events and a simulation clock t0t_0. At each step it removes the earliest valid event, advances the clock to that event's time, updates the affected state, records any outcomes, and schedules consequential events. This event-driven advance skips intervals in which the model has no scheduled change.

  1. Initialise the clock, entity states, resources, random streams, and future-event list.
  2. Remove the earliest valid event and advance the clock to its scheduled time.
  3. Update clinical states, resource occupancy, costs, or outcomes caused by the event.
  4. Schedule any resulting future events and invalidate superseded ones.
  5. Stop under the prespecified horizon or other termination rule, processing events at the horizon according to the chosen boundary convention.

An illustrative event record can be represented as (t,p,s,k,i)(t,p,s,k,i), with time tt, tie priority pp, unique sequence number ss, event kind kk, and entity identifier ii. The tuple is an implementation pattern, not a universal data standard; a priority queue or heap can retrieve the minimum ordered entry efficiently. A unique sequence number makes tied events reproducible, while clinical ordering still needs an explicit rule where it changes outcomes.

Follow an illustrative treatment pathway

Suppose a patient arrives at time 0, has a diagnostic result at day 2, begins treatment at day 5, and may later experience an adverse event or recurrence. Processing the day-2 result can update eligibility and place a treatment-start event on the calendar. If death occurs before a scheduled treatment or recurrence, the model must cancel or ignore events that no longer apply.

Scheduled timeEventPossible change after execution
Day 0Patient arrivalCreate the patient state and schedule diagnostic work.
Day 2Diagnostic resultUpdate disease information and schedule treatment if eligible.
Day 5Treatment startApply treatment cost, reserve any needed capacity, and schedule later outcomes.
Day 20Adverse eventApply an event cost and utility change if the event remains applicable.

The day-20 entry is a possible modelled event, not a prediction for any particular patient. If the model instead schedules candidate times for competing outcomes, it must specify their joint assumptions and whether an event changes or cancels the other candidates. An event list is an execution mechanism; the underlying clinical distributions and causal structure determine whether the simulation is credible.

Accumulate costs and health over irregular intervals

Event timing matters in health economics because costs can occur at an event and health can accrue between events. A model can integrate a utility rate over each interval in a given health state and apply discounted costs or effects at the times specified by its perspective and discounting convention. This avoids treating all events as if they happened at a common cycle boundary.

For a patient whose state has utility uju_j over consecutive intervals [tj,tj+1)[t_j,t_{j+1}), an illustrative undiscounted calculation is

QALYs=∑juj tj+1−tj365.25,\mathrm{QALYs}=\sum_j u_j\,\frac{t_{j+1}-t_j}{365.25},

when simulation time is measured in days and the year-length convention is 365.25 days. If utility is 0.8 for 100 days, that interval contributes 0.8(100/365.25)≈0.21900.8(100/365.25)\approx 0.2190 QALYs. Discounting, changing utility within an interval, and terminal events require corresponding adjustments; use the same convention across compared strategies.

Resolve simultaneous events and stale entries

Two events can have the same scheduled time even in a continuous-time model because of fixed appointments, rounded times, or generated dependencies. Arbitrary processing order may change a patient's state, resource availability, or recorded cost, so prespecify whether, for example, a death at a given instant takes precedence over a treatment event at that instant. Stable insertion order is reproducible, but it is not automatically the clinically appropriate ordering.

Rescheduling can leave a stale event in a heap unless the implementation removes it or checks a validity flag when it is reached. The model should also reject attempts to schedule an event in the past and guard against an unbounded chain of zero-time events. These rules matter for both numerical correctness and a traceable account of why an event occurred.

Verify the event calendar and its outputs

Verification tests whether the coded queue follows the intended event logic, while validation asks whether the model represents the clinical and operational setting adequately. Inspect small deterministic traces before relying on stochastic results; a trace should show time, event type, entity, state before and after, and any newly scheduled or invalidated events. Compare simulated flow and resource use with appropriate observed or expected patterns where data permit.

  • Confirm that processed event times never move backward and that no valid scheduled event is silently lost.
  • Test simultaneous events, terminal events, cancellation, horizon boundaries, and zero-duration transitions with explicit expected traces.
  • Reconcile resource occupancy, patient counts, and accumulated costs and QALYs with event logs in a small example.
  • Check whether a patient's resource-waiting priority changes access while the event calendar remains time ordered.
  • Run sensitivity and uncertainty analyses on the event-time inputs and consequential clinical or economic outputs.

Sources and technical basis

SimPy's developer documentation describes time ordering and deterministic tie handling for an event calendar. The simmer methods publication explains the event list and event loop, while its resource documentation describes the separate waiting line. A health-economic tutorial demonstrates how discrete-event simulation can represent clinical pathways and model costs and outcomes.

Library

Publications

1
  • Journal article

    Modeling Using Discrete Event Simulation: A Report of the ISPOR-SMDM Modeling Good Research Practices Task Force-4 — Karnon, Stahl, Brennan, Caro, Mar & Moller, Task Force Report 4 ed., 2012 (Value in Health / Medical Decision Making)

    Best-practice guidance on discrete event simulation (DES) for health economic evaluation — when DES is preferable to cohort approaches, and how to structure, populate and validate such models.

Frequently Asked Questions (6)

  • What is an event queue?

    The ordered list of scheduled future events awaiting execution within a discrete event simulation, sorted by the time each is due to occur.

    Source: Law & Kelton 2000

  • How does the event queue keep a simulation in order?

    The event queue holds all events that have been scheduled but not yet happened, kept sorted by the time each is due. The simulation always takes the earliest event from the front of the queue, advances its clock to that time, and carries the event out, which may add further events to the queue in their proper place. Processing events strictly in time order this way ensures the model handles them in the sequence they would really occur. Pidd (2004) describes this structure.

    Source: Pidd 2004

  • How does an event queue work?

    An event queue works by holding scheduled future events in order of their occurrence time, so the earliest is always at the front. The simulation takes the next event from the queue, advances the clock to its time, and processes it, which may schedule new events that are inserted into the queue in time order. This continues, with events removed as they are processed and added as they are scheduled, so the queue always reflects the pending events and their order.

    Source: Law & Kelton 2000

  • Why is the event queue important in a simulation?

    The event queue is important because it organises the events that drive a discrete event simulation, ensuring they are processed in the correct time order. By keeping scheduled events sorted by time and always providing the earliest next, it lets the simulation advance from event to event correctly, skipping the intervals between. Without the event queue, the model could not maintain the proper sequence of occurrences, so it is the central structure that coordinates the timing and processing of events.

    Source: Law & Kelton 2000

  • How are events added to and removed from the event queue?

    Events are added to the event queue when they are scheduled, inserted at the position corresponding to their occurrence time so the queue stays ordered, and removed when they are processed, taken from the front as the earliest pending event. Processing an event may schedule further events, which are then inserted. This continual insertion and removal, always maintaining time order, is how the simulation manages the flow of events, so the queue's efficient handling of these operations affects the simulation's performance.

    Source: Law & Kelton 2000

  • How does the event queue drive the simulation clock?

    The event queue drives the simulation clock by determining the next time to which the clock advances: the simulation takes the earliest event from the queue and moves the clock directly to that event's time, skipping the interval since the last event. Because the state changes only at events, the clock jumps from one scheduled event to the next rather than ticking continuously. The event queue thus governs the progression of time, advancing the clock to each successive event as it is processed.

    Source: Law & Kelton 2000

Trust Record

Verified by Dr Darrin Baines

British health economist

Professional identity: darrinbaines.org

Verification date: 23 Sep 2026

Content version: 1.0.0

Canonical Identity

Term code
HE-EM-DES-009

Stable URI · Machine-readable · Resolvable · CC BY 4.0