DATA 420 - Modeling and Simulation - Spring 2024

Program #4 — Agent-Based Models I

Possible experience: +40XP

Due: Thursday, March 21, midnight

The Mesa Agent-Based Modeling Framework

In this homework, you'll be reading about, and following the introductory tutorial for, the Mesa Python ABM framework. Mesa is completely open-source and researcher-friendly, and its big payoff is that it automates a lot of the tedious stuff (agent scheduling, collecting and tabulating results, running suites and parameter sweeps) that can take up a modeler's time and distract his/her focus from the actual problem at hand.

I love Mesa, and the people who created Mesa. Jackie Kazil, Tom Pike, David Masad and others are fantastic colleagues who are not only brilliant, but also excellent writers and patient explainers of their craft to mere mortals. Many of them are also affiliated with the outstanding computational science program at nearby George Mason University (which is a great choice for graduate school, by the way, if you're interested in this modeling and simulation stuff). They have not only spent many selfless hours developing Mesa so it can be of use to others, but they have also nurtured a strong and vibrant Mesa community eager to promote its use and help newcomers. Check out the discussion board on the github site if you need help or just want to learn more.

The assignment

First, carefully and thoughtfully read the overview section on readthedocs:

https://mesa.readthedocs.io/en/latest/overview.html

Then, unhurriedly and purposefully go through the entire introductory tutorial, which will involve reproducing and extending the Boltzmann wealth model we started in class in Mesa:

https://mesa.readthedocs.io/en/latest/tutorials/intro_tutorial.html

You can use the same IDE (Spyder, vim, IDLE, Notepad++, CoCalc, Colab, whatever else) that you've been using the whole semester.

Note that one important step of this tutorial will be actually installing Mesa on your system. Some of you may find this challenging or even frustrating, due to the tendency of some modern operating systems to obscure important truths from the user so they don't even know where their own files actually are.

Installing Mesa can be done through either Anaconda or the pip utility. If you got Python on your machine via the Anaconda distribution, you're probably better off getting mesa that way as well, since it's just fewer steps. To do it this way, open your Anaconda prompt and run:

$ conda install mesa

If you're like me, and don't use Anaconda, instead run:

$ pip install mesa

Restart your IDE (e.g., Spyder) after doing this to make sure it gets the up-to-date packages. Then make sure the version of Mesa you have is 2.2 or later. (You can tell the version by typing these two lines in your console: "import mesa" followed by "print(mesa.__version__)". Note the "dunder" before and after the word version.)

Please

Avoid the temptation to whiz through the tutorial on a superficial level, following the instructions without thinking about what they really mean, in order to reach as quickly as possible a finished product you can turn in. That approach will do two things: (1) you'll get a perfect score on this homework, and (2) you'll have no idea what's going on in the homeworks after this one.

Instead, work through the tutorial on a deep level, thinking carefully about what each line of code and each sentence means, and experimenting and tinkering as you go.

Turning it in

Send an email to data420submissions@gmail.com with three attachments: (1) a .py file with your complete Boltzmann simulation, (2) a .png image file depicting the spatial grid at simulation's end for 110 agents on a 15×15 grid, and (3) a .png of a line plot showing the Gini coefficient over time. The subject line of this email should be "DATA 420 Program #4 turnin".

Getting help

Come to office hours, or send me email with subject line "DATA 420 Program #4 help!!"