Mesa 4 goals #2972
Replies: 10 comments 69 replies
-
|
I broadly agree with these ideas with a few caveats.
|
Beta Was this translation helpful? Give feedback.
-
TimeA thread to discuss time. In my vision, there is a single universal truth of time. That's kept in the model in
One complication: So many stuff is build around |
Beta Was this translation helpful? Give feedback.
-
Removing
|
Beta Was this translation helpful? Give feedback.
-
PerformanceThere have been previous discussions on making Mesa more performant. I believe that as part of the move to Mesa 4.0, we should conduct extensive profiling and testing to determine the overhead of the Mesa framework itself, while also exploring ways to reduce it. To be clear: in any non-trivial ABM in Python, the user-written code is highly likely to dominate the runtime. Even in our example models, this is true. For example, I have been running some tests on Schelling. Most of the runtime is in Critical here is the word "reasonably". Two options have been previously discussed: using Cython and migrating parts of the codebase to Rust. I am open to exploring both. However, either will have profound ramifications: we need to completely overhaul the building and distribution if we include compiled code. Moreover, although I have used Cython and understand basic Rust, I am not a fluent developer in Cython, and the steep learning curve of Rust has so far been an obstacle, as I simply don't have the time for it. So, there is a skill issue on the maintainer side that also needs to be considered. |
Beta Was this translation helpful? Give feedback.
-
Mesa exceptionsFor Mesa 4.0, it might also be good to make a decision on custom Mesa exceptions. Currently, we heavily rely on the various built-in exceptions or generic Exceptions with more informative messages. However, I don't know the best practice in python for how to proceed on this. |
Beta Was this translation helpful? Give feedback.
-
Keyword-only argumentsWe could consider using keyword-only arguments (using the While it's can be perceived a bit defensive, it does make things nicely explicit and makes it one obvious way to do things. Methods with several parameters or where the order isn't obvious are natural candidates. Of course we have to find some balance here. See PEP 3102. |
Beta Was this translation helpful? Give feedback.
-
Mesa signals#2291 added experimental support for signals to Mesa. However, at present, they are not part of the core functionality. For Mesa 4, I would like to make them a core part of Mesa that users can hook into. To be clear: I don't advocate shifting Mesa to a fully reactive programming style. Rather, signals are simply another convenient mechanism available to users. It will always be up to the user to decide whether to use it and profile their models to see the performance implications. Why? Signals are very convenient for creating loose coupling between model parts. It also makes it easier to use reactive programming patterns where appropriate. Currently, it is very difficult to implement data collection on a subset of agents whose membership varies over runtime. Likewise, parts of the model may be relevant only if certain conditions are met. At present, this condition must be checked at every model step. Signals might make it easier (and potentially faster) to implement these types of things. What signals to add? At a minimum, I would like to add signals to Additional suggestions for places to add signals are welcome. |
Beta Was this translation helpful? Give feedback.
-
Proposal: Add Real-World Signal Performance BenchmarksProblemMesa Signals (#3166) is becoming core to Mesa 4.0 (behavioral framework, data collection #3145, stopping conditions #2921), but we lack benchmarks showing signal overhead in real simulation contexts. Current gap:
Can't answer: "What's the performance cost of using signals in my model?" Proposed SolutionAdd 3 benchmark scenarios to existing benchmark suite: 1. Signal Overhead Benchmark
2. Signal Density Impact
3. Signal vs. Polling
Expected Outcomes
Implementation
|
Beta Was this translation helpful? Give feedback.
-
|
Hi @quaquel ! I saw your note about needing a dynamic agent model for ContinuousSpace benchmarking. I have started building a Predator-Prey model to address this. I've got the Mesa 4.0 continuous space and random movement wired up, and I am working on adding the dynamic birth/death/energy mechanics next. I will open a PR in mesa-examples once it's fully ready! |
Beta Was this translation helpful? Give feedback.
-
Formalizing design proposal processMesa Enhancement Proposals - MEPs I feel like the annoying person who constantly brings this up, but also has been annoyed at times by changes that were unexpected or designs I would have done differently, but didn't have the opportunity to chime in. While everyone doesn't need to track everything, there is no good way for people to keep a future pulse on Mesa. I think we need some more formality around changes. It is difficult to track and discuss when the final design is being held in 1 or 2 heads and is being linked across 1 PR, 1 comment thread in a discussion, and an issue. There is no cleanly structured way to move an idea from "discussion" to "accepted design". Mesa has experienced a lot of growth over the year -- people need predictability. Mesa 4 seems like a good time to do it. Looking at this thread alone: signals, the Scenario class, data collection backends, keyword-only arguments, and the module system have all received conceptual approval but it is not clear what was decided and why and alternatives -- that might be someone's head and it gets put into a PR, but by the time a PR is submitted, it feels like the element is "done". Furthermore, six months from now, a new contributor (or even a current maintainer) has no authoritative place to look to understand why something is the way it is. ProposalPython's PEP process process does this well. Borrowing from it, but scaled down... Structure of a Mesa Enhancement Proposal (MEP)
Process:
Mesa 4 involves multiple interconnected breaking changes: the time model, signals, data collection, spatial abstractions, the module system. These need to be designed in harmony. Proposals will have cross-cutting implications, but each element can discussed independently and in context to each other. This also gives a clear map of what to code to, so by the time it is a fully submitted, coded up PR there is no discussion conceptually. I don't want overhead. No one wants that. I don't see this as that. Trivial changes (bug fixes, docs, small additions) don't need proposals. The requirement should be on something like: does this change a public API or introduce a new abstraction? If yes, a proposal. If no, a normal PR. Extra benefits: |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Update 2026-01-14: We're starting to move towards Mesa 4 development. See #3132 as tracking issue.
As we start development towards Mesa 4.0 soon, we have an opportunity to address fundamental challenges in agent-based modeling from a clean slate design. In this discussion I want to start aligning our overarching goals and priorities, focusing on what users should be able to do.
I would like to invite the community to help shape these priorities and identify what matters most for the future of Mesa.
Personally, I would propose focussing Mesa 4.0 on two areas: Fundamentals and Extendibility.
Fundamentals
Time & Space in order
Users should be able to model temporal dynamics and spatial relationships as naturally as they think about them. Today, Mesa requires users to choose between fixed time steps and complex simulator objects, while spatial modeling involves navigating multiple overlapping abstractions. In Mesa 4, a researcher studying disease spread should be able to schedule events at arbitrary times (an infection after 3.7 days), have agents perform tasks with explicit durations (a commute that takes 45 minutes), and seamlessly mix regular stepping with event-driven behavior—all without managing separate simulator objects or worrying about time unit mismatches.
Similarly, when modeling movement, users should be able to work with a unified coordinate system where agents have positions, spaces have properties, and everything relates through clear geometric relationships. Whether modeling flocking birds in continuous 2D space, pedestrians navigating urban networks, or cells on a grid, the conceptual model should be consistent and the transitions between representations should be straightforward.
Cleansheet Experimentation and Data Collection
Users should be able to design sophisticated experiments and collect data without fighting Mesa's infrastructure. A researcher running parameter sweeps on an HPC cluster should have the same simple experience as a student doing local replications on their laptop—just with appropriate scaling. Users should be able to specify complex experimental designs (Latin hypercube sampling, adaptive parameter exploration), execute them across diverse computing environments (from laptops to cloud platforms), and have their data land in formats that their analysis tools already understand (Parquet, Zarr, Xarray). The barrier between "running my model" and "analyzing my results" should vanish: data collection should integrate naturally with modern Python analytics tools, support heterogeneous agent types and spatial properties without manual wrangling, and provide clean provenance tracking for reproducibility. Whether someone needs a quick parameter sweep or a systematic exploration of thousands of scenarios, the path should be clear and the tools should get out of the way.
Stable, Performant Visualization
Users should be able to visualize their models reliably without the visualization system being a source of uncertainty. In Mesa 4, visualization should be a stable, well-documented tool that users can depend on across releases. Someone building a model for policy presentations should be confident that their visualizations will work the same way six months later, that performance will be acceptable for their model scale, and that they can customize what they need without diving into internals. The focus should shift from adding new experimental features to ensuring what exists works consistently, performs well, and has clear documentation. Users should spend their time thinking about what insights to show from their model, not debugging visualization quirks or working around performance issues.
Extendable
Powerful Agent Behavior
Users should be able to model sophisticated agent behavior without implementing everything from scratch. A modeler studying cooperation should be able to give agents competing goals, time-consuming tasks that can be interrupted, and continuous states that evolve based on environment and actions—using composable building blocks rather than ad-hoc conditional logic. Agents in an evacuation model should be able to start moving toward an exit, reassess when conditions change, prioritize helping others over escaping, and track continuous stress levels that affect their decisions. Users modeling hunter-gatherers should express that hunting takes hours, can be abandoned if threats appear, and success depends on continuously updated energy states—without manually tracking dozens of counters and flags. The infrastructure should make modeling human-like reasoning and decision-making natural rather than forcing everything into single-step reactive rules.
ML/RL/DL/AI Integration
Users should be able to integrate modern AI and machine learning approaches into their agent-based models without impedance mismatches. A researcher studying learning in agent populations should be able to calibrate model parameters against real-world data using simulation-based inference, train agents with reinforcement learning, or have agents make decisions via language models—with Mesa providing the scaffolding rather than forcing them to bridge incompatible abstractions. Someone building a policy model should be able to specify prior distributions over micro-parameters, run inference to identify parameter sets consistent with macro observations, and quantify how much variance their agent-based hypothesis actually explains. Users experimenting with LLM-driven agents should be able to manage context windows, enforce structured outputs, and integrate local or cloud models without building custom orchestration. The boundary between Mesa models and the ML ecosystem should be clean: models should be differentiable where possible, inference tools should connect naturally, and the framework should support both traditional parameter calibration and modern learned behaviors.
Extensibility Through Modules
Users should be able to build on and share sophisticated modeling components without either reinventing the wheel or depending on fragile code. A researcher implementing a new negotiation protocol should be able to package it as a reusable module that others can install, understand, and compose with their own models. Someone studying epidemiology should be able to draw on a library of disease transmission models, economic primitives, or movement behaviors—each maintained by domain experts, with clear documentation and tested examples—rather than copying code from papers or reimplementing from descriptions. The Mesa ecosystem should make high-quality components discoverable, provide clear expectations about compatibility and maintenance, and create paths for community contributions to move from experiments to stable, widely-used infrastructure. Users should be able to focus on their research questions, confident that the behavioral building blocks they need are either already available or can be contributed back to benefit others.
These goals might be a starting point for discussion. Pursuing all of them simultaneously probably isn't feasible, so we need your input: Which of these matters most for your work? What are we missing? What tradeoffs should we consider? Please share your thoughts, use cases, and priorities in the discussions linked above and here in this thread.
Beta Was this translation helpful? Give feedback.
All reactions