Rémi Pelloux / case study / Modelly

Case study

Modelly

A Python framework for agent-based models, where a result you got once is a result you can get again.

Modelly documentation home page with a live epidemic model
The documentation site, with an epidemic model running behind the page.
Role
Author and maintainer
Stack
Python, numpy, pandas, Solara
Release
1.5.1, pip install modelly-abm
Site
remipelloux.github.io/Modelly
Source
github.com/RemiPelloux/Modelly

Problem

Agent-based models are how researchers study markets, epidemics or cities. They are easy to describe and hard to keep correct, reproducible and fast. Modelly gives the parts that carry the load as small objects, so the model file reads like a description of the system.

What I built

  • Scenarios: the parameters of a run as one typed class, with one seed.
  • Agents with a step(), grouped in ordered sets, and columns that store their attributes in numpy arrays.
  • Spaces: square and hexagonal grids, networks, Voronoi meshes and continuous space.
  • One scheduler for ticks, events, generators and priorities.
  • Reporters that land in pandas, a browser view built on Solara, and a codemod for models written for Mesa.

How it works

The engine keeps one Python object per agent, which keeps models easy to write, and moves the heavy work into arrays. Continuous space answers neighbour queries for the whole population with one KD-tree, and step phases can act on every agent at once. Files stay under 300 lines and functions under 25, and a script enforces it. A 100-line version of the same idea runs in the lab.

Limits

It needs Python 3.12 or later. Stable names follow semantic versioning, and the newest packages are still marked provisional.

All selected work Next: OpenPlod