Mesa 2.3.0.dev0__tar.gz → 2.3.0rc1__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 (143) hide show
  1. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/.github/workflows/build_lint.yml +9 -40
  2. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/.github/workflows/release.yml +1 -0
  3. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/.pre-commit-config.yaml +2 -2
  4. mesa-2.3.0rc1/CODE_OF_CONDUCT.md +131 -0
  5. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/HISTORY.md +115 -0
  6. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/PKG-INFO +4 -3
  7. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/README.md +1 -1
  8. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/benchmarks/Flocking/flocking.py +37 -38
  9. mesa-2.3.0rc1/benchmarks/Schelling/schelling.py +109 -0
  10. mesa-2.3.0rc1/benchmarks/WolfSheep/wolf_sheep.py +254 -0
  11. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/benchmarks/global_benchmark.py +11 -6
  12. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/index.md +1 -1
  13. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/tutorials/intro_tutorial.ipynb +7 -7
  14. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/__init__.py +2 -1
  15. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/agent.py +2 -16
  16. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/datacollection.py +1 -0
  17. mesa-2.3.0rc1/mesa/experimental/__init__.py +5 -0
  18. mesa-2.3.0rc1/mesa/experimental/cell_space/__init__.py +23 -0
  19. mesa-2.3.0rc1/mesa/experimental/cell_space/cell.py +152 -0
  20. mesa-2.3.0rc1/mesa/experimental/cell_space/cell_agent.py +37 -0
  21. mesa-2.3.0rc1/mesa/experimental/cell_space/cell_collection.py +81 -0
  22. mesa-2.3.0rc1/mesa/experimental/cell_space/discrete_space.py +64 -0
  23. mesa-2.3.0rc1/mesa/experimental/cell_space/grid.py +204 -0
  24. mesa-2.3.0rc1/mesa/experimental/cell_space/network.py +40 -0
  25. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/experimental/components/altair.py +13 -1
  26. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/experimental/components/matplotlib.py +3 -0
  27. mesa-2.3.0rc1/mesa/experimental/devs/__init__.py +4 -0
  28. mesa-2.3.0rc1/mesa/experimental/devs/eventlist.py +166 -0
  29. mesa-2.3.0rc1/mesa/experimental/devs/examples/epstein_civil_violence.py +273 -0
  30. {mesa-2.3.0.dev0/benchmarks/WolfSheep → mesa-2.3.0rc1/mesa/experimental/devs/examples}/wolf_sheep.py +57 -28
  31. mesa-2.3.0rc1/mesa/experimental/devs/simulator.py +293 -0
  32. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/experimental/jupyter_viz.py +51 -31
  33. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/model.py +2 -4
  34. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/space.py +26 -13
  35. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/time.py +3 -110
  36. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/pyproject.toml +44 -40
  37. mesa-2.3.0rc1/tests/test_cell_space.py +465 -0
  38. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_datacollector.py +1 -0
  39. mesa-2.3.0rc1/tests/test_devs.py +282 -0
  40. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_examples.py +2 -2
  41. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_grid.py +11 -10
  42. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_jupyter_viz.py +49 -45
  43. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_space.py +24 -24
  44. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_time.py +0 -115
  45. mesa-2.3.0.dev0/CODE_OF_CONDUCT.md +0 -46
  46. mesa-2.3.0.dev0/benchmarks/Schelling/schelling.py +0 -86
  47. mesa-2.3.0.dev0/mesa/experimental/__init__.py +0 -1
  48. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/.codespellignore +0 -0
  49. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/.coveragerc +0 -0
  50. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/.github/ISSUE_TEMPLATE/asking-help.md +0 -0
  51. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/.github/ISSUE_TEMPLATE/bug-report.md +0 -0
  52. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/.github/ISSUE_TEMPLATE/feature-request.md +0 -0
  53. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/.github/dependabot.yml +0 -0
  54. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/.github/release.yml +0 -0
  55. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/.github/workflows/benchmarks.yml +0 -0
  56. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/.gitignore +0 -0
  57. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/.readthedocs.yml +0 -0
  58. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/CITATION.bib +0 -0
  59. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/CONTRIBUTING.md +0 -0
  60. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/Dockerfile +0 -0
  61. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/LICENSE +0 -0
  62. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/benchmarks/Flocking/__init__.py +0 -0
  63. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/benchmarks/Schelling/__init__.py +0 -0
  64. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/benchmarks/WolfSheep/__init__.py +0 -0
  65. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/benchmarks/compare_timings.py +0 -0
  66. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/benchmarks/configurations.py +0 -0
  67. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/codecov.yaml +0 -0
  68. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docker-compose.yml +0 -0
  69. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/Makefile +0 -0
  70. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/README.md +0 -0
  71. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/apis/api_main.md +0 -0
  72. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/apis/batchrunner.md +0 -0
  73. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/apis/datacollection.md +0 -0
  74. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/apis/init.md +0 -0
  75. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/apis/space.md +0 -0
  76. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/apis/time.md +0 -0
  77. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/apis/visualization.md +0 -0
  78. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/best-practices.md +0 -0
  79. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/conf.py +0 -0
  80. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/howto.md +0 -0
  81. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/Mesa_Screenshot.png +0 -0
  82. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/mesa_logo.ico +0 -0
  83. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/mesa_logo.png +0 -0
  84. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/tutorial/br_ginis.png +0 -0
  85. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/tutorial/dc_endwealth.png +0 -0
  86. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/tutorial/dc_gini.png +0 -0
  87. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/tutorial/dc_oneagent.png +0 -0
  88. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/tutorial/first_hist.png +0 -0
  89. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/tutorial/multirun_hist.png +0 -0
  90. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/tutorial/numpy_grid.png +0 -0
  91. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/tutorial/viz_chart.png +0 -0
  92. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/tutorial/viz_empty.png +0 -0
  93. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/tutorial/viz_greycircles.png +0 -0
  94. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/tutorial/viz_histogram.png +0 -0
  95. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/images/tutorial/viz_redcircles.png +0 -0
  96. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/make.bat +0 -0
  97. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/mesa.md +0 -0
  98. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/mesa.visualization.md +0 -0
  99. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/mesa.visualization.modules.md +0 -0
  100. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/modular-visualization.md +0 -0
  101. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/overview.md +0 -0
  102. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/packages.md +0 -0
  103. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/tutorials/MoneyModel.py +0 -0
  104. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/tutorials/adv_tutorial_legacy.ipynb +0 -0
  105. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/tutorials/files/viz_chart.png +0 -0
  106. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/tutorials/files/viz_empty.png +0 -0
  107. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/tutorials/files/viz_greycircles.png +0 -0
  108. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/tutorials/files/viz_histogram.png +0 -0
  109. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/tutorials/files/viz_redcircles.png +0 -0
  110. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/tutorials/files/viz_slider.png +0 -0
  111. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/docs/tutorials/visualization_tutorial.ipynb +0 -0
  112. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/batchrunner.py +0 -0
  113. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/cookiecutter-mesa/cookiecutter.json +0 -0
  114. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/cookiecutter-mesa/hooks/post_gen_project.py +0 -0
  115. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/README.md +0 -0
  116. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/run.pytemplate +0 -0
  117. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/setup.pytemplate +0 -0
  118. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/__init__.py +0 -0
  119. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/model.pytemplate +0 -0
  120. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/cookiecutter-mesa/{{cookiecutter.snake}}/{{cookiecutter.snake}}/server.pytemplate +0 -0
  121. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/experimental/UserParam.py +0 -0
  122. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/flat/__init__.py +0 -0
  123. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/flat/visualization.py +0 -0
  124. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/main.py +0 -0
  125. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/visualization/ModularVisualization.py +0 -0
  126. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/visualization/TextVisualization.py +0 -0
  127. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/visualization/UserParam.py +0 -0
  128. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/visualization/__init__.py +0 -0
  129. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mesa/visualization/modules.py +0 -0
  130. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/mypy.ini +0 -0
  131. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/__init__.py +0 -0
  132. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/read_requirements.py +0 -0
  133. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_agent.py +0 -0
  134. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_batch_run.py +0 -0
  135. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_end_to_end_viz.sh +0 -0
  136. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_import_namespace.py +0 -0
  137. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_lifespan.py +0 -0
  138. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_main.py +0 -0
  139. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_model.py +0 -0
  140. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_scaffold.py +0 -0
  141. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_tornado.py +0 -0
  142. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_usersettableparam.py +0 -0
  143. {mesa-2.3.0.dev0 → mesa-2.3.0rc1}/tests/test_visualization.py +0 -0
