Mesa 3.0.0a1__tar.gz → 3.0.0a3__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 (134) hide show
  1. mesa-3.0.0a3/.github/PULL_REQUEST_TEMPLATE/bug.md +16 -0
  2. mesa-3.0.0a3/.github/PULL_REQUEST_TEMPLATE/feature.md +16 -0
  3. {mesa-3.0.0a1 → mesa-3.0.0a3}/.github/workflows/build_lint.yml +10 -4
  4. {mesa-3.0.0a1 → mesa-3.0.0a3}/.pre-commit-config.yaml +2 -2
  5. {mesa-3.0.0a1 → mesa-3.0.0a3}/CONTRIBUTING.md +34 -0
  6. {mesa-3.0.0a1 → mesa-3.0.0a3}/HISTORY.md +79 -0
  7. {mesa-3.0.0a1 → mesa-3.0.0a3}/PKG-INFO +16 -5
  8. {mesa-3.0.0a1 → mesa-3.0.0a3}/README.md +12 -3
  9. mesa-3.0.0a3/benchmarks/BoltzmannWealth/boltzmann_wealth.py +77 -0
  10. {mesa-3.0.0a1 → mesa-3.0.0a3}/benchmarks/configurations.py +25 -1
  11. {mesa-3.0.0a1 → mesa-3.0.0a3}/benchmarks/global_benchmark.py +11 -7
  12. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/conf.py +1 -1
  13. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/index.md +1 -0
  14. mesa-3.0.0a3/docs/migration_guide.md +67 -0
  15. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/tutorials/intro_tutorial.ipynb +60 -54
  16. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/tutorials/visualization_tutorial.ipynb +7 -2
  17. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/__init__.py +1 -1
  18. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/agent.py +220 -42
  19. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/batchrunner.py +4 -4
  20. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/datacollection.py +2 -2
  21. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/experimental/cell_space/__init__.py +2 -0
  22. mesa-3.0.0a3/mesa/experimental/cell_space/voronoi.py +264 -0
  23. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/experimental/devs/eventlist.py +11 -0
  24. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/model.py +98 -36
  25. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/space.py +3 -3
  26. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/time.py +0 -7
  27. mesa-3.0.0a3/mesa/visualization/components/matplotlib.py +224 -0
  28. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/visualization/solara_viz.py +9 -4
  29. {mesa-3.0.0a1 → mesa-3.0.0a3}/pyproject.toml +4 -1
  30. mesa-3.0.0a3/tests/__init__.py +0 -0
  31. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_agent.py +168 -7
  32. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_cell_space.py +23 -0
  33. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_examples.py +1 -0
  34. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_model.py +3 -1
  35. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_solara_viz.py +14 -1
  36. mesa-3.0.0a1/mesa/visualization/components/matplotlib.py +0 -134
  37. {mesa-3.0.0a1 → mesa-3.0.0a3}/.codespellignore +0 -0
  38. {mesa-3.0.0a1 → mesa-3.0.0a3}/.coveragerc +0 -0
  39. {mesa-3.0.0a1 → mesa-3.0.0a3}/.github/ISSUE_TEMPLATE/asking-help.md +0 -0
  40. {mesa-3.0.0a1 → mesa-3.0.0a3}/.github/ISSUE_TEMPLATE/bug-report.md +0 -0
  41. {mesa-3.0.0a1 → mesa-3.0.0a3}/.github/ISSUE_TEMPLATE/feature-request.md +0 -0
  42. {mesa-3.0.0a1 → mesa-3.0.0a3}/.github/dependabot.yml +0 -0
  43. {mesa-3.0.0a1 → mesa-3.0.0a3}/.github/release.yml +0 -0
  44. {mesa-3.0.0a1 → mesa-3.0.0a3}/.github/workflows/benchmarks.yml +0 -0
  45. {mesa-3.0.0a1 → mesa-3.0.0a3}/.github/workflows/release.yml +0 -0
  46. {mesa-3.0.0a1 → mesa-3.0.0a3}/.gitignore +0 -0
  47. {mesa-3.0.0a1 → mesa-3.0.0a3}/.readthedocs.yml +0 -0
  48. {mesa-3.0.0a1 → mesa-3.0.0a3}/CITATION.bib +0 -0
  49. {mesa-3.0.0a1 → mesa-3.0.0a3}/CODE_OF_CONDUCT.md +0 -0
  50. {mesa-3.0.0a1 → mesa-3.0.0a3}/Dockerfile +0 -0
  51. {mesa-3.0.0a1 → mesa-3.0.0a3}/LICENSE +0 -0
  52. {mesa-3.0.0a1/benchmarks/Flocking → mesa-3.0.0a3/benchmarks/BoltzmannWealth}/__init__.py +0 -0
  53. {mesa-3.0.0a1/benchmarks/Schelling → mesa-3.0.0a3/benchmarks/Flocking}/__init__.py +0 -0
  54. {mesa-3.0.0a1 → mesa-3.0.0a3}/benchmarks/Flocking/flocking.py +0 -0
  55. {mesa-3.0.0a1/benchmarks/WolfSheep → mesa-3.0.0a3/benchmarks/Schelling}/__init__.py +0 -0
  56. {mesa-3.0.0a1 → mesa-3.0.0a3}/benchmarks/Schelling/schelling.py +0 -0
  57. {mesa-3.0.0a1/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}} → mesa-3.0.0a3/benchmarks/WolfSheep}/__init__.py +0 -0
  58. {mesa-3.0.0a1 → mesa-3.0.0a3}/benchmarks/WolfSheep/wolf_sheep.py +0 -0
  59. {mesa-3.0.0a1 → mesa-3.0.0a3}/benchmarks/compare_timings.py +0 -0
  60. {mesa-3.0.0a1 → mesa-3.0.0a3}/codecov.yaml +0 -0
  61. {mesa-3.0.0a1 → mesa-3.0.0a3}/docker-compose.yml +0 -0
  62. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/Makefile +0 -0
  63. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/README.md +0 -0
  64. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/apis/api_main.md +0 -0
  65. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/apis/batchrunner.md +0 -0
  66. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/apis/datacollection.md +0 -0
  67. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/apis/experimental.md +0 -0
  68. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/apis/init.md +0 -0
  69. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/apis/space.md +0 -0
  70. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/apis/time.md +0 -0
  71. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/apis/visualization.md +0 -0
  72. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/best-practices.md +0 -0
  73. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/howto.md +0 -0
  74. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/Mesa_Screenshot.png +0 -0
  75. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/mesa_logo.ico +0 -0
  76. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/mesa_logo.png +0 -0
  77. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/tutorial/br_ginis.png +0 -0
  78. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/tutorial/dc_endwealth.png +0 -0
  79. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/tutorial/dc_gini.png +0 -0
  80. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/tutorial/dc_oneagent.png +0 -0
  81. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/tutorial/first_hist.png +0 -0
  82. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/tutorial/multirun_hist.png +0 -0
  83. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/tutorial/numpy_grid.png +0 -0
  84. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/tutorial/viz_chart.png +0 -0
  85. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/tutorial/viz_empty.png +0 -0
  86. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/tutorial/viz_greycircles.png +0 -0
  87. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/tutorial/viz_histogram.png +0 -0
  88. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/images/tutorial/viz_redcircles.png +0 -0
  89. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/make.bat +0 -0
  90. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/mesa.md +0 -0
  91. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/overview.md +0 -0
  92. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/packages.md +0 -0
  93. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/tutorials/MoneyModel.py +0 -0
  94. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/tutorials/files/viz_chart.png +0 -0
  95. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/tutorials/files/viz_empty.png +0 -0
  96. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/tutorials/files/viz_greycircles.png +0 -0
  97. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/tutorials/files/viz_histogram.png +0 -0
  98. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/tutorials/files/viz_redcircles.png +0 -0
  99. {mesa-3.0.0a1 → mesa-3.0.0a3}/docs/tutorials/files/viz_slider.png +0 -0
  100. {mesa-3.0.0a1 → mesa-3.0.0a3}/maintenance/fetch_unlabeled_prs.py +0 -0
  101. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/cookiecutter-mesa/cookiecutter.json +0 -0
  102. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/cookiecutter-mesa/hooks/post_gen_project.py +0 -0
  103. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/README.md +0 -0
  104. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/app.pytemplate +0 -0
  105. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/setup.pytemplate +0 -0
  106. {mesa-3.0.0a1/tests → mesa-3.0.0a3/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}}/__init__.py +0 -0
  107. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/model.pytemplate +0 -0
  108. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/experimental/__init__.py +0 -0
  109. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/experimental/cell_space/cell.py +0 -0
  110. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/experimental/cell_space/cell_agent.py +0 -0
  111. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/experimental/cell_space/cell_collection.py +0 -0
  112. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/experimental/cell_space/discrete_space.py +0 -0
  113. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/experimental/cell_space/grid.py +0 -0
  114. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/experimental/cell_space/network.py +0 -0
  115. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/experimental/devs/__init__.py +0 -0
  116. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/experimental/devs/examples/epstein_civil_violence.py +0 -0
  117. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/experimental/devs/examples/wolf_sheep.py +0 -0
  118. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/experimental/devs/simulator.py +0 -0
  119. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/main.py +0 -0
  120. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/visualization/UserParam.py +0 -0
  121. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/visualization/__init__.py +0 -0
  122. {mesa-3.0.0a1 → mesa-3.0.0a3}/mesa/visualization/components/altair.py +0 -0
  123. {mesa-3.0.0a1 → mesa-3.0.0a3}/mypy.ini +0 -0
  124. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/read_requirements.py +0 -0
  125. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_batch_run.py +1 -1
  126. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_datacollector.py +0 -0
  127. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_devs.py +0 -0
  128. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_end_to_end_viz.sh +0 -0
  129. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_grid.py +0 -0
  130. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_import_namespace.py +0 -0
  131. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_lifespan.py +0 -0
  132. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_scaffold.py +0 -0
  133. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_space.py +0 -0
  134. {mesa-3.0.0a1 → mesa-3.0.0a3}/tests/test_time.py +0 -0
