"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
ICPSR - Complex Systems Models in the Social Sciences - Lab Session 4 - Professor Daniel Martin Katz
1. Introduction to Computing
for Complex Systems
(Lab Session 4)
daniel martin katz
illinois institute of technology
chicago kent college of law
@computationaldanielmartinkatz.com computationallegalstudies.com
2. 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
9. We Need to see
What “update-
varables” is
Actually Doing
10.
11.
12. Here we are going to “set” some of our
“turtles-own” variables
13.
14. “Set” the Turtles-own Variable “similar-nearby”
to the count of “turtles-on” neighbors (8 of them)
but only those with color = my color
15. “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
16. 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”
17. Now Lets Look at “Update-globals”
It involves “lets” and “sets”
uses the globals but also some of the
turtles-own variables
18. I will allow you to review this on your own
However, consider the syntax of “sum”
19. (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.)
25. 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
26. 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
27. 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
30. 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
31.
32. 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
33. 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)
34. 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)
35.
36. An Exercise
Start With the Default
Implementation of
Social Segregation
Imagine that you are
interested in
developing a certain
style of integration
37. 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!
Homework Exercise
38. Send Me Your Best
Effort
daniel.martin.katz@gmail.com
I will announce the
Winner
43. Simple Birth Rates
take a few minutes and play around with the model
consider the questions offered above
44. 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?
46. 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