Mesa 3.0.0a3__tar.gz → 3.0.0a5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of Mesa might be problematic. Click here for more details.

Files changed (152) hide show
  1. {mesa-3.0.0a3 → mesa-3.0.0a5}/.github/ISSUE_TEMPLATE/bug-report.md +2 -1
  2. mesa-3.0.0a5/.github/ISSUE_TEMPLATE/config.yml +5 -0
  3. {mesa-3.0.0a3 → mesa-3.0.0a5}/.github/workflows/build_lint.yml +1 -5
  4. {mesa-3.0.0a3 → mesa-3.0.0a5}/.pre-commit-config.yaml +1 -1
  5. {mesa-3.0.0a3 → mesa-3.0.0a5}/HISTORY.md +99 -0
  6. {mesa-3.0.0a3 → mesa-3.0.0a5}/PKG-INFO +2 -1
  7. mesa-3.0.0a5/benchmarks/BoltzmannWealth/__init__.py +1 -0
  8. {mesa-3.0.0a3 → mesa-3.0.0a5}/benchmarks/BoltzmannWealth/boltzmann_wealth.py +43 -8
  9. mesa-3.0.0a5/benchmarks/Flocking/__init__.py +1 -0
  10. {mesa-3.0.0a3 → mesa-3.0.0a5}/benchmarks/Flocking/flocking.py +20 -29
  11. mesa-3.0.0a5/benchmarks/Schelling/__init__.py +1 -0
  12. {mesa-3.0.0a3 → mesa-3.0.0a5}/benchmarks/Schelling/schelling.py +24 -30
  13. mesa-3.0.0a5/benchmarks/WolfSheep/__init__.py +1 -0
  14. {mesa-3.0.0a3 → mesa-3.0.0a5}/benchmarks/WolfSheep/wolf_sheep.py +39 -39
  15. {mesa-3.0.0a3 → mesa-3.0.0a5}/benchmarks/compare_timings.py +13 -2
  16. {mesa-3.0.0a3 → mesa-3.0.0a5}/benchmarks/configurations.py +2 -0
  17. {mesa-3.0.0a3 → mesa-3.0.0a5}/benchmarks/global_benchmark.py +19 -0
  18. mesa-3.0.0a5/docs/apis/agent.md +8 -0
  19. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/apis/api_main.md +2 -1
  20. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/apis/batchrunner.md +2 -0
  21. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/apis/datacollection.md +2 -0
  22. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/apis/experimental.md +1 -5
  23. mesa-3.0.0a5/docs/apis/model.md +7 -0
  24. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/apis/space.md +2 -0
  25. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/apis/time.md +2 -0
  26. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/conf.py +6 -3
  27. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/index.md +2 -2
  28. mesa-3.0.0a5/docs/migration_guide.md +294 -0
  29. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/overview.md +5 -5
  30. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/tutorials/MoneyModel.py +21 -6
  31. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/tutorials/intro_tutorial.ipynb +31 -31
  32. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/tutorials/visualization_tutorial.ipynb +42 -23
  33. {mesa-3.0.0a3 → mesa-3.0.0a5}/maintenance/fetch_unlabeled_prs.py +2 -1
  34. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/__init__.py +2 -3
  35. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/agent.py +193 -75
  36. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/batchrunner.py +18 -23
  37. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/cookiecutter-mesa/hooks/post_gen_project.py +2 -0
  38. mesa-3.0.0a5/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/__init__.py +1 -0
  39. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/datacollection.py +138 -27
  40. {mesa-3.0.0a3/mesa/visualization → mesa-3.0.0a5/mesa/experimental}/UserParam.py +17 -6
  41. mesa-3.0.0a5/mesa/experimental/__init__.py +7 -0
  42. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/experimental/cell_space/__init__.py +7 -0
  43. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/experimental/cell_space/cell.py +61 -20
  44. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/experimental/cell_space/cell_agent.py +12 -7
  45. mesa-3.0.0a5/mesa/experimental/cell_space/cell_collection.py +118 -0
  46. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/experimental/cell_space/discrete_space.py +16 -5
  47. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/experimental/cell_space/grid.py +19 -8
  48. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/experimental/cell_space/network.py +9 -7
  49. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/experimental/cell_space/voronoi.py +26 -33
  50. {mesa-3.0.0a3/mesa/visualization → mesa-3.0.0a5/mesa/experimental}/components/altair.py +10 -0
  51. {mesa-3.0.0a3/mesa/visualization → mesa-3.0.0a5/mesa/experimental}/components/matplotlib.py +18 -0
  52. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/experimental/devs/__init__.py +2 -0
  53. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/experimental/devs/eventlist.py +36 -15
  54. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/experimental/devs/examples/epstein_civil_violence.py +71 -39
  55. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/experimental/devs/examples/wolf_sheep.py +43 -44
  56. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/experimental/devs/simulator.py +55 -15
  57. {mesa-3.0.0a3/mesa/visualization → mesa-3.0.0a5/mesa/experimental}/solara_viz.py +13 -22
  58. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/main.py +6 -4
  59. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/model.py +64 -61
  60. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/space.py +154 -123
  61. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/time.py +57 -67
  62. mesa-3.0.0a5/mesa/visualization/UserParam.py +69 -0
  63. mesa-3.0.0a5/mesa/visualization/__init__.py +15 -0
  64. mesa-3.0.0a5/mesa/visualization/components/altair.py +88 -0
  65. mesa-3.0.0a5/mesa/visualization/components/matplotlib.py +248 -0
  66. mesa-3.0.0a5/mesa/visualization/solara_viz.py +468 -0
  67. mesa-3.0.0a5/mesa/visualization/utils.py +9 -0
  68. {mesa-3.0.0a3 → mesa-3.0.0a5}/pyproject.toml +4 -0
  69. mesa-3.0.0a5/tests/__init__.py +1 -0
  70. {mesa-3.0.0a3 → mesa-3.0.0a5}/tests/read_requirements.py +1 -0
  71. {mesa-3.0.0a3 → mesa-3.0.0a5}/tests/test_agent.py +232 -35
  72. {mesa-3.0.0a3 → mesa-3.0.0a5}/tests/test_batch_run.py +49 -34
  73. {mesa-3.0.0a3 → mesa-3.0.0a5}/tests/test_cell_space.py +110 -72
  74. mesa-3.0.0a5/tests/test_datacollector.py +387 -0
  75. {mesa-3.0.0a3 → mesa-3.0.0a5}/tests/test_devs.py +6 -0
  76. {mesa-3.0.0a3 → mesa-3.0.0a5}/tests/test_examples.py +7 -5
  77. {mesa-3.0.0a3 → mesa-3.0.0a5}/tests/test_grid.py +38 -88
  78. {mesa-3.0.0a3 → mesa-3.0.0a5}/tests/test_import_namespace.py +7 -2
  79. {mesa-3.0.0a3 → mesa-3.0.0a5}/tests/test_lifespan.py +18 -19
  80. {mesa-3.0.0a3 → mesa-3.0.0a5}/tests/test_model.py +29 -5
  81. {mesa-3.0.0a3 → mesa-3.0.0a5}/tests/test_scaffold.py +4 -5
  82. {mesa-3.0.0a3 → mesa-3.0.0a5}/tests/test_solara_viz.py +33 -52
  83. {mesa-3.0.0a3 → mesa-3.0.0a5}/tests/test_space.py +134 -171
  84. mesa-3.0.0a3/.github/ISSUE_TEMPLATE/asking-help.md +0 -9
  85. mesa-3.0.0a3/benchmarks/BoltzmannWealth/__init__.py +0 -0
  86. mesa-3.0.0a3/benchmarks/Flocking/__init__.py +0 -0
  87. mesa-3.0.0a3/benchmarks/Schelling/__init__.py +0 -0
  88. mesa-3.0.0a3/benchmarks/WolfSheep/__init__.py +0 -0
  89. mesa-3.0.0a3/docs/apis/init.md +0 -11
  90. mesa-3.0.0a3/docs/migration_guide.md +0 -67
  91. mesa-3.0.0a3/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/__init__.py +0 -0
  92. mesa-3.0.0a3/mesa/experimental/__init__.py +0 -3
  93. mesa-3.0.0a3/mesa/experimental/cell_space/cell_collection.py +0 -81
  94. mesa-3.0.0a3/mesa/visualization/__init__.py +0 -3
  95. mesa-3.0.0a3/tests/__init__.py +0 -0
  96. mesa-3.0.0a3/tests/test_datacollector.py +0 -234
  97. mesa-3.0.0a3/tests/test_time.py +0 -342
  98. {mesa-3.0.0a3 → mesa-3.0.0a5}/.codespellignore +0 -0
  99. {mesa-3.0.0a3 → mesa-3.0.0a5}/.coveragerc +0 -0
  100. {mesa-3.0.0a3 → mesa-3.0.0a5}/.github/ISSUE_TEMPLATE/feature-request.md +0 -0
  101. {mesa-3.0.0a3 → mesa-3.0.0a5}/.github/PULL_REQUEST_TEMPLATE/bug.md +0 -0
  102. {mesa-3.0.0a3 → mesa-3.0.0a5}/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -0
  103. {mesa-3.0.0a3 → mesa-3.0.0a5}/.github/dependabot.yml +0 -0
  104. {mesa-3.0.0a3 → mesa-3.0.0a5}/.github/release.yml +0 -0
  105. {mesa-3.0.0a3 → mesa-3.0.0a5}/.github/workflows/benchmarks.yml +0 -0
  106. {mesa-3.0.0a3 → mesa-3.0.0a5}/.github/workflows/release.yml +0 -0
  107. {mesa-3.0.0a3 → mesa-3.0.0a5}/.gitignore +0 -0
  108. {mesa-3.0.0a3 → mesa-3.0.0a5}/.readthedocs.yml +0 -0
  109. {mesa-3.0.0a3 → mesa-3.0.0a5}/CITATION.bib +0 -0
  110. {mesa-3.0.0a3 → mesa-3.0.0a5}/CODE_OF_CONDUCT.md +0 -0
  111. {mesa-3.0.0a3 → mesa-3.0.0a5}/CONTRIBUTING.md +0 -0
  112. {mesa-3.0.0a3 → mesa-3.0.0a5}/Dockerfile +0 -0
  113. {mesa-3.0.0a3 → mesa-3.0.0a5}/LICENSE +0 -0
  114. {mesa-3.0.0a3 → mesa-3.0.0a5}/README.md +0 -0
  115. {mesa-3.0.0a3 → mesa-3.0.0a5}/codecov.yaml +0 -0
  116. {mesa-3.0.0a3 → mesa-3.0.0a5}/docker-compose.yml +0 -0
  117. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/Makefile +0 -0
  118. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/README.md +0 -0
  119. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/apis/visualization.md +0 -0
  120. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/best-practices.md +0 -0
  121. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/howto.md +0 -0
  122. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/Mesa_Screenshot.png +0 -0
  123. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/mesa_logo.ico +0 -0
  124. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/mesa_logo.png +0 -0
  125. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/tutorial/br_ginis.png +0 -0
  126. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/tutorial/dc_endwealth.png +0 -0
  127. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/tutorial/dc_gini.png +0 -0
  128. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/tutorial/dc_oneagent.png +0 -0
  129. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/tutorial/first_hist.png +0 -0
  130. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/tutorial/multirun_hist.png +0 -0
  131. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/tutorial/numpy_grid.png +0 -0
  132. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/tutorial/viz_chart.png +0 -0
  133. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/tutorial/viz_empty.png +0 -0
  134. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/tutorial/viz_greycircles.png +0 -0
  135. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/tutorial/viz_histogram.png +0 -0
  136. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/images/tutorial/viz_redcircles.png +0 -0
  137. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/make.bat +0 -0
  138. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/mesa.md +0 -0
  139. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/packages.md +0 -0
  140. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/tutorials/files/viz_chart.png +0 -0
  141. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/tutorials/files/viz_empty.png +0 -0
  142. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/tutorials/files/viz_greycircles.png +0 -0
  143. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/tutorials/files/viz_histogram.png +0 -0
  144. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/tutorials/files/viz_redcircles.png +0 -0
  145. {mesa-3.0.0a3 → mesa-3.0.0a5}/docs/tutorials/files/viz_slider.png +0 -0
  146. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/cookiecutter-mesa/cookiecutter.json +0 -0
  147. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/README.md +0 -0
  148. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/app.pytemplate +0 -0
  149. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/setup.pytemplate +0 -0
  150. {mesa-3.0.0a3 → mesa-3.0.0a5}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/model.pytemplate +0 -0
  151. {mesa-3.0.0a3 → mesa-3.0.0a5}/mypy.ini +0 -0
  152. {mesa-3.0.0a3 → mesa-3.0.0a5}/tests/test_end_to_end_viz.sh +0 -0
