Skip to content

Commit c96ee45

Browse files
EwoutHrht
authored andcommitted
docs: Update Readme and tutorial to mention Mesa 3.0 pre-releases
Note that the updated tutorials will only be pushed to the latest version of Readthedocs, not to the stable version we normally link to.
1 parent 6a31300 commit c96ee45

File tree

3 files changed

+74
-58
lines changed

3 files changed

+74
-58
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,19 @@ can be displayed in browser windows or Jupyter.*
2828

2929
## Using Mesa
3030

31-
Getting started quickly:
31+
To install our latest stable release (2.3.x), run:
3232

3333
``` bash
34-
pip install mesa
34+
pip install -U mesa
3535
```
3636

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:
3844

3945
``` bash
4046
pip install -U -e git+https://github.com/projectmesa/mesa@main#egg=mesa

docs/tutorials/intro_tutorial.ipynb

Lines changed: 60 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
"pip install --upgrade mesa\n",
6767
"```\n",
6868
"\n",
69+
"If you want to use our newest features, you can also opt to install our latest pre-release version:\n",
70+
"\n",
71+
"```bash\n",
72+
"pip install --upgrade --pre mesa\n",
73+
"```\n",
74+
"\n",
6975
"Install Jupyter Notebook (optional):\n",
7076
"\n",
7177
"```bash\n",
@@ -1209,15 +1215,19 @@
12091215
},
12101216
{
12111217
"cell_type": "markdown",
1212-
"source": [
1213-
"We can create different kinds of plot from this filtered DataFrame. For example, a point plot with error bars."
1214-
],
12151218
"metadata": {
12161219
"collapsed": false
1217-
}
1220+
},
1221+
"source": [
1222+
"We can create different kinds of plot from this filtered DataFrame. For example, a point plot with error bars."
1223+
]
12181224
},
12191225
{
12201226
"cell_type": "code",
1227+
"execution_count": null,
1228+
"metadata": {
1229+
"collapsed": false
1230+
},
12211231
"outputs": [],
12221232
"source": [
12231233
"# Create a point plot with error bars\n",
@@ -1228,11 +1238,7 @@
12281238
" ylabel=\"Gini coefficient\",\n",
12291239
" title=\"Gini coefficient vs. number of agents\",\n",
12301240
");"
1231-
],
1232-
"metadata": {
1233-
"collapsed": false
1234-
},
1235-
"execution_count": null
1241+
]
12361242
},
12371243
{
12381244
"cell_type": "markdown",
@@ -1284,16 +1290,20 @@
12841290
},
12851291
{
12861292
"cell_type": "markdown",
1293+
"metadata": {
1294+
"collapsed": false
1295+
},
12871296
"source": [
12881297
"### Analyzing model reporters: Comparing 5 scenarios\n",
12891298
"Other insights might be gathered when we compare the Gini coefficient of different scenarios. For example, we can compare the Gini coefficient of a population with 25 agents to the Gini coefficient of a population with 400 agents. While doing this, we increase the number of iterations to 25 to get a better estimate of the Gini coefficient for each population size and get usable error estimations."
1290-
],
1291-
"metadata": {
1292-
"collapsed": false
1293-
}
1299+
]
12941300
},
12951301
{
12961302
"cell_type": "code",
1303+
"execution_count": null,
1304+
"metadata": {
1305+
"collapsed": false
1306+
},
12971307
"outputs": [],
12981308
"source": [
12991309
"params = {\"width\": 10, \"height\": 10, \"N\": [5, 10, 20, 40, 80]}\n",
@@ -1309,27 +1319,27 @@
13091319
")\n",
13101320
"\n",
13111321
"results_5s_df = pd.DataFrame(results_5s)"
1312-
],
1313-
"metadata": {
1314-
"collapsed": false
1315-
},
1316-
"execution_count": null
1322+
]
13171323
},
13181324
{
13191325
"cell_type": "code",
1326+
"execution_count": null,
1327+
"metadata": {
1328+
"collapsed": false
1329+
},
13201330
"outputs": [],
13211331
"source": [
13221332
"# Again filter the results to only contain the data of one agent (the Gini coefficient will be the same for the entire population at any time)\n",
13231333
"results_5s_df_filtered = results_5s_df[(results_5s_df.AgentID == 0)]\n",
13241334
"results_5s_df_filtered.head(3)"
1325-
],
1326-
"metadata": {
1327-
"collapsed": false
1328-
},
1329-
"execution_count": null
1335+
]
13301336
},
13311337
{
13321338
"cell_type": "code",
1339+
"execution_count": null,
1340+
"metadata": {
1341+
"collapsed": false
1342+
},
13331343
"outputs": [],
13341344
"source": [
13351345
"# Create a lineplot with error bars\n",
@@ -1344,35 +1354,35 @@
13441354
"g.figure.set_size_inches(8, 4)\n",
13451355
"plot_title = \"Gini coefficient for different population sizes\\n(mean over 100 runs, with 95% confidence interval)\"\n",
13461356
"g.set(title=plot_title, ylabel=\"Gini coefficient\");"
1347-
],
1348-
"metadata": {
1349-
"collapsed": false
1350-
},
1351-
"execution_count": null
1357+
]
13521358
},
13531359
{
13541360
"cell_type": "markdown",
1355-
"source": [
1356-
"In this case it looks like the Gini coefficient increases slower for smaller populations. This can be because of different things, either because the Gini coefficient is a measure of inequality and the smaller the population, the more likely it is that the agents are all in the same wealth class, or because there are less interactions between agents in smaller populations, which means that the wealth of an agent is less likely to change."
1357-
],
13581361
"metadata": {
13591362
"collapsed": false
1360-
}
1363+
},
1364+
"source": [
1365+
"In this case it looks like the Gini coefficient increases slower for smaller populations. This can be because of different things, either because the Gini coefficient is a measure of inequality and the smaller the population, the more likely it is that the agents are all in the same wealth class, or because there are less interactions between agents in smaller populations, which means that the wealth of an agent is less likely to change."
1366+
]
13611367
},
13621368
{
13631369
"cell_type": "markdown",
1370+
"metadata": {
1371+
"collapsed": false
1372+
},
13641373
"source": [
13651374
"### Analyzing agent reporters\n",
13661375
"From the agents we collected the wealth and the number of consecutive rounds without a transaction. We can compare the 5 different population sizes by plotting the average number of consecutive rounds without a transaction for each population size.\n",
13671376
"\n",
13681377
"Note that we're aggregating multiple times here: First we take the average of all agents for each single replication. Then we plot the averages for all replications, with the error band showing the 95% confidence interval of that first average (over all agents). So this error band is representing the uncertainty of the mean value of the number of consecutive rounds without a transaction for each population size."
1369-
],
1370-
"metadata": {
1371-
"collapsed": false
1372-
}
1378+
]
13731379
},
13741380
{
13751381
"cell_type": "code",
1382+
"execution_count": null,
1383+
"metadata": {
1384+
"collapsed": false
1385+
},
13761386
"outputs": [],
13771387
"source": [
13781388
"# Calculate the mean of the wealth and the number of consecutive rounds for all agents in each episode\n",
@@ -1382,14 +1392,14 @@
13821392
" .reset_index()\n",
13831393
")\n",
13841394
"agg_results_df.head(3)"
1385-
],
1386-
"metadata": {
1387-
"collapsed": false
1388-
},
1389-
"execution_count": null
1395+
]
13901396
},
13911397
{
13921398
"cell_type": "code",
1399+
"execution_count": null,
1400+
"metadata": {
1401+
"collapsed": false
1402+
},
13931403
"outputs": [],
13941404
"source": [
13951405
"# Create a line plot with error bars\n",
@@ -1401,23 +1411,22 @@
14011411
" title=\"Average number of consecutive rounds without a transaction for different population sizes\\n(mean with 95% confidence interval)\",\n",
14021412
" ylabel=\"Consecutive rounds without a transaction\",\n",
14031413
");"
1404-
],
1405-
"metadata": {
1406-
"collapsed": false
1407-
},
1408-
"execution_count": null
1414+
]
14091415
},
14101416
{
14111417
"cell_type": "markdown",
1412-
"source": [
1413-
"It can be clearly seen that the lower the number of agents, the higher the number of consecutive rounds without a transaction. This is because the agents have fewer interactions with each other and therefore the wealth of an agent is less likely to change."
1414-
],
14151418
"metadata": {
14161419
"collapsed": false
1417-
}
1420+
},
1421+
"source": [
1422+
"It can be clearly seen that the lower the number of agents, the higher the number of consecutive rounds without a transaction. This is because the agents have fewer interactions with each other and therefore the wealth of an agent is less likely to change."
1423+
]
14181424
},
14191425
{
14201426
"cell_type": "markdown",
1427+
"metadata": {
1428+
"collapsed": false
1429+
},
14211430
"source": [
14221431
"#### General steps for analyzing results\n",
14231432
"\n",
@@ -1430,10 +1439,7 @@
14301439
"5. Transform, filter and aggregate the results to get the data you want to analyze. Make sure it's in long format, so that each row represents a single value.\n",
14311440
"6. Choose a plot type, what to plot on the x and y axis, which columns to use for the hue. Seaborn also has an amazing [Example Gallery](https://seaborn.pydata.org/examples/index.html).\n",
14321441
"7. Plot the data and analyze the results."
1433-
],
1434-
"metadata": {
1435-
"collapsed": false
1436-
}
1442+
]
14371443
},
14381444
{
14391445
"cell_type": "markdown",

docs/tutorials/visualization_tutorial.ipynb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
"cell_type": "markdown",
1212
"metadata": {},
1313
"source": [
14+
"*This version of the visualisation tutorial is updated for Mesa 3.0, and works with Mesa `3.0.0a1` and above. If you are using Mesa 2.3.x, check out the [stable version](https://mesa.readthedocs.io/en/stable/tutorials/visualization_tutorial.html) of this tutorial on Readthedocs.*\n",
15+
"\n",
1416
"**Important:** \n",
1517
"- 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",
1618
"- 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",
@@ -39,8 +41,10 @@
3941
},
4042
"outputs": [],
4143
"source": [
42-
"%pip install --quiet mesa\n",
44+
"# Install and import the latest Mesa pre-release version\n",
45+
"%pip install --quiet --upgrade --pre mesa\n",
4346
"import mesa\n",
47+
"print(f\"Mesa version: {mesa.__version__}\")\n",
4448
"\n",
4549
"# You can either define the BoltzmannWealthModel (aka MoneyModel) or install mesa-models:\n",
4650
"%pip install --quiet -U git+https://github.com/projectmesa/mesa-examples#egg=mesa-models\n",

0 commit comments

Comments
 (0)