3.11. Lab 10: Agent-based models

Due Date: 11:59pm March 10, 2024

Labs should be submitted as a single Jupyter notebook to CourseLink Dropbox

This lab counts for 4% of the final grade

To do in advance of this lab:

  • Make sure you have run the code in Allen Downey’s Chapter 9 notebook.

3.11.1. Exercises

Complete the exercises corresponding to Exercise 9.1 – 9.2 in Chapter 9 of Think Complexity (version 2):

  1. Launch chap09.ipynb and run the code. There are some short exercises embedded in the notebook to complete.

  2. Bill Bishop, author of The Big Sort, argues that American society is increasingly segregated by political opinion, as people choose to live among like-minded neighbors.

    The mechanism Bishop hypothesizes is not that people, like the agents in Schelling’s model, are more likely to move if they are isolated, but that when they move for any reason, they are likely to choose a neighborhood with people like themselves.

    Write a version of Schelling’s model to simulate this kind of behavior and see if it yields similar degrees of segregation.

    There are several ways you can model Bishop’s hypothesis. In Downey’s implementation, a random selection of agents moves during each step. Each agent considers \(k\) randomly-chosen empty locations and chooses the one with the highest fraction of similar neighbors. How does the degree of segregation depend on \(k\)?

  3. In the first version of SugarScape, we never add agents, so once the population falls, it never recovers. In the second version, we only replace agents when they die, so the population is constant. Now let’s see what happens if we add some “population pressure”.

    Write a version of SugarScape that adds a new agent at the end of every step. Add code to compute the average vision and the average metabolism of the agents at the end of each step. Run the model for a few hundred steps and plot the population over time, as well as the average vision and average metabolism.

    You should be able to implement this model by inheriting from SugarScape and overriding __init__ and step.

3.11.2. Submission

Please submit a single Jupyter notebook which completes the above exercises, filling in Allen Downey’s Chapter 9 notebook. There are already placeholders in the notebook for your work.