@@ -11,7 +11,8 @@ about: Let us know if something is broken on Mesa
11
11
  <!-- A clear and concise description of what you expected to happen -->
12
12
 
13
13
  **To Reproduce**
14
- <!-- Steps to reproduce the bug, or a link to a project where the bug is visible -->
14
+ <!-- Steps to reproduce the bug, or a link to a project where the bug is visible
15
+ Include a Minimal reproducible example: https://stackoverflow.com/help/minimal-reproducible-example -->
15
16
 
16
17
  **Additional context**
17
18
  <!--
@@ -0,0 +1,5 @@
1
+ blank_issues_enabled: true
2
+ contact_links:
3
+ - name: Questions, ideas, showcases and more
4
+ url: https://github.com/projectmesa/mesa/discussions
5
+ about: Discuss Mesa, ask questions, share ideas, and showcase your projects
@@ -53,12 +53,8 @@ jobs:
53
53
  cache: 'pip'
54
54
  - name: Install uv
55
55
  run: pip install uv
56
- - name: Install Mesa with uv pip
56
+ - name: Install Mesa and dependencies
57
57
  run: uv pip install --system .[dev]
58
- if: matrix.python-version != '3.13'
59
- - name: Install Mesa with pip
60
- run: pip install .[dev]
61
- if: matrix.python-version == '3.13'
62
58
  - name: Test with pytest