@@ -7,11 +7,9 @@ on:
7
7
  - release**
8
8
  paths-ignore:
9
9
  - '**.md'
10
- - '**.rst'
11
10
  pull_request:
12
11
  paths-ignore:
13
12
  - '**.md'
14
- - '**.rst'
15
13
 
16
14
  # This will cancel previous run if a newer job that obsoletes the said previous
17
15
  # run, is started.
@@ -48,30 +46,12 @@ jobs:
48
46
  uses: actions/setup-python@v5
49
47
  with:
50
48
  python-version: ${{ matrix.python-version }}
51
- - if: ${{ runner.os == 'Windows' }}
52
- # This is needed so that restoring cache on Windows is fast.
53
- # See until https://github.com/actions/cache/issues/752 is resolved.
54
- name: Use GNU tar
55
- shell: cmd
56
- run: |
57
- echo "Adding GNU tar to PATH"
58
- echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%"
59
- - uses: actions/cache@v4
60
- with:
61
- path: ${{ env.pythonLocation }}
62
- key: ${{ runner.os }}-pip-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
63
- - name: Install dependencies
64
- # Only if the cache misses
65
- # Based on https://github.com/pypa/pip/issues/8049#issuecomment-633845028
66
- # read_requirements.py should be removed once
67
- # https://github.com/pypa/pip/issues/11440 is resolved.
68
- if: steps.cache.outputs.cache-hit != 'true'
69
- run: |
70
- pip install toml
71
- python tests/read_requirements.py > requirements.txt
72
- pip install -r requirements.txt
49
+ cache: 'pip'
50
+ - name: Install uv
51
+ run: pip install uv
73
52
  - name: Install Mesa
