ICPSR - Complex Systems Models in the Social Sciences - Lab Session 7 - Professor Daniel Martin Katz
ICPSR - Complex Systems Models in the Social Sciences - Lab Session 3 - Professor Daniel Martin Katz
-
Upload
daniel-martin-katz -
Category
Education
-
view
449 -
download
0
description
Transcript of ICPSR - Complex Systems Models in the Social Sciences - Lab Session 3 - Professor Daniel Martin Katz
Introduction to Computing for Complex Systems
(Lab Session 3)
Daniel Martin KatzMichigan State University
College of Law
A Few Books Worth Considering
Goals for Today
Finish Exploration of the Forest Fire Model
Begin exploration of theSchelling Segregation Model
Every item in our Model is:
Important Principles fromOur Last Session
(1) Defined within the Model
(2) Is a Primitive that is defined in the Netlogo Dictionary
OR
(remember we can think of primitives as the raw materials of models)
(such as in Globals, Breeds or in a subroutine)
Exploring the Forest Fire Model
http://ccl.northwestern.edu/netlogo/models/Fire
(CONDT.)
The Forest Fire Model
The Forest Fire Model
3-D Forest Fire Model
(1) Modify the Color of the Forest to Blue
(2) Make the Fire Move North to South Instead of West to East
How Did We Do?
Modify the Color of the Forest to Blue
What Elements of the Code Do We Modify?
The Forest Fire Model
Procedures
The Forest Fire Model
Procedures
Make the Fire Move North to South Instead of West to East
Make the Fire Move North to South Instead of West to East
What Elements of the Code Do We Modify?
The Forest Fire Model
Procedures
The Forest Fire Model
Procedures
Try this Instead:
In what sense is this model random?
In what sense is this model deterministic?
Thinking conceptually about the model procedures
all of these models involve a mixture of determinism and randomness
In what sense is this model random?
Thinking conceptually about the model procedures
Placement of the patches
subject to the selected density level
Watch the Model in 3D
Watch the Model in 3D
Watch the Model in 3D
Watch the Model in 3D
In what sense is this model deterministic?
Thinking conceptually about the model procedures
The fire is really for G.U.I. purposes
result is basically already determined before the fire spreads
Back to the Forest Fire
Model Procedures
relies upon:if not any? stopask fires ask neighbors4fade-embersignitetick
The ‘To Go’ Procedure
if is a condition and you can think of it as:
if x condition is met than do action y
(otherwise move on to the next line)
The ‘To Go’ Procedure
This is going to kill the model if
condition is achieved
vs.
Forever Button
Once-only Button
The ‘To Go’ Procedure
Why is this Arguably the KEY piece of code?
What does it mean in plain english?
The ‘To Go’ Procedure
What is neighbors4?
Remember our basic rule:
The ‘To Go’ Procedure
It is defined within the program
or it is one of the netlogo primitives
The ‘To Go’ Procedure
Neighbors and Neighbors4
turtle turtle
neighbors4 neighbors(think of
this as the 8 neighbors)
turtle
(a) we are asking “fires”
The ‘To Go’ Procedure
(b) to ask their 4 neighbors
(c) the 4 neighbors that are green
(d) to run the “ignite” protocol
(e) and then set their breed to embers
(f) now run the “fade-embers” protocol
The ‘To Go’ Procedure
The ‘To Go’ Procedure
The ‘To Go’ Procedure
When is this finally going to halt?
It is a forever button which can be halted using “STOP”
“STOP” is triggered when the “if” condition is satisfied
Lets Discuss Some Extensions of The Forest Fire Model
Extensions of The Forest Fire Model
What are the actual dynamics that generate and sustain forest fires?
What else could we incorporate into this model?
A Non-Exhaustive List
Differential Levels of Moisture
Variable Terrain (Rivers, etc.)
Prior Interventions (Firewalls, etc)
Wind and other Weather Patterns
Some of the Existing Extensions
different forms of implementation may impact the results
Implementation Matters
different forms of implementation may be more qualitatively appropriate
sophistication regarding implementation allows you to be a more critical consumer of scholarship
the neighbors4 example
Neighbors and Neighbors4
turtle turtle
neighbors4 neighbors(think of
this as the 8 neighbors)
turtle
Neighbors and Neighbors4
neighbors(think of
this as the 8 neighbors)
what did the implementer of the model decide?
neighbors4
decided that the fire could not move diagonally
this is probably not qualitatively reasonable
Step 1: map the dependancies
Step 2: learn the syntax and functionality for all unknown primitives
Protocol to Decode 3rd Party Implementation
Step 3: read each line of code and determine what it doing
Mapping of the Code
just some examples of primitives from the dictionary that we have already learned
Protocol to Decode 3rd Party Implementation
Next We Went Line by Line Through the Code
Step 4: sketch a procedures map that follows the chronology of your program
There is one additional step that often proves useful
Protocol to Decode 3rd Party Implementation
Particularly when you are writing a model from scratch
Very Rough Sketch of the Fire Procedures Map
(1)
(2) (1)(a)(i)
(1)(a)
(1)(a)(ii)
(1)(b)
the point is just to aid in your understanding
(2)(a)
(2)(a)(i)
(2)(a)(i)(I)
(2)(b)
(2)(b)(i) (3) - End
Loop Until “if”
Condition is met
The Value for Global Must Get “Set” Somewhere in the Model Procedures
Globals -- one other note
Mapping of the Code
Introduction to theSchelling
Segregation Model
What Does this Title Mean?
What is the micro to macro disconnect?
relationship to the ecological inference
fallacy?
Schelling Social Segregation Model
Schelling Social Segregation Model
Schelling Social Segregation Model
Schelling Social Segregation Model
Schelling Social Segregation Model
Schelling Social Segregation Model
Schelling Social Segregation Model
versus
note: stopped model before % unhappy = 0
Schelling Social Segregation Model
Test these Parameters and report
Results
Schelling Social Segregation Model
Schelling Social Segregation Model
Schelling Social Segregation Model
Schelling Social Segregation Model
versus
Schelling Social Segregation Model
the full model
Print This and Draw the Connections for a Full Map
of the Schelling Code
Mapping of the Schelling Code(%-similar-wanted is a slider)
Learn the Syntax and Functionality for all unknown Primitives
(starting with “to setup”)
Again this is the conditional “if” statement
It is relying upon “number”
Is number a netlogo primitive?
It is the name of the slider
How could I rename this “totalagents”?
Take 5 minutes and Try to Figure it out
(1) Right Click (ctrl + Click on Mac)
on the “number” slider
(2) change the global variable name from “number” to “totalagents”
Modifying the name (or values) of a Slider
Modifying the name (or values) of a Slider
Notice the error Message
Must Change all instances from “number”
to “totalagents”
Then double check by hitting
the “check” Button
We have learned a small exception to our rule
Revised Rule --> everything in the model:
(1) defined somewhere in the code (2) is a primitive (3) it is something like a slider
What is this doing in plain english?
clear everything
if the end user selects a slider value that exceeds the number of patches
tell that end user to modify and try again
(1) Close Netlogo
(2) Discard the Changes
(3) Restart the Segregation model
Quick Reset
Open the SchellingSegregation Model
Delete all procedures except those shown to left
What is has this done to the model?
<Only Red Turtles>
<“Go” button is red>
What is this doing in plain english?
asks all of the patches
to randomly “sprout” 1 turtle per patch
and make that turtle color = red
What is this doing in plain english?
now take half of those turtles
and set turtle color = green
We Need to see What “update-varables” is Actually Doing
Here we are going to “set” some of our “turtles-own” variables
“Set” the Turtles-own Variable “similar-nearby”
to the count of “turtles-on” neighbors (8 of them)
but only those with color = my color
“Set” the Turtles-own Variable “similar-nearby”
to the count of “turtles-on” neighbors (8 of them)
but only those with color = not my color
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”