# Practical Problem 19: Schelling Model

In this excersize you will implement the Schelling model. A very famous model for social, geographical segregation. Before you start, you can read the information in the explorable “T. Schelling plays Go”.

## Simulation 1: Patches

Implement the Schelling Model in netlogo with two species **A** and **B** in a **patch simulation**. So in this simulation patches can either have type **A**, **B** or **"empty"**.

Control parameters should be

- the density of non-empty patches (so the number \(N\))
- the tolerance level (the fraction of patches of the other type in an interaction radius \(R\))
- the interaction radius \(R\)

## Simulation 2: Turtles

Now let's implement a turtle-version of the Schelling model. Instead of patches, place \(N\) turtles randomly in the world. These turtles now either have type **A** or **B**. We no longer have "empty" as a state. When turtles decide to move because the fraction of "others" around them is too high, the move to a random location in the world.

## Simulation 3: Network

We can do yet another version of the Schelling model. Generate a random network of turtles with a mean degree of \(k\). This degree should now be a controllable parameter that replaces the interaction radius. In the network implementation turtles only interact with their link neighbors. A good value for this mean degree is between 1 and 4. You you define the mean degree by using the link density formula: \(k = p(N-1)\), where \(k\) is the mean degree.

Implement a switch that toggles between circular network layout and spring-layout.

When turtles decide, they are unhappy, they cut all their links and connect to a random set of other turtles. When turtles reconnect, the should keep their previous degree.

## Simulation 4: The Schelling swarm

Finally, reimplement a swarm of turtles the performs collective motion according to the Viszek Model. You can reuse the netlogo code from the corresponding previous Practice Problem 11. Again we need to types of turtles A and B.

In addition to the radius \(R\) that governs the swarming behavior, add a new slider that controls the "Schelling-Radius". Within the Schelling radius each turtle determines in combination with the "tolerance for others"-parameter whether it is happy or not. When a turtle is "unhappy", i.e. the fraction of other turtles is too large, is doesn't relocate somewhere else. Instead, it starts moving at a different speed.

The way to implement this is by defining a happyness variable for each turtle. Additionally we need to speed sliders, a speed that governs how fast happy turtles move and one for the speed of unhappy turtles. And depending on the happyness state a turtle moves at the corresponding speed.