63
59
  run: pytest --durations=10 --cov=mesa tests/ --cov-report=xml
64
60
  - if: matrix.os == 'ubuntu'
@@ -4,7 +4,7 @@ ci:
4
4
  repos:
5
5
  - repo: https://github.com/astral-sh/ruff-pre-commit
6
6
  # Ruff version.
7
- rev: v0.5.6
7
+ rev: v0.6.3
8
8
  hooks:
9
9
  # Run the linter.
10
10
  - id: ruff
@@ -1,6 +1,105 @@
1
1
  ---
2
2
  title: Release History
3
3
  ---
4
+ # 3.0.0a5 (2024-09-21)
5
+ ## Highlights
6
+ Mesa v3.0 alpha 5 release contains many quality of life updates, a big new feature for the DataCollector and a major deprecation.
7
+
8
+ The entire `mesa.time` module, including all schedulers, has been deprecated ([#2306](https://github.com/projectmesa/mesa/pull/2306)). Users are encouraged to transition to AgentSet functionality for more flexible and explicit agent activation patterns. Check the [migration guide](https://mesa.readthedocs.io/en/latest/migration_guide.html#time-and-schedulers) on how to upgrade.
9
+
10
+ The DataCollector now supports collecting data from specific Agent subclasses using the new `agenttype_reporters` parameter ([#2300](https://github.com/projectmesa/mesa/pull/2300)). This allows collecting different metrics for different agent types. For example:
11
+
12
+ ```python
13
+ self.datacollector = DataCollector(
14
+ agenttype_reporters={
15
+ Wolf: {"sheep_eaten": "sheep_eaten"},
16
+ Sheep: {"wool": "wool_amount"}
17
+ }
18
+ )
19
+ ```
20
+
21
+ Furthermore, a new `shuffle_do()` method for AgentSets provides a faster way to perform `shuffle().do()` ([#2283](https://github.com/projectmesa/mesa/pull/2283)). The GroupBy class gained `count()` and `agg()` methods to count the number of agents in groups and aggregate variables of them ([#2290](https://github.com/projectmesa/mesa/pull/2290)). The `CellCollection.select` method was updated to use `at_most` instead of `n`, aligning with the AgentSet API ([#2307](https://github.com/projectmesa/mesa/pull/2307)). Additionally, the Cell class now features a dedicated `neighborhood` property for direct neighbors (default radius=1) and a `get_neighborhood` method for larger radii ([#2309](https://github.com/projectmesa/mesa/pull/2309)).
22
+
23
+ Finally, SolaraViz received updates improving its interface and performance ([#2299](https://github.com/projectmesa/mesa/pull/2299), [#2304](https://github.com/projectmesa/mesa/pull/2304)). Cell connections in grids and networks are now public and named for more intuitive agent movements ([#2296](https://github.com/projectmesa/mesa/pull/2296)). The Model class initialization process was simplified by moving random seed and random object creation to `__init__` ([#1940](https://github.com/projectmesa/mesa/pull/1940)). Documentation has been extensively updated, including enforcing Google docstrings ([#2294](https://github.com/projectmesa/mesa/pull/2294)) and reorganizing the API documentation ([#2298](https://github.com/projectmesa/mesa/pull/2298)) for better clarity and navigation.
24
+
25
+ While the Mesa 3.0 timeline is still being discussed, we're aiming at the first Mesa 3.0 beta in October followed by a stable release in November. Testing new features and sharing feedback is appreciated!
26
+
27
+ ## What's Changed
28
+ ### 🎉 New features added
29
+ * GroupBy: Add `count` and `agg` methods by @EwoutH in https://github.com/projectmesa/mesa/pull/2290
30
+ * datacollector: Allow collecting data from Agent (sub)classes by @EwoutH in https://github.com/projectmesa/mesa/pull/2300
31
+ * Add optimized shuffle_do() method to AgentSet by @EwoutH in https://github.com/projectmesa/mesa/pull/2283
32
+ ### 🛠 Enhancements made
33
+ * Make cell connections public and named by @Corvince in https://github.com/projectmesa/mesa/pull/2296
34
+ * SolaraViz Updates by @Corvince in https://github.com/projectmesa/mesa/pull/2299
35
+ * Solara viz: use_task for non-threaded continuous play by @Corvince in https://github.com/projectmesa/mesa/pull/2304
36
+ * Update to CellCollection.select by @quaquel in https://github.com/projectmesa/mesa/pull/2307
37
+ ### 📜 Documentation improvements
38
+ * Enforce google docstrings by @quaquel in https://github.com/projectmesa/mesa/pull/2294
39
+ * Api docs by @quaquel in https://github.com/projectmesa/mesa/pull/2298
40
+ * update migration guide to describe solaraviz updates by @Corvince in https://github.com/projectmesa/mesa/pull/2297
41
+ * Migration Guide: Add Model initialization requirement and automatic Agent.unique_id assignment by @EwoutH in https://github.com/projectmesa/mesa/pull/2302
42
+ * Deprecate Time module and all its Schedulers by @EwoutH in https://github.com/projectmesa/mesa/pull/2306
43
+ ### 🔧 Maintenance
44
+ * make typing behavior of AgentSet.get explicit by @quaquel in https://github.com/projectmesa/mesa/pull/2293
45
+ * model: Move random seed and random to __init__ by @rht in https://github.com/projectmesa/mesa/pull/1940
46
+ * Remove schedulers from benchmark models. by @quaquel in https://github.com/projectmesa/mesa/pull/2308
47
+
48
+ **Full Changelog**: https://github.com/projectmesa/mesa/compare/v3.0.0a4...v3.0.0a5
49
+
50
+ # 3.0.0a4 (2024-09-09)
51
+ ## Highlights
52
+ Mesa 3.0.0a4 contains two major breaking changes:
53
+ 1. The Agent's `unique_id` is now automatically assigned, so doesn't need to be passed to the Agent class anymore. In a subclassed custom Agent, like normally used, this now looks like this:
54
+ ```diff
55
+ class Wolf(Agent):
56
+ - def __init__(self, unique_id, model, energy=None):
57
+ + def __init__(self, model, energy=None):
58
+ # When initializing the super class (Agent), passing unique_id isn't needed anymore
59
+ - super().__init__(unique_id, model)
60
+ + super().__init__(model)
61
+
62
+ - wolf = Wolf(unique_id, model)
63
+ + wolf = Wolf(model)
64
+ ```
65
+ Example models were updated in [mesa-examples#194](https://github.com/projectmesa/mesa-examples/pull/194), which shows more examples on how to update existing models.
66
+
67
+ 2. Our visualisation API is being overhauled, to be more flexible and powerful. For more details, see [#2278](https://github.com/projectmesa/mesa/pull/2278).
68
+ - An initial update to the tutorial was made in [#2289](https://github.com/projectmesa/mesa/pull/2289) and is [available here](https://mesa.readthedocs.io/en/latest/tutorials/visualization_tutorial.html).
69
+ - An initial example model was updated in [mesa-examples#195](https://github.com/projectmesa/mesa-examples/pull/195), and more examples will be updated in [mesa-examples#195](https://github.com/projectmesa/mesa-examples/pull/193).
70
+ - The old SolaraViz API is still available at `mesa.experimental`, but might be removed in future releases.
71
+
72
+ Furthermore, the AgentSet has a new `agg` method to quickly get an aggerate value (for example `min_energy = model.agents.agg("energy", min)`) ([#2266](https://github.com/projectmesa/mesa/pull/2266)), The Model `get_agents_of_type` function is replaced by directly exposing the `agents_by_type` property (which can be accessed as a dict) ([#2267](https://github.com/projectmesa/mesa/pull/2267), [mesa-examples#190](https://github.com/projectmesa/mesa-examples/pull/190)) and the AgentSet get() methods can now handle missing values by replacing it with a default value ([#2279](https://github.com/projectmesa/mesa/pull/2279)).
73
+
74
+ Finally, it fixes a bug in which the Grid's `move_agent_to_one_of` method with `selection="closest"` selected a location deterministically, instead of randomly ([#2118](https://github.com/projectmesa/mesa/pull/2118)).
75
+
76
+ ## What's Changed
77
+ ### ⚠️ Breaking changes
78
+ * move solara_viz back to experimental by @Corvince in https://github.com/projectmesa/mesa/pull/2278
79
+ * track unique_id automatically by @quaquel in https://github.com/projectmesa/mesa/pull/2260
80
+ ### 🎉 New features added
81
+ * AgentSet: Add `agg` method by @EwoutH in https://github.com/projectmesa/mesa/pull/2266
82
+ * Implement new SolaraViz API by @Corvince in https://github.com/projectmesa/mesa/pull/2263
83
+ ### 🛠 Enhancements made
84
+ * Model: Replace `get_agents_of_type` method with `agents_by_type` property by @EwoutH in https://github.com/projectmesa/mesa/pull/2267
85
+ * add default SolaraViz by @Corvince in https://github.com/projectmesa/mesa/pull/2280
86
+ * Simplify ModelController by @Corvince in https://github.com/projectmesa/mesa/pull/2282
87
+ * Add default values and missing value handling to `agentset.get` by @quaquel in https://github.com/projectmesa/mesa/pull/2279
88
+ ### 🐛 Bugs fixed
89
+ * Fix deterministic behavior in `move_agent_to_one_of` with `selection="closest"` by @OrenBochman in https://github.com/projectmesa/mesa/pull/2118
90
+ ### 📜 Documentation improvements
91
+ * docs: Fix Visualization Tutorial (main branch) by @EwoutH in https://github.com/projectmesa/mesa/pull/2271
92
+ * Docs: Fix broken relative links by removing `.html` suffix by @EwoutH in https://github.com/projectmesa/mesa/pull/2274
93
+ * Readthedocs: Don't let notebook failures pass silently by @EwoutH in https://github.com/projectmesa/mesa/pull/2276
94
+ * Update viz tutorial to the new API by @Corvince in https://github.com/projectmesa/mesa/pull/2289
95
+ ### 🔧 Maintenance
96
+ * Resolve multiprocessing warning, state Python 3.13 support by @rht in https://github.com/projectmesa/mesa/pull/2246
97
+
98
+ ## New Contributors
99
+ * @OrenBochman made their first contribution in https://github.com/projectmesa/mesa/pull/2118
100
+
101
+ **Full Changelog**: https://github.com/projectmesa/mesa/compare/v3.0.0a3...v3.0.0a4
102
+
4
103
  # 3.0.0a3 (2024-08-30)
5
104
  ## Highlights
6
105
  Developments toward Mesa 3.0 are steaming ahead, and our fourth alpha release is packed with features and updates - only 8 days after our third.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: Mesa
3
- Version: 3.0.0a3
3
+ Version: 3.0.0a5
4
4
  Summary: Agent-based modeling (ABM) in Python
5
5
  Project-URL: homepage, https://github.com/projectmesa/mesa
6
6
  Project-URL: repository, https://github.com/projectmesa/mesa
@@ -17,6 +17,7 @@ Classifier: Programming Language :: Python :: 3 :: Only
17
17
  Classifier: Programming Language :: Python :: 3.10
18
18
  Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
20
21
  Classifier: Topic :: Scientific/Engineering
21
22
  Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
23
  Classifier: Topic :: Scientific/Engineering :: Artificial Life
@@ -0,0 +1 @@
1
+ """init file for BoltzmannWealth module."""
@@ -1,8 +1,21 @@
1
- # https://github.com/projectmesa/mesa-examples/blob/main/examples/boltzmann_wealth_model_experimental/model.py
1
+ """boltmann wealth model for performance benchmarking.
2
+
3
+ https://github.com/projectmesa/mesa-examples/blob/main/examples/boltzmann_wealth_model_experimental/model.py
4
+ """
5
+
2
6
  import mesa
3
7
 
4
8
 
5
9
  def compute_gini(model):
10
+ """Calculate gini for wealth in model.
11
+
12
+ Args:
13
+ model: a Model instance
14
+
15
+ Returns:
16
+ float: gini score
17
+
18
+ """
6
19
  agent_wealths = [agent.wealth for agent in model.agents]
7
20
  x = sorted(agent_wealths)
8
21
  n = model.num_agents
@@ -19,16 +32,23 @@ class BoltzmannWealth(mesa.Model):
19
32
  """
20
33
 
21
34
  def __init__(self, seed=None, n=100, width=10, height=10):
22
- super().__init__()
35
+ """Initializes the model.
36
+
37
+ Args:
38
+ seed: the seed for random number generator
39
+ n: the number of agents
40
+ width: the width of the grid
41
+ height: the height of the grid
42
+ """
43
+ super().__init__(seed)
23
44
  self.num_agents = n
24
45
  self.grid = mesa.space.MultiGrid(width, height, True)
25
- self.schedule = mesa.time.RandomActivation(self)
26
46
  self.datacollector = mesa.DataCollector(
27
47
  model_reporters={"Gini": compute_gini}, agent_reporters={"Wealth": "wealth"}
28
48
  )
29
49
  # Create agents
30
- for i in range(self.num_agents):
31
- a = MoneyAgent(i, self)
50
+ for _ in range(self.num_agents):
51
+ a = MoneyAgent(self)
32
52
  # Add the agent to a random grid cell
33
53
  x = self.random.randrange(self.grid.width)
34
54
  y = self.random.randrange(self.grid.height)
@@ -38,11 +58,18 @@ class BoltzmannWealth(mesa.Model):
38
58
  self.datacollector.collect(self)
39
59
 
40
60
  def step(self):
41
- self.agents.shuffle().do("step")
61
+ """Run the model for a single step."""
62
+ self.agents.shuffle_do("step")
42
63
  # collect data
43
64
  self.datacollector.collect(self)
44
65
 
45
66
  def run_model(self, n):
67
+ """Run the model for n steps.
68
+
69
+ Args:
70
+ n: the number of steps for which to run the model
71
+
72
+ """
46
73
  for _i in range(n):
47
74
  self.step()
48
75
 
@@ -50,11 +77,17 @@ class BoltzmannWealth(mesa.Model):
50
77
  class MoneyAgent(mesa.Agent):
51
78
  """An agent with fixed initial wealth."""
52
79
 
53
- def __init__(self, unique_id, model):
54
- super().__init__(unique_id, model)
80
+ def __init__(self, model):
81
+ """Instantiate an agent.
82
+
83
+ Args:
84
+ model: a Model instance
85
+ """
86
+ super().__init__(model)
55
87
  self.wealth = 1
56
88
 
57
89
  def move(self):
90
+ """Move the agent to a random neighboring cell."""
58
91
  possible_steps = self.model.grid.get_neighborhood(
59
92
  self.pos, moore=True, include_center=False
60
93
  )
@@ -62,6 +95,7 @@ class MoneyAgent(mesa.Agent):
62
95
  self.model.grid.move_agent(self, new_position)
63
96
 
64
97
  def give_money(self):
98
+ """Give money to a random cell mate."""
65
99
  cellmates = self.model.grid.get_cell_list_contents([self.pos])
66
100
  cellmates.pop(
67
101
  cellmates.index(self)
@@ -72,6 +106,7 @@ class MoneyAgent(mesa.Agent):
72
106
  self.wealth -= 1
73
107
 
74
108
  def step(self):
109
+ """Run the agent for 1 step."""
75
110
  self.move()
76
111
  if self.wealth > 0:
77
112
  self.give_money()
@@ -0,0 +1 @@
1
+ """initi for flocking benchmark model."""
@@ -1,7 +1,5 @@
1
- """
2
- Flockers
3
- =============================================================
4
- A Mesa implementation of Craig Reynolds's Boids flocker model.
1
+ """A Mesa implementation of Craig Reynolds's Boids flocker model.
2
+
5
3
  Uses numpy arrays to represent vectors.
6
4
  """
7
5
 
@@ -11,8 +9,7 @@ import mesa
11
9
 
12
10
 
13
11
  class Boid(mesa.Agent):
14
- """
15
- A Boid-style flocker agent.
12
+ """A Boid-style flocker agent.
16
13
 
17
14
  The agent follows three behaviors to flock:
18
15
  - Cohesion: steering towards neighboring agents.
@@ -27,7 +24,6 @@ class Boid(mesa.Agent):
27
24
 
28
25
  def __init__(
29
26
  self,
30
- unique_id,
31
27
  model,
32
28
  speed,
33
29
  direction,
@@ -37,11 +33,10 @@ class Boid(mesa.Agent):
37
33
  separate=0.015,
38
34
  match=0.05,
39
35
  ):
40
- """
41
- Create a new Boid flocker agent.
36
+ """Create a new Boid flocker agent.
42
37
 
43
38
  Args:
44
- unique_id: Unique agent identifier.
39
+ model: a Model instance
45
40
  speed: Distance to move per step.
46
41
  direction: numpy vector for the Boid's direction of movement.
47
42
  vision: Radius to look around for nearby Boids.
@@ -51,7 +46,7 @@ class Boid(mesa.Agent):
51
46
  match: the relative importance of matching neighbors' directions
52
47
 
53
48
  """
54
- super().__init__(unique_id, model)
49
+ super().__init__(model)
55
50
  self.speed = speed
56
51
  self.direction = direction
57
52
  self.vision = vision
@@ -61,10 +56,7 @@ class Boid(mesa.Agent):
61
56
  self.match_factor = match
62
57
 
63
58
  def step(self):
64
- """
65
- Get the Boid's neighbors, compute the new vector, and move accordingly.
66
- """
67
-
59
+ """Get the Boid's neighbors, compute the new vector, and move accordingly."""
68
60
  neighbors = self.model.space.get_neighbors(self.pos, self.vision, False)
69
61
  n = 0
70
62
  match_vector, separation_vector, cohere = np.zeros((3, 2))
@@ -86,9 +78,7 @@ class Boid(mesa.Agent):
86
78
 
87
79
 
88
80
  class BoidFlockers(mesa.Model):
89
- """
90
- Flocker model class. Handles agent creation, placement and scheduling.
91
- """
81
+ """Flocker model class. Handles agent creation, placement and scheduling."""
92
82
 
93
83
  def __init__(
94
84
  self,
@@ -104,18 +94,21 @@ class BoidFlockers(mesa.Model):
104
94
  match=0.05,
105
95
  simulator=None,
106
96
  ):
107
- """
108
- Create a new Flockers model.
97
+ """Create a new Flockers model.
109
98
 
110
99
  Args:
100
+ seed: seed for random number generator
111
101
  population: Number of Boids
112
- width, height: Size of the space.
102
+ width: the width of the space
103
+ height: the height of the space
113
104
  speed: How fast should the Boids move.
114
105
  vision: How far around should each Boid look for its neighbors
115
- separation: What's the minimum distance each Boid will attempt to
116
- keep from any other
117
- cohere, separate, match: factors for the relative importance of
106
+ separation: What's the minimum distance each Boid will attempt to keep from any other
107
+ cohere: the relative importance of matching neighbors' positions'
108
+ separate: the relative importance of avoiding close neighbors
109
+ match: factors for the relative importance of
118
110
  the three drives.
111
+ simulator: a Simulator Instance
119
112
  """
120
113
  super().__init__(seed=seed)
121
114
  self.population = population
@@ -123,7 +116,6 @@ class BoidFlockers(mesa.Model):
123
116
  self.height = height
124
117
  self.simulator = simulator
125
118
 
126
- self.schedule = mesa.time.RandomActivation(self)
127
119
  self.space = mesa.space.ContinuousSpace(self.width, self.height, True)
128
120
  self.factors = {
129
121
  "cohere": cohere,
@@ -131,13 +123,12 @@ class BoidFlockers(mesa.Model):
131
123
  "match": match,
132
124
  }
133
125
 
134
- for i in range(self.population):
126
+ for _ in range(self.population):
135
127
  x = self.random.random() * self.space.x_max
136
128
  y = self.random.random() * self.space.y_max
137
129
  pos = np.array((x, y))
138
130
  direction = np.random.random(2) * 2 - 1
139
131
  boid = Boid(
140
- unique_id=i,
141
132
  model=self,
142
133
  speed=speed,
143
134
  direction=direction,
@@ -146,10 +137,10 @@ class BoidFlockers(mesa.Model):
146
137
  **self.factors,
147
138
  )
148
139
  self.space.place_agent(boid, pos)
149
- self.schedule.add(boid)
150
140
 
151
141
  def step(self):
152
- self.schedule.step()
142
+ """Run the model for one step."""
143
+ self.agents.shuffle_do("step")
153
144
 
154
145
 
155
146
  if __name__ == "__main__":
@@ -0,0 +1 @@
1
+ """Schelling separation for performance benchmarking."""
@@ -1,29 +1,30 @@
1
+ """Schelling separation for performance benchmarking."""
2
+
1
3
  from mesa import Model
2
4
  from mesa.experimental.cell_space import CellAgent, OrthogonalMooreGrid
3
- from mesa.time import RandomActivation
4
5
 
5
6
 
6
7
  class SchellingAgent(CellAgent):
7
- """
8
- Schelling segregation agent
9
- """
8
+ """Schelling segregation agent."""
9
+
10
+ def __init__(self, model, agent_type, radius, homophily):
11
+ """Create a new Schelling agent.
10
12
 
11
- def __init__(self, unique_id, model, agent_type, radius, homophily):
12
- """
13
- Create a new Schelling agent.
14
13
  Args:
15
- unique_id: Unique identifier for the agent.
16
- x, y: Agent initial location.
17
- agent_type: Indicator for the agent's type (minority=1, majority=0)
14
+ model: model instance
15
+ agent_type: type of agent (minority=1, majority=0)
16
+ radius: size of neighborhood of agent
17
+ homophily: fraction of neighbors of the same type that triggers movement
18
18
  """
19
- super().__init__(unique_id, model)
19
+ super().__init__(model)
20
20
  self.type = agent_type
21
21
  self.radius = radius
22
22
  self.homophily = homophily
23
23
 
24
24
  def step(self):
25
+ """Run one step of the agent."""
25
26
  similar = 0
26
- neighborhood = self.cell.neighborhood(radius=self.radius)
27
+ neighborhood = self.cell.get_neighborhood(radius=self.radius)
27
28
  for neighbor in neighborhood.agents:
28
29
  if neighbor.type == self.type:
29
30
  similar += 1
@@ -36,9 +37,7 @@ class SchellingAgent(CellAgent):
36
37
 
37
38
 
38
39
  class Schelling(Model):
39
- """
40
- Model class for the Schelling segregation model.
41
- """
40
+ """Model class for the Schelling segregation model."""
42
41
 
43
42
  def __init__(
44
43
  self,
@@ -51,22 +50,22 @@ class Schelling(Model):
51
50
  seed=None,
52
51
  simulator=None,
53
52
  ):
54
- """
55
- Create a new Schelling model.
53
+ """Create a new Schelling model.
56
54
 
57
55
  Args:
58
- height, width: Size of the space.
59
- density: Initial Chance for a cell to populated
60
- minority_pc: Chances for an agent to be in minority class
56
+ height: height of the grid
57
+ width: width of the grid
61
58
  homophily: Minimum number of agents of same class needed to be happy
62
59
  radius: Search radius for checking similarity
63
- seed: Seed for Reproducibility
60
+ density: Initial Chance for a cell to populated
61
+ minority_pc: Chances for an agent to be in minority class
62
+ seed: the seed for the random number generator
63
+ simulator: a simulator instance
64
64
  """
65
65
  super().__init__(seed=seed)
66
66
  self.minority_pc = minority_pc
67
67
  self.simulator = simulator
68
68
 
69
- self.schedule = RandomActivation(self)
70
69
  self.grid = OrthogonalMooreGrid(
71
70
  [height, width],
72
71
  torus=True,
@@ -81,18 +80,13 @@ class Schelling(Model):
81
80
  for cell in self.grid:
82
81
  if self.random.random() < density:
83
82
  agent_type = 1 if self.random.random() < self.minority_pc else 0
84
- agent = SchellingAgent(
85
- self.next_id(), self, agent_type, radius, homophily
86
- )
83
+ agent = SchellingAgent(self, agent_type, radius, homophily)
87
84
  agent.move_to(cell)
88
- self.schedule.add(agent)
89
85
 
90
86
  def step(self):
91
- """
92
- Run one step of the model.
93
- """
87
+ """Run one step of the model."""
94
88
  self.happy = 0 # Reset counter of happy agents
95
- self.schedule.step()
89
+ self.agents.shuffle_do("step")
96
90
 
97
91
 
98
92
  if __name__ == "__main__":
@@ -0,0 +1 @@
1
+ """Wolf-Sheep Predation Model for performance benchmarking."""