DATA 420 - Modeling and Simulation - Spring 2026

Homework #4 — Agent-Based Models I

Possible experience: +40XP

Due: Thursday, April 2, midnight

The Schelling Segregation Model

In this project, you'll be making changes to the Schelling Segregation Model and investigating how it responds to various values of the diversity tolerance THRESHOLD. You will perform a parameter sweep of this variable and plotting the results.

Instructions

  1. Use the implementation we wrote in class as a starting point for this assignment. Make sure you can get it running.
  2. Write a method on the District class to measure the level of segregation in a given model. It should compute the average fraction of agents' neighbors who are the same color as they are. To illustrate, let's say you had four agents in your model: The segregation score for this model would therefore be the average of ⅓, ⅓, 1, and ½, which is .542.
  3. Wire this function into a datacollector object for the model, and compute its value each iteration, as in the tutorial walk-through.
  4. For a sensible value of THRESHOLD (your choice), generate a time plot of segregation vs. time (iteration number). You should see the segregation start out fairly low, and then climb to a fixed level when the model reaches equilibrium. Label and title this plot, and save it to turn in.
  5. Now run a parameter sweep of the THRESHOLD parameter so you can get an idea of how this affects the degree of residential segregation. Use at least 20 different values for THRESHOLD, and run the simulation at least 10 times (averaging the results) for each value. (In simulation lingo, you'll be sweeping 20 different values of THRESHOLD, using a 10-run suite for each.)
  6. Produce and save a well-labeled, clearly-presented plot of THRESHOLD vs. average-segregation-in-final-generation.
  7. Make one of the following changes to the model:
    1. Use a different neighborhood type/size. Instead of a Moore neighborhood of distance 1, use a Von Neumann neighborhood of distance 2, or a Moore neighborhood of distance 2, or anything else.
    2. Vary the sizes of the two groups, so that there are fewer (or more) blue people than red people.
    3. Have the model "intelligently teleport" instead of randomly teleporting. "Intelligent teleport" means that instead of a dissatisfied person moving to a random square, he/she always moves to a random square that satisfies his/her THRESHOLD. (Red people who think they're around too many blue folks will thus not counterproductively teleport into the middle of another blue neighborhood.)
    4. Make the model support degrees of tolerance. Instead of every person having the same threshold, make blue agents "racist" and red agents "tolerant." Racist agents will simply have a higher THRESHOLD than tolerant ones. (If you choose this option, realize that the "degree of racism" goes with the agent, not the square. So when a person teleports to a different location, you'll need to make sure that they still maintain their same degree of racism in their new square.)
    5. Some other interesting change to the model, of your own invention, and of a complexity similar to the complexity of the previous options. (If you're unsure what level of complexity your proposed change is, feel free to ask me.)
  8. Before going to the next step, make sure to run your simulation a good number of times, watching the animation carefully, and verify that it's working properly.
  9. Produce and save a parameter sweep plot for your changed model. It could be another parameter sweep of THRESHOLD vs. average-segregation-in-final-generation, like you did for the original model. Or it could be a sweep of some other parameter (neighborhood size, fraction-of-agents-who-are-blue, racist THRESHOLD, etc.)
  10. Write a ½-1 single-spaced report in which you summarize the behavior of the original model, describe the change you made to it, and compare/contrast your new model's results to the original.

Turning it in

Send me an email with five attachments: (1) a .py file with your modified Schelling simulation from item #6, (2) a .png image file with your time plot from item #3, (3) a .png image file with your parameter sweep from item #5, (4) a .png image file with your modified parameter sweep from item #8, and (5) your write-up from item #9. The subject line of this email should be "DATA 420 Homework #4 turnin".

Getting help

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