My first cell is just for importing all the different functions and utilities I will use throughout the rest of my code. The second cell allows the user to pick the value of a variable f which will determine the size of the n x n matrix/n x n BlockGrid. The third cell creates the grids that I use in the fourth cell to assign blocks a certain color. The fifth cell, although not fully functional yet, is intended to look at the surrounding blocks and see if their "neighbors" are the same color or have the same value. Once they look at all the neighboring blocks the cell also calculates how satisfied the blocks are by dividing the surrounding blocks with the same color/value by the total number of surrounding blocks. I will then write some code that makes it so if the block has a satisfaction rate lower than a certain percentage (which should be another variable that the user can control) it will decide to move to another open block. This will keep happening until all blocks are satisfied.
For my base question I "should be able to replicate figures in the paper and reproduce some of the phase transition behavior observed" in the SchellingModel folder. Which means I have to write a code that 'makes it so if the block has a satisfaction rate lower than a certain percentage it will decide to move to another open block. This will keep happening until all blocks are satisfied.' Another question I am thinking of looking into is what would happen to the time it takes for all the differnet blocks to be satisfied if I added a third type of block. An additional question I have considered doing is how different grid sizes would affect the time it takes for all the blocks to get to a point where they are all satisfied.
These pieces of code are meant to represent the Schelling Model where like members prefer to be together/near to each other based on their specific satisfaction percentage, the percentage of their neighbors that are similar to them and at which they no longer feel like they have to move. First the model will be simulated by two colored blocks (blue and orange), but another topic I was planning to explore is to see how adding a new colored block (new member) to the simulation affects it's dynamic. There are also several times thoughout my code that I time the program to see what about the size of the grid, percentage of each member, and satisfaction percentage affect the time it takes for every member to be satisfied. To illustrate the affect of this model I'm using IPython Blocks. For this project I decided to simulate what it might be like if a certain race in a given neighborhood was given priority to move first. In this case there would appear to more segragated blocks in a population instead of groupings because all the blocks of a certain color given priority would be able to move first and thus closer to all the blocks of the same type.
1) The first schelling_project_work notebook addresses the original prompt of there being members in a given grid who want to be near like members and are willing to move based off their satisfaction percentage. 2) The schelling_project_work_question1 explores how adding a third member to the simulation would affect it's dynamic/speed at reaching the end goal of having all the members be satisfied. 3) The schelling_project_work_question2 explores how changing the size of the grid/population also affects the time it takes for every member to be satisfied in a three member model.
1) StackOverflow 2) IPython Blocks 3) Python.org 4) Class Notes 5) Homework Solutions
In [ ]: