icpsr - complex systems models in the social sciences - lab session 4 - professor daniel martin katz

58
Introduction to Computing for Complex Systems (Lab Session 4) Daniel Martin Katz Michigan State University College of Law

Upload: daniel-martin-katz

Post on 13-Dec-2014

347 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Introduction to Computing for Complex Systems

(Lab Session 4)

Daniel Martin KatzMichigan State University

College of Law

Page 2: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Take a Look at this Article

from the Economist

(July 22, 2010)

Agent Based Models and

Positive Economic Theory

Refer Back to my slides about equilibrium and its discontents

Page 3: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
Page 4: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Schelling Social Segregation Model

Page 5: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

the full model

Page 6: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
Page 7: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Print This and Draw the Connections for a Full Map

of the Schelling Code

Page 8: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Mapping of the Schelling Code(%-similar-wanted is a slider)

Page 9: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

We Need to see What “update-varables” is Actually Doing

Page 10: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
Page 11: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
Page 12: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Here we are going to “set” some of our “turtles-own” variables

Page 13: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
Page 14: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

“Set” the Turtles-own Variable “similar-nearby”

to the count of “turtles-on” neighbors (8 of them)

but only those with color = my color

Page 15: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

“Set” the Turtles-own Variable “other-nearby”

to the count of “turtles-on” neighbors (8 of them)

but only those with color = not my color

Page 16: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Take a look at what is happening here

The “happy?” condition is going to be important

involves an agent by agent comparison of the spread between “similarity-wanted” & “similar-nearby”

Page 17: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Now Lets Look at “Update-globals”

It involves “lets” and “sets”

uses the globals but also some of the turtles-own variables

Page 18: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

I will allow you to review this on your own

However, consider the syntax of “sum”

Page 19: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

(1) Right Click (ctrl + Click on Mac) on the “percent-similar” plot

(2) This will appear and will allow for various modifications(color, interval, etc.)

Page 20: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
Page 21: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
Page 22: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
Page 23: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
Page 24: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

We now consider the “to go” portion of the code

Page 25: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

lets reduce the “to go” procedures

the “to go” portion of the code

above are the major new elements

remember conceptually the model relies upon movement if a turtle is unhappy

Page 26: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Again, we have the “if”

the “to go” portion of the code

The “to go” button with stop when all turtles are “happy?”

Here is how “Happy?” gets set:

model continues to tick until every agent is above the “%-similar-wanted” as set on the slider

Page 27: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

create an agentset of “not happy?” turtles

the movement portion of the code

For that agentset we run the “find-new-spot” procedures

We know from the “to go” procedures that this is going to continue to run until the “if” condition is satisfied

Page 28: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

the movement portion of the code

Page 29: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

the movement portion of the code

Page 30: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

the movement portion of the code

Notice that it is going to re-run the “find-new-spot”

If the “if” condition is met

In other words, agents are going to move until they find a open patch

then agent will occupy the center of open patch

Page 31: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
Page 32: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Thinking about Extensions to the Schelling Model

This is closer to a “representative agent” model

Agents are homogenous in their %similar-wanted

In reality, there is likely variance across agents

In other words, comparing across agents there are differential preferences with respect to the %similar-wanted

Page 33: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Thinking about Extensions to the Schelling Model

spatial considerations

The 8 neighbors might not be how individuals actually make their assessments

agents might make choices based upon a wider assessment of the neighborhood

there might be different “prices” for different patches (i.e. a simulated housing market)

Page 34: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Thinking about Extensions to the Schelling Model

structural considerations

the model could encode certain barriers to entry to particular neighborhoods

barriers could be highly asymmetric(i.e. red turtles face no barriers and green turtles face high barriers)

Page 35: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
Page 36: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

An Exercise

Start With the Default Implementation of

Social Segregation

Imagine that you are interested in

developing a certain style of integration

Page 37: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Modify the Code as Needed in Order to Produce The Closest Possible Model Run to the Camouflage

Note: this involves 4 Groups not 2 Groups

Your Goal!

An Exercise

Page 38: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Send Me Your Best Effort

[email protected]

I will announce the Winner

Page 39: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
Page 40: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Rates

Page 41: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Rates

Page 42: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Rates

Page 43: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Rates

take a few minutes and play around with the model

consider the questions offered above

Page 44: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Thinking Conceptually:Simple Birth Rates

What Does the Turtle Movement Add to the Model?

Are Turtles Added to the Model? and If So How?

Are Turtles Removed from the Model? and If So How?

Page 45: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Rates:Exploring the Code

Page 46: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Step 1: map the dependancies

Step 2: learn the syntax and functionality for all unknown primitives

Step 3: read each line of code and determine what it doing

Simple Birth Rates

Step 4: sketch a procedures map that follows the chronology of your program

At this point it is more Important for you to go though the models line by line on your own using

the above protocol

Page 47: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Rates

Page 48: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Experiment

Basic Setup

Simple Birth Rates

Death

Plots

Reproduction

Movement

Page 49: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Rates

“To Setup” Procedures

Page 50: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Rates

“To Go” Procedures

Page 51: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Rates

Turtle Movement Procedures

Page 52: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Rates

PleaseReview “ifelse”

How does it work?

Page 53: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Rates

Take a Look at the

Reproduction Procedures

Page 54: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Rates

Death Procedures

Plot Procedures

Page 55: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
Page 56: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Rates

Right Click (ctrl + Click on Mac) on the “run experiment” Button

Page 57: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Ratesforever button

Notice observer is selected

Calls upon the go-experiment

sub-procedures

Name of our Button

Page 58: ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz

Simple Birth Rates

Take a look at this for later in the week

Automation is really going to help us