Lecture 11
Agent-based models
in CUS

Esteban Moro

Network Science Institute | Northeastern University

NETS 7983 Computational Urban Science

2025-03-31

Welcome!

This week:

Agent-Based Models

ABM model to simulate epidemic spreading in the Boston MSA, from [1]

ABM model to simulate simultaneously the public health and economic impact of epidemics, from [2]

You are here

Data -> Methods -> Models -> Applications.

Aims

  • Introduce Agent-Based Models (ABMs) and their use in urban science
  • Describe the main components of ABMs
  • Discuss the strengths and challenges of ABMs
  • Present software and tools for building ABMs

Contents

  • Introduction: What is an Agent-Based Model?
  • Examples of use of ABM
  • Validation and calibration of ABMs
  • Sensitivity analysis of ABMs
  • Software and tools for ABMs
  • Conclusions
  • Further reading

Introduction

What is an Agent-Based Model?

An agent-based model (ABM) is a form of computational social science. They are computational models used to simulate the actions and interactions of autonomous agents (individuals, groups, or entities) within a defined environment, with the goal of assessing their effects on the system as a whole.

What is an Agent-Based Model?

Parts of an ABM:

  • Agents: autonomous entities that interact with each other and the environment. Agents can be individuals, groups, or entities. For example, in traffic simulations, agents can be cars, pedestrians, or traffic lights.

  • Environment: the space in which agents interact. The environment can be physical, social, or abstract. For example, in traffic simulations, the environment can be a road network, a city, or a virtual world.

  • Rules: the rules that govern the behavior of agents and the environment. Rules can be deterministic or stochastic. For example, in traffic simulations, rules can be traffic laws, traffic signals, the cost of different modalities, etc.

  • Interactions: the interactions between agents and the environment. Interactions can be direct or indirect. For example, in traffic simulations, interactions can be collisions between cars, congestion on the road, different types of modalities, etc.

What is an Agent-Based Model?

Key steps in building an ABM:

  1. Building the model
  • Identify the research question and target phenomenon to be modeled.
  • Determine minimal agent attributes and behaviors (e.g., preferences, thresholds, strategies).
  • Define how the environment is represented (e.g., grid, network, continuous space).
  1. Implementation:
  • Develop the model using a programming language or a simulation platform (python, C, NetLogo, GAMA, MatSim, etc.)
  • Initialize the model with agents and environment.
  • Run the model and analyze the results.

What is an Agent-Based Model?

  1. Evaluation, calibration, sensitivity
  • Calibrate the model by adjusting the parameters to match the observed past data.

  • Validate the model by comparing the results with new empirical data or other theoretical predictions.

  • Sensitivity analysis to test the robustness of the model to small changes in the parameters.

Why ABM?

  • ABMs are used to study complex systems where the interactions of agents produce emergent properties that cannot be understood by studying the agents in isolation.

  • This is the famous “more than the sum of its parts” idea in which macro behavior emerges from micro decisions [3].

  • ABMs are bottom-up models, in which the behavior of the system is determined by the behavior of the individuals, contrary to top-down, which assumes that all agents in the city are identical.

  • ABMs are used to study systems that are not amenable to mathematical, empirical, or experimental analysis. For example, ABMs are used to study the behavior of crowds, traffic, and the spread of diseases.

  • ABMs are used to study systems that are too large or too complex to be studied by other methods. For example, ABMs are used to study the behavior of cities, economies, and ecosystems where multiple systems of systems interact.

Why ABM?

  • ABMs are used across many disciplines, including physics, economics, biology, sociology, geography, engineering, computer science, and urban science.

  • They are called different names in different disciplines, including

    • Monte Carlo simulations in physical sciences,
    • Individual-based models in biology and ecology,
    • Cellular automata or multi-agent systems in computer science,
    • Agent-based computational economic models in economics.

Examples of use of ABM

Examples of use of ABM

  • Economics: ABMs are used to study the behavior of markets, firms, and consumers.

  • For example, Palmer, Lebaron, Brian Arthur, and many others built the famous Santa Fe artificial stock market model to study the behavior of financial markets [4] [5]. The idea was to see whether the heterogeneous behavior of traders could explain the stylized facts of financial markets (fluctuations, fat tails, etc.)

Example of decision-making flowchart in a stock market ABM, from [6]

Examples of use of ABM

  • Segregation: Probably one of the most famous ABM in economics is the Schelling segregation model [7] In this model, Schelling showed that even if individuals have a weak preference for living near people of the same income or race, segregation can emerge at the macro level.

Segregation patterns emerging from the Schelling model, from The Parable of the Polygons. Initial configuration

Segregation patterns after running the model

Examples of use of ABM

Let’s use this example to describe the main components of an ABM:

  • Research question: How does large-scale segregation emerge in a city where individuals have not large tendencies to segregate?
  • Environment: a grid where agents can live.
  • Agents: individuals with a slight preference for living near people of the same income or race. For example, agents of type A prefer to live surrounded by at least 30% of agents of type A.
  • Rules: agents can move to a vacant cell if they are unhappy with their current location.
  • Interactions: agents interact with their neighbors to determine if they are happy or not.

