4.5: Event scheduling

Contents

4.5: Event scheduling#

Learning objectives

By the end of this model, you will be able to:

  1. Distinguish the two time-progression schemes:

    • Explain the difference between incremental and next-event time progression.

    • Recognise the situations in which each scheme is appropriate.

  2. Reason about model efficiency:

    • Identify the idle activations that make incremental progression wasteful.

    • Estimate how event scheduling reduces the number of agent activations.

  3. Apply event scheduling in Mesa:

    • Use a Mesa model’s built-in schedule_event() and run_for() methods to run an event-scheduled model.

    • Adapt a model to schedule events for known future moments rather than activate every agent at every step.

Agent-based models advance time in one of two ways, and the choice has a large effect on how fast a model runs.

Under incremental time progression, the model clock advances by a fixed step and every agent is activated at each step. This is simple, but it is wasteful whenever an agent has nothing to do. In Epstein’s civil violence model, for example, a jailed agent is still activated at every step, only to reduce its remaining jail time by one, even though the moment of release is already known when the agent is arrested.

Under next-event time progression, state changes are represented as time-stamped events held in a sorted queue. The clock jumps directly to the timestamp of the next event, executes it, and may schedule further events. An agent that must wait is activated only when its event is due, not at every step in between. The two schemes can also be combined into a hybrid that keeps the familiar step-based update while allowing events to be scheduled for later, which is often easy to add to an existing model and can reduce its runtime substantially. In Mesa, every model carries a time-ordered event queue: model.schedule_event() places an event at a future moment, and model.run_for() advances the clock and fires events as they fall due.

This also makes a broader point. Agent-based modelling is not limited to emergence from spatial interaction. Because a Mesa model can schedule events on a queue, it can also express discrete-event simulation (DES), a modelling paradigm in its own right, in which the clock jumps from one scheduled event to the next.

This short overview visualises the same core idea: the simulation clock need only move when a meaningful event occurs.

Understanding Discrete Event Simulation, Part 1: What Is Discrete Event Simulation, MATLAB.

The activity below contrasts the two schemes on the same scenario, in which each agent needs to act only at a few scheduled moments and is idle in between. Before you run it, predict which scheme performs fewer agent activations, and how large the gap becomes when agents spend most of their time waiting.

Learning Activity: Incremental vs event-driven time
tell incremental time-stepping apart from event-driven scheduling.
Six agents running for eighteen time units, each needing to act at only a few shaded moments and idle the rest of the time, like a jailed agent waiting for release, shown under incremental time beside event-driven time.
Press Play or Step to advance the clock and compare the activation counts under incremental and event-driven time.
Clock: 0 / 18
Incremental: activate every agent, every stepactivations: 0
Event-driven: execute only scheduled eventsactivations: 0

Key takeaways#

Key takeaways

  • Incremental scheduling checks every agent every tick; event scheduling jumps directly to planned changes.

  • Event scheduling saves work when most agents are idle, but the saving depends on model conditions.

  • The exercises measure both computational efficiency and whether scheduling changes substantive results.

Begin with 4.5.1: Exercises to build, run, test, and extend the model.