Segration demo by computational agent simulation

For the fun of it, (and to learn more about Numpy’s multidimensional arrays) I decided to repeat Thomas Shelling’s famous experiment which demonstrates that segregation based on any real or imagined divider, such as gender, income, language,age, ethnicity, race, social status, religion, sexual preference etc, can occur by very innocent, non-prejudist,non-discriminating reasons: it suffices that each ‘agent’ has a slight preference for any specific characteristic, such as gender, language etc for segregation, that is, clustering of people with similar characteristics or preferences, to occur.  That clustering could occur in many different domains, such as selection of friends, where individuals decide to live,  or choice of restaurants to visit.

Thomas Schelling conducted his experiment by flipping coins, but that seems very time consuming, so I wrote a Python program to do the simulation.

My simulation takes place on a 20 x 20 grid, where each  green and black cell of the grid represents an individual ‘agent’. An agent is either ‘green’ or ‘black’, the color representing the agent’s preference on the selected dividing characteristic. Basically, ‘greens’ prefer other ‘greens’, ‘blacks’ prefer other ‘blacks’.

The below image shows the initial state of the board, where I’ve placed the agents according to a specific pattern ( you might want to think about this initial pattern as some lefty politician’s wet dream… 🙂

Image

The black and green squares represent agents located at a specific location on the grid, each agent with having differing preference on any of the dividing categories mentioned above.

The grey squares are free, i.e. currently unpopulated slots.

In my model, the ‘satisfaction’ of the current situation of each client is expressed by a very simple parameter: any agent that is surrounded by more than 2 non-peer agents of its 8 possible ‘neighbors’, feels dissatisfied with its current neighborhood, and will move to one of the free slots. The dissatisfied agent looks for any free slot which would result in a lower number of ‘non-peer’ neighbors, and if such a slot is found, the agent will move to that slot.

The simulation proceeds in a number of iterations, where each agent, at each iteration, determines whether it is satisfied with its current neighborhood (number of non-peers <3) or whether it wants to move.

In the initial state of the simulation, the average number of non-peer neighbors for all the agents is 2.8, that is, on average, any agent is dissatisfied with its current neighborhood.

After one iteration, the ‘board’ looks like below:

Image

Many of the agents have moved, but the average number of ‘non-peer’ neighbors is 2.62, that is still above the satisfaction limit of 2.

After 10 iterations, the average number of non-peer neighbors has decresed to 1.44, that is, below the limit of 2, and and we are starting to see some clustering, that is, segregation along the dividing characteristic emerging.

shelling-10-1.44

After 100 iterations, the clustering is very clear:  most of the green and black agents have settled in their own, fully segregated neighborhoods, and the few that have not have settled in the segregated areas have mostly found space in the ‘wilderness’, where they have few if any neighbors. And if they have any neighbors of non-peer kind, their number is below the limit.

The average number of non-peer neighbors has now decreased to 0.47.

Image

The only still dissatisfied agents are now those sitting on the border of the two segregated areas, and it seems like the model has now reached close to it’s optimum – even if I increase the number of iterations to 10000, the remaining dissatisfied agents are unable to improve their situation.

Advertisements

About swdevperestroika

High tech industry veteran, avid hacker reluctantly transformed to mgmt consultant.
This entry was posted in Complex Systems and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s