Multi-paradigm modelling & analysis of complex systems
Marco Galli — ORCID 0009-0000-2569-1168 — 2026
PolyModel is an environment for building and analysing models of complex systems, inspired by the method in Hiroki Sayama's Introduction to the Modeling and Analysis of Complex Systems. Six paradigms live in one application, share one model contract, and are served by the same analysis tools:
| Paradigm | What the state is | Examples included |
|---|---|---|
| Dynamical systems | a vector | logistic map, Lotka-Volterra, normal forms, Lorenz |
| Cellular automata | a grid of discrete cells | Game of Life, majority vote, forest fire, Wolfram's 256 1-D rules |
| Networks | values on graph nodes | SIR epidemic, opinion dynamics, Kuramoto |
| Agent-based (reactive) | agents with rules | Schelling, boids, predator-prey |
| Agent-based (neural) | agents with learned policies | PPO foraging alongside scripted agents |
| Continuous fields | a field on a lattice | diffusion, Turing instability, Gray-Scott |
Comparable tools are single-paradigm simulation engines. PolyModel differs on two axes:
- Analysis is first class, not an export step. Fixed points and their stability (numerical Jacobian, eigenvalues), bifurcation diagrams, Morris and Sobol sensitivity, Lyapunov exponents, network structure and percolation, and the dispersion relation of a field are all built in.
- Deep-RL agents are native. Learned policies run in the same world as rule-based agents, batched so a population of thousands costs one forward pass.
It is not the fastest simulator. It does not beat Golly at pure Game of Life, nor Repast HPC at massive agent counts. Those are specialised and mature; this is a modelling-and-analysis environment that happens to run reasonably fast.
Step-by-step instructions for every platform are in INSTALL.md — start there if you have not used Docker before.
The short version, from the source folder:
docker compose up -d --buildThen open http://localhost:1060. The interface is bilingual (English / Italian) with a light and a dark theme.
Or download the ready-made image from the latest release and skip the build entirely:
docker load -i polymodel-1.0.0.tar.gz
docker run -d -p 1060:1060 --name polymodel polymodel:1.0.0pip install -r requirements.txt
cd web && npm install && npm run build && cd ..
uvicorn polymodel.api.app:app --host 127.0.0.1 --port 1060For machines without internet access, build the image once on a connected machine and ship it as a file:
./scripts/build-bundle.sh # or scripts\build-bundle.ps1 on WindowsThis writes dist/polymodel-<version>.tar.gz plus a compose file. On the target
machine:
docker load -i polymodel-<version>.tar.gz
docker compose up -dThese are not style preferences; they shaped the code and the tests.
Every claim is computed, and pinned to something known. The teaching sections are anchored to closed-form results and the test suite checks them:
| Claim | Reference value | Measured |
|---|---|---|
| Lyapunov exponent, logistic map at r = 4 | ln 2 = 0.693147 | 0.693157 |
| Lyapunov exponent, Lorenz system | ≈ 0.906 | 0.908 |
| Feigenbaum constant from the cascade | 4.669202 | 4.6690 |
| Hopf limit cycle radius | √r | exact to 4 decimals |
| Rule 90 space-time diagram | Pascal's triangle mod 2 | identical, cell by cell |
| Diffusing Gaussian variance | σ₀² + 2Dt | within 0.2% |
| Turing onset wavenumber | (Dv·a11 + Du·a22)/(2·Du·Dv) | exact to 1e-9 |
| Numba boids kernel | pure-Python reference | identical to 1e-12 |
Limits are declared, not hidden. Feasibility envelopes are reported at runtime:
asynchronous cellular updating on a large grid, O(n²) flocking costs, neural
population sizes, graphs too large to draw, and the explicit-integrator stability
limit dt ≤ dx²/(4D) which the field runner enforces rather than letting a diverged
computation look like structure.
Learned controllers are never shown alone. Wherever a policy is trained, the result is measured on identical seeded episodes against a scripted or analytic reference, and both are displayed. On the chaos-control task the exact law reaches 1.000 and the learned policy 0.041 — reported as it stands.
Where a method fails, it says so. The automatic Wolfram classifier disagrees with the literature on rule 110; the panel shows both classifications and explains why no simple statistic detects class 4. The thresholds were not tuned until the answer looked right.
polymodel/
├── core/ model contract, runners (map/ODE, cellular, network, agent, field), RNG
├── spec/ declarative model schema, safe expression evaluator, blocks, codegen
├── backends/ one execution engine per paradigm
├── analysis/ stability, bifurcation, sensitivity, Lyapunov, networks, dispersion
├── models/ the example model library
├── didactics/ function gallery and the guided lessons (book Parts II and III)
├── experiments/ headless entry points for long runs
└── api/ FastAPI application, registry, services
web/ React interface (bilingual, canvas rendering, block editor)
tests/ 190 tests
- Every run is determined by its seed; the seed is part of every request.
- Models built in the block editor are stored as JSON specifications under
user_models/and can be exported as standalone, readable Python that carries its own specification and can be reopened in the editor. - Batch results (bifurcation sweeps, sensitivity indices, percolation curves) are
written to
results/as CSV and are downloadable from the interface. - Trained policies are saved to
results/policy_*.pt.
Interactive training and heavy sweeps are deliberately capped so the interface stays responsive. For serious runs use the headless entry points:
python -m polymodel.experiments.slice6_neural_demo 200
python -m polymodel.experiments.slice5_agents_demo
python -m polymodel.experiments.slice2_bifurcation_demoThe container is roughly 1.7 GB. Most of it is the scientific stack itself: torch ≈ 750 MB, llvmlite ≈ 173 MB, scipy ≈ 109 MB, sympy ≈ 74 MB. The build removes test directories, bytecode caches and the installer, which is all that can honestly be removed; the rest is the price of having deep-RL agents, a JIT compiler and a numerical library in the same image.
python -m pytest -q190 tests, about two minutes. They are the specification: if a number appears in the interface, there is a test pinning it to a reference value.
BSD 3-Clause. You may use, modify and redistribute this freely, including commercially, provided the copyright notice is kept and the author's name is not used to endorse derived products without permission. See LICENSE.
Archived on Zenodo. Two DOIs exist and they are not interchangeable:
- 10.5281/zenodo.21469147 — the concept DOI, always resolving to the latest version. Use it to refer to the software in general.
- 10.5281/zenodo.21469148 — the DOI of version 1.0.0 specifically. Use it in a paper, where a reader must be able to obtain exactly the version you ran.
@software{galli_polymodel_2026,
author = {Galli, Marco},
title = {PolyModel: Multi-paradigm modelling \& analysis of complex systems},
year = {2026},
version = {1.0.0},
publisher = {Zenodo},
doi = {10.5281/zenodo.21469147},
url = {https://github.com/marcogalli72/polymodel},
orcid = {0009-0000-2569-1168}
}Every source file carries the author's name and ORCID in its header.