Even a slight preference for living near people of the same type can lead to large-scale segregation. This model is one of the most famous examples of how macro behavior can emerge from micro decisions.

Examples of use of ABM

  • Epidemics: ABMs are used to study the spread of diseases in populations. For example, ABMs were used during the COVID-19 pandemic to study the effectiveness of different public health interventions, such as testing, contact tracing, and quarantine and their effect on the economy.

ABM model to simulate epidemic spreading in the Boston MSA, from [1]

ABM model to simulate simultaneously the public health and economic impact of epidemics, from [2]

Examples of use of ABM

Let’s use this example to describe the main components of an ABM:

  • Research question: How do mobility and visits to different places affect the spread of a disease in a city?
  • Environment: City and the different POIs agents can visit.
  • Agents: individuals with different mobility patterns and preferences for visiting different places.
  • Rules: agents must stay home or move to different places depending on their preferences and on the policies in place because of the pandemic.
  • Interactions: agents can infect other agents if they are in the same place at the same time through a biological process.

This ABM model can be used to simulate public health and economic interventions in urban areas during epidemics.

Examples of use of ABM

Traffic and Congestion: ABMs are widely applied to understand vehicle flows in urban areas. For example, ABMs are used to study the impact of new transportation policies on urban mobility, the effect of traffic congestion on the economy, and the behavior of drivers in traffic jams.

The MatSim model of Berlin

Examples of use of ABM

Let’s use this example to describe the main components of an ABM for transportation simulations:

  • Research question: How do drivers choose routes and departure times, and how do these choices lead to congestion or underuse of certain roads?
  • Environment: A road network with junctions, highways, and local streets—often derived from GIS data (e.g., OpenStreetMap).
  • Agents: Individuals (drivers), each with specific departure times, trip purposes, and route preferences. In more advanced models, agents can also represent freight vehicles, public transit users, pedestrians, and cyclists.
  • Rules
    • Agents attempt to minimize travel time or avoid congestion (e.g., by taking alternative routes).
    • Traffic signals, capacity constraints, tolls, or variable speed limits shape how quickly agents can move.
  • Interactions
    • Agents occupying road segments reduce travel speed for others (i.e., congestion) or decide to go to another route.

Examples of use of ABM

More recently, researchers are using LLMs as agents in ABMs. Since LLMs incorporate more detailed information about individuals, agents are more context-aware, have more flexibility in their behavior than fixed rules, can adopt more human-like interaction, etc.

llustration of how large language model-empowered agents in ABMs, from [8]

Validation, calibration and sensitivity of ABMs

Validation and calibration of ABMs

  • Calibration: the process of adjusting the parameters of the model to match the observed data. Calibration is used to ensure that the model is consistent with the real-world system.

    • For example, in traffic simulations, calibration can involve adjusting the parameters of the model (e.g., travel speeds, traffic volumes, traffic signal timings) to match the observed data.
  • Validation: the process of comparing the results of the model with empirical data or theoretical predictions. Validation is used to determine whether the model is an accurate representation of the real-world system.

    • For example, in traffic simulations, validation can involve comparing the model’s predictions of traffic flows during road closures or accidents with the observed data.

Sensitivity analysis of ABMs

  • Sensitivity analysis: the process of testing the robustness of the model by varying the parameters and observing the effects on the results. Sensitivity analysis is used to determine how changes in the model’s parameters affect the model’s predictions.

    • For example, in traffic simulations, sensitivity analysis can involve varying the parameters of the model (e.g., individual preferences, trip purposes, etc.) and observing the effects on traffic flow, travel times, and congestion.

Strengths of ABMs

  • Flexibility: ABMs can be used to study a wide range of phenomena, from the behavior of individuals in social networks to the spread of diseases in populations.

  • Emergent behavior: one of the most powerful features is the ability to reproduce emergent behaviors from individual actions

  • Heterogeneity: ABMs can represent the heterogeneity of agents, which is often not possible in other models.

  • Complexity, non-linearity and mutiple equilibria: ABMs can describe complex systems with multiple equilibria, non-linear dynamics, and feedback loops.

Strengths of ABMs

ABMs can be seen also as experimental laboratories to test different hypotheses and scenarios (experiments in silico)

  • What-if analysis: ABMs can be used to study the effects of different policies, interventions, or scenarios on the system as a whole.

  • Causality: ABMs can be used to study the causal relationships between interventions and changes in behavior.

