Simple Agent-based Macro Model in Python

Alex Linnen



The purpose of this project is to familiarise myself with the tools available in Python to create agent-based models. Python offers many advantages over other languages, due to it’s simplicity and vast library of data science packages. I reviewed several Python packages before starting this project, but eventually decided on Mesa. This is a package for creating agent-based models in Python, in a similar manner to the JAS package used in Java.

This model contains four modules:

  • – contains the model class and initialises values, as well as some useful functions for retrieving and manipulating data.
  • – contains the agent classes for both households and firms.
  • – constructs the user interface.
  • – launches the model.

The project folder can be found on Github. Click here to view and download it.

As of 16th May:

So far, I have been experimenting with Mesa and slowly importing elements of the Lengnick (2013) macro model, I have managed to build the agent classes and populate each list of households and firms in the model class. The next step will be to construct an event schedule for each tick of the model when running.

Code for populating agent lists, as of 16/05/2021.




For any further information, please contact