v2.2.0
Highlights
The 2.2.0 release of the Mesa library introduces several updates and new features for managing and scheduling agents and modelling the environment, along with an experimental release policy aimed at enhancing development speed and community feedback. Below are key highlights of the new (experimental) features in this release. Mesa 2.2.0 supports Python 3.9+.
Despite the minor version number, this is one of our biggest releases yet.
Experimental feature policy (discussion #1909)
This release introduces an experimental feature policy aimed at accelerating development and gathering community feedback. Features like #1890, #1898, and #1916 are marked as experimental under this policy.
Policy overview:
- Experimental features can be added or changed in any release, even patch releases.
- They don’t need a diligent review for every change, allowing for quicker development cycles.
- Community feedback is encouraged through discussion threads.
Native support for multiple Agent types (PR #1894)
This update introduces a agents
variable to the Mesa Model
class, offering a first step in supporting multiple agent types as first class citizens. Each Model
is now initialized with an self.agents
variable (an AgentSet
) in which all the agents are tracked. You can now always ask which agents are in the model with model.agents
. It's the foundation which will allow us to solve problems with scheduling, data collection and visualisation of multiple agent types in the future.
🧪 AgentSet class (PR #1916)
The new AgentSet
class encapsulates and manages collections of agents, streamlining the process of selecting, sorting, and applying actions to groups of agents.
Key features:
- Flexible and efficient agent management and manipulation.
- Methods like
select
,shuffle
,sort
, anddo
for intuitive operations.
Example:
# Applying a method to each agent
model.agents.do('step')
# Filtering and shuffling agents
shuffled_agents = model.agents.select(lambda agent: agent.attribute > threshold).shuffle()
The AgentSet is an experimental feature. We would love feedback on it in #1919.
🧪 PropertyLayer and _PropertyGrid (PR #1898)
The introduction of PropertyLayer
and the extension of SingleGrid
and MultiGrid
classes to support cell properties mark a significant enhancement in Mesa's environmental modeling capabilities. It allows to add different layers of variables to grids, that can be used to represent spatial environmental properties, such as elevation, pollution, flood levels or foliage.
Key features:
- Efficient management of environmental properties like terrain types and resources.
- Dynamic interaction between agents and their environment.
- Fast modification and selection of cells based on one or multiple properties
Example:
from mesa.space import SingleGrid, PropertyLayer
grid = SingleGrid(10, 10, False)
property_layer = PropertyLayer("elevation", 10, 10, default_value=0)
grid.add_property_layer(property_layer)
# Modify multiple cells values
grid.properties["elevation"].modify_cells(np.multiply, 2)
# Select cells that have an elevation of at least 50
high_elevation_cells = grid.properties["elevation"].select_cells(condition=lambda x: x > 50)
The PropertyLayer is an experimental feature. We would love feedback on it in #1932.
🧪 DiscreteEventScheduler (PR #1890)
The DiscreteEventScheduler
is an innovative addition to the Mesa time module, tailored for discrete event simulations. This scheduler advances simulations based on specific event timings rather than regular intervals, providing more flexibility in modeling complex systems.
Key Features:
- Efficient handling of events scheduled for specific simulation times.
- Randomized execution order for events scheduled at the same time.
The DiscreteEventScheduler is an experimental feature. We would love feedback on it in #1923.
What's Changed
🧪 Experimental features
- Native support for multiple agent types by @EwoutH in #1894
- space: Implement PropertyLayer and _PropertyGrid by @EwoutH in #1898
- Add DiscreteEventScheduler by @EwoutH in #1890
🎉 New features added
🛠 Enhancements made
- Reimplement schedulers to use AgentSet by @quaquel in #1926
- space: Let move_agent choose from multiple positions by @EwoutH in #1920
🐛 Bugs fixed
- Work around for initializing model._agent by @quaquel in #1928
- Honor disabled space drawer option when rendering in the browser by @rlskoeser in #1907
📜 Documentation improvements
- Document empties property by @EwoutH in #1888
- docs: Fix README.md inline code formatting by @rht in #1887
🔧 Maintenance
- ci: Speed up pip install by caching deps install output by @rht in #1885
- Create release.yml file for automatic release notes generation by @EwoutH in #1925
- Drop support for Python 3.8 by @rht in #1756
New Contributors
Full Changelog: v2.1.5...v2.2.0