@@ -0,0 +1,16 @@
1
+ ## Summary
2
+ <!-- Provide a brief summary of the bug and its impact. -->
3
+
4
+ ## Bug / Issue
5
+ <!-- Link to the related issue(s) and describe the bug. Include details like the context, what was expected, and what actually happened. -->
6
+
7
+ ## Implementation
8
+ <!-- Describe the changes made to resolve the issue. Highlight any important parts of the code that were modified. -->
9
+
10
+ ## Testing
11
+ <!-- Detail the testing performed to verify the fix. Include information on test cases, steps taken, and any relevant results.
12
+
13
+ If you're fixing the visualisation, add before/after screenshots. -->
14
+
15
+ ## Additional Notes
16
+ <!-- Add any additional information that may be relevant for the reviewers, such as potential side effects, dependencies, or related work.
@@ -0,0 +1,16 @@
1
+ ## Summary
2
+ <!-- Provide a concise summary of the feature and its purpose. -->
3
+
4
+ ## Motive
5
+ <!-- Explain the reasoning behind this feature. Include details on the problem it addresses or the enhancement it provides. -->
6
+
7
+ ## Implementation
8
+ <!-- Describe how the feature was implemented. Include details on the approach taken, important decisions made, and code changes. -->
9
+
10
+ ## Usage Examples
11
+ <!-- Provide code snippets or examples demonstrating how to use the new feature. Highlight key scenarios where this feature will be beneficial.
12
+
13
+ If you're modifying the visualisation, add before/after screenshots. -->
14
+
15
+ ## Additional Notes
16
+ <!-- Add any additional information that may be relevant for the reviewers, such as potential side effects, dependencies, or related work. -->
@@ -33,6 +33,8 @@ jobs:
33
33
  os: [windows, ubuntu, macos]
