Of course feel free to use your own Python environment, or clone repo and install locally (pip install .). This is the recommended and tested procedure however.
Tested on the practicum PC (and my own Windows laptop)
Jupyter Notebooks
We will be using Jupyter Notebooks for our Python code with Visual Studio Code (and our environment setup initialized in VS code).
But feel free to use your own IDE and organization.
Downloading models
Lets download the basic Mesa models
We can run models now
Run all netlogo and python basic models and inspect them carefully. What do these simple models do?
Runthrough of netlogo things and mesa code
with some highlights by Wim
Do it yourself assignment (general)
For each practicum I want you to organize your own model library
This model library has well-annotated markdown-edited notebooks (Python) or info tabs (Netlogo)
What does this model do, what are chunks of code that are complicated, and what could I use this for? Use the online documentation for explanations.
A personal model library will serve future you well
Grid Model Questions
In the NetLogo grid model, what initializes the turtles position randomly?
let direction one-of [0 90 180 270]
setxy random-pxcor random-pycor
ask patches [if (pxcor + pycor) mod 2 = 0 [ set pcolor white ]]
set heading direction
Grid Model Questions
What characterizes the agents move posibility? (google terms if needed)
The agent can only move to a cell in a Von Neumann neighborhood
The agent can only move to a cell in a Moore neighborhood
The number of move options of the agents changes randomly
None of these
Grid Model Questions
What does possible_moves = [(x, (y+1)%h), ((x+1)%w, y), (x, (y-1)%h), ((x-1)%w, y)] represent?
We move the agent to a random position
The directions that the agent could go to with torus wrapping
Diagonal movement options
Grid Model Questions
Compare the implementation of the agent movement in NetLogo and Mesa.
NetLogo sets direction and moves, Mesa selects coordinates directly
Both use the same movement implementation
Only Mesa calculates possible moves
Grid Model Questions (Open Question)
Lets say we now want to have the agents be able to move to any patch surrounding the current patch, including the diagonals. What would you change in netlogo? What would you change in Python? Impress your neighbor, and explain what you did to them (and vice versa).
Grid Model Questions (Use your own imagination)
Make a copy of the grid models. And try to think of a simple thing you can add that make your model behave slightly more interesting from your perspective. Try to implement the change both in Netlogo and in Python.
Continuous Model Questions
Which Mesa components are essential for a basic continuous space model? (Select all correct)
ContinuousSpace to define the simulation space
ContinuousSpaceAgent as the base class for agents
OrthogonalMooreGrid for discrete cells
mesa.Model as the base class for the simulation model
Continuous Model Questions
What happens if you don’t call self.agents.add(agent) after creating an agent?
The agent moves randomly anyway
The model crashes immediately
The agent exists but won’t be included in model.agents.do(“step”)
The visualization will not work
Continuous Model Questions (Use your own imagination)
Modify the Mesa continuous model so that the model behavior is slightly different or more complex. Impress your neighbor, and explain what you did to them (and vice versa).
Network Model Questions
Check out the network basic models.
Network Model Questions
For the python implementation, what’s the key difference between this network visualization and the previous grid/continuous visualizations?
Network visualization is faster to render
Network uses custom matplotlib plotting while grid/continuous use Mesa’s make_space_component
Network models can’t use Mesa’s visualization system
Custom plotting only works for small networks
Self-study
During this first practicum you were likely lost because many operations are foreign. The only way to learn is to look up things in the python code you do not understand. Then once you understand you write it out in your own words in the jupyter notebook Markdown sections and save it for future reference (in your personal model library).