Earn Higher Grades With Instant Assignment Help.Ask Question!

Python Programming
(5/5)

Racial segregation has always been a pernicious social problem in the United States.Although much effort has been extended to desegregate our schools, churches.

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Digital Humanities / Finance

Overview

Racial segregation has always been a pernicious social problem in the United States. Although much effort has been extended to desegregate our schools, churches, and neighborhoods, the US continues to remain segregated (https://tcf.org/content/commentary/racial-segregation-is-still-a-problem/) by race and economic lines. Why is segregation such a difficult problem to eradicate?

In 1971, the American economist Thomas Schelling (https://en.wikipedia.org/wiki/Thomas_Schelling) created an agent-based model that might help explain why segregation is so difficult to combat. His model of segregation showed that even when individuals (or "agents") didn't mind being surrounded or living by agents of a different race, they would still choose to segregate themselves from other agents over time! Although the model is quite simple, it gives a fascinating look at how individuals might self- segregate, even when they have no explicit desire to do so.

In this assignment, you will create a simulation of Schelling's model. The user should be able to set a number of parameters of the model and watch it go.

How the Model Works

Schelling's model will now be explained with some minor changes. Suppose there are two types of agents: X and O. The two types of agents might represent different races, ethnicity, economic status, etc. Two populations of the two agent types are initially placed into random locations of a neighborhood represented by a grid. After placing all the agents in the grid, each cell is either occupied by an agent or is empty as shown below.

Now we must determine if each agent is satisfied with its current location. A satisfied agent is one that is surrounded by at least a fractoin t of agents that are like itself. This threshold t is one that will apply to all agents in the model, even though in reality everyone might have a different threshold they are satisfied with. Note that the higher the threshold, the higher the likelihood the agents will not be satisfied with their current location.

For example, if t = .3, agent X is satisfied if at least 30% of its neighbors are also X. If fewer than 30% are X, then the agent is not satisfied, and it will want to change its location in the grid. For the remainder of this explanation, let's assume a threshold t of .3. This means every agent is fine with being in the minority as long as there are at least 30% of similar agents in adjacent cells.

The picture below shows a satisfied agent because 50% of X's neighbors are also X (.5 > t)

In the pciture below, agent X is not satisfied because only 25% of its neighbors are X (.25 < t). Notice that in this example empty cells are not counted when calculating similarity.

When an agent is not satisfied, it can be moved to any vacant location in the grid. Any algorithm can be used to choose this new location. For example, a randomly selected cell may be chosen, or the agent could move to the nearest available location.

In the image below, all dissatisfied agents have an asterisk next to them.

The next image shows the new configuration after all the dissatisfied agents have been moved to unoccupied cells at random. Note that the new configuration may cause some agents which were previously satisfied to become dissatisfied

All dissatisfied agents must be moved in the same round. After the round is complete, a new round begins, and dissatisfied agents are once again moved to new locations in the grid.

These rounds continue until all agents in the neighborhood are satisfied with their location

Okay, so what do I have to do?

You will create code that simulates the Schelling model for two distinct populations. Consider the following parameters for the Schelling model:

grid size: tuple of integers (n,m)

fraction of population 1: float between 0 and 1.

fraction of vacant sites in the grid: float betweein 0 and 1. tolerance: float between 0 and 1

Write a function   start(grid_size,pop,vacancy) that creates and returns a 2-D  numpy array of the appropriate size consisting of integers where each element of the array is assigned as follows:

part of first demographic: 1 part of second demographic: -1 vacant: 0

The array your function returns should have the appropriate characteristics as specified by the input parameters provided.

File "<ipython-input-1-2c7a386a02a2>", line

SyntaxError: unexpected EOF while parsing

But wait, there's more!

Write a second function next_round(arr,tolerance) that takes as input an n by m array like the one you just created and returns a new 2-D array one step in the future where all dissatisfied agents have been moved. Remember, since there may be more dissatisfied agents than vacancies in the grid, you need to move them one at a time, this way each time an agent is randomly assigned to a vacant site, a vacancy at a new location is created.

File "<ipython-input-2-25bb51c91c51>", line 4

SyntaxError: unexpected EOF while parsing

Last bit! (almost)

Finally write a function make_list(n) that returns a list of n numpy arrays where the first array is created using start and the second using next_round on the first array and the third using next_round on the second, and so on.

File "<ipython-input-3-8048fee1353a>", line 5

SyntaxError: unexpected EOF while parsing

Really last bit!

Try out your code. Create a list of length 100 using the parameter values:

size=(30,30) pop=.5 vacant = .1

tolerance = .3

In class we will see how to visualize this evolution of the grid using matplotlib. Try it out! I've included some code to help with this in the hw_files folder on Courseworks if you want to get started early.

And finally, are there still dissatisfied agents in the grid? How could you write an alternative function to make_list that makes a list exactly big enough so that in the final grid there are no more dissatisfied agents. You don't have to do this, but it wouldn't be too hard

Attachments:
(5/5)

Related Questions

CSI 1420 Introduction to C Programming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Fu

The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Assignment To Be Done By Our ExpertsGet A+ Grade Solution Guaranteed

expert
joyComputer science
(4/5)
12 Answers Hire Me
expert
Robert DLaw
(4.8/5)
897 Answers Hire Me
expert
Dr Samuel BarberaStatistics
(5/5)
916 Answers Hire Me
expert
Tutor For YouEconomics
(5/5)
833 Answers Hire Me