34
34
  python-version: ["3.12"]
35
35
  include:
36
+ - os: ubuntu
37
+ python-version: "3.13"
36
38
  - os: ubuntu
37
39
  python-version: "3.11"
38
40
  - os: ubuntu
@@ -47,12 +49,16 @@ jobs:
47
49
  uses: actions/setup-python@v5
48
50
  with:
49
51
  python-version: ${{ matrix.python-version }}
52
+ allow-prereleases: true
50
53
  cache: 'pip'
51
54
  - name: Install uv
52
55
  run: pip install uv
53
- - name: Install Mesa
54
- # See https://github.com/astral-sh/uv/issues/1945
56
+ - name: Install Mesa with uv pip
55
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'
56
62
  - name: Test with pytest
57
63
  run: pytest --durations=10 --cov=mesa tests/ --cov-report=xml
58
64
  - if: matrix.os == 'ubuntu'
@@ -71,7 +77,7 @@ jobs:
71
77
  - name: Install uv
72
78
  run: pip install uv
73
79
  - name: Install Mesa
74
- run: uv pip install --system .[dev]
80
+ run: uv pip install --system .[examples]
75
81
  - name: Checkout mesa-examples
76
82
  uses: actions/checkout@v4
77
83
  with:
@@ -80,4 +86,4 @@ jobs:
80
86
  - name: Test examples
81
87
  run: |
82
88
  cd mesa-examples
83
- pytest test_examples.py
89
+ pytest -rA -Werror -Wdefault::FutureWarning test_examples.py
@@ -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.0
7
+ rev: v0.5.6
8
8
  hooks:
9
9
  # Run the linter.
10
10
  - id: ruff
@@ -14,7 +14,7 @@ repos:
14
14
  - id: ruff-format
15
15
  types_or: [ python, pyi, jupyter ]
16
16
  - repo: https://github.com/asottile/pyupgrade
17
- rev: v3.16.0
17
+ rev: v3.17.0
18
18
  hooks:
19
19
  - id: pyupgrade
20
20
  args: [--py310-plus]
@@ -36,6 +36,40 @@ discuss via [Matrix] OR via [an issue].
36
36
  - Describe the change w/ ticket number(s) that the code fixes.