Challenges of ABMs

  • Too much freedom: the sheer extent of choice in constructing ABMs compared to more traditional models means that

    • Modelers have to make many choices
    • Simulations can vary dramatically on those assumptions.
    • Difficult to compare models and results and to extend them to other situations
  • Calibration and validation: ABMs are typically calibrated and validated using empirical data at the macro-level. But given the amount of degrees of freedom to construct them we can always find a model that fits the data. Thus, ABMs models typically overfit the data.

  • Interpretation: ABMs can be difficult to interpret because they are often complex and involve many interacting components. It can be difficult to understand how the behavior of individual agents leads to the behavior of the system as a whole.

Software and tools for ABMs

Software and tools for ABMs

  • NetLogo: a popular platform for building ABMs. NetLogo is a multi-agent programmable modeling environment that is used by students, teachers, and researchers to build models of complex systems. NetLogo has extensions to R and Python.

NetLogo interface

Software and tools for ABMs

  • MATSim is an open-source framework for large-scale agent-based transport simulations. MATSim is used to study the behavior of individuals in transportation systems, including traffic congestion, public transit, and active transportation.

Software and tools for ABMs

  • GAMA: a platform for building spatially explicit agent-based models. GAMA is used by researchers and practitioners to study complex systems, including urban systems, social networks, and ecosystems.

GAMA interface

Software and tools for ABMs

  • GLEAM: a platform for building agent-based models of infectious diseases. GLEAM is used by researchers and public health officials to study the spread of diseases in populations, including COVID-19, influenza, and Ebola.

GLEAM epidemic model

Software and tools for ABMs

More tools:

Conclusions

  • Agent-based models (ABMs) are computational models used to simulate the actions and interactions of autonomous agents in complex systems.

  • ABMs are used to study a wide range of phenomena, from traffic in urban areas and consumption of goods to the spread of diseases in populations.

  • ABMs can explain the emergence of collective behavior from individual actions and, thus, they are use to study complex systems but also to simulate what-if scenarios and causal relationships

  • However, ABMs are complex and difficult to interpret, and they require careful calibration, validation, and sensitivity analysis.

Further reading

References

[1]
A. Aleta et al., “Modelling the impact of testing, contact tracing and household quarantine on second waves of COVID-19,” Nature Human Behaviour, vol. 4, no. 9, pp. 964–971, Sep. 2020, doi: 10.1038/s41562-020-0931-9.
[2]
M. Pangallo et al., “The unequal effects of the health–economy trade-off during the COVID-19 pandemic,” Nature Human Behaviour, vol. 8, no. 2, pp. 264–275, Feb. 2024, doi: 10.1038/s41562-023-01747-x.
[3]
T. C. Schelling, Micromotives and Macrobehavior, Revised edition. Erscheinungsort nicht ermittelbar: W. W. Norton & Company, 2006.
[4]
R. G. Palmer, W. B. Arthur, J. H. Holland, and B. LeBaron, “An artificial stock market,” Artificial Life and Robotics, vol. 3, no. 1, pp. 27–31, Mar. 1999, doi: 10.1007/BF02481484.
[5]
B. LeBaron, “Chapter 24 Agent-based Computational Finance,” in Handbook of Computational Economics, vol. 2, L. Tesfatsion and K. L. Judd, Eds., Elsevier, 2006, pp. 1187–1233. doi: 10.1016/S1574-0021(05)02024-1.
[6]
B. D. Kluger and M. E. McBride, “Intraday trading patterns in an intelligent autonomous agent-based stock market,” Journal of Economic Behavior & Organization, vol. 79, no. 3, pp. 226–245, Aug. 2011, doi: 10.1016/j.jebo.2011.01.032.
[7]
T. C. Schelling, “Models of Segregation,” The American Economic Review, vol. 59, no. 2, pp. 488–493, 1969, Accessed: Feb. 19, 2024. [Online]. Available: https://www.jstor.org/stable/1823701
[8]
C. Gao et al., “Large language models empowered agent-based modeling and simulation: A survey and perspectives,” Humanities and Social Sciences Communications, vol. 11, no. 1, pp. 1–24, Sep. 2024, doi: 10.1057/s41599-024-03611-3.
[9]
N. Gilbert, “The Idea of Agent-Based Modeling,” in Agent-Based Models, SAGE Publications, Inc., 2008, pp. 2–21. doi: 10.4135/9781412983259.
[10]
E. Bruch and J. Atwell, “Agent-based models in empirical social research,” Sociological Methods & Research, vol. 44, no. 2, pp. 186–221, 2015, doi: 10.1177/0049124113506405.
[11]
A. Crooks, A. Heppenstall, N. Malleson, and E. Manley, “Agent-Based Modeling and the City: A Gallery of Applications,” in Urban Informatics, W. Shi, M. F. Goodchild, M. Batty, M.-P. Kwan, and A. Zhang, Eds., Singapore: Springer, 2021, pp. 885–910. doi: 10.1007/978-981-15-8983-6_46.
[12]
A. Turrell, “Agent-Based Models: Understanding the Economy from the Bottom Up.” Rochester, NY, Dec. 2016. Accessed: Mar. 17, 2025. [Online]. Available: https://papers.ssrn.com/abstract=2898740