Skip to content

Commit 80b7556

Browse files
authored
Update after MPIEvolBiol workshop (#7)
* update all * deelte more large files
1 parent cbec898 commit 80b7556

12 files changed

Lines changed: 727 additions & 1911 deletions

notebooks/Predator_Prey_1.mp4

-495 KB
Binary file not shown.
-179 KB
Binary file not shown.

notebooks/ABM_Tutorial_Block.ipynb renamed to notebooks/agent_based_modelling_intro.ipynb

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
]
1010
},
1111
{
12+
"attachments": {},
1213
"cell_type": "markdown",
1314
"id": "32c878b0",
1415
"metadata": {},
1516
"source": [
16-
"This course introduces the [Agents.jl](https://juliadynamics.github.io/Agents.jl/stable/) Julia package for agent based modelling. The notebook is created by [Alejandra Ramirez](https://github.com/MA-Ramirez)\n",
17-
"and George Datseris.\n",
17+
"This course introduces the [Agents.jl](https://juliadynamics.github.io/Agents.jl/stable/) Julia package for agent based modelling.\n",
1818
"\n",
1919
"Agent based modelling are simulations where autonomous agents react to their environment and interact with each other given a predefined set of rules. \n",
2020
"These rules are formulated based on explicit statements rather than mathematical equations (such as: “If condition X is fulfilled, do action Y, and then perform operation Z on all nearby agents”).\n",
@@ -224,12 +224,20 @@
224224
]
225225
},
226226
{
227+
"attachments": {},
228+
"cell_type": "markdown",
229+
"id": "c3126a56",
230+
"metadata": {},
231+
"source": [
232+
"The first version of the model will be agents (rabbit) performing random walks, losing energy, and dying."
233+
]
234+
},
235+
{
236+
"attachments": {},
227237
"cell_type": "markdown",
228238
"id": "5c115fca",
229239
"metadata": {},
230240
"source": [
231-
"The first steps in any simulation with Agents.jl is to decide the space and the agent types. \n",
232-
"\n",
233241
"### 1. Choose the space \n",
234242
"\n",
235243
"The space is a grid space so we define"
@@ -622,13 +630,16 @@
622630
]
623631
},
624632
{
633+
"attachments": {},
625634
"cell_type": "markdown",
626635
"id": "e5994737",
627636
"metadata": {},
628637
"source": [
629638
"### 5. Visualize the model and animate its time evolution\n",
630639
"\n",
631-
"Alright, things seem to work. All rabbits die, since they eat no food but loose energy. But let's also visualize the model! To do so it is very easy! We choose a color/size/marker for the agents and call `abmplot`!"
640+
"Alright, things seem to work. All rabbits die, since they eat no food but loose energy. But let's also visualize the model! To do so it is very easy! We choose a color/size/marker for the agents and call `abmplot`!\n",
641+
"\n",
642+
"The way this works is that agents are plotted as a scatter plot (each marker is one agent). Then, the user decides how the agents will be plotting by providing a function that given an agent it gives its color or size or marker."
632643
]
633644
},
634645
{
@@ -642,9 +653,10 @@
642653
"\n",
643654
"using GLMakie # this allows videos and interactive apps\n",
644655
"model = init_rabbits() # refresh model\n",
645-
"rabbitcolor(a) = :orange\n",
646-
"rabbitmarker(a) = :circle\n",
647-
"fig, = abmplot(model; ac = rabbitcolor, am = rabbitmarker)\n",
656+
"rabbitcolor(agent) = :orange # all agents have the same color\n",
657+
"rabbitmarker(agent) = :circle\n",
658+
"rabbitsize(agent) = agent.energy # size depends on agent\n",
659+
"fig, = abmplot(model; ac = rabbitcolor, am = rabbitmarker, as = rabbitsize)\n",
648660
"fig"
649661
]
650662
},
@@ -664,7 +676,7 @@
664676
"outputs": [],
665677
"source": [
666678
"fig, = abmplot(model; \n",
667-
" ac = rabbitcolor, am = rabbitmarker,\n",
679+
" ac = rabbitcolor, am = rabbitmarker, as = rabbitsize,\n",
668680
" agent_step! = rabbit_step!, \n",
669681
")\n",
670682
"\n",
@@ -934,7 +946,7 @@
934946
"plotkwargs = (;\n",
935947
" ac = (\"white\", 0.5),\n",
936948
" offset = agent -> (0.25rand(), 0.25rand()),\n",
937-
" as = 20,\n",
949+
" as = agent.energy,\n",
938950
" #additional keyword arguments propagated to the scatter! call.\n",
939951
" scatterkwargs = (strokewidth = 1.0, strokecolor = :black),\n",
940952
" heatarray = grasscolor,\n",
@@ -1537,6 +1549,7 @@
15371549
]
15381550
},
15391551
{
1552+
"attachments": {},
15401553
"cell_type": "markdown",
15411554
"id": "adbefad7",
15421555
"metadata": {},
@@ -1559,21 +1572,10 @@
15591572
"* Reproduction of strategies is only allowed on empty neighbouring sites, to mimic a finite carrying capacity of the system\n",
15601573
"* Mobility is represented via $\\epsilon$, this exchange rate represent the likelihood of agents to swap position with a neighbouring individual or hop onto an empty neighbouring site.\n",
15611574
"\n",
1562-
"![Spatial RPS instructions](SpatialRPS_instructions.png)\n",
1563-
"\n",
15641575
"Whether selection, reproduction or mobility occurs is computed according to the rates (probability = rate* number of agents).\n",
15651576
"\n",
1566-
"Explore the system's evolution for different exchange rate values.\n",
1567-
"\n"
1577+
"Explore the system's evolution for different exchange rate values."
15681578
]
1569-
},
1570-
{
1571-
"cell_type": "code",
1572-
"execution_count": 36,
1573-
"id": "ced17cdc",
1574-
"metadata": {},
1575-
"outputs": [],
1576-
"source": []
15771579
}
15781580
],
15791581
"metadata": {

notebooks/basins_ex_fig_1.png

6.04 KB
Loading

0 commit comments

Comments
 (0)