Skip to content

Commit

Permalink
- update README screenshot and make some minor updates
Browse files Browse the repository at this point in the history
- add Colab badge to intro tutorial and make some minor updates
- update visualization tutorial so it references git install of mesa-models
  • Loading branch information
tpike3 committed Jul 29, 2023
1 parent f1e3e97 commit 551cebb
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 15 deletions.
3 changes: 1 addition & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ Mesa allows users to quickly create agent-based models using built-in core compo
:alt: A screenshot of the Schelling Model in Mesa

*Above: A Mesa implementation of the Schelling segregation model,
being visualized in a browser window and analyzed in a Jupyter
notebook.*
this can be displayed in browser windows or Jupyter.*

.. _`Mesa` : https://github.com/projectmesa/mesa/
Expand Down
Binary file modified docs/images/Mesa_Screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 32 additions & 10 deletions docs/tutorials/intro_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,34 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Introductory Tutorial"
"# Introductory Tutorial\n",
"\n",
"### The Boltzmann Wealth Model "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**Important:** \n",
"- If you are just exploring Mesa and want the fastest way to execute the code we recommend executing this tutorial online in a Colab notebook. [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/projectmesa/mesa/blob/main/docs/tutorials/intro_tutorial.ipynb)\n",
"- If you have installed mesa and are running locally, please ensure that your [Mesa version](https://pypi.org/project/Mesa/) is up-to-date in order to run this tutorial.\n",
"\n",
"## Tutorial Description\n",
"Important: you must ensure that your Mesa version is up-to-date in order to run this tutorial.\n",
"\n",
"[Mesa](https://github.com/projectmesa/mesa) is a Python framework for [agent-based modeling](https://en.wikipedia.org/wiki/Agent-based_model). This tutorial will assist you in getting started. Working through the tutorial will help you discover the core features of Mesa. Through the tutorial, you are walked through creating a starter-level model. Functionality is added progressively as the process unfolds. Should anyone find any errors, bugs, have a suggestion, or just are looking for clarification, [let us know](https://github.com/projectmesa/mesa/issues)!\n",
"\n",
"The premise of this tutorial is to create a starter-level model representing agents exchanging money. This exchange of money affects wealth. Next, *space* is added to allow agents to move based on the change in wealth as time progresses.\n",
"The premise of this tutorial is to create a starter-level model representing agents exchanging money. This exchange of money affects wealth. \n",
"\n",
"Next, *space* is added to allow agents to move based on the change in wealth as time progresses.\n",
"\n",
"Two of Mesa's analytic tools: the *data collector* and *batch runner* are then used to examine the dynamics of this simple model. \n",
"\n",
"### More Tutorials: \n",
"\n",
"Two of Mesa's analytic tools: the *data collector* and *batch runner* will be used to examine this movement. After that an *interactive visualization* is added which allows model viewing as it runs.\n",
"Visualization: There is a separate [visualization tutorial](https://mesa.readthedocs.io/en/stable/tutorials/visualization_tutorial.html) that will take users through building a visualization for this model (aka Boltzmann Wealth Model).\n",
"\n",
"Finally, the creation of a custom visualization module in JavaScript is explored."
"Advanced Visualization: There is also an [advanced visualization tutorial](https://mesa.readthedocs.io/en/stable/tutorials/adv_tutorial_legacy.html) that will show users how to use the JavaScript based visualization option, which also uses this model as its base. "
]
},
{
Expand Down Expand Up @@ -67,7 +78,22 @@
"\n",
"```bash\n",
"pip install matplotlib\n",
"```\n"
"```\n",
"\n",
"\n",
"**If running in Google Colab run the below cell to install Mesa.** (This will also work in a locally installed version of Jupyter.)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# SKIP THIS CELL unless running in colab\n",
"\n",
"!pip install mesa\n",
"# The exclamation points tell jupyter to do the command via the command line"
]
},
{
Expand Down Expand Up @@ -803,8 +829,6 @@
},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"agent_counts = np.zeros((model.grid.width, model.grid.height))\n",
"for cell_content, (x, y) in model.grid.coord_iter():\n",
" agent_count = len(cell_content)\n",
Expand Down Expand Up @@ -1230,8 +1254,6 @@
},
"outputs": [],
"source": [
"import pandas as pd\n",
"\n",
"results_df = pd.DataFrame(results)\n",
"print(results_df.keys())"
]
Expand Down
12 changes: 9 additions & 3 deletions docs/tutorials/visualization_tutorial.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"We recommend to execute this tutorial online in a Colab notebook, so that you can explore the visualization output: [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/projectmesa/mesa/blob/main/docs/tutorials/visualization_tutorial.ipynb)\n",
"**Important:** \n",
"- If you are just exploring Mesa and want the fastest way to execute the code we recommend executing this tutorial online in a Colab notebook. [![Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/projectmesa/mesa/blob/main/docs/tutorials/visualization_tutorial.ipynb)\n",
"- If you have installed mesa and are running locally, please ensure that your [Mesa version](https://pypi.org/project/Mesa/) is up-to-date in order to run this tutorial.\n",
"\n",
"### Adding visualization\n",
"\n",
Expand Down Expand Up @@ -42,6 +44,10 @@
"\n",
"# You can either define the BoltzmannWealthModel (aka MoneyModel) or install mesa-models:\n",
"%pip install --quiet -U -e git+https://github.com/projectmesa/mesa-examples#egg=mesa-models\n",
"\n",
"# For Colab you must change the directory to reference mesa-models installed from github on the previous line.\n",
"%cd src\n",
"\n",
"from mesa_models.boltzmann_wealth_model.model import BoltzmannWealthModel"
]
},
Expand Down Expand Up @@ -245,7 +251,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -259,7 +265,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.12"
"version": "3.9.6"
},
"nbsphinx": {
"execute": "never"
Expand Down

0 comments on commit 551cebb

Please sign in to comment.