Mesa 3.0.0b2__tar.gz → 3.0.0rc0__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.
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.gitignore +2 -1
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.pre-commit-config.yaml +3 -3
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/PKG-INFO +1 -1
- mesa-3.0.0rc0/docs/apis/visualization.md +47 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/conf.py +13 -6
- mesa-3.0.0rc0/docs/examples_overview_template.txt +3 -0
- mesa-3.0.0rc0/docs/images/wolf_sheep.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/index.md +1 -2
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/migration_guide.md +8 -4
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/overview.md +8 -4
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/tutorials/MoneyModel.py +1 -1
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/tutorials/intro_tutorial.ipynb +2 -4
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/tutorials/visualization_tutorial.ipynb +97 -66
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/__init__.py +1 -1
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/batchrunner.py +26 -1
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/README.md +11 -11
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/epstein_civil_violence/agents.py +44 -38
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/epstein_civil_violence/app.py +29 -28
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/epstein_civil_violence/model.py +33 -65
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/pd_grid/app.py +8 -4
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/sugarscape_g1mt/app.py +5 -13
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/wolf_sheep/app.py +25 -18
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/boid_flockers/app.py +2 -2
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/boltzmann_wealth_model/app.py +14 -10
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/conways_game_of_life/app.py +15 -3
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/schelling/app.py +5 -5
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/virus_on_network/app.py +25 -47
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/space.py +0 -30
- mesa-3.0.0rc0/mesa/visualization/__init__.py +26 -0
- mesa-3.0.0rc0/mesa/visualization/components/__init__.py +83 -0
- mesa-3.0.0b2/mesa/visualization/components/altair.py → mesa-3.0.0rc0/mesa/visualization/components/altair_components.py +34 -2
- mesa-3.0.0rc0/mesa/visualization/components/matplotlib_components.py +176 -0
- mesa-3.0.0rc0/mesa/visualization/mpl_space_drawing.py +558 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/visualization/solara_viz.py +30 -20
- mesa-3.0.0rc0/tests/test_components_matplotlib.py +158 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/test_solara_viz.py +59 -11
- mesa-3.0.0b2/docs/apis/visualization.md +0 -21
- mesa-3.0.0b2/docs/examples.md +0 -14
- mesa-3.0.0b2/docs/examples_overview_template.txt +0 -10
- mesa-3.0.0b2/docs/howto.md +0 -122
- mesa-3.0.0b2/docs/images/wolf_scheep.png +0 -0
- mesa-3.0.0b2/mesa/visualization/__init__.py +0 -15
- mesa-3.0.0b2/mesa/visualization/components/matplotlib.py +0 -386
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.codespellignore +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.coveragerc +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.github/ISSUE_TEMPLATE/bug-report.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.github/ISSUE_TEMPLATE/feature-request.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.github/PULL_REQUEST_TEMPLATE/bug.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.github/PULL_REQUEST_TEMPLATE/feature.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.github/dependabot.yml +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.github/pull_request_template.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.github/release.yml +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.github/workflows/benchmarks.yml +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.github/workflows/build_lint.yml +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.github/workflows/release.yml +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/.readthedocs.yml +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/CITATION.bib +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/CODE_OF_CONDUCT.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/CONTRIBUTING.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/Dockerfile +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/HISTORY.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/LICENSE +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/NOTICE +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/README.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/benchmarks/BoltzmannWealth/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/benchmarks/BoltzmannWealth/boltzmann_wealth.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/benchmarks/Flocking/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/benchmarks/Flocking/flocking.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/benchmarks/Schelling/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/benchmarks/Schelling/schelling.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/benchmarks/WolfSheep/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/benchmarks/WolfSheep/wolf_sheep.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/benchmarks/compare_timings.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/benchmarks/configurations.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/benchmarks/global_benchmark.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/binder/environment.yml +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/codecov.yaml +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docker-compose.yml +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/Makefile +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/README.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/_static/switcher.json +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/apis/agent.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/apis/api_main.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/apis/batchrunner.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/apis/datacollection.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/apis/experimental.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/apis/model.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/apis/space.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/apis/time.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/best-practices.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/example_template.txt +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/images/mesa_logo.ico +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/images/mesa_logo.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/images/tutorial/br_ginis.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/images/tutorial/dc_endwealth.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/images/tutorial/dc_gini.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/images/tutorial/dc_oneagent.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/images/tutorial/first_hist.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/images/tutorial/multirun_hist.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/images/tutorial/numpy_grid.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/images/tutorial/viz_chart.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/images/tutorial/viz_empty.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/images/tutorial/viz_greycircles.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/images/tutorial/viz_histogram.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/images/tutorial/viz_redcircles.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/make.bat +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/mesa.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/packages.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/tutorials/files/viz_chart.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/tutorials/files/viz_empty.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/tutorials/files/viz_greycircles.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/tutorials/files/viz_histogram.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/tutorials/files/viz_redcircles.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/docs/tutorials/files/viz_slider.png +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/maintenance/fetch_unlabeled_prs.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/agent.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/datacollection.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/epstein_civil_violence/Epstein Civil Violence.ipynb +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/epstein_civil_violence/Readme.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/epstein_civil_violence/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/pd_grid/Readme.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/pd_grid/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/pd_grid/agents.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/pd_grid/analysis.ipynb +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/pd_grid/model.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/sugarscape_g1mt/Readme.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/sugarscape_g1mt/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/sugarscape_g1mt/agents.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/sugarscape_g1mt/model.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/sugarscape_g1mt/sugar-map.txt +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/sugarscape_g1mt/tests.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/wolf_sheep/Readme.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/wolf_sheep/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/wolf_sheep/agents.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/advanced/wolf_sheep/model.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/boid_flockers/Readme.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/boid_flockers/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/boid_flockers/agents.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/boid_flockers/model.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/boltzmann_wealth_model/Readme.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/boltzmann_wealth_model/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/boltzmann_wealth_model/agents.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/boltzmann_wealth_model/model.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/boltzmann_wealth_model/st_app.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/conways_game_of_life/Readme.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/conways_game_of_life/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/conways_game_of_life/agents.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/conways_game_of_life/model.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/conways_game_of_life/st_app.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/schelling/Readme.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/schelling/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/schelling/agents.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/schelling/analysis.ipynb +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/schelling/model.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/virus_on_network/Readme.md +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/virus_on_network/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/virus_on_network/agents.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/examples/basic/virus_on_network/model.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/UserParam.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/cell_space/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/cell_space/cell.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/cell_space/cell_agent.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/cell_space/cell_collection.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/cell_space/discrete_space.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/cell_space/grid.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/cell_space/network.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/cell_space/voronoi.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/components/altair.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/components/matplotlib.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/devs/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/devs/eventlist.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/devs/examples/epstein_civil_violence.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/devs/examples/wolf_sheep.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/devs/simulator.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/experimental/solara_viz.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/model.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/time.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/visualization/UserParam.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mesa/visualization/utils.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/mypy.ini +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/pyproject.toml +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/__init__.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/read_requirements.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/test_agent.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/test_batch_run.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/test_cell_space.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/test_datacollector.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/test_devs.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/test_end_to_end_viz.sh +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/test_examples.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/test_grid.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/test_import_namespace.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/test_lifespan.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/test_model.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/test_space.py +0 -0
- {mesa-3.0.0b2 → mesa-3.0.0rc0}/tests/test_time.py +0 -0
|
@@ -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.
|
|
7
|
+
rev: v0.7.2
|
|
8
8
|
hooks:
|
|
9
9
|
# Run the linter.
|
|
10
10
|
- id: ruff
|
|
@@ -14,12 +14,12 @@ repos:
|
|
|
14
14
|
- id: ruff-format
|
|
15
15
|
types_or: [ python, pyi, jupyter ]
|
|
16
16
|
- repo: https://github.com/asottile/pyupgrade
|
|
17
|
-
rev: v3.
|
|
17
|
+
rev: v3.19.0
|
|
18
18
|
hooks:
|
|
19
19
|
- id: pyupgrade
|
|
20
20
|
args: [--py310-plus]
|
|
21
21
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
22
|
-
rev:
|
|
22
|
+
rev: v5.0.0 # Use the ref you want to point at
|
|
23
23
|
hooks:
|
|
24
24
|
- id: trailing-whitespace
|
|
25
25
|
- id: check-toml
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Visualization
|
|
2
|
+
|
|
3
|
+
For a detailed tutorial, please refer to our [Visualization Tutorial](../tutorials/visualization_tutorial.ipynb).
|
|
4
|
+
|
|
5
|
+
## Jupyter Visualization
|
|
6
|
+
|
|
7
|
+
```{eval-rst}
|
|
8
|
+
.. automodule:: mesa.visualization.solara_viz
|
|
9
|
+
:members:
|
|
10
|
+
:undoc-members:
|
|
11
|
+
:show-inheritance:
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## User Parameters
|
|
15
|
+
|
|
16
|
+
```{eval-rst}
|
|
17
|
+
.. automodule:: mesa.visualization.UserParam
|
|
18
|
+
:members:
|
|
19
|
+
:undoc-members:
|
|
20
|
+
:show-inheritance:
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## Matplotlib-based visualizations
|
|
25
|
+
|
|
26
|
+
```{eval-rst}
|
|
27
|
+
.. automodule:: mesa.visualization.components.matplotlib_components
|
|
28
|
+
:members:
|
|
29
|
+
:undoc-members:
|
|
30
|
+
:show-inheritance:
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```{eval-rst}
|
|
34
|
+
.. automodule:: mesa.visualization.mpl_space_drawing
|
|
35
|
+
:members:
|
|
36
|
+
:undoc-members:
|
|
37
|
+
:show-inheritance:
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Altair-based visualizations
|
|
41
|
+
|
|
42
|
+
```{eval-rst}
|
|
43
|
+
.. automodule:: mesa.visualization.components.altair_components
|
|
44
|
+
:members:
|
|
45
|
+
:undoc-members:
|
|
46
|
+
:show-inheritance:
|
|
47
|
+
```
|
|
@@ -316,17 +316,20 @@ def setup_examples_pages():
|
|
|
316
316
|
# create md files for all examples
|
|
317
317
|
# check what examples exist
|
|
318
318
|
examples_folder = osp.abspath(osp.join(HERE, "..", "mesa", "examples"))
|
|
319
|
-
basic_examples = [f.path for f in os.scandir(osp.join(examples_folder, "basic")) if f.is_dir() and not f.name.startswith("__") ]
|
|
320
|
-
advanced_examples = [f.path for f in os.scandir(osp.join(examples_folder, "advanced")) if f.is_dir() and not f.name.startswith("__")]
|
|
319
|
+
basic_examples = [("basic", f.path) for f in os.scandir(osp.join(examples_folder, "basic")) if f.is_dir() and not f.name.startswith("__") ]
|
|
320
|
+
advanced_examples = [("advanced", f.path) for f in os.scandir(osp.join(examples_folder, "advanced")) if f.is_dir() and not f.name.startswith("__")]
|
|
321
321
|
examples = basic_examples + advanced_examples
|
|
322
322
|
|
|
323
323
|
with open(os.path.join(HERE, "example_template.txt")) as fh:
|
|
324
324
|
template = string.Template(fh.read())
|
|
325
325
|
|
|
326
|
-
pathlib.Path(os.path.join(HERE, "examples"))
|
|
326
|
+
root_folder = pathlib.Path(os.path.join(HERE, "examples"))
|
|
327
|
+
root_folder.mkdir(parents=True, exist_ok=True)
|
|
328
|
+
pathlib.Path(os.path.join(root_folder, "basic")).mkdir(parents=True, exist_ok=True)
|
|
329
|
+
pathlib.Path(os.path.join(root_folder, "advanced")).mkdir(parents=True, exist_ok=True)
|
|
327
330
|
|
|
328
331
|
examples_md = []
|
|
329
|
-
for example in examples:
|
|
332
|
+
for kind, example in examples:
|
|
330
333
|
base_name = os.path.basename(os.path.normpath(example))
|
|
331
334
|
|
|
332
335
|
agent_filename = os.path.join(example, "agents.py")
|
|
@@ -337,17 +340,21 @@ def setup_examples_pages():
|
|
|
337
340
|
md_filename = f"{base_name}.md"
|
|
338
341
|
examples_md.append(base_name)
|
|
339
342
|
|
|
340
|
-
md_filepath = os.path.join(HERE, "examples", md_filename)
|
|
343
|
+
md_filepath = os.path.join(HERE, "examples", kind, md_filename)
|
|
341
344
|
write_example_md_file(agent_filename, model_filename, readme_filename, app_filename, md_filepath, template)
|
|
342
345
|
|
|
343
346
|
# create overview of examples.md
|
|
344
347
|
with open(os.path.join(HERE, "examples_overview_template.txt")) as fh:
|
|
345
348
|
template = string.Template(fh.read())
|
|
346
349
|
|
|
350
|
+
with open(os.path.join(examples_folder, "README.md")) as fh:
|
|
351
|
+
readme_md = fh.read()
|
|
352
|
+
|
|
347
353
|
with open(os.path.join(HERE, "examples.md"), "w") as fh:
|
|
348
354
|
content = template.substitute(
|
|
349
355
|
dict(
|
|
350
|
-
|
|
356
|
+
readme=readme_md,
|
|
357
|
+
# examples="\n".join([f"{' '.join(base_name.split('_'))} </examples/{base_name}>" for base_name in examples_md]),
|
|
351
358
|
)
|
|
352
359
|
)
|
|
353
360
|
fh.write(content)
|
|
Binary file
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
Mesa allows users to quickly create agent-based models using built-in core components (such as spatial grids and agent schedulers) or customized implementations; visualize them using a browser-based interface; and analyze their results using Python's data analysis tools. Its goal is to be the Python-based counterpart to NetLogo, Repast, or MASON.
|
|
22
22
|
|
|
23
|
-