74
- run: pip install --no-deps .
53
+ # See https://github.com/astral-sh/uv/issues/1945
54
+ run: uv pip install --system .[dev]
75
55
  - name: Test with pytest
76
56
  run: pytest --durations=10 --cov=mesa tests/ --cov-report=xml
77
57
  - if: matrix.os == 'ubuntu'
@@ -86,22 +66,11 @@ jobs:
86
66
  uses: actions/setup-python@v5
87
67
  with:
88
68
  python-version: "3.12"
89
- - uses: actions/cache@v4
90
- with:
91
- path: ${{ env.pythonLocation }}
92
- key: test-examples-pip-${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}
93
- - name: Install dependencies
94
- # Only if the cache misses
95
- # Based on https://github.com/pypa/pip/issues/8049#issuecomment-633845028
96
- # read_requirements.py should be removed once
97
- # https://github.com/pypa/pip/issues/11440 is resolved.
98
- if: steps.cache.outputs.cache-hit != 'true'
99
- run: |
100
- pip install toml
101
- python tests/read_requirements.py > requirements.txt
102
- pip install -r requirements.txt
69
+ cache: 'pip'
70
+ - name: Install uv
71
+ run: pip install uv
103
72
  - name: Install Mesa
104
- run: pip install --no-deps .
73
+ run: uv pip install --system .[dev]
105
74
  - name: Checkout mesa-examples
106
75
  uses: actions/checkout@v4
107
76
  with:
@@ -31,6 +31,7 @@ jobs:
31
31
  uses: actions/setup-python@v5
32
32
  with:
33
33
  python-version: "3.12"
34
+ cache: 'pip'
34
35
  - name: Install dependencies
35
36
  run: pip install -U pip hatch
36
37
  - name: Build distributions
@@ -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.2.0
7
+ rev: v0.3.5
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.15.0
17
+ rev: v3.15.2
18
18
  hooks:
19
19
  - id: pyupgrade
20
20
  args: [--py38-plus]
