tool · draft

AgentPy

Open-source Python library by Joël Foramitti for building agent-based models and running experiments on them in Jupyter; no longer actively developed, and its authors point new projects to Mesa.

People & society

What is reusable: open sourceopen dataAPIopen participation BSD-3-Clause

Interactive simulation of Schelling's segregation model in a Jupyter notebook. Foramitti, Journal of Open Source Software (2021), CC BY 4.0.

AgentPy is an open-source library for building and analysing agent-based models in Python, written by Joël Foramitti.1,5 An agent-based model simulates many individual agents, each acting on its own rules, to see what patterns emerge from their interaction.5 AgentPy keeps the whole job in one place: designing the model, watching it run interactively, running experiments over many runs, and analysing the output, all inside IPython or a Jupyter notebook.1

A model has four levels.3 Agents are the building blocks. They live in environments: a grid of discrete positions, a continuous space or a network. A model holds the agents, environments, parameters and procedures, and an experiment runs a model many times with different parameter combinations.3 For that last step it provides parameter sampling (similar to BehaviorSpace in NetLogo), Monte Carlo experiments, random number control, parallel computing and Sobol sensitivity analysis, which measures how much each parameter drives the result.3,4 It is built to work with Python libraries such as NumPy, pandas, NetworkX, SALib and the EMA Workbench.4,5 Its model library includes wealth transfer, virus spread, flocking, segregation and forest fire models.1

It installs with pip and is under the BSD-3-Clause licence.2 The paper describing it appeared in the Journal of Open Source Software on 22 June 2021, with Foramitti at the Universitat Autònoma de Barcelona and the Vrije Universiteit Amsterdam.5 Version 0.1.5, of December 2021, is the latest release.6 AgentPy is no longer under active development, and its authors recommend Mesa for new projects.2

For someone modelling a place, AgentPy offers only abstract spaces: grids, continuous spaces and networks, with no map layer.3 It remains a readable way to learn agent-based modelling and to run experiments over a model's parameters. For new work tied to real geography, Mesa with Mesa-Geo or Agents.jl with its OpenStreetMap space are maintained alternatives.

form
open-source Python library
group
Agents and system dynamics
homepage
https://agentpy.readthedocs.io/
licence
BSD-3-Clause
cost
free

does a similar job

  • Mesa tool draft

    Open-source Python library for building agent-based models, with grids, networks, data collection and a browser view; Mesa-Geo adds maps, so agents can live in real geography loaded from GIS files.

    open sourceopen dataAPIopen participation

  • Agents.jl tool draft

    Open-source Julia library from JuliaDynamics for agent-based models, with grids, networks, continuous space and OpenStreetMap road networks, and both step-by-step and event-driven time.

    open sourceopen dataAPIopen participation

  • NetLogo tool draft

    Free, open-source environment for agent-based modelling, created by Uri Wilensky and developed at Northwestern University; widely used in teaching and research, with a desktop version and NetLogo Web in the browser.

    open sourceopen dataAPIopen participation

Tags: agent-based, Python, Jupyter, sensitivity analysis, simulation framework

staging: drafts and proposals shown