|
|
24
24
|
*A visualisation of the Wolf Sheep model build with Mesa.*
|
|
25
25
|
|
|
26
26
|
## Features
|
|
@@ -78,7 +78,6 @@ tutorials/visualization_tutorial
|
|
|
78
78
|
Examples <examples>
|
|
79
79
|
Migration guide <migration_guide>
|
|
80
80
|
Best Practices <best-practices>
|
|
81
|
-
How-to Guide <howto>
|
|
82
81
|
API Documentation <apis/api_main>
|
|
83
82
|
Mesa Packages <packages>
|
|
84
83
|
```
|
|
@@ -253,6 +253,8 @@ Ref: Original discussion [#1912](https://github.com/projectmesa/mesa/discussions
|
|
|
253
253
|
Mesa has adopted a new API for our frontend. If you already migrated to the experimental new SolaraViz you can still use
|
|
254
254
|
the import from mesa.experimental. Otherwise here is a list of things you need to change.
|
|
255
255
|
|
|
256
|
+
> **Note:** SolaraViz is experimental and still in active development for Mesa 3.0. While we attempt to minimize them, there might be API breaking changes between Mesa 3.0 and 3.1. There won't be breaking changes between Mesa 3.0.x patch releases.
|
|
257
|
+
|
|
256
258
|
#### Model Initialization
|
|
257
259
|
|
|
258
260
|
Previously SolaraViz was initialized by providing a `model_cls` and a `model_params`. This has changed to expect a model instance `model`. You can still provide (user-settable) `model_params`, but only if users should be able to change them. It is now also possible to pass in a "reactive model" by first calling `model = solara.reactive(model)`. This is useful for notebook environments. It allows you to pass the model to the SolaraViz Module, but continue to use the model. For example calling `model.value.step()` (notice the extra .value) will automatically update the plots. This currently only automatically works for the step method, you can force visualization updates by calling `model.value.force_update()`.
|
|
@@ -268,9 +270,9 @@ from mesa.experimental import SolaraViz
|
|
|
268
270
|
SolaraViz(model_cls, model_params, agent_portrayal=agent_portrayal)
|
|
269
271
|
|
|
270
272
|
# new
|
|
271
|
-
from mesa.visualization import SolaraViz,
|
|
273
|
+
from mesa.visualization import SolaraViz, make_space_component
|
|
272
274
|
|
|
273
|
-
SolaraViz(model, components=[
|
|
275
|
+
SolaraViz(model, components=[make_space_component(agent_portrayal)])
|
|
274
276
|
```
|
|
275
277
|
|
|
276
278
|
#### Plotting "measures"
|
|
@@ -281,15 +283,17 @@ SolaraViz(model, components=[make_space_matplotlib(agent_portrayal)])
|
|
|
281
283
|
# old
|
|
282
284
|
from mesa.experimental import SolaraViz
|
|
283
285
|
|
|
286
|
+
|
|
284
287
|
def make_plot(model):
|
|
285
288
|
...
|
|
286
289
|
|
|
290
|
+
|
|
287
291
|
SolaraViz(model_cls, model_params, measures=[make_plot, "foo", ["bar", "baz"]])
|
|
288
292
|
|
|
289
293
|
# new
|
|
290
|
-
from mesa.visualization import SolaraViz,
|
|
294
|
+
from mesa.visualization import SolaraViz, make_plot_component
|
|
291
295
|
|
|
292
|
-
SolaraViz(model, components=[make_plot,
|
|
296
|
+
SolaraViz(model, components=[make_plot, make_plot_component("foo"), make_plot_component("bar", "baz")])
|
|
293
297
|
```
|
|
294
298
|
|
|
295
299
|
#### Plotting text
|
|
@@ -167,12 +167,16 @@ The results are returned as a list of dictionaries, which can be easily converte
|
|
|
167
167
|
### Visualization
|
|
168
168
|
Mesa now uses a new browser-based visualization system called SolaraViz. This allows for interactive, customizable visualizations of your models. Here's a basic example of how to set up a visualization:
|
|
169
169
|
|
|
170
|
+
> **Note:** SolaraViz is experimental and still in active development for Mesa 3.0. While we attempt to minimize them, there might be API breaking changes between Mesa 3.0 and 3.1. There won't be breaking changes between Mesa 3.0.x patch releases.
|
|
171
|
+
|
|
170
172
|
```python
|
|
171
|
-
from mesa.visualization import SolaraViz,
|
|
173
|
+
from mesa.visualization import SolaraViz, make_space_component, make_plot_component
|
|
174
|
+
|
|
172
175
|
|
|
173
176
|
def agent_portrayal(agent):
|
|
174
177
|
return {"color": "blue", "size": 50}
|
|
175
178
|
|
|
179
|
+
|
|
176
180
|
model_params = {
|
|
177
181
|
"N": {
|
|
178
182
|
"type": "SliderInt",
|
|
@@ -181,14 +185,14 @@ model_params = {
|
|
|
181
185
|
"min": 10,
|
|
182
186
|
"max": 100,
|
|
183
187
|
"step": 1,
|
|
184
|
-
|
|
188
|
+
}
|
|
185
189
|
}
|
|
186
190
|
|
|
187
191
|
page = SolaraViz(
|
|
188
192
|
MyModel,
|
|
189
193
|
[
|
|
190
|
-
|
|
191
|
-
|
|
194
|
+
make_space_component(agent_portrayal),
|
|
195
|
+
make_plot_component("mean_age")
|
|
192
196
|
],
|
|
193
197
|
model_params=model_params
|
|
194
198
|
)
|
|
@@ -49,7 +49,7 @@ class MoneyAgent(mesa.Agent):
|
|
|
49
49
|
class MoneyModel(mesa.Model):
|
|
50
50
|
"""A model with some number of agents."""
|
|
51
51
|
|
|
52
|
-
def __init__(self, n, width, height, seed=None):
|
|
52
|
+
def __init__(self, n=10, width=10, height=10, seed=None):
|
|
53
53
|
"""Initialize a MoneyModel instance.
|
|
54
54
|
|
|
55
55
|
Args:
|
|
@@ -259,7 +259,7 @@
|
|
|
259
259
|
"\n",
|
|
260
260
|
"With the basics of the Agent class and Model class created we can no activate the agents to `do` things\n",
|
|
261
261
|
"\n",
|
|
262
|
-
"**Background:** Mesa's `do` function calls agent functions the grow your ABM. A step is the smallest unit of time in the model, and is often referred to as a tick. The `do` function and Python functionality can be configured to activate agents in different orders. This can be important as the order in which agents are activated can impact the results of the model [Comer2014]. At each step of the model, one or more of the agents -- usually all of them -- are activated and take their own step, changing internally and/or interacting with one another or the environment
|
|
262
|
+
"**Background:** Mesa's `do` function calls agent functions the grow your ABM. A step is the smallest unit of time in the model, and is often referred to as a tick. The `do` function and Python functionality can be configured to activate agents in different orders. This can be important as the order in which agents are activated can impact the results of the model [Comer2014]. At each step of the model, one or more of the agents -- usually all of them -- are activated and take their own step, changing internally and/or interacting with one another or the environment.\n",
|
|
263
263
|
"\n",
|
|
264
264
|
"**Model-specific information:** For this section we will randomly reorder the Agent activation order using `mesa.Agent.shuffle_do` and have the agents `step` function print the agent unique id they are assigned during the agent creation process. \n",
|
|
265
265
|
"\n",
|
|
@@ -1498,9 +1498,7 @@
|
|
|
1498
1498
|
{
|
|
1499
1499
|
"cell_type": "markdown",
|
|
1500
1500
|
"metadata": {},
|
|
1501
|
-
"source": [
|
|
1502
|
-
"**note for Windows OS users:** If you are running this tutorial in Jupyter, make sure that you set `number_processes = 1` (single process). If `number_processes` is greater than 1, it is less straightforward to set up. You can read [Mesa's how-to guide](https://github.com/projectmesa/mesa/blob/main/docs/howto.md), in 'Using multi-process `batch_run` on Windows' section for how to do it."
|
|
1503
|
-
]
|
|
1501
|
+
"source": "**note for Windows OS users:** If you are running this tutorial in Jupyter, make sure that you set `number_processes = 1` (single process). If `number_processes` is greater than 1, it is less straightforward to set up. For details on how to use multiprocessing on windows, see [multiprocessing's programming guidelines](https://docs.python.org/3/library/multiprocessing.html#multiprocessing-programming). "
|
|
1504
1502
|
},
|
|
1505
1503
|
{
|
|
1506
1504
|
"cell_type": "code",
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
{
|
|
4
4
|
"cell_type": "markdown",
|
|
5
5
|
"metadata": {},
|
|
6
|
-
"source":
|
|
7
|
-
"# Visualization Tutorial"
|
|
8
|
-
]
|
|
6
|
+
"source": "# Visualization Tutorial"
|
|
9
7
|
},
|
|
10
8
|
{
|
|
11
9
|
"cell_type": "markdown",
|
|
@@ -13,6 +11,8 @@
|
|
|
13
11
|
"source": [
|
|
14
12
|
"*This version of the visualisation tutorial is updated for Mesa 3.0, and works with Mesa `3.0.0a4` and above. If you are using Mesa 2.3.x, check out the [stable version](https://mesa.readthedocs.io/stable/tutorials/visualization_tutorial.html) of this tutorial on Readthedocs.*\n",
|
|
15
13
|
"\n",
|
|
14
|
+
"> **Note:** SolaraViz is experimental and still in active development for Mesa 3.0. While we attempt to minimize them, there might be API breaking changes between Mesa 3.0 and 3.1. There won't be breaking changes between Mesa 3.0.x patch releases.\n",
|
|
15
|
+
"\n",
|
|
16
16
|
"**Important:** \n",
|
|
17
17
|
"- If you are just exploring Mesa and want the fastest way to the the dashboard and code checkout [](https://py.cafe/app/tpike3/boltzmann-wealth-model) (click \"Editor\" to see the code)\n",
|
|
18
18
|
"- If you want to see the dashboard in an interactive notebook try [](https://mybinder.org/v2/gh/projectmesa/mesa/main?labpath=docs%2Ftutorials%2Fvisualization_tutorial.ipynb)\n",
|
|
@@ -51,34 +51,25 @@
|
|
|
51
51
|
]
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
|
-
"cell_type": "code",
|
|
55
|
-
"execution_count": 1,
|
|
56
54
|
"metadata": {},
|
|
57
|
-
"
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
"output_type": "stream",
|
|
61
|
-
"text": [
|
|
62
|
-
"Mesa version: 3.0.0b1\n"
|
|
63
|
-
]
|
|
64
|
-
}
|
|
65
|
-
],
|
|
55
|
+
"cell_type": "code",
|
|
56
|
+
"outputs": [],
|
|
57
|
+
"execution_count": null,
|
|
66
58
|
"source": [
|
|
67
59
|
"import mesa\n",
|
|
68
60
|
"print(f\"Mesa version: {mesa.__version__}\")\n",
|
|
69
61
|
"\n",
|
|
70
|
-
"from mesa.visualization import SolaraViz,
|
|
62
|
+
"from mesa.visualization import SolaraViz, make_plot_component, make_space_component\n",
|
|
63
|
+
"\n",
|
|
71
64
|
"# Import the local MoneyModel.py\n",
|
|
72
65
|
"from MoneyModel import MoneyModel\n"
|
|
73
66
|
]
|
|
74
67
|
},
|
|
75
68
|
{
|
|
69
|
+
"metadata": {},
|
|
76
70
|
"cell_type": "code",
|
|
77
|
-
"execution_count": null,
|
|
78
|
-
"metadata": {
|
|
79
|
-
"tags": []
|
|
80
|
-
},
|
|
81
71
|
"outputs": [],
|
|
72
|
+
"execution_count": null,
|
|
82
73
|
"source": [
|
|
83
74
|
"def agent_portrayal(agent):\n",
|
|
84
75
|
" return {\n",
|
|
@@ -88,17 +79,15 @@
|
|
|
88
79
|
]
|
|
89
80
|
},
|
|
90
81
|
{
|
|
91
|
-
"cell_type": "markdown",
|
|
92
82
|
"metadata": {},
|
|
93
|
-
"
|
|
94
|
-
|
|
95
|
-
]
|
|
83
|
+
"cell_type": "markdown",
|
|
84
|
+
"source": "In addition to the portrayal method, we instantiate the model parameters, some of which are modifiable by user inputs. In this case, the number of agents, N, is specified as a slider of integers."
|
|
96
85
|
},
|
|
97
86
|
{
|
|
98
|
-
"cell_type": "code",
|
|
99
|
-
"execution_count": null,
|
|
100
87
|
"metadata": {},
|
|
88
|
+
"cell_type": "code",
|
|
101
89
|
"outputs": [],
|
|
90
|
+
"execution_count": null,
|
|
102
91
|
"source": [
|
|
103
92
|
"model_params = {\n",
|
|
104
93
|
" \"n\": {\n",
|
|
@@ -115,8 +104,8 @@
|
|
|
115
104
|
]
|
|
116
105
|
},
|
|
117
106
|
{
|
|
118
|
-
"cell_type": "markdown",
|
|
119
107
|
"metadata": {},
|
|
108
|
+
"cell_type": "markdown",
|
|
120
109
|
"source": [
|
|
121
110
|
"Next, we instantiate the visualization object which (by default) displays the grid containing the agents, and timeseries of values computed by the model's data collector. In this example, we specify the Gini coefficient.\n",
|
|
122
111
|
"\n",
|
|
@@ -129,18 +118,16 @@
|
|
|
129
118
|
]
|
|
130
119
|
},
|
|
131
120
|
{
|
|
121
|
+
"metadata": {},
|
|
132
122
|
"cell_type": "code",
|
|
133
|
-
"execution_count": null,
|
|
134
|
-
"metadata": {
|
|
135
|
-
"tags": []
|
|
136
|
-
},
|
|
137
123
|
"outputs": [],
|
|
124
|
+
"execution_count": null,
|
|
138
125
|
"source": [
|
|
139
126
|
"# Create initial model instance\n",
|
|
140
127
|
"model1 = MoneyModel(50, 10, 10)\n",
|
|
141
128
|
"\n",
|
|
142
|
-
"SpaceGraph =
|
|
143
|
-
"GiniPlot =
|
|
129
|
+
"SpaceGraph = make_space_component(agent_portrayal)\n",
|
|
130
|
+
"GiniPlot = make_plot_component(\"Gini\")\n",
|
|
144
131
|
"\n",
|
|
145
132
|
"page = SolaraViz(\n",
|
|
146
133
|
" model1,\n",
|
|
@@ -153,8 +140,8 @@
|
|
|
153
140
|
]
|
|
154
141
|
},
|
|
155
142
|
{
|
|
156
|
-
"cell_type": "markdown",
|
|
157
143
|
"metadata": {},
|
|
144
|
+
"cell_type": "markdown",
|
|
158
145
|
"source": [
|
|
159
146
|
"## Part 2 - Dynamic Agent Representation \n",
|
|
160
147
|
"\n",
|
|
@@ -168,24 +155,24 @@
|
|
|
168
155
|
]
|
|
169
156
|
},
|
|
170
157
|
{
|
|
171
|
-
"cell_type": "code",
|
|
172
|
-
"execution_count": null,
|
|
173
158
|
"metadata": {},
|
|
159
|
+
"cell_type": "code",
|
|
174
160
|
"outputs": [],
|
|
161
|
+
"execution_count": null,
|
|
175
162
|
"source": [
|
|
176
163
|
"import mesa\n",
|
|
177
164
|
"print(f\"Mesa version: {mesa.__version__}\")\n",
|
|
178
165
|
"\n",
|
|
179
|
-
"from mesa.visualization import SolaraViz,
|
|
166
|
+
"from mesa.visualization import SolaraViz, make_plot_component, make_space_component\n",
|
|
180
167
|
"# Import the local MoneyModel.py\n",
|
|
181
168
|
"from MoneyModel import MoneyModel\n"
|
|
182
169
|
]
|
|
183
170
|
},
|
|
184
171
|
{
|
|
185
|
-
"cell_type": "code",
|
|
186
|
-
"execution_count": null,
|
|
187
172
|
"metadata": {},
|
|
173
|
+
"cell_type": "code",
|
|
188
174
|
"outputs": [],
|
|
175
|
+
"execution_count": null,
|
|
189
176
|
"source": [
|
|
190
177
|
"def agent_portrayal(agent):\n",
|
|
191
178
|
" size = 10\n",
|
|
@@ -210,16 +197,16 @@
|
|
|
210
197
|
]
|
|
211
198
|
},
|
|
212
199
|
{
|
|
213
|
-
"cell_type": "code",
|
|
214
|
-
"execution_count": null,
|
|
215
200
|
"metadata": {},
|
|
201
|
+
"cell_type": "code",
|
|
216
202
|
"outputs": [],
|
|
203
|
+
"execution_count": null,
|
|
217
204
|
"source": [
|
|
218
205
|
"# Create initial model instance\n",
|
|
219
206
|
"model1 = MoneyModel(50, 10, 10)\n",
|
|
220
207
|
"\n",
|
|
221
|
-
"SpaceGraph =
|
|
222
|
-
"GiniPlot =
|
|
208
|
+
"SpaceGraph = make_space_component(agent_portrayal)\n",
|
|
209
|
+
"GiniPlot = make_plot_component(\"Gini\")\n",
|
|
223
210
|
"\n",
|
|
224
211
|
"page = SolaraViz(\n",
|
|
225
212
|
" model1,\n",
|
|
@@ -232,8 +219,8 @@
|
|
|
232
219
|
]
|
|
233
220
|
},
|
|
234
221
|
{
|
|
235
|
-
"cell_type": "markdown",
|
|
236
222
|
"metadata": {},
|
|
223
|
+
"cell_type": "markdown",
|
|
237
224
|
"source": [
|
|
238
225
|
"## Part 3 - Custom Components \n",
|
|
239
226
|
"\n",
|
|
@@ -249,10 +236,10 @@
|
|
|
249
236
|
]
|
|
250
237
|
},
|
|
251
238
|
{
|
|
252
|
-
"cell_type": "code",
|
|
253
|
-
"execution_count": null,
|
|
254
239
|
"metadata": {},
|
|
240
|
+
"cell_type": "code",
|
|
255
241
|
"outputs": [],
|
|
242
|
+
"execution_count": null,
|
|
256
243
|
"source": [
|
|
257
244
|
"import mesa\n",
|
|
258
245
|
"print(f\"Mesa version: {mesa.__version__}\")\n",
|
|
@@ -260,16 +247,16 @@
|
|
|
260
247
|
"from matplotlib.figure import Figure\n",
|
|
261
248
|
"\n",
|
|
262
249
|
"from mesa.visualization.utils import update_counter\n",
|
|
263
|
-
"from mesa.visualization import SolaraViz,
|
|
250
|
+
"from mesa.visualization import SolaraViz, make_plot_component, make_space_component\n",
|
|
264
251
|
"# Import the local MoneyModel.py\n",
|
|
265
252
|
"from MoneyModel import MoneyModel\n"
|
|
266
253
|
]
|
|
267
254
|
},
|
|
268
255
|
{
|
|
269
|
-
"cell_type": "code",
|
|
270
|
-
"execution_count": null,
|
|
271
256
|
"metadata": {},
|
|
257
|
+
"cell_type": "code",
|
|
272
258
|
"outputs": [],
|
|
259
|
+
"execution_count": null,
|
|
273
260
|
"source": [
|
|
274
261
|
"def agent_portrayal(agent):\n",
|
|
275
262
|
" size = 10\n",
|
|
@@ -294,17 +281,15 @@
|
|
|
294
281
|
]
|
|
295
282
|
},
|
|
296
283
|
{
|
|
297
|
-
"cell_type": "markdown",
|
|
298
284
|
"metadata": {},
|
|
299
|
-
"
|
|
300
|
-
|
|
301
|
-
]
|
|
285
|
+
"cell_type": "markdown",
|
|
286
|
+
"source": "Next, we update our solara frontend to use this new component"
|
|
302
287
|
},
|
|
303
288
|
{
|
|
304
|
-
"cell_type": "code",
|
|
305
|
-
"execution_count": null,
|
|
306
289
|
"metadata": {},
|
|
290
|
+
"cell_type": "code",
|
|
307
291
|
"outputs": [],
|
|
292
|
+
"execution_count": null,
|
|
308
293
|
"source": [
|
|
309
294
|
"@solara.component\n",
|
|
310
295
|
"def Histogram(model):\n",
|
|
@@ -321,23 +306,26 @@
|
|
|
321
306
|
]
|
|
322
307
|
},
|
|
323
308
|
{
|
|
324
|
-
"cell_type": "code",
|
|
325
|
-
"execution_count": null,
|
|
326
309
|
"metadata": {},
|
|
310
|
+
"cell_type": "code",
|
|
327
311
|
"outputs": [],
|
|
312
|
+
"execution_count": null,
|
|
328
313
|
"source": [
|
|
329
314
|
"# Create initial model instance\n",
|
|
330
315
|
"model1 = MoneyModel(50, 10, 10)\n",
|
|
331
316
|
"\n",
|
|
332
|
-
"SpaceGraph =
|
|
333
|
-
"GiniPlot =
|
|
317
|
+
"SpaceGraph = make_space_component(agent_portrayal)\n",
|
|
318
|
+
"GiniPlot = make_plot_component(\"Gini\")"
|
|
334
319
|
]
|
|
335
320
|
},
|
|
336
321
|
{
|
|
337
322
|
"cell_type": "code",
|
|
338
|
-
"
|
|
339
|
-
|
|
340
|
-
|
|
323
|
+
"metadata": {
|
|
324
|
+
"ExecuteTime": {
|
|
325
|
+
"end_time": "2024-10-29T19:38:49.471838Z",
|
|
326
|
+
"start_time": "2024-10-29T19:38:47.897295Z"
|
|
327
|
+
}
|
|
328
|
+
},
|
|
341
329
|
"source": [
|
|
342
330
|
"page = SolaraViz(\n",
|
|
343
331
|
" model1,\n",
|
|
@@ -347,7 +335,27 @@
|
|
|
347
335
|
")\n",
|
|
348
336
|
"# This is required to render the visualization in the Jupyter notebook\n",
|
|
349
337
|
"page"
|
|
350
|
-
]
|
|
338
|
+
],
|
|
339
|
+
"outputs": [
|
|
340
|
+
{
|
|
341
|
+
"data": {
|
|
342
|
+
"text/plain": [
|
|
343
|
+
"Cannot show ipywidgets in text"
|
|
344
|
+
],
|
|
345
|
+
"text/html": [
|
|
346
|
+
"Cannot show widget. You probably want to rerun the code cell above (<i>Click in the code cell, and press Shift+Enter <kbd>⇧</kbd>+<kbd>↩</kbd></i>)."
|
|
347
|
+
],
|
|
348
|
+
"application/vnd.jupyter.widget-view+json": {
|
|
349
|
+
"version_major": 2,
|
|
350
|
+
"version_minor": 0,
|
|
351
|
+
"model_id": "bc71b89ee5684038a194eee4c36f4a4c"
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
"metadata": {},
|
|
355
|
+
"output_type": "display_data"
|
|
356
|
+
}
|
|
357
|
+
],
|
|
358
|
+
"execution_count": 12
|
|
351
359
|
},
|
|
352
360
|
{
|
|
353
361
|
"cell_type": "markdown",
|
|
@@ -358,12 +366,35 @@
|
|
|
358
366
|
},
|
|
359
367
|
{
|
|
360
368
|
"cell_type": "code",
|
|
361
|
-
"
|
|
362
|
-
|
|
363
|
-
|
|
369
|
+
"metadata": {
|
|
370
|
+
"ExecuteTime": {
|
|
371
|
+
"end_time": "2024-10-29T19:38:49.505725Z",
|
|
372
|
+
"start_time": "2024-10-29T19:38:49.472599Z"
|
|
373
|
+
}
|
|
374
|
+
},
|
|
364
375
|
"source": [
|
|
365
376
|
"Histogram(model1)"
|
|
366
|
-
]
|
|
377
|
+
],
|
|
378
|
+
"outputs": [
|
|
379
|
+
{
|
|
380
|
+
"data": {
|
|
381
|
+
"text/plain": [
|
|
382
|
+
"Cannot show ipywidgets in text"
|
|
383
|
+
],
|
|
384
|
+
"text/html": [
|
|
385
|
+
"Cannot show widget. You probably want to rerun the code cell above (<i>Click in the code cell, and press Shift+Enter <kbd>⇧</kbd>+<kbd>↩</kbd></i>)."
|
|
386
|
+
],
|
|
387
|
+
"application/vnd.jupyter.widget-view+json": {
|
|
388
|
+
"version_major": 2,
|
|
389
|
+
"version_minor": 0,
|
|
390
|
+
"model_id": "0491f167a1434a92b78535078bd082a8"
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
"metadata": {},
|
|
394
|
+
"output_type": "display_data"
|
|
395
|
+
}
|
|
396
|
+
],
|
|
397
|
+
"execution_count": 13
|
|
367
398
|
},
|
|
368
399
|
{
|
|
369
400
|
"cell_type": "markdown",
|
|
@@ -24,7 +24,7 @@ __all__ = [
|
|
|
24
24
|
]
|
|
25
25
|
|
|
26
26
|
__title__ = "mesa"
|
|
27
|
-
__version__ = "3.0.
|
|
27
|
+
__version__ = "3.0.0rc0"
|
|
28
28
|
__license__ = "Apache 2.0"
|
|
29
29
|
_this_year = datetime.datetime.now(tz=datetime.timezone.utc).date().year
|
|
30
30
|
__copyright__ = f"Copyright {_this_year} Project Mesa Team"
|
|
@@ -1,4 +1,29 @@
|
|
|
1
|
-
"""batchrunner for running a factorial experiment design over a model.
|
|
1
|
+
"""batchrunner for running a factorial experiment design over a model.
|
|
2
|
+
|
|
3
|
+
To take advantage of parallel execution of experiments, `batch_run` uses
|
|
4
|
+
multiprocessing if ``number_processes`` is larger than 1. It is strongly advised
|
|
5
|
+
to only run in parallel using a normal python file (so don't try to do it in a
|
|
6
|
+
jupyter notebook). Moreover, best practice when using multiprocessing is to
|
|
7
|
+
put the code inside an ``if __name__ == '__main__':`` code black as shown below::
|
|
8
|
+
|
|
9
|
+
from mesa.batchrunner import batch_run
|
|
10
|
+
|
|
11
|
+
params = {"width": 10, "height": 10, "N": range(10, 500, 10)}
|
|
12
|
+
|
|
13
|
+
if __name__ == '__main__':
|
|
14
|
+
results = batch_run(
|
|
15
|
+
MoneyModel,
|
|
16
|
+
parameters=params,
|
|
17
|
+
iterations=5,
|
|
18
|
+
max_steps=100,
|
|
19
|
+
number_processes=None,
|
|
20
|
+
data_collection_period=1,
|
|
21
|
+
display_progress=True,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
"""
|
|
2
27
|
|
|
3
28
|
import itertools
|
|
4
29
|
import multiprocessing
|