@@ -0,0 +1,131 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ * Demonstrating empathy and kindness toward other people
21
+ * Being respectful of differing opinions, viewpoints, and experiences
22
+ * Giving and gracefully accepting constructive feedback
23
+ * Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ * Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ * The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ * Trolling, insulting or derogatory comments, and personal or political attacks
33
+ * Public or private harassment
34
+ * Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ * Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official email address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at [@jackiekazil](https://matrix.to/#/@jackiekazil:matrix.org) and/or [@edgeofchaos](https://matrix.to/#/@edgeofchaos:matrix.org). Violations posted as Github comments, discussion, etc maybe also be reported via the [report functionality](https://docs.github.com/en/communities/maintaining-your-safety-on-github/reporting-abuse-or-spam)
63
+ All complaints will be reviewed and investigated promptly and fairly.
64
+
65
+ All community leaders are obligated to respect the privacy and security of the
66
+ reporter of any incident.
67
+
68
+ ## Enforcement Guidelines
69
+
70
+ Community leaders will follow these Community Impact Guidelines in determining
71
+ the consequences for any action they deem in violation of this Code of Conduct:
72
+
73
+ ### 1. Correction
74
+
75
+ **Community Impact**: Use of inappropriate language or other behavior deemed
76
+ unprofessional or unwelcome in the community.
77
+
78
+ **Consequence**: A private, written warning from community leaders, providing
79
+ clarity around the nature of the violation and an explanation of why the
80
+ behavior was inappropriate. A public apology may be requested.
81
+
82
+ ### 2. Warning
83
+
84
+ **Community Impact**: A violation through a single incident or series of
85
+ actions.
86
+
87
+ **Consequence**: A warning with consequences for continued behavior. No
88
+ interaction with the people involved, including unsolicited interaction with
89
+ those enforcing the Code of Conduct, for a specified period of time. This
90
+ includes avoiding interactions in community spaces as well as external channels
91
+ like social media. Violating these terms may lead to a temporary or permanent
92
+ ban.
93
+
94
+ ### 3. Temporary Ban
95
+
96
+ **Community Impact**: A serious violation of community standards, including
97
+ sustained inappropriate behavior.
98
+
99
+ **Consequence**: A temporary ban from any sort of interaction or public
100
+ communication with the community for a specified period of time. No public or
101
+ private interaction with the people involved, including unsolicited interaction
102
+ with those enforcing the Code of Conduct, is allowed during this period.
103
+ Violating these terms may lead to a permanent ban.
104
+
105
+ ### 4. Permanent Ban
106
+
107
+ **Community Impact**: Demonstrating a pattern of violation of community
108
+ standards, including sustained inappropriate behavior, harassment of an
109
+ individual, or aggression toward or disparagement of classes of individuals.
110
+
111
+ **Consequence**: A permanent ban from any sort of public interaction within the
112
+ community.
113
+
114
+ ## Attribution
115
+
116
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
117
+ version 2.1, available at
118
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
119
+
120
+ Community Impact Guidelines were inspired by
121
+ [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
122
+
123
+ For answers to common questions about this code of conduct, see the FAQ at
124
+ [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
125
+ [https://www.contributor-covenant.org/translations][translations].
126
+
127
+ [homepage]: https://www.contributor-covenant.org
128
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
129
+ [Mozilla CoC]: https://github.com/mozilla/diversity
130
+ [FAQ]: https://www.contributor-covenant.org/faq
131
+ [translations]: https://www.contributor-covenant.org/translations
@@ -1,6 +1,121 @@
1
1
  ---
2
2
  title: Release History
3
3
  ---
4
+ # 2.3.0-rc1 (2024-04-18)
5
+ ## Highlights
6
+ The 2.3.0-rc1 release is our first release candidate pre-release, meant to test all the new features and enhancement for the upcoming 2.3.0 release.
7
+
8
+ There are two main new features:
9
+ - The experimental cell-centric discrete spaces, as added in #1994. It allows having cells with not only properties but also active behaviors: the `CellAgent`. Its inspired by NetLogo's [patches](https://ccl.northwestern.edu/netlogo/bind/primitive/patches.html) but extend and generalize this concept further.
10
+ - Full support for discrete event scheduling, as added in #2066. It allows scheduling events (like Agent actions) at any time, including non-integer timesteps.
11
+
12
+ There are a lot of other features: The Jupyter visualisation now supports easier way to specify sliders, `NetworkGrid.get_neighbors()` supports a radius, `AgentSet.get()` can retrieve multiple attributes and there are now benchmarks to track Mesa performance during development.
13
+
14
+ Finally, 2.3.0 stabilizes the `AgentSet` (including `model.agents`), making it the first experimental Mesa feature that is taken out of it's experimental phase.
15
+
16
+ Install this pre-release with:
17
+ ```
18
+ pip install --pre mesa
19
+ ```
20
+ We would love feedback before we release 2.3.0 stable in ~1 week.
21
+
22
+ ## What's Changed
23
+ ### 🧪 Experimental features
24
+ * Add cell-centric discrete spaces (experimental) by @Corvince in https://github.com/projectmesa/mesa/pull/1994
25
+ ### 🎉 New features added
26
+ * Add performance benchmarking scripts by @EwoutH in https://github.com/projectmesa/mesa/pull/1979
27
+ * feat: Implement Slider class for JupyterViz by @rht in https://github.com/projectmesa/mesa/pull/1972
28
+ * Stabilize AgentSet by @EwoutH in https://github.com/projectmesa/mesa/pull/2065
29
+ * Support discrete event scheduling by @quaquel in https://github.com/projectmesa/mesa/pull/2066
30
+ ### 🛠 Enhancements made
31
+ * JupyterViz: Automatically deduce display name from model class by @rht in https://github.com/projectmesa/mesa/pull/1975
32
+ * Add radius argument to NetworkGrid.get_neighbors() by @EwoutH in https://github.com/projectmesa/mesa/pull/1973
33
+ * Speedup of Agentset.shuffle by @quaquel in https://github.com/projectmesa/mesa/pull/2010
34
+ * feat: Let mesa runserver detect server.py as fallback by @rht in https://github.com/projectmesa/mesa/pull/2015
35
+ * JupyterViz: {Convert make_plot & prepare ColorCard} to become Solara component by @rht in https://github.com/projectmesa/mesa/pull/2020
36
+ * new feature: AgentSet.get can retrieve one or more then one attribute by @quaquel in https://github.com/projectmesa/mesa/pull/2044
37
+ * Update CODE_OF_CONDUCT.md to version 2+ of contrib convenant by @jackiekazil in https://github.com/projectmesa/mesa/pull/2052
38
+ * Improve flocking benchmark by @coderbeta1 in https://github.com/projectmesa/mesa/pull/2054
39
+ * Remove JupyterViz Altair marker overlap for huge grid size by @rht in https://github.com/projectmesa/mesa/pull/2062
40
+ * Add tooltip option to Altair chart by @FoFFolo in https://github.com/projectmesa/mesa/pull/2082
41
+ * feat: Display model seed & allow user to specify it in JupyterViz by @rht in https://github.com/projectmesa/mesa/pull/2069
42
+ * warn if placing already placed agent by @puer-robustus in https://github.com/projectmesa/mesa/pull/2083
43
+ ### 🐛 Bugs fixed
44
+ * fix: Apply default value to slider by @rht in https://github.com/projectmesa/mesa/pull/2016
45
+ * fix: Initialize model _steps and _time during __new__ by @rht in https://github.com/projectmesa/mesa/pull/2026
46
+ * fix: Use model.schedule only when it is not None by @rht in https://github.com/projectmesa/mesa/pull/2050
47
+ * fix: Remove JupyterViz grid marker overlap for huge grid size by @rht in https://github.com/projectmesa/mesa/pull/2049
48
+ ### 📜 Documentation improvements
49
+ * Improve readability of badges by @rht in https://github.com/projectmesa/mesa/pull/2009
50
+ * More pythonic implementation of wolf sheep by @quaquel in https://github.com/projectmesa/mesa/pull/2011
51
+ * Adding super().__init__() to MoneyModel tutorial by @sw23 in https://github.com/projectmesa/mesa/pull/2025
52
+ * docs: Convert howto.rst -> howto.md via rst2myst by @rht in https://github.com/projectmesa/mesa/pull/2033
53
+ * docs: Convert best-practices,overview,packages,mesa,index to .md via rst2myst by @rht in https://github.com/projectmesa/mesa/pull/2034
54
+ * docs: Convert api/*.rst -> api/*.md via rst2myst by @rht in https://github.com/projectmesa/mesa/pull/2035
55
+ * docs: Rewrite howto.md using ChatGPT for clarity and conciseness by @rht in https://github.com/projectmesa/mesa/pull/2037
56
+ * docs: Corrected Contributing Guide Link to Ensure Accessibility by @sahusiddharth in https://github.com/projectmesa/mesa/pull/2057
57
+ * Rename links to internal .rst files to .md by @rht in https://github.com/projectmesa/mesa/pull/2058
58
+ * docs: improve introductory tutorial by @puer-robustus in https://github.com/projectmesa/mesa/pull/2087
59
+ ### 🔧 Maintenance
60
+ * Quality of Life: Make codecov less meticulous by @Corvince in https://github.com/projectmesa/mesa/pull/1966
61
+ * Add CI workflow for performance benchmarks by @EwoutH in https://github.com/projectmesa/mesa/pull/1983
62
+ * tests: Resolve warnings by defining PropertyLayer dtypes by @EwoutH in https://github.com/projectmesa/mesa/pull/1987
63
+ * benchmarks.yml: Fix PR branch checkout when triggered by comment by @EwoutH in https://github.com/projectmesa/mesa/pull/1998
64
+ * Quality of life: automatically fix ruff errors by @Corvince in https://github.com/projectmesa/mesa/pull/2004
65
+ * benchmarks.yml: Run on addition of label instead of comment by @EwoutH in https://github.com/projectmesa/mesa/pull/2002
66
+ * ci: Move codespell to pre-commit by @rht in https://github.com/projectmesa/mesa/pull/2040
67
+ * Schelling by @coderbeta1 in https://github.com/projectmesa/mesa/pull/2053
68
+ * Move ruff lint settings into dedicated section by @Corvince in https://github.com/projectmesa/mesa/pull/2073
69
+ * ci: Use uv pip for faster build by @rht in https://github.com/projectmesa/mesa/pull/2038
70
+ * test: Remove place_agent duplicate warnings by @rht in https://github.com/projectmesa/mesa/pull/2086
71
+ ### Other changes
72
+ * Minor edits to benchmarking code by @quaquel in https://github.com/projectmesa/mesa/pull/1985
73
+ * build(deps): bump codecov/codecov-action from 3 to 4 by @dependabot in https://github.com/projectmesa/mesa/pull/2030
74
+ * [pre-commit.ci] pre-commit autoupdate by @pre-commit-ci in https://github.com/projectmesa/mesa/pull/2029
75
+ * tests: Speed up test_batch_run by @rht in https://github.com/projectmesa/mesa/pull/2039
76
+ * Update benchmarks.yml by @Corvince in https://github.com/projectmesa/mesa/pull/2043
77
+ * docs: Convert visualization .rst -> .md via rst2myst by @rht in https://github.com/projectmesa/mesa/pull/2036
78
+ * docs: Convert CONTRIBUTING .rst -> .md via rst2myst by @rht in https://github.com/projectmesa/mesa/pull/2041
79
+ * Correct wolf energy gained from eating sheep by @JackAtOmenApps in https://github.com/projectmesa/mesa/pull/2048
80
+ * feat: Implement Altair version of grid visualization by @rht in https://github.com/projectmesa/mesa/pull/1991
81
+
82
+ ## New Contributors
83
+ * @sw23 made their first contribution in https://github.com/projectmesa/mesa/pull/2025
84
+ * @JackAtOmenApps made their first contribution in https://github.com/projectmesa/mesa/pull/2048
85
+ * @coderbeta1 made their first contribution in https://github.com/projectmesa/mesa/pull/2054
86
+ * @sahusiddharth made their first contribution in https://github.com/projectmesa/mesa/pull/2057
87
+ * @FoFFolo made their first contribution in https://github.com/projectmesa/mesa/pull/2082
88
+ * @puer-robustus made their first contribution in https://github.com/projectmesa/mesa/pull/2083
89
+
90
+ **Full Changelog**: https://github.com/projectmesa/mesa/compare/v2.2.4...2.3.0-rc1
91
+
92
+ # 2.2.4 (2024-01-26)
93
+ ## Highlights
94
+ Mesa v2.2.4 is a small but important bugfix release for the 2.2 release series. It fixes an essential bug in where agents weren't shuffled in the `BaseScheduler`, affecting mainly the `RandomActivation` scheduler (effectively making it sequential activation)([#2007](https://github.com/projectmesa/mesa/pull/2007)). It also fixes a small behaviour change in `RandomActivationByType.agents_by_type()` ([#1996](https://github.com/projectmesa/mesa/pull/1996)). Furthermore, this release adds an internal clock to the `Model`, which allows to use a Mesa model without a scheduler (using the `AgentSet` API)([#1942](https://github.com/projectmesa/mesa/pull/1942)).
95
+
96
+ Updating from previous 2.2 releases is highly recommended, especially when using the `RandomActivation` scheduler.
97
+
98
+ ## What's Changed
99
+ ### 🛠 Enhancements made
100
+ * refactor: Remove dependence on model.schedule, add clock to Model by @rht in https://github.com/projectmesa/mesa/pull/1942
101
+ ### 🐛 Bugs fixed
102
+ * Fix AgentSet inplace shuffle (and thus RandomActivation), add tests by @EwoutH and @quaquel in https://github.com/projectmesa/mesa/pull/2007
103
+ * fix: Reverse dict key and value for agents_by_type by @rht in https://github.com/projectmesa/mesa/pull/1996
104
+
105
+ **Full Changelog**: https://github.com/projectmesa/mesa/compare/v2.2.3...v2.2.4
106
+
107
+ # 2.2.3 (2024-01-22)
108
+ ## Highlights
109
+ Mesa 2.2.3 is a small release with two improvements to the experimental Solara visualisation, on request of one of our contributors. No stable features have changed.
110
+
111
+ ## What's Changed
112
+ ### 🧪 Experimental features
113
+ * solara_viz: Add borders around ContinuousSpace by @EwoutH in https://github.com/projectmesa/mesa/pull/1988
114
+ ### 🐛 Bugs fixed
115
+ * fix: Explicitly specify JupyterViz space view limits by @rht in https://github.com/projectmesa/mesa/pull/1984
116
+
117
+ **Full Changelog**: https://github.com/projectmesa/mesa/compare/v2.2.2...v2.2.3
118
+
4
119
  # 2.2.2 (2024-01-22)
5
120
 
6
121
  ## Highlights
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: Mesa
3
- Version: 2.3.0.dev0
3
+ Version: 2.3.0rc1
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
@@ -34,6 +34,7 @@ Requires-Dist: tqdm
34
34
  Provides-Extra: dev
35
35
  Requires-Dist: coverage; extra == 'dev'
36
36
  Requires-Dist: pytest-cov; extra == 'dev'
37
+ Requires-Dist: pytest-mock; extra == 'dev'
37
38
  Requires-Dist: pytest>=4.6; extra == 'dev'
38
39
  Requires-Dist: ruff~=0.1.1; extra == 'dev'
39
40
  Requires-Dist: sphinx; extra == 'dev'
@@ -162,7 +163,7 @@ If you would like to add a feature, please reach out via [ticket](https://github
162
163
  join a dev session (see [Mesa discussions](https://github.com/projectmesa/mesa/discussions)). A feature is most likely
163
164
  to be added if you build it!
164
165
 
165
- Don't forget to checkout the [Contributors guide](https://github.com/projectmesa/mesa/blob/main/CONTRIBUTING.rst).
166
+ Don't forget to checkout the [Contributors guide](https://github.com/projectmesa/mesa/blob/main/CONTRIBUTING.md).
166
167
 
167
168
  ## Citing Mesa
168
169
 
@@ -114,7 +114,7 @@ If you would like to add a feature, please reach out via [ticket](https://github
114
114
  join a dev session (see [Mesa discussions](https://github.com/projectmesa/mesa/discussions)). A feature is most likely
115
115
  to be added if you build it!
116
116
 
117
- Don't forget to checkout the [Contributors guide](https://github.com/projectmesa/mesa/blob/main/CONTRIBUTING.rst).
117
+ Don't forget to checkout the [Contributors guide](https://github.com/projectmesa/mesa/blob/main/CONTRIBUTING.md).
118
118
 
119
119
  ## Citing Mesa
120
120
 
@@ -20,7 +20,7 @@ class Boid(mesa.Agent):
20
20
  - Alignment: try to fly in the same direction as the neighbors.
21
21
 
22
22
  Boids have a vision that defines the radius in which they look for their
23
- neighbors to flock with. Their speed (a scalar) and velocity (a vector)
23
+ neighbors to flock with. Their speed (a scalar) and direction (a vector)
24
24
  define their movement. Separation is their desired minimum distance from
25
25
  any other Boid.
26
26
  """
@@ -29,9 +29,8 @@ class Boid(mesa.Agent):
29
29
  self,
30
30
  unique_id,
31
31
  model,
32
- pos,
33
32
  speed,
34
- velocity,
33
+ direction,
35
34
  vision,
36
35
  separation,
37
36
  cohere=0.03,
@@ -43,20 +42,18 @@ class Boid(mesa.Agent):
43
42
 
44
43
  Args:
45
44
  unique_id: Unique agent identifier.
46
- pos: Starting position
47
45
  speed: Distance to move per step.
48
- heading: numpy vector for the Boid's direction of movement.
46
+ direction: numpy vector for the Boid's direction of movement.
49
47
  vision: Radius to look around for nearby Boids.
50
48
  separation: Minimum distance to maintain from other Boids.
51
49
  cohere: the relative importance of matching neighbors' positions
52
50
  separate: the relative importance of avoiding close neighbors
53
- match: the relative importance of matching neighbors' headings
51
+ match: the relative importance of matching neighbors' directions
54
52
 
55
53
  """
56
54
  super().__init__(unique_id, model)
57
- self.pos = np.array(pos)
58
55
  self.speed = speed
59
- self.velocity = velocity
56
+ self.direction = direction
60
57
  self.vision = vision
61
58
  self.separation = separation
62
59
  self.cohere_factor = cohere
@@ -77,14 +74,14 @@ class Boid(mesa.Agent):
77
74
  cohere += heading
78
75
  if self.model.space.get_distance(self.pos, neighbor.pos) < self.separation:
79
76
  separation_vector -= heading
80
- match_vector += neighbor.velocity
77
+ match_vector += neighbor.direction
81
78
  n = max(n, 1)
82
79
  cohere = cohere * self.cohere_factor
83
80
  separation_vector = separation_vector * self.separate_factor
84
81
  match_vector = match_vector * self.match_factor
85
- self.velocity += (cohere + separation_vector + match_vector) / n
86
- self.velocity /= np.linalg.norm(self.velocity)
87
- new_pos = self.pos + self.velocity * self.speed
82
+ self.direction += (cohere + separation_vector + match_vector) / n
83
+ self.direction /= np.linalg.norm(self.direction)
84
+ new_pos = self.pos + self.direction * self.speed
88
85
  self.model.space.move_agent(self, new_pos)
89
86
 
90
87
 
@@ -95,16 +92,17 @@ class BoidFlockers(mesa.Model):
95
92
 
96
93
  def __init__(
97
94
  self,
98
- seed,
99
- population,
100
- width,
101
- height,
102
- vision,
95
+ seed=None,
96
+ population=100,
97
+ width=100,
98
+ height=100,
99
+ vision=10,
103
100
  speed=1,
104
101
  separation=1,
105
102
  cohere=0.03,
106
103
  separate=0.015,
107
104
  match=0.05,
105
+ simulator=None,
108
106
  ):
109
107
  """
110
108
  Create a new Flockers model.
@@ -117,34 +115,35 @@ class BoidFlockers(mesa.Model):
117
115
  separation: What's the minimum distance each Boid will attempt to
118
116
  keep from any other
119
117
  cohere, separate, match: factors for the relative importance of
120
- the three drives."""
118
+ the three drives.
119
+ """
121
120
  super().__init__(seed=seed)
122
121
  self.population = population
123
- self.vision = vision
124
- self.speed = speed
125
- self.separation = separation
122
+ self.width = width
123
+ self.height = height
124
+ self.simulator = simulator
125
+
126
126
  self.schedule = mesa.time.RandomActivation(self)
127
- self.space = mesa.space.ContinuousSpace(width, height, True)
128
- self.factors = {"cohere": cohere, "separate": separate, "match": match}
129
- self.make_agents()
127
+ self.space = mesa.space.ContinuousSpace(self.width, self.height, True)
128
+ self.factors = {
129
+ "cohere": cohere,
130
+ "separate": separate,
131
+ "match": match,
132
+ }
130
133
 
131
- def make_agents(self):
132
- """
133
- Create self.population agents, with random positions and starting headings.
134
- """
135
134
  for i in range(self.population):
136
135
  x = self.random.random() * self.space.x_max
137
136
  y = self.random.random() * self.space.y_max
138
137
  pos = np.array((x, y))
139
- velocity = np.random.random(2) * 2 - 1
138
+ direction = np.random.random(2) * 2 - 1
140
139
  boid = Boid(
141
- i,
142
- self,
143
- pos,
144
- self.speed,
145
- velocity,
146
- self.vision,
147
- self.separation,
140
+ unique_id=i,
141
+ model=self,
142
+ pos=pos,
143
+ speed=speed,
144
+ direction=direction,
145
+ vision=vision,
146
+ separation=separation,
148
147
  **self.factors,
149
148
  )
150
149
  self.space.place_agent(boid, pos)
@@ -157,8 +156,8 @@ class BoidFlockers(mesa.Model):
157
156
  if __name__ == "__main__":
158
157
  import time
159
158
 
160
- # model = BoidFlockers(15, 200, 100, 100, 5)
161
- model = BoidFlockers(15, 400, 100, 100, 15)
159
+ # model = BoidFlockers(seed=15, population=200, width=100, height=100, vision=5)
160
+ model = BoidFlockers(seed=15, population=400, width=100, height=100, vision=15)
162
161
 
163
162
  start_time = time.perf_counter()
164
163
  for _ in range(100):
@@ -0,0 +1,109 @@
1
+ from mesa import Model
2
+ from mesa.experimental.cell_space import CellAgent, OrthogonalMooreGrid
3
+ from mesa.time import RandomActivation
4
+
5
+
6
+ class SchellingAgent(CellAgent):
7
+ """
8
+ Schelling segregation agent
9
+ """
10
+
11
+ def __init__(self, unique_id, model, agent_type, radius, homophily):
12
+ """
13
+ Create a new Schelling agent.
14
+ 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)
18
+ """
19
+ super().__init__(unique_id, model)
20
+ self.type = agent_type
21
+ self.radius = radius
22
+ self.homophily = homophily
23
+
24
+ def step(self):
25
+ similar = 0
26
+ neighborhood = self.cell.neighborhood(radius=self.radius)
27
+ for neighbor in neighborhood.agents:
28
+ if neighbor.type == self.type:
29
+ similar += 1
30
+
31
+ # If unhappy, move:
32
+ if similar < self.homophily:
33
+ self.move_to(self.model.grid.select_random_empty_cell())
34
+ else:
35
+ self.model.happy += 1
36
+
37
+
38
+ class Schelling(Model):
39
+ """
40
+ Model class for the Schelling segregation model.
41
+ """
42
+
43
+ def __init__(
44
+ self,
45
+ height=40,
46
+ width=40,
47
+ homophily=3,
48
+ radius=1,
49
+ density=0.8,
50
+ minority_pc=0.5,
51
+ seed=None,
52
+ simulator=None,
53
+ ):
54
+ """
55
+ Create a new Schelling model.
56
+
57
+ 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
61
+ homophily: Minimum number of agents of same class needed to be happy
62
+ radius: Search radius for checking similarity
63
+ seed: Seed for Reproducibility
64
+ """
65
+ super().__init__(seed=seed)
66
+ self.minority_pc = minority_pc
67
+ self.simulator = simulator
68
+
69
+ self.schedule = RandomActivation(self)
70
+ self.grid = OrthogonalMooreGrid(
71
+ [height, width],
72
+ torus=True,
73
+ capacity=1,
74
+ random=self.random,
75
+ )
76
+
77
+ # Set up agents
78
+ # We use a grid iterator that returns
79
+ # the coordinates of a cell as well as
80
+ # its contents. (coord_iter)
81
+ for cell in self.grid:
82
+ if self.random.random() < density:
83
+ 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
+ )
87
+ agent.move_to(cell)
88
+ self.schedule.add(agent)
89
+
90
+ def step(self):
91
+ """
92
+ Run one step of the model.
93
+ """
94
+ self.happy = 0 # Reset counter of happy agents
95
+ self.schedule.step()
96
+
97
+
98
+ if __name__ == "__main__":
99
+ import time
100
+
101
+ # model = Schelling(seed=15, height=40, width=40, homophily=3, radius=1, density=0.625)
102
+ model = Schelling(
103
+ seed=15, height=100, width=100, homophily=8, radius=2, density=0.8
104
+ )
105
+
106
+ start_time = time.perf_counter()
107
+ for _ in range(100):
108
+ model.step()
109
+ print(time.perf_counter() - start_time)