Modelly is an agent-based modeling (ABM) framework for Python. Declare a
typed scenario, give your agents behaviour, run the world forward in time, then measure, replay and
publish it. Seeded runs, numpy-backed agents, grids, networks and continuous space, discrete-event
time, pandas data collection, browser visualization. Fast by construction, reproducible by default.
Status: stable, Python 3.12+, release 1.5.2. Every public name has a stability level
(docs/api_stability.toml): stable names follow semantic versioning and the deprecation policy;
the newest packages are marked provisional. The current version is modelly.__version__.
pip install modelly-abm
python -c "import modelly; print(modelly.__version__)" # the import name is modelly
Agent-based models are how researchers study systems whose behaviour emerges from many
interacting parts: markets, epidemics, ecosystems, cities, opinions. The models are easy to
describe and hard to keep correct, reproducible and fast. Modelly exists to remove that gap.
What we are building
A research instrument, not a toy. Every run is seeded, every parameter lives in a typed
scenario, every dataset lands in pandas. A result you got once is a result you can get again.
Fast by construction. The hot paths of a simulation (activating agents, moving them,
looking up neighbours, recording data) are measured, benchmarked before every release, and written so the cost
per agent-step stays flat as models grow. Performance is a feature with a test, not a hope.
Small, readable modules. A researcher should be able to open any file and understand it in
one sitting. Files stay under 300 lines, functions under 25, and the rule is enforced by a script,
not by goodwill. The Pelloux guidelines are the contract.
One mental model from notebook to cluster. The same scenario object drives a quick look in a
notebook, a browser visualization, a parameter sweep and a batch of replications.
Where we are going. The engine keeps one Python object per agent, which is what makes models
easy to write, and moves the heavy lifting into arrays: Column attributes give the model a numpy
view of every agent, continuous space answers neighbour queries for the whole population with one
KD-tree, vectorised step phases act on the whole population, and one model can be split across
processes or run its columns on a GPU (Scale out and connect).
The performance audit records what has been done and what is next.
Why Modelly
Modelly gives you the boring, load-bearing parts as small composable objects, so your model file
reads like the description of the system instead of the plumbing around it:
Building block
What it gives you
Scenario
Parameters as a typed class: one run, one seed, one config object
Agents
Agent classes with a step(), grouped in ordered AgentSets
Columns
Attributes stored in numpy arrays, readable per agent and as a whole
Space
Orthogonal / hexagonal grids, cells, networks, Voronoi meshes, continuous space
Time
Discrete ticks, events, generators and priorities in one scheduler
Data
Reporters and datasets that land in pandas, ready to plot
Agents wander a grid and hand one unit of wealth to a random cellmate. Inequality emerges.
The same code ships as example.py.
from modelly import Model
from modelly.space import CellAgent, OrthogonalMooreGrid
from modelly.scenarios import Scenario
class WealthScenario(Scenario):
"""Everything that can vary between runs lives here."""
n: int = 120
width: int = 12
height: int = 12
class MoneyAgent(CellAgent):
def __init__(self, model, cell):
super().__init__(model)
self.cell = cell
self.wealth = 1
def step(self):
self.cell = self.cell.neighborhood.select_random_cell()
cellmates = [a for a in self.cell.agents if a is not self]
if self.wealth > 0 and cellmates:
self.random.choice(cellmates).wealth += 1
self.wealth -= 1
class WealthModel(Model):
def __init__(self, scenario: WealthScenario = WealthScenario):
super().__init__(scenario=scenario)
self.grid = OrthogonalMooreGrid(
(scenario.width, scenario.height), random=self.random
)
MoneyAgent.create_agents(
self,
scenario.n,
self.random.choices(self.grid.all_cells.cells, k=scenario.n),
)
def step(self):
self.agents.shuffle_do("step") # every agent, in random order
@property
def gini(self):
x = sorted(a.wealth for a in self.agents)
n = len(x)
weighted = sum(xi * (n - i) for i, xi in enumerate(x))
return 1 + 1 / n - 2 * weighted / (n * sum(x))
model = WealthModel()
for _ in range(100):
model.step()
print(model.gini) # 0.0 at the start, about 0.6 after 100 ticks
Three pieces, and nothing else: a scenario of inputs, agents that know one thing each,
and a model that owns the world and advances it.
Record it, then look at it
from modelly.data.collector import DataCollector
class WealthModel(Model):
def __init__(self, scenario: WealthScenario = WealthScenario):
super().__init__(scenario=scenario)
# ... grid and agents as above ...
self.datacollector = DataCollector(
model_reporters={"Gini": "gini"}, # anything reachable from the model
agent_reporters={"Wealth": "wealth"}, # anything on each agent
)
def step(self):
self.agents.shuffle_do("step")
self.datacollector.collect(self) # one row per tick
model_vars = model.datacollector.get_model_vars_dataframe() # Gini per tick
agent_vars = model.datacollector.get_agent_vars_dataframe() # wealth per agent per tick
agent_vars.groupby("Step")["Wealth"].mean().plot()
Both frames are plain pandas, so everything you already know how to do keeps working.
Attribute reporters are gathered in C (operator.attrgetter), so a string reporter is the fast
path, not just the convenient one.
Vectorise the bulk work
An agent-based model has two kinds of work: what one agent does in its step, which is Python
by nature, and what the model does to all agents at once (aggregate, filter, record, update),
which should be numpy. Declare a Column and the attribute lives in a model-owned array: the
agent keeps reading and writing it as before, and the model gets a zero-copy view of everyone.
import numpy as np
from modelly import Agent, Column, Model
class MoneyAgent(Agent):
wealth = Column(int, default=1) # one numpy array for the whole class
def step(self):
other = self.random.choice(self.model.agents.to_list())
if self.wealth > 0: # per-agent access works as before
other.wealth += 1
self.wealth -= 1
class WealthModel(Model):
@property
def gini(self):
x = np.sort(self.columns[MoneyAgent].wealth) # view, no copy
n = len(x)
return 1 + 1 / n - 2 * np.sum(x * (n - np.arange(n))) / (n * x.sum())
def tax(self):
w = self.columns[MoneyAgent].wealth
w[w > 10] -= 1 # bulk update, in place
def rich(self):
table = self.columns[MoneyAgent]
return table.where(table.wealth > 10) # an AgentSet
Nothing else changes: model.agents, shuffle_do, DataCollector and the examples work the
same, and attribute reporters on a column are recorded straight from the array. Measured on
10,000 agents:
Operation
Plain attribute
Column
Gini coefficient
1.09 ms
0.03 ms
Count agents with wealth > 0
0.94 ms
0.008 ms
Mean wealth
0.47 ms
0.009 ms
Decrement every wealth > 5
0.15 ms
0.004 ms
DataCollector.collect, one reporter
0.95 ms
0.46 ms
One agent.wealth read inside step
6 ns
27 ns
The last row is the trade-off: use columns for attributes you aggregate, filter, record or update
in bulk; a plain attribute is still the cheapest thing to touch inside step. In the Boltzmann
example the object loop is unchanged within noise while the model-level work is 30x cheaper.
The whole population at once
Two more operations run over everyone in one call, so a model can move its population-wide phases
out of the per-agent loop:
# A whole-population step for the sheep: decrement, die, reproduce, no per-agent loop.
table = self.columns[Sheep]
table.energy -= 1
table.remove_where(table.energy < 0)
table.do_where(table.draw(0.04), "spawn_offspring") # one seeded draw per sheep
# Continuous space: one KD-tree answers the whole flock, same snapshot for all.
lists = self.space.neighbors_within(radius=5.0)
for boid in self.agents:
boid.neighbors = lists[boid]
draw uses the model's seeded numpy generator, so the run stays reproducible. neighbors_within
is O(n log n) for the whole flock instead of one O(n) scan per agent, is periodic on a torus, and
is cached while no position changes. The Boids example uses it: 2,000 boids go from 98 ms to
42 ms per step.
Replications in parallel
from modelly.scenarios import RunConfiguration, run_scenarios
scenarios = WealthScenario(n=5000, rng=1).spawn_replications(32) # 32 independent seeds
store = run_scenarios(scenarios, RunConfiguration(WealthModel, until=200), workers=8)
Each replication carries its own seed derived from the base scenario, so the sweep is
reproducible; workers= spreads it over processes.
For a plain factorial experiment, run_grid is the one-call version: every combination times
the replicates, each run with its own seed, results in design order whatever the number of
workers, so the DataFrame is identical to the sequential loop's.
from modelly import run_grid
def season(task): # a notebook function works: on Linux the workers are forked
model = Orchard(budget=task["budget"], invasion=task["invasion"], rng=task["seed"])
model.run_for(100)
return {"harvested": model.harvested, "rotten": model.rotten}
results = run_grid(
season, {"budget": [0, 150, 300, 600], "invasion": [3, 10, 30]}, replicates=3
)
Populations as cohorts
When individuals in the same state face the same probabilities (an insect's stage, age and
sex), one row with a count replaces them all, and each per-individual draw becomes one
binomial draw per row with exactly the same law. CohortTable holds such a population with no
agent objects; the stage-structured playbook runs 251x faster than its individual Mesa 2.3
version and agrees with it statistically.
from modelly import CohortTable
insects = CohortTable(model.rng, stage=np.int8, age=np.int16, female=bool)
insects.add(500, stage=EGG)
insects.thin(daily_survival[insects["stage"]]) # Binomial(count, s) per row
insects.split(0.5, where=emerging, stage=ADULT, female=True) # sex at emergence
eggs = insects.draw(lay_prob, where=mature_females).sum() * clutch
Scale out and connect
Each item keeps the authoring model above; each number is measured on one laptop and recorded
in the docs it links to, shortfalls included.
Split runs (modelly.distributed): one model across processes with MPI, Dask or locally,
byte-identical to a single process at 1, 2, 4 and 16 partitions; weak scaling on a 16-core
laptop stays far below a cluster's, 85% at 2 workers and 5% at 16 (guide).
GPU backend (modelly.gpu): columns, cohorts and cell operations on CuPy or JAX, same
integer state as numpy; 34x faster at 10 million agents on a laptop RTX 5050, slower at
20,000 (guide).
Differentiable models (modelly.diff): JAX-traced phases and gradient calibration that
recovers known parameters on two zoo models (guide).
Live data and assimilation (modelly.stream): sources, replicate ensembles, a particle
filter (nowcast error 5 people against 69 unfiltered on the tutorial's synthetic truth) and an
ensemble Kalman filter (tutorial).
Fields and ODEs (modelly.couple): diffusion, advection and decay on a grid layer, ODE and
stock-flow parts, a checked coupling schedule; mass conserved to round-off (guide).
Emulators and history matching (modelly.emulate): Gaussian-process and neural emulators,
active learning, waves that shrink the plausible space from 17% to 2.5% on the SEIR zoo model (guide).
Synthetic populations (modelly.population): people from census tables, households,
places and contact networks; three zoo models on real Burlington data, licences bundled (guide).
A model in the browser: modelly export-web model.py:Model writes a static site that runs
it in Pyodide; every bundled model verified in headless Chromium; first load 8 s on a 50 Mbit/s
line for a model without scipy, 21 s on a fast 4G profile (guide).
Studio II: ensemble, assimilation, experiment, analysis and WebGL map tabs, a session
recorded as a script that reproduces the run (guide).
Tools: a NetLogo translator for a stated subset (guide),
modelly lint --lsp for editors, pre-commit hooks, 21 lint rules, strict typing on the
research packages.
New in 1.5: ecosystem and collaboration
A model hub.modelly hub search epidemic, modelly hub install within_host: published
models with their card, DOI and checksums, from a public index
(hub); modelly hub publish prepares yours
(guide).
Model cards. Every zoo model says what it is for, what it must not be used for and how it
was validated; modelly card check fails when a model changed since its validation ran
(guide).
Decisions and causes. Strategies compared on common random numbers with intervals,
cost-effectiveness, robust decisions across futures, treatment effects, attribution,
counterfactuals (decisions, causes).
Continuous dynamics in agents. An ODE in every agent with events, time-varying inputs,
delays, stochastic equations, a mean-field companion and gradients; solve_batch takes each
system's own solve_ivp steps for a whole population at once (guide).
Language-model agents that remember and talk: memory, plans, tools, conversations and an
evaluation harness (guide).
R, Julia and Studio for everyone.library(modelly) and using Modelly, tested on three
OSs; Studio with a no-code mode, scenario comparison, reports, a model builder, a classroom
mode, five languages and the WCAG 2.2 AA checks (R and Julia,
Studio, accessibility).
Ready for 2.0. Plugin API v1 frozen for 1.x; every 2.0 change warns or changes no call, and
modelly migrate --check-2.0 lists what a project must change (deprecations).
Modelly, Mesa, NetLogo or Agents.jl?
Modelly
Mesa
NetLogo
Agents.jl
Language
Python
Python
NetLogo
Julia
Authoring model
Model, Agent, AgentSet, typed Scenario
Model, Agent, AgentSet
turtles, patches, links
ABM, agent structs
Per-agent attributes in arrays
Column: one numpy array per attribute, zero-copy views
no
no
yes
Population-wide operations
draw, do_where, remove_where, one KD-tree query per step
one seed on the scenario, derived seeds per replication
model seed
run seed
model RNG
Data out
pandas, incremental frames
pandas
CSV, BehaviorSpace
DataFrames.jl
Visualization
Solara in the browser, matplotlib, altair
Solara
built-in GUI
Makie
Moving from Mesa
codemod plus a construct-by-construct guide
–
–
–
Pick Modelly when you want Mesa's authoring model with numpy underneath, measured performance,
and a scenario object that makes every run reproducible. Pick NetLogo for teaching and its GUI,
Agents.jl when the rest of your stack is Julia.
Coming from Mesa
Modelly's authoring model is the one Mesa 3 users know (Model, Agent, AgentSet,
DataCollector), with one grid system and no schedulers. A codemod does the mechanical part of a
move and reports the rest, each line pointing at a section of the guide:
python -m modelly.migrate path/to/your/model/ # dry run: diff plus report
python -m modelly.migrate path/to/your/model/ --write # apply the rewrites
It rewrites imports to the domain-package paths (modelly.space, modelly.time, modelly.data,
modelly.batch, modelly.viz), agent constructors and scheduler attributes, and flags scheduler classes,
legacy grid calls, batch_run, simulators and seed= for you to decide. The construct-by-construct
map, for Mesa 2.x and 3.x, is docs/migrating_from_mesa.md.
Checking a model
A static check finds the bugs that break reproducibility (random draws outside the model's
generators, wall-clock values, a missing super().__init__, loops over sets) and the loops that
make a step O(N²) (an agent scanning self.model.agents, nested population loops):
python -m modelly.lint path/to/your/model/ # exits 1 on findings, so it works in CI
python -m modelly.lint --explain MDL101 # why a rule matters, with a fix
python -m modelly.lint --diff src/ # the safe fixes (MDL001, 002, 003, 009) as a diff
python -m modelly.lint --fix src/ # apply them, then report what is left
A new project starts clean: modelly new my-model --template grid (or network, continuous,
cohort, geo, llm) writes a package with a seeded scenario, an agent and a model, a determinism test, the
lint settings and a README with an ODD outline. See
docs/new_project.md.
In Jupyter, %load_ext modelly.ipython adds %modelly lint and %modelly profile, and a model
displays its scenario, time and population by agent class.
Every tool is also one command: python -m modelly --help (or modelly --help once installed)
lists them, and modelly lint src/ is python -m modelly.lint src/. Every rule, with the fix, is in docs/lint.md;
modelly lint --lsp serves the same findings and fixes to an editor over the language server
protocol, and .pre-commit-hooks.yaml offers modelly-lint and modelly-lint-fix to pre-commit.
Its runtime companion runs the model and shows where each step's time goes: every
AgentSet.do / shuffle_do call by agent class and method, with its cost per agent,
DataCollector.collect, scheduled events, births and deaths, plus hints that point at lint codes:
From Python, with modelly.profile.Profiler(model) as prof: model.run_for(100), then
prof.report() or prof.to_dataframe(). See docs/profile.md.
Checkpoints
A long run can be saved and resumed bit for bit, in the same process or a new one:
model.run_for(50)
model.save("run.ckpt") # agents, spaces, events, data, both generators
model = WolfSheep.load("run.ckpt") # only load files you trust: it is a pickle
model.run_for(50) # identical to running 100 steps in one go
model.checkpoint_every(100, "run-{time:05.0f}.ckpt")
modelly run, verify, bundle, odd: manifests and archivable studies
modelly.timetravel
checkpoint rings, rewind, replay, branch, run diff
modelly.llm
language-model agents with a replayable response cache, memory, tools, conversations, evaluation
modelly.studio
modelly studio, the browser workbench
modelly.web
modelly export-web, a model as a static site
modelly.zoo
18 validated models, each with a test against a known result and a model card
modelly.netlogo
modelly netlogo, the NetLogo translator
modelly.lint
python -m modelly.lint, static checks for models, --lsp
modelly.profile
python -m modelly.profile and Profiler, where a running model's time goes
modelly.migrate
python -m modelly.migrate, the Mesa codemod; --check-2.0 for 1.x projects
modelly._native
the five compiled modules (fastrng, fastloop, fastcell, fastset, fastevents), each with a pure-Python twin
The top-level names (modelly.Agent, modelly.Model, modelly.DataCollector, modelly.Column,
modelly.CohortTable, modelly.FastRandom, modelly.run_batch, modelly.run_grid) import from
modelly directly.
How the engine stays fast
The data structures are chosen for the operations a simulation actually performs, and each choice
is backed by a measurement in docs/performance.md.
Structure
Backed by
Why
AgentSet (every view)
ordered dict keyed on weakref.ref
O(1) membership and removal, stable order for reproducible shuffles, no zombie agents; half the cost of WeakKeyDictionary
model.agents (the registry)
ordered dict keyed on the agent
Strong references where the lifecycle is explicit; views downgrade to weak sets in one place
Cell.agents
list
Cells hold a handful of agents; append and remove beat any indexed structure at that size
Cell neighbourhoods
per-cell dict cache
One lookup per query; invalidating one cell never touches another, and a discarded grid is freed
Empty cells in any discrete space
swap-remove list + index
O(1) random empty cell at any fill level, built lazily the first time a space turns out to be dense
Property layers
np.ndarray per layer
Vectorised updates on the array, per-cell accessors on the cells, one source of truth
Continuous space
one np.ndarray of positions, one KD-tree per step
Per-agent queries are numpy; neighbors_within answers the whole population in one periodic tree query
Event queue
a compiled binary heap (fastevents.c) with lazy cancellation and compaction
O(log n) scheduling that never degrades under repeated cancel/reschedule; the same ordering as its pure-Python twin
Benchmarks
Two questions, two methods, both in the repository.
Same code on both frameworks. A research notebook written for Mesa 2.3, migrated with
the codemod and nothing else changed, identical seeds, outputs checked bit-identical, CPU time
pinned and alternating: Modelly runs at Mesa's speed within a few percent (0.94 of Mesa's time
seeded with FastRandom, 1.02 to 1.04 with random.Random); that model spends most of its
time in its own code. Two public playbooks migrated the same way (benchmarks/migrated_mesa2/), which
spend most of theirs in framework calls, run at 0.21 and 0.37 of Mesa 2.3's time with
bit-identical output. Five Mesa 3.5 playbooks migrated by the codemod alone
(benchmarks/migrated_mesa3/) run at 0.44 to 0.91 of Mesa 3.5's time; they are not bit-identical
(the random streams differ) but agree in distribution over 100 seeds. The method and every
round are in
docs/performance.md.
Same model, each framework's own idiom.benchmarks/playbooks/ holds eight models written
for Mesa 2.3 and for the current Mesa 3.5 the way their APIs intend, four of them also for the
vectorised mesa-frames, three also as a hand-vectorised Mesa 3.5 baseline, and for Modelly with columns, vectorised phases, CellIndex and one
KD-tree per step. The runner executes each in its own environment, pinned to one core, rotating
the order every round, checks that the implementations agree in distribution (over shared
seeds, every statistic) and that each is deterministic, and records the machine and versions.
CPU seconds of the steps at the large size, median of ten rounds in one session on a
performance core, this machine, at a fixed 1.9 GHz base frequency (performance governor, turbo
disabled; every per-round ratio within 19% of its median, and a second session agrees within 4%). Absolute seconds are therefore longer
than with turbo; the ratios are the point:
Playbook
Mesa 2.3
Mesa 3.5
Mesa 3.5 + numpy
mesa-frames
Modelly, cell lists
Modelly
vs Mesa 2.3
vs Mesa 3.5
vs mesa-frames
Grid epidemic (SIR, random walk, synchronous)
6.52 s
3.99 s
0.034 s
1.07 s
2.67 s
0.155 s
42x
26x
6.9x
Predator-prey with grass (births and deaths every step)
3.33 s
3.67 s
2.17 s
0.52 s
6.4x
7.1x
Flocking in continuous space
24.44 s
24.49 s
0.75 s
33x
33x
Virus on a random network
7.85 s
2.52 s
0.195 s
40x
13x
Stage-structured insect population, individuals
3.72 s
2.00 s
0.70 s
5.3x
2.9x
Same population as a CohortTable (binomial thinning)
3.72 s
2.00 s
0.015 s
251x
135x
Schelling segregation (moves to random empty cells)
4.55 s
3.57 s
0.112 s
1.94 s
0.322 s
0.201 s
23x
18x
9.6x
Boltzmann wealth exchange, Gini by a DataCollector
2.09 s
1.14 s
0.121 s
1.00 s
0.328 s
6.4x
3.5x
3.0x
Sugarscape, constant growback (vision, best sugar in sight)
1.49 s
1.44 s
2.12 s
1.12 s
0.326 s
4.6x
4.4x
6.5x
"Mesa 3.5 + numpy" (mesa3np_model.py) is what a Mesa modeller can write by giving up agent
objects: a mesa.Model holding the population as numpy arrays over Mesa's grid and property
layers, with the same vectorised phases as Modelly. It is faster than Modelly's columns (4.5x on
the epidemic, 1.8x on Schelling, 2.7x on Boltzmann): Modelly keeps an Agent per individual,
with its step(), its identity and the agent-set API, and pays for that bookkeeping. With agents
on both sides, Modelly columns are 2.9 to 33x faster than Mesa 3.5, 4.6 to 42x faster than
Mesa 2.3 (4.0 to 32x including construction) and 3.0 to 9.6x faster than mesa-frames, and the
lead grows with the population on the epidemic and Schelling's model (119x over Mesa 2.3 at
200,000 agents; paper/scripts/sizes.py). On flocking, part of the gain is the neighbour
search: Mesa 3.5 with one scipy.spatial.cKDTree per step (flocking/mesa3kd_model.py, same
statistics as Mesa 3.5 on every seed) runs 2.7x faster than Mesa 3.5's own search, and Modelly
is 12x faster again.
Where Modelly keeps Mesa's data structure (agents held in cell lists, modelly-cells in the
results) the gap closes to 1.3 to 2.4x over Mesa 2.3 on the epidemic, predator-prey and
Sugarscape models: the layout is where the time is, not the interpreter. (Schelling's model with
cell lists stays 14x ahead of Mesa 2.3: it counts every resident's similar neighbours at once.)
Every vectorised phase rests on a stated equivalence argument, in
docs/vectorised_phases.md; the full tables with the agreement
checks are in benchmarks/playbooks/results/README.md.
Future roadmap
Each release page records what shipped and what fell short, measured: 1.3.0
(calibration, sensitivity, experiments, provenance, Studio, the zoo), 1.4.0
(scale out and connect) and 1.5.0 (the section above). Next, without dates:
1.6.0, in progress, finishes what 1.5 left open (hub publications, community
plugins, R and Julia II, a Studio workbench) and ships 2.0's riskiest designs as opt-in
previews; then 2.0.0, one space API, one clock, columns by default, typed scenarios, a
stable ABI and checkpoint format, with its deprecations already announced in
docs/deprecations.md and checked by modelly migrate --check-2.0. Each
item keeps today's authoring model: you still write a Model, an Agent subclass and a
Scenario.
Built-in examples
Real, runnable models that ship with the package, good reading material for the patterns above.
Model
Shows
Path
Boltzmann Wealth
Money exchange on a grid, emerging inequality
modelly/examples/basic/boltzmann_wealth_model
Schelling
Segregation from local tolerance thresholds
modelly/examples/basic/schelling
Conway's Game of Life
Cellular automaton, cell-state transitions
modelly/examples/basic/conways_game_of_life
Virus on Network
SIR epidemic on a contact network
modelly/examples/basic/virus_on_network
Boid Flockers
Continuous space, alignment and cohesion
modelly/examples/basic/boid_flockers
Wolf Sheep
Predator and prey ecology on a grid
modelly/examples/advanced/wolf_sheep
Sugarscape G1MT
Resource harvesting, trade and growth
modelly/examples/advanced/sugarscape_g1mt
Epstein Civil Violence
Regime shifts from agent state
modelly/examples/advanced/epstein_civil_violence
Prisoner's Dilemma
Pairwise strategic interaction
modelly/examples/advanced/pd_grid
Alliance Formation
Network structure and group formation
modelly/examples/advanced/alliance_formation
The zoo adds 18 research models with validation tests (age-structured SEIR, Bass diffusion,
Schelling on real census tracts, traffic on OpenStreetMap streets, a hospital-capacity
epidemic): python -m modelly.zoo list, documented in docs/zoo.
Run one:
solara run modelly/examples/basic/boltzmann_wealth_model/app.py # browser UI
modelly export-web modelly.zoo.forest_fire.model:ForestFire --out site/ # the same, as a static site
docs/apis/: agents, agent sets, columns, model, space, time, data, migrate
Changelog
CHANGELOG.md: what each release added, changed and fixed
The tutorials are executable: open them locally, in Colab, or through Binder (links at the top of
each notebook).
Development
git clone https://github.com/RemiPelloux/Modelly.git && cd Modelly
pip install -e ".[dev]"
bash scripts/ci-local.sh # lint, format, strict types, tests, size audit: the local gate
bash scripts/release-checks.sh # before a release: MPI, SLURM, bundles, Pyodide, browsers, docs, bench
bash scripts/ci-local.sh --list # stage names, run a subset with: ci-local.sh lint test
python -m modelly.dev gate # the same gate without bash: Windows, macOS and Linux
bash scripts/build-native.sh # compile modelly/_native in place; MODELLY_PURE_PYTHON=1 forces the Python twins
The coverage badge at the top of this page is produced by that gate: the test stage measures
coverage and rewrites docs/images/badges/coverage.svg, so commit the badge with your change.
Hosted CI runs only two workflows: the Release workflow builds the wheels for Linux, macOS and
Windows on a tag and publishes to PyPI, and the docs workflow publishes the site; every other
check runs on the maintainer's machine before a release, on Linux x86-64.
Code discipline is written down in pelloux-guidelines.md: small files,
short functions, surgical changes, conventional commits. scripts/audit-pelloux.sh enforces the
size limits against pelloux-baseline.json; legacy oversized files are listed there and may shrink
but never grow. The repository layout and how the brand assets are generated are in
CONTRIBUTING.md.
Contributing
Issues, ideas and pull requests are welcome on the
issue tracker. If you are adding a feature, opening
a ticket first is the fastest route: it keeps the patch small and reviewable.
Everything you need is in CONTRIBUTING.md: local setup, tests, the lint and
format commands the gate runs, docs, and how a pull request is reviewed. By taking part you agree to
our Code of Conduct.
Citing
If Modelly contributes to a publication, cite it with the metadata in CITATION.cff
(GitHub shows a "Cite this repository" button that formats it for you). The paper in
paper/ describes release 1.4.2, with every number traced to a file in this repository.
License
Modelly is released under the Apache License 2.0. Third-party attribution is recorded in
NOTICE.
Modelly: build the system, run the world, watch what emerges.