Mesa Time Module

Objects for handling the time component of a model. In particular, this module contains Schedulers, which handle agent activation. A Scheduler is an object which controls when agents are called upon to act, and when.

The activation order can have a serious impact on model behavior, so it’s important to specify it explicitly. Example simple activation regimes include activating all agents in the same order every step, shuffling the activation order every time, activating each agent on average once per step, and more.

Key concepts:

Step: Many models advance in ‘steps’. A step may involve the activation of all agents, or a random (or selected) subset of them. Each agent in turn may have their own step() method.

Time: Some models may simulate a continuous ‘clock’ instead of discrete steps. However, by default, the Time is equal to the number of steps the model has taken.

class mesa.time.BaseScheduler(model: mesa.model.Model)[source]

Simplest scheduler; activates agents one at a time, in the order they were added.

Assumes that each agent added has a step method which takes no arguments.

(This is explicitly meant to replicate the scheduler in MASON).

add(agent: mesa.agent.Agent)None[source]

Add an Agent object to the schedule.


agent: An Agent to be added to the schedule. NOTE: The agent must have a step() method.

agent_buffer(shuffled: bool = False)Iterator[mesa.agent.Agent][source]

Simple generator that yields the agents while letting the user remove and/or add agents during stepping.


Returns the current number of agents in the queue.

remove(agent: mesa.agent.Agent)None[source]

Remove all instances of a given agent from the schedule.


agent: An agent object.


Execute the step of all the agents, one at a time.

class mesa.time.RandomActivation(model: mesa.model.Model)[source]

A scheduler which activates each agent once per step, in random order, with the order reshuffled every step.

This is equivalent to the NetLogo ‘ask agents…’ and is generally the default behavior for an ABM.

Assumes that all agents have a step(model) method.


Executes the step of all agents, one at a time, in random order.

class mesa.time.SimultaneousActivation(model: mesa.model.Model)[source]

A scheduler to simulate the simultaneous activation of all the agents.

This scheduler requires that each agent have two methods: step and advance. step() activates the agent and stages any necessary changes, but does not apply them yet. advance() then applies the changes.


Step all agents, then advance them.

class mesa.time.StagedActivation(model: mesa.model.Model, stage_list: Optional[List[str]] = None, shuffle: bool = False, shuffle_between_stages: bool = False)[source]

A scheduler which allows agent activation to be divided into several stages instead of a single step method. All agents execute one stage before moving on to the next.

Agents must have all the stage methods implemented. Stage methods take a model object as their only argument.

This schedule tracks steps and time separately. Time advances in fractional increments of 1 / (# of stages), meaning that 1 step = 1 unit of time.


Executes all the stages for all agents.