37
37
  - Format your commit message as per [Tim Pope's guideline].
38
38
 
39
+ ## I have no idea where to start
40
+ That's fine! Here's a rough outline where you could start, depending on your experience:
41
+
42
+ ### I'm a modeller (but not an experienced developer)
43
+ You already know how to build Mesa models (if not skip below), and probably have found things Mesa can't do (elegantly). You want to improve that. Awesome!
44
+
45
+ First step is to install some proper tools, if you haven't already.
46
+ - A good IDE helps for code development, testing and formatting. [PyCharm](https://www.jetbrains.com/pycharm/) or [VSCode](https://code.visualstudio.com/) for example.
47
+ - Dive into Git and GitHub. Watch some videos, this takes some time to click. [GitHub Desktop](https://desktop.github.com/) is great.
48
+ - [`https://github.dev/projectmesa/mesa`](https://github.dev/projectmesa/mesa) is great for small changes (to docs).
49
+
50
+ Learn the tools, talk to us about what you want to change, and open a small PR. Or update an [example model](https://github.com/projectmesa/mesa-examples) (check open [issues](https://github.com/projectmesa/mesa-examples/issues))!
51
+
52
+ ### I'm a developer (but not a modeller)
53
+ Awesome! You have the basics of open-source software development (if not check above), but not much modelling experience.
54
+
55
+ First step is to start thinking like a modeller. To understand the fine details about our library and contribute meaningfully, get some modelling experience:
56
+ - Go though our [Introductory Tutorial](https://mesa.readthedocs.io/en/latest/tutorials/intro_tutorial.html) and [Visualization Tutorial](https://mesa.readthedocs.io/en/latest/tutorials/visualization_tutorial.html). While going through them, dive into the source code to really see what everything does.
57
+ - Follow an ABM course (if possible). They might be a bit outdated programming language wise, but conceptual they're sound.
58
+ - This MOOC on ABM concepts: [Agent Based Modeling](https://ocw.tudelft.nl/course-lectures/agent-based-modeling/)
59
+ - This MOOC on practical ABM modelling: [Agent-Based Models with Python: An Introduction to Mesa](https://www.complexityexplorer.org/courses/172-agent-based-models-with-python-an-introduction-to-mesa)
60
+ - Go though multiple of our [examples](https://github.com/projectmesa/mesa-examples). Play with them, modify things and get a feel for Mesa and ABMs.
61
+ - Check our open [issues](https://github.com/projectmesa/mesa-examples/issues) for the examples.
62
+ - If you see anything you want to improve, feel free to open a (small) PR!
63
+ - If you have a feel for Mesa, check our [discussions](https://github.com/projectmesa/mesa/discussions) and [issues](https://github.com/projectmesa/mesa/issues).
64
+ - Also go thought our [release notes](https://github.com/projectmesa/mesa/releases) to see what we recently have been working on, and see some examples of successful PRs.
65
+ - Once you found or thought of a nice idea, comment on the issue/discussion (or open a new one) and get to work!
66
+
67
+ ### I'm both
68
+ That's great! You can just start working on things, reach out to us. Skim to the list above if you feel you're missing anything. Start small but don't be afraid to dream big!
69
+
70
+ ### I'm neither
71
+ Start with creating your own models, for fun. Once you have some experience, move to the topics above.
72
+
39
73
  ## Testing and Code Standards
40
74
 
41
75
  ```{image} https://codecov.io/gh/projectmesa/mesa/branch/main/graph/badge.svg
@@ -1,6 +1,85 @@
1
1
  ---
2
2
  title: Release History
3
3
  ---
4
+ # 3.0.0a3 (2024-08-30)
5
+ ## Highlights
6
+ 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.
7
+
8
+ Mesa 3.0.0a3 contains one breaking change: We now automatically increase the `steps` counter by one at the beginning of each `Model.steps()` call. That means increasing `steps` by hand isn't necessary anymore.
9
+
10
+ The big new features is the experimental Voronoi grid that @vitorfrois implemented in #2084. It allows creating cells in a [Voronoi](https://en.wikipedia.org/wiki/Voronoi_diagram) layout as part of the experimental cell space. An example using it to model Cholera spread can be [found here](https://github.com/projectmesa/mesa-examples/pull/118).
11
+
12
+ The AgentSet got a lot of love with two brand new methods: `.groupby()` to split in groups (#2220) and `.set()` to easily assign variables to all agents in that set (#2254). The `select()` method is improved by allowing to select at most a fraction of the agents (#2253), and we split the `do()` method in `do()` and `map()` to make a distinction between the return types (#2237).
13
+
14
+ Furthermore, we improved the performance of accessing `Model.agents`, squashed a bug in SolaraViz, started testing on Python 3.13 and added a new benchmark model.
15
+
16
+ Our example models also got more love: We removed the `RandomActivation` scheduler in 14 models and removed SimultaneousActivation in 3 models ([examples#183](https://github.com/projectmesa/mesa-examples/pull/183)). They now use the automatic step increase and AgentSet functionality. We started testing our GIS model in CI ([examples#171](https://github.com/projectmesa/mesa-examples/pull/171)) and resolved a lot of bugs in them ([examples#172](https://github.com/projectmesa/mesa-examples/issues/172), help appreciated!).
17
+
18
+ Finally, we have two brand new examples: An Ant Colony Optimization model using an Ant System approach to the Traveling Salesman problem, a Mesa NetworkGrid, and a custom visualisation with SolaraViz ([examples#157](https://github.com/projectmesa/mesa-examples/pull/157) by @zjost). The first example using the `PropertyLayer` was added, a very fast implementation of Conway's Game of Life ([examples#182](https://github.com/projectmesa/mesa-examples/pull/182)).
19
+
20
+ To help the transition to Mesa 3.0, we started writing a [migration guide](https://mesa.readthedocs.io/en/latest/migration_guide.html). Progress is tracked in #2233, feedback and help is appreciated! Finally, we also added a new section to our [contributor guide](https://github.com/projectmesa/mesa/blob/main/CONTRIBUTING.md#i-have-no-idea-where-to-start) to get new contributors up to speed.
21
+
22
+ This pre-release can be installed as always with `pip install --pre mesa`
23
+
24
+ ## What's Changed
25
+ ### ⚠️ Breaking changes
26
+ * model: Automatically increase `steps` counter by @EwoutH in https://github.com/projectmesa/mesa/pull/2223
27
+ ### 🧪 Experimental features
28
+ * Voronoi Tessellation based Discrete Space by @vitorfrois in https://github.com/projectmesa/mesa/pull/2084
29
+ ### 🎉 New features added
30
+ * Add AgentSet.groupby by @quaquel in https://github.com/projectmesa/mesa/pull/2220
31
+ * AgentSet: Add `set` method by @EwoutH in https://github.com/projectmesa/mesa/pull/2254
32
+ ### 🛠 Enhancements made
33
+ * Split AgentSet into map and do to separate return types by @quaquel in https://github.com/projectmesa/mesa/pull/2237
34
+ * Performance enhancements for Model.agents by @quaquel in https://github.com/projectmesa/mesa/pull/2251
35
+ * AgentSet: Allow selecting a fraction of agents in the AgentSet by @EwoutH in https://github.com/projectmesa/mesa/pull/2253
36
+ ### 🐛 Bugs fixed
37
+ * SolaraViz: Reset components when params are changed by @rht in https://github.com/projectmesa/mesa/pull/2240
38
+ ### 📜 Documentation improvements
39
+ * Contribution: Add "I have no idea where to start" section by @EwoutH in https://github.com/projectmesa/mesa/pull/2258
40
+ * Write initial Mesa Migration guide by @EwoutH in https://github.com/projectmesa/mesa/pull/2257
41
+ ### 🔧 Maintenance
42
+ * CI: Add test job for Python 3.13 by @EwoutH in https://github.com/projectmesa/mesa/pull/2173
43
+ * Add pull request templates by @EwoutH in https://github.com/projectmesa/mesa/pull/2217
44
+ * benchmarks: Add BoltzmannWealth model by @EwoutH in https://github.com/projectmesa/mesa/pull/2252
45
+ * CI: Add optional dependency for examples by @EwoutH in https://github.com/projectmesa/mesa/pull/2261
46
+
47
+ ## New Contributors
48
+ * @vitorfrois made their first contribution in https://github.com/projectmesa/mesa/pull/2084
49
+
50
+ **Full Changelog**: https://github.com/projectmesa/mesa/compare/v3.0.0a2...v3.0.0a3
51
+
52
+ # 3.0.0a2 (2024-08-21)
53
+ ## Highlights
54
+ In Mesa 3.0 alpha 2 (`v3.0.0a2`) we've done more clean-up in preparation for Mesa 3.0. We now [require](https://github.com/projectmesa/mesa/pull/2218) `super().__init__()` to run on initializing a Mesa model subclass, `Model.agents` is now fully reserved for the Model's internal AgentSet and we fixed a bug in our Solara space_drawer.
55
+
56
+ A new feature was added in [#2219](https://github.com/projectmesa/mesa/pull/2219), which now also allows `AgentSet.do()` to take any callable function, instead of only a string referencing to an Agent method. The argument name was changed from `method_name` to `method`.
57
+
58
+ The new Solara visualisation now allows portraying agents in different shapes, checkout some examples in [#2214](https://github.com/projectmesa/mesa/pull/2214).
59
+
60
+ We're also working hard on our [example models](https://github.com/projectmesa/mesa-examples). All model warnings were [resolved](https://github.com/projectmesa/mesa-examples/pull/153) and we've [replaced](https://github.com/projectmesa/mesa-examples/pull/161) a lot of schedulers with simpler and more flexible AgentSet functionality. Checkout our [open issues](https://github.com/projectmesa/mesa-examples/issues) if you want to help improve our example models further!
61
+
62
+ ## What's Changed
63
+ ### ⚠️ Breaking changes
64
+ * breaking: Add dependencies argument to custom space_drawer by @rht in https://github.com/projectmesa/mesa/pull/2209
65
+ * Require Mesa models to be initialized with `super().__init__()` by @EwoutH in https://github.com/projectmesa/mesa/pull/2218
66
+ * Allow AgentSet.do() to take Callable function by @quaquel in https://github.com/projectmesa/mesa/pull/2219
67
+ * Change warning when setting model.agents to error by @EwoutH in https://github.com/projectmesa/mesa/pull/2225
68
+ ### 🧪 Experimental features
69
+ * devs/eventlist: Add repr method to print EventList pretty by @EwoutH in https://github.com/projectmesa/mesa/pull/2195
70
+ ### 🛠 Enhancements made
71
+ * Visualisation: Allow specifying Agent shapes in agent_portrayal by @rmhopkins4 in https://github.com/projectmesa/mesa/pull/2214
72
+ ### 📜 Documentation improvements
73
+ * docs/conf.py: Use modern `intersphinx_mapping` format by @EwoutH in https://github.com/projectmesa/mesa/pull/2206
74
+ * docs: Update Readme and tutorials to mention Mesa 3.0 pre-releases by @EwoutH in https://github.com/projectmesa/mesa/pull/2203
75
+ ### 🔧 Maintenance
76
+ * CI: Let pytest treat warnings as errors for examples by @EwoutH in https://github.com/projectmesa/mesa/pull/2204
77
+
78
+ ## New Contributors
79
+ * @rmhopkins4 made their first contribution in https://github.com/projectmesa/mesa/pull/2214
80
+
81
+ **Full Changelog**: https://github.com/projectmesa/mesa/compare/v3.0.0a1...v3.0.0a2
82
+
4
83
  # 3.0.0a1 (2024-08-01)
5
84
  ## Highlights
6
85
  Mesa 3.0 alpha 1 (`v3.0.0a1`) is another step towards our next major version. This release introduces a name change from JupyterViz (jupyter_viz) to SolaraViz (solara_viz), to better represent the tech stack being used. It also includes two bugfixes also present in 2.3.2.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: Mesa
3
- Version: 3.0.0a1
3
+ Version: 3.0.0a3
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
@@ -30,7 +30,6 @@ Requires-Dist: pandas
30
30
  Requires-Dist: solara
31
31
  Requires-Dist: tqdm
32
32
  Provides-Extra: dev
33
- Requires-Dist: coverage; extra == 'dev'
34
33
  Requires-Dist: pytest-cov; extra == 'dev'
35
34
  Requires-Dist: pytest-mock; extra == 'dev'
36
35
  Requires-Dist: pytest>=4.6; extra == 'dev'
@@ -43,6 +42,9 @@ Requires-Dist: myst-parser; extra == 'docs'
43
42
  Requires-Dist: pydata-sphinx-theme; extra == 'docs'
44
43
  Requires-Dist: seaborn; extra == 'docs'
45
44
  Requires-Dist: sphinx; extra == 'docs'
45
+ Provides-Extra: examples
46
+ Requires-Dist: pytest>=4.6; extra == 'examples'
47
+ Requires-Dist: scipy; extra == 'examples'
46
48
  Description-Content-Type: text/markdown
47
49
 
48
50
  # Mesa: Agent-based modeling in Python
@@ -75,13 +77,19 @@ can be displayed in browser windows or Jupyter.*
75
77
 
76
78
  ## Using Mesa
77
79
 
78
- Getting started quickly:
80
+ To install our latest stable release (2.3.x), run:
79
81
 
80
82
  ``` bash
81
- pip install mesa
83
+ pip install -U mesa
82
84
  ```
83
85
 
84
- You can also use `pip` to install the github version:
86
+ To install our latest pre-release (3.0.0 alpha), run:
87
+
88
+ ``` bash
89
+ pip install -U --pre mesa
90
+ ```
91
+
92
+ You can also use `pip` to install the latest GitHub version:
85
93
 
86
94
  ``` bash
87
95
  pip install -U -e git+https://github.com/projectmesa/mesa@main#egg=mesa
@@ -93,15 +101,18 @@ Or any other (development) branch on this repo or your own fork:
93
101
  pip install -U -e git+https://github.com/YOUR_FORK/mesa@YOUR_BRANCH#egg=mesa
94
102
  ```
95
103
 
104
+ ## Resources
96
105
  For resources or help on using Mesa, check out the following:
97
106
 
98
107
  - [Intro to Mesa Tutorial](http://mesa.readthedocs.org/en/stable/tutorials/intro_tutorial.html) (An introductory model, the Boltzmann
99
108
  Wealth Model, for beginners or those new to Mesa.)
109
+ - [Visualization Tutorial](https://mesa.readthedocs.io/en/stable/tutorials/visualization_tutorial.html) (An introduction into our Solara visualization)
100
110
  - [Complexity Explorer Tutorial](https://www.complexityexplorer.org/courses/172-agent-based-models-with-python-an-introduction-to-mesa) (An advanced-beginner model,
101
111
  SugarScape with Traders, with instructional videos)
102
112
  - [Mesa Examples](https://github.com/projectmesa/mesa-examples/tree/main/examples) (A repository of seminal ABMs using Mesa and
103
113
  examples of employing specific Mesa Features)
104
114
  - [Docs](http://mesa.readthedocs.org/) (Mesa's documentation, API and useful snippets)
115
+ - [Development version docs](https://mesa.readthedocs.io/en/latest/) (the latest version docs if you're using a pre-release Mesa version)
105
116
  - [Discussions](https://github.com/projectmesa/mesa/discussions) (GitHub threaded discussions about Mesa)
106
117
  - [Matrix Chat](https://matrix.to/#/#project-mesa:matrix.org) (Chat Forum via Matrix to talk about Mesa)
107
118
 
@@ -28,13 +28,19 @@ can be displayed in browser windows or Jupyter.*
28
28
 
29
29
  ## Using Mesa
30
30
 
31
- Getting started quickly:
31
+ To install our latest stable release (2.3.x), run:
32
32
 
33
33
  ``` bash
34
- pip install mesa
34
+ pip install -U mesa
35
35
  ```
36
36
 
37
- You can also use `pip` to install the github version:
37
+ To install our latest pre-release (3.0.0 alpha), run:
38
+
39
+ ``` bash
40
+ pip install -U --pre mesa
41
+ ```
42
+
43
+ You can also use `pip` to install the latest GitHub version:
38
44
 
39
45
  ``` bash
40
46
  pip install -U -e git+https://github.com/projectmesa/mesa@main#egg=mesa
@@ -46,15 +52,18 @@ Or any other (development) branch on this repo or your own fork:
46
52
  pip install -U -e git+https://github.com/YOUR_FORK/mesa@YOUR_BRANCH#egg=mesa
47
53
  ```
48
54
 
55
+ ## Resources
49
56
  For resources or help on using Mesa, check out the following:
50
57
 
51
58
  - [Intro to Mesa Tutorial](http://mesa.readthedocs.org/en/stable/tutorials/intro_tutorial.html) (An introductory model, the Boltzmann
52
59
  Wealth Model, for beginners or those new to Mesa.)
60
+ - [Visualization Tutorial](https://mesa.readthedocs.io/en/stable/tutorials/visualization_tutorial.html) (An introduction into our Solara visualization)
53
61
  - [Complexity Explorer Tutorial](https://www.complexityexplorer.org/courses/172-agent-based-models-with-python-an-introduction-to-mesa) (An advanced-beginner model,
54
62
  SugarScape with Traders, with instructional videos)
55
63
  - [Mesa Examples](https://github.com/projectmesa/mesa-examples/tree/main/examples) (A repository of seminal ABMs using Mesa and
56
64
  examples of employing specific Mesa Features)
57
65
  - [Docs](http://mesa.readthedocs.org/) (Mesa's documentation, API and useful snippets)
66
+ - [Development version docs](https://mesa.readthedocs.io/en/latest/) (the latest version docs if you're using a pre-release Mesa version)
58
67
  - [Discussions](https://github.com/projectmesa/mesa/discussions) (GitHub threaded discussions about Mesa)
59
68
  - [Matrix Chat](https://matrix.to/#/#project-mesa:matrix.org) (Chat Forum via Matrix to talk about Mesa)
60
69
 
@@ -0,0 +1,77 @@
1
+ # https://github.com/projectmesa/mesa-examples/blob/main/examples/boltzmann_wealth_model_experimental/model.py
2
+ import mesa
3
+
4
+
5
+ def compute_gini(model):
6
+ agent_wealths = [agent.wealth for agent in model.agents]
7
+ x = sorted(agent_wealths)
8
+ n = model.num_agents
9
+ b = sum(xi * (n - i) for i, xi in enumerate(x)) / (n * sum(x))
10
+ return 1 + (1 / n) - 2 * b
11
+
12
+
13
+ class BoltzmannWealth(mesa.Model):
14
+ """A simple model of an economy where agents exchange currency at random.
15
+
16
+ All the agents begin with one unit of currency, and each time step can give
17
+ a unit of currency to another agent. Note how, over time, this produces a
18
+ highly skewed distribution of wealth.
19
+ """
20
+
21
+ def __init__(self, seed=None, n=100, width=10, height=10):
22
+ super().__init__()
23
+ self.num_agents = n
24
+ self.grid = mesa.space.MultiGrid(width, height, True)
25
+ self.schedule = mesa.time.RandomActivation(self)
26
+ self.datacollector = mesa.DataCollector(
27
+ model_reporters={"Gini": compute_gini}, agent_reporters={"Wealth": "wealth"}
28
+ )
29
+ # Create agents
30
+ for i in range(self.num_agents):
31
+ a = MoneyAgent(i, self)
32
+ # Add the agent to a random grid cell
33
+ x = self.random.randrange(self.grid.width)
34
+ y = self.random.randrange(self.grid.height)
35
+ self.grid.place_agent(a, (x, y))
36
+
37
+ self.running = True
38
+ self.datacollector.collect(self)
39
+
40
+ def step(self):
41
+ self.agents.shuffle().do("step")
42
+ # collect data
43
+ self.datacollector.collect(self)
44
+
45
+ def run_model(self, n):
46
+ for _i in range(n):
47
+ self.step()
48
+
49
+
50
+ class MoneyAgent(mesa.Agent):
51
+ """An agent with fixed initial wealth."""
52
+
53
+ def __init__(self, unique_id, model):
54
+ super().__init__(unique_id, model)
55
+ self.wealth = 1
56
+
57
+ def move(self):
58
+ possible_steps = self.model.grid.get_neighborhood(
59
+ self.pos, moore=True, include_center=False
60
+ )
61
+ new_position = self.random.choice(possible_steps)
62
+ self.model.grid.move_agent(self, new_position)
63
+
64
+ def give_money(self):
65
+ cellmates = self.model.grid.get_cell_list_contents([self.pos])
66
+ cellmates.pop(
67
+ cellmates.index(self)
68
+ ) # Ensure agent is not giving money to itself
69
+ if len(cellmates) > 0:
70
+ other = self.random.choice(cellmates)
71
+ other.wealth += 1
72
+ self.wealth -= 1
73
+
74
+ def step(self):
75
+ self.move()
76
+ if self.wealth > 0:
77
+ self.give_money()
@@ -1,8 +1,32 @@
1
+ from BoltzmannWealth.boltzmann_wealth import BoltzmannWealth
1
2
  from Flocking.flocking import BoidFlockers
2
3
  from Schelling.schelling import Schelling
3
4
  from WolfSheep.wolf_sheep import WolfSheep
4
5
 
5
6
  configurations = {
7
+ # Schelling Model Configurations
8
+ BoltzmannWealth: {
9
+ "small": {
10
+ "seeds": 50,
11
+ "replications": 5,
12
+ "steps": 125,
13
+ "parameters": {
14
+ "n": 100,
15
+ "width": 10,
16
+ "height": 10,
17
+ },
18
+ },
19
+ "large": {
20
+ "seeds": 10,
21
+ "replications": 3,
22
+ "steps": 10,
23
+ "parameters": {
24
+ "n": 10000,
25
+ "width": 100,
26
+ "height": 100,
27
+ },
28
+ },
29
+ },
6
30
  # Schelling Model Configurations
7
31
  Schelling: {
8
32
  "small": {
@@ -35,7 +59,7 @@ configurations = {
35
59
  "small": {
36
60
  "seeds": 50,
37
61
  "replications": 5,
38
- "steps": 40,
62
+ "steps": 80,
39
63
  "parameters": {
40
64
  "height": 25,
41
65
  "width": 25,
@@ -16,18 +16,22 @@ sys.path.insert(0, os.path.abspath(".."))
16
16
 
17
17
  # Generic function to initialize and run a model
18
18
  def run_model(model_class, seed, parameters):
19
+ no_simulator = ["BoltzmannWealth"]
19
20
  start_init = timeit.default_timer()
20
- simulator = ABMSimulator()
21
- model = model_class(simulator=simulator, seed=seed, **parameters)
22
- simulator.setup(model)
21
+ if model_class.__name__ in no_simulator:
22
+ model = model_class(seed=seed, **parameters)
23
+ else:
24
+ simulator = ABMSimulator()
25
+ model = model_class(simulator=simulator, seed=seed, **parameters)
26
+ simulator.setup(model)
23
27
 
24
28
  end_init_start_run = timeit.default_timer()
25
29
 
26
- simulator.run_for(config["steps"])
30
+ if model_class.__name__ in no_simulator:
31
+ model.run_model(config["steps"])
32
+ else:
33
+ simulator.run_for(config["steps"])
27
34
 
28
- # for _ in range(config["steps"]):
29
- # model.step()
30
- # time.sleep(0.0001)
31
35
  end_run = timeit.default_timer()
32
36
 
33
37
  return (end_init_start_run - start_init), (end_run - end_init_start_run)
@@ -279,4 +279,4 @@ texinfo_documents = [
279
279
 
280
280
 
281
281
  # Example configuration for intersphinx: refer to the Python standard library.
282
- intersphinx_mapping = {"http://docs.python.org/": None}
282
+ intersphinx_mapping = {'python': ('https://docs.python.org/3', None)}
@@ -81,6 +81,7 @@ ABM features users have shared that you may want to use in your model
81
81
  Mesa Overview <overview>
82
82
  tutorials/intro_tutorial
83
83
  tutorials/visualization_tutorial
84
+ Migration guide <migration_guide>
84
85
  Best Practices <best-practices>
85
86
  How-to Guide <howto>
86
87
  API Documentation <apis/api_main>
@@ -0,0 +1,67 @@
1
+ # Mesa Migration guide
2
+ This guide contains breaking changes between major Mesa versions and how to resolve them.
3
+
4
+ Non-breaking changes aren't included, for those see our [Release history](https://github.com/projectmesa/mesa/releases).
5
+
6
+ ## Mesa 3.0
7
+ <!-- TODO small introduction-->
8
+
9
+ _This guide is a work in progress. The development of it is tracked in [Issue #2233](https://github.com/projectmesa/mesa/issues/2233)._
10
+
11
+ ### Reserved and private variables
12
+ <!-- TODO: Update this section based on https://github.com/projectmesa/mesa/discussions/2230 -->
13
+
14
+ #### Reserved variables
15
+ Currently, we have reserved the following variables:
16
+ - Model: `agents`, `current_id`, `random`, `running`, `steps`, `time`.
17
+ - Agent: `unique_id`, `model`.
18
+
19
+ You can use (read) any reserved variable, but Mesa may update them automatically and rely on them, so modify/update at your own risk.
20
+ #### Private variables
21
+ Any variables starting with an underscore (`_`) are considered private and for Mesa's internal use. We might use any of those. Modifying or overwriting any private variable is at your own risk.
22
+
23
+ - Ref: [Discussion #2230](https://github.com/projectmesa/mesa/discussions/2230), [PR #2225](https://github.com/projectmesa/mesa/pull/2225)
24
+
25
+
26
+ ### Removal of `mesa.flat` namespace
27
+ The `mesa.flat` namespace is removed. Use the full namespace for your imports.
28
+
29
+ - Ref: [PR #2091](https://github.com/projectmesa/mesa/pull/2091)
30
+
31
+
32
+ ### Automatic assignment of `unique_id` to Agents
33
+ <!-- TODO -->
34
+
35
+ - Ref: [PR #2226](https://github.com/projectmesa/mesa/pull/2226)
36
+
37
+
38
+ ### AgentSet and `Model.agents`
39
+ #### AgentSet
40
+ <!-- TODO -->
41
+
42
+ #### `Model.agents`
43
+ <!-- TODO -->
44
+
45
+
46
+ ### Time and schedulers
47
+ <!-- TODO general explanation-->
48
+
49
+ #### Automatic increase of the `steps` counter
50
+ The `steps` counter is now automatically increased. With each call to `Model.steps()` it's increased by 1, at the beginning of the step.
51
+
52
+ You can access it by `Model.steps`, and it's internally in the datacollector, batchrunner and the visualisation.
53
+
54
+ - Ref: [PR #2223](https://github.com/projectmesa/mesa/pull/2223), Mesa-examples [PR #161](https://github.com/projectmesa/mesa-examples/pull/161)
55
+
56
+ #### Removal of `Model._time` and rename `._steps`
57
+ - `Model._time` is removed. You can define your own time variable if needed.
58
+ - `Model._steps` steps is renamed to `Model.steps`.
59
+
60
+ #### Removal of `Model._advance_time()`
61
+ - The `Model._advance_time()` method is removed. This now happens automatically.
62
+
63
+ <!-- TODO deprecate all schedulers? -->
64
+
65
+
66
+ ### Visualisation
67
+ <!-- TODO -->