Introduction to Computing
for Complex Systems
(Lab Session 5)
daniel martin katz
illinois institute of technology
chicago ...
Simple Birth Rates
Simple Birth Rates
Simple Birth Rates
Simple Birth Rates
take a few minutes and play around with the model
consider the questions offered above
Thinking Conceptually:
Simple Birth Rates
What Does the Turtle Movement Add to the Model?
Are Turtles Added to the Model?
...
Simple Birth Rates:
Exploring the Code
Simple
Birth
Rates
Experiment
Basic Setup
Simple Birth Rates
Death
Plots
Reproduction
Movement
Simple Birth Rates
“To Setup” Procedures
Simple
Birth
Rates
“To Go”
Procedures
Simple Birth Rates
Turtle Movement
Procedures
Simple Birth Rates
Please
Review
“ifelse”
How does
it work?
Simple Birth Rates
Take a Look
at the
Reproduction
Procedures
Simple Birth Rates
Death
Procedures
Plot
Procedures
Step 1: map the dependancies
Step 2: learn the syntax and
functionality for all
unknown primitives
Step 3: read each line ...
Wolf-Sheep Predation
The Lotka-Volterra Equation is Traditional
Approach to this Question is Differential
Equation
Classic Predator-Prey
Questi...
Wolf-Sheep Predation
Wolf-Sheep Predation
A Mini Eco-System Model
Sheep rely on Grass
Wolf rely upon Sheep
Implicitly Wolf rely upon grass
Wolf-Sheep Predation
Set Different Starting Values for Sheep
Return Rates for Food Can Differ
There are Birth Rates for Gr...
Wolf-Sheep Predation
Lots of
Parameters
Grass
switcher
Shows how close an
agent is to death
Plots are
Useful for
observing...
Wolf-Sheep Predation
Wolf-Sheep Predation
Wolf-Sheep Predation
Relies upon a number of different rules
that we have seen in prior models
reproduction rule
death rul...
Wolf-Sheep Predation
This is default settings with grass on
What is happening in the model?
Wolf-Sheep Predation
What is happening in the model?
Changed 1 parameter “sheep gain from food”
(From 4 to 8)
Wolf-Sheep Predation
Notice the difference in the 4 model runs
Changed 1 extra parameter “wolf gain from food”
Still “shee...
Wolf-Sheep Predation
Wolf Sheep is more of an agent based model
remember in simple birth rates there
was a system level ca...
Wolf-Sheep Predation
You can observe these interactions and the
declining energy counts
mr. wolf
better get
some food
Wolf-Sheep Predation
This energy count might
useful in a number of
models
Simulated Market where
“energy” could become
mon...
Novel Recombinations
of Code
We are trying to show a set of models
with useful features
to your substantive question(s) of...
Recycle & Reuse Code
You should re-use as much
code as possible
also, a code “scrapyard” from which you
might acquire part...
Getting to the
Code “Scrapyard”
Some Examples From
The Code “Scrapyard”
The Flocking Model
Scale-free correlations in starling flocks
Andrea Cavagnaa,b,1
, Alessio Cimarellib
, Irene Giardinaa,b,1
, Giorgio Parisib...
This is a really
interesting paper
Jing Han, Ming Li & Lei Guo
“soft control on collective
behavior of a group of
autonomo...
The Flocking Model
The Flocking Model
The Flocking Model
Take a few minutes
and explore the
model including
these questions
The Flocking Model
The Flocking Model
The Flocking Model
What is “Population”?
It is a variable on the
slider
What is happening in
the “To Setup”?
create popula...
ask turtles [flock]
The Flocking Model
(We will get to [flock]
in just a moment)
to understand how
“display” helps the
int...
The Flocking Model
What is [ask turtles [FD 0.2]?
Turtles are moving FD .2
Immediately Updated using
the “display” command...
The Flocking Model
back to ask turtles [flock]
which is used in the “to go”
“to flock” gateway to
balance of the model
The Flocking Model
flockmates = turtles-own agentset of nearby turtles
We use the “Set” Command to assign it a value
“Set”...
What is
“other turtles
in-radius vision”?
Other = All Turtles
in Radius Except for
the Calling Turtle
Radius = Allows for
...
It is going to use an “if” springing condition
If no flockmates than it is
going to tick the model
forward (rinse and repe...
“find-nearest-neighbor”
First how does it do the “find-nearest-neighbor”?
it has to “set” a value for this
looks within th...
remember “ifelse” sets up two possible conditions ...
the “ifelse” split in the road
Take a look at how it is split up
Not...
Cohere, Align & Separate
If Condition is
satisfied than
[ separate ]
If Condition is not
satisfied (i.e. else)
[ align coh...
Cohere, Align & Separate
relies upon other
procedures as
shown above
= slider variable
= nested procedure
The Hawk/Dove Model
http://ccl.northwestern.edu/netlogo/models/community/
The Hawk/Dove Model
In the Community Models it is called “game theory”
http://ccl.northwestern.edu/netlogo/models/communit...
The Hawk/Dove Model
Easiest Thing is to simultaneously
install 3.1.5 along with Netlogo 4.1
Current Version of “gametheory...
How to Acquire
Netlogo 3.1.5
http://ccl.northwestern.edu/netlogo/download.shtml
The Hawk/Dove Model
After Installing, Open Version 3.1.5 on your desktop
From within 3.1.5 File ---> Open
Find the “gameth...
The Hawk/Dove Model
the interface is slightly different and
some of the syntax is slightly different
The Hawk/Dove Model
The Hawk/Dove Model
The Hawk/Dove Model
Can you identify instances where the “retaliator”
behavioral strategy does not win out?
Parameter Sweeps?
Thinking about “parameter sweeps”
We would like to be able to evaluate all possible
parameter values wit...
Parameter Sweeps?
Perhaps we do not have to search the full space
perhaps we can grid the analysis and
interpolate between...
ICPSR - Complex Systems Models in the Social Sciences - Lab Session 5 - Professor Daniel Martin Katz
Upcoming SlideShare
Loading in...5
×

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

1,583

Published on

Published in: Business, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,583
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
31
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "ICPSR - Complex Systems Models in the Social Sciences - Lab Session 5 - Professor Daniel Martin Katz"

  1. 1. Introduction to Computing for Complex Systems (Lab Session 5) daniel martin katz illinois institute of technology chicago kent college of law @computationaldanielmartinkatz.com computationallegalstudies.com
  2. 2. Simple Birth Rates
  3. 3. Simple Birth Rates
  4. 4. Simple Birth Rates
  5. 5. Simple Birth Rates take a few minutes and play around with the model consider the questions offered above
  6. 6. 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?
  7. 7. Simple Birth Rates: Exploring the Code
  8. 8. Simple Birth Rates
  9. 9. Experiment Basic Setup Simple Birth Rates Death Plots Reproduction Movement
  10. 10. Simple Birth Rates “To Setup” Procedures
  11. 11. Simple Birth Rates “To Go” Procedures
  12. 12. Simple Birth Rates Turtle Movement Procedures
  13. 13. Simple Birth Rates Please Review “ifelse” How does it work?
  14. 14. Simple Birth Rates Take a Look at the Reproduction Procedures
  15. 15. Simple Birth Rates Death Procedures Plot Procedures
  16. 16. 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
  17. 17. Wolf-Sheep Predation
  18. 18. The Lotka-Volterra Equation is Traditional Approach to this Question is Differential Equation Classic Predator-Prey Question to answer ... what do we learn through the Agent Based Implementation that is not captured the standard approach?
  19. 19. Wolf-Sheep Predation
  20. 20. Wolf-Sheep Predation A Mini Eco-System Model Sheep rely on Grass Wolf rely upon Sheep Implicitly Wolf rely upon grass
  21. 21. Wolf-Sheep Predation Set Different Starting Values for Sheep Return Rates for Food Can Differ There are Birth Rates for Grass, Sheep, Wolves
  22. 22. Wolf-Sheep Predation Lots of Parameters Grass switcher Shows how close an agent is to death Plots are Useful for observing model stability
  23. 23. Wolf-Sheep Predation
  24. 24. Wolf-Sheep Predation
  25. 25. Wolf-Sheep Predation Relies upon a number of different rules that we have seen in prior models reproduction rule death rule different initial conditions spatial movement around the landscape etc.
  26. 26. Wolf-Sheep Predation This is default settings with grass on What is happening in the model?
  27. 27. Wolf-Sheep Predation What is happening in the model? Changed 1 parameter “sheep gain from food” (From 4 to 8)
  28. 28. Wolf-Sheep Predation Notice the difference in the 4 model runs Changed 1 extra parameter “wolf gain from food” Still “sheep gain from food” (From 4 to 8) Now also “wolf gain from food” (From 20 to 40)
  29. 29. Wolf-Sheep Predation Wolf Sheep is more of an agent based model remember in simple birth rates there was a system level carrying capacity Here we keep track of individual turtles and they can die based upon individual values And of course individual spatial interactions Sheep vs. Grass wolf v. sheep
  30. 30. Wolf-Sheep Predation You can observe these interactions and the declining energy counts mr. wolf better get some food
  31. 31. Wolf-Sheep Predation This energy count might useful in a number of models Simulated Market where “energy” could become money, etc. Agents could make various cost / benefit calculations as they undertake a given action Those agents need not make the “optimal” choice (i.e. they could have cognitive biases, etc. and you could write those into the model)
  32. 32. Novel Recombinations of Code We are trying to show a set of models with useful features to your substantive question(s) of interest Then you can develop various novel combinations of these and other models
  33. 33. Recycle & Reuse Code You should re-use as much code as possible also, a code “scrapyard” from which you might acquire parts to fix your model Lots of Code Examples in existing models Lots of Code Examples online
  34. 34. Getting to the Code “Scrapyard”
  35. 35. Some Examples From The Code “Scrapyard”
  36. 36. The Flocking Model
  37. 37. Scale-free correlations in starling flocks Andrea Cavagnaa,b,1 , Alessio Cimarellib , Irene Giardinaa,b,1 , Giorgio Parisib,c,d,1 , Raffaele Santagatib , Fabio Stefaninib,2 , and Massimiliano Vialea,b a Istituto dei Sistemi Complessi, Consiglio Nazionale delle Ricerche, 00185 Rome, Italy; b Dipartimento di Fisica, Università di Roma “La Sapienza”, 00185 Rome, Italy; c Sezione Istituto Nazionale di Fisica Nucleare, Università di Roma “La Sapienza”, 00185 Rome, Italy; and d Unità Organizzativa di Supporto di Roma, Istituto per i Processi Chimico-Fisici, Consiglio Nazionale delle Ricerche, 00185 Rome, Italy Contributed by Giorgio Parisi, May 11, 2010 (sent for review December 6, 2009) From bird flocks to fish schools, animal groups often seem to react to environmental perturbations as if of one mind. Most studies in collective animal behavior have aimed to understand how a glob- ally ordered state may emerge from simple behavioral rules. Less effort has been devoted to understanding the origin of collective response, namely the way the group as a whole reacts to its envi- ronment. Yet, in the presence of strong predatory pressure on the group, collective response may yield a significant adaptive advan- tage. Here we suggest that collective response in animal groups may be achieved through scale-free behavioral correlations. By reconstructing the 3D position and velocity of individual birds in large flocks of starlings, we measured to what extent the velocity fluctuations of different birds are correlated to each other. We found that the range of such spatial correlation does not have a constant value, but it scales with the linear size of the flock. This result indicates that behavioral correlations are scale free: The change in the behavioral state of one animal affects and is affected by that of all other animals in the group, no matter how large the group is. Scale-free correlations provide each animal with an effective perception range much larger than the direct interindivid- ual interaction range, thus enhancing global response to perturba- tions. Our results suggest that flocks behave as critical systems, poised to respond maximally to environmental perturbations. animal groups | collective behavior | flocking | self-organization | emergent behavior Of all distinctive traits of collective animal behavior the most conspicuous is the emergence of global order, namely the fact that all individuals within the group synchronize to some extent their behavioral state (1–3). In many cases global ordering amounts to an alignment of the individual directions of motion, as in bird flocks, fish schools, mammal herds, and in some insect swarms (4–6). Yet, global ordering can affect also other behav- ioral states, as it happens with the synchronous flashing of tropical fireflies (7) or the synchronous clapping in human crowds (8). The presence of order within an animal group is easy to detect. However, order may have radically different origins, and dis- covering what is the underlying coordination mechanism is not straightforward. Order can be the effect of a top–down central- ized control mechanism (for example, due to the presence of one or more leaders), or it can be a bottom–up self-organized feature emerging from local behavioral rules (9). In reality, the lines are often blurred and hierarchical and distributed control may combine together (10). However, even in the two extreme cases, discriminating between the two types of global ordering is not trivial. In fact, the prominent difference between the centralized and the self-organized paradigm is not order, but response. Collective response is the way a group as a whole reacts to its environment. It is often crucial for a group, or for subsets of it, to respond coherently to perturbations. For gregarious animals under strong predatory pressure, in particular, collective re- sponse is vital (2, 11, 12). The remarkable thing about a flock of birds is not merely the globally ordered motion of the group, but the way the flock dodges a falcon’s attack. Collective response is the trademark of self-organized order as opposed to a central- ized one. Consider a group where all individuals follow a leader, without interacting with one another. Such a system is strongly ordered, as everyone moves in the same direction. Yet, there is no passing of information from individual to individual and hence behavioral fluctuations are independent: The change of direction of one animal (different from the leader) has very little influence on that of other animals, due to the centralized nature of information transfer. As a consequence, collective response is very poor: Unless detected directly by the leader, an external perturbation does not elicit a global reaction by the group. Re- sponse, unlike order, is the real signature of self-organization. In self-organized groups the efficiency of collective response depends on the way individual behavioral changes, typically forced by localized environmental perturbations, succeed in modifying the behavior of the whole group. This key process is ruled by behavioral correlations. Correlation is the expression of an indirect information transfer mediated by the direct in- teraction between the individuals: Two animals that are outside their range of direct interaction (be it visual, acoustic, hydrody- namic, or any other) may still be correlated if information is transferred from one to another through the intermediate interacting animals. The turn of one bird attacked by a predator has an influence not only over the neighbors directly interacting with it, but also over all birds that are correlated to it. Correla- tion measures how the behavioral changes of one animal in- fluence those of other animals across the group. Behavioral correlations are therefore ultimately responsible for the group’s ability to respond collectively to its environment. In the same way, correlations are likely to play a fundamental role in other kinds of collective decision-making processes where informed individuals (e.g., on food location or migration routes) can ex- tend their influence over many other group members (10). Of course, behavioral correlations are the product of in- terindividual interaction. Yet interaction and correlation are dif- ferent things and they may have a different spatial (and sometimes temporal) span. Interaction is local in space and its range is typ- ically quite short. A former study (13) shows that in bird flocks the interaction range is of the order of few individuals. On the other hand, the correlation length, namely the spatial span of the cor- relation, can be significantly larger than the interaction range, depending chiefly on the level of noise in the system. An ele- mentary example is the game of telephone: A player whispers a phrase into her neighbor’s ear. The neighbor passes on the message to the next player and so on. The direct interaction range is equal to one, whereas the correlation length, i.e., the number of Author contributions: A. Cavagna, I.G., and G.P. designedresearch; A. Cavagna, A. Cimarelli, I.G., R.S., F.S., and M.V. performed research; A. Cavagna, I.G., F.S., and M.V. contributed new reagents/analytic tools; A. Cavagna, A.Cimarelli, I.G., G.P., F.S., and M.V. analyzed data; and A. Cavagna wrote the paper. The authors declare no conflict of interest. Freely available online through the PNAS open access option. 1 To whom correspondence may be addressed. E-mail: andrea.cavagna@roma1.infn.it, irene.giardina@roma1.infn.it, or giorgio.parisi@roma1.infn.it. 2 Present address: Institut für Neuroinformatik, Universität Zürich, Winterthurerstrasse 190, CH-8057 Zurich, Switzerland. This article contains supporting information online at www.pnas.org/lookup/suppl/doi:10. 1073/pnas.1005766107/-/DCSupplemental. www.pnas.org/cgi/doi/10.1073/pnas.1005766107 PNAS | June 29, 2010 | vol. 107 | no. 26 | 11865–11870 ECOLOGY June 29, 2010 Issue Flocking is still an active area of research
  38. 38. This is a really interesting paper Jing Han, Ming Li & Lei Guo “soft control on collective behavior of a group of autonomous Agents by a shill agent” arXiv:1007.0803v1[cs.MA]6Jul2010 PUBLISHED IN JOURNAL OF SYSTEMS SCIENCE AND COMPLEXITY, 2006(19):54-62 1 Soft Control on Collective Behavior of a Group of Autonomous Agents by a Shill Agent Jing Han, Ming Li and Lei Guo Abstract This paper asks a new question: how can we control the collective behavior of self-organized multi- agent systems? We try to answer the question by proposing a new notion called ‘Soft Control’, which keeps the local rule of the existing agents in the system. We show the feasibility of soft control by a case study. Consider the simple but typical distributed multi-agent model proposed by Vicsek et al. for flocking of birds: each agent moves with the same speed but with different headings which are updated using a local rule based on the average of its own heading and the headings of its neighbors. Most studies of this model are about the self-organized collective behavior, such as synchronization of headings. We want to intervene in the collective behavior (headings) of the group by soft control. A specified method is to add a special agent, called a ‘Shill’, which can be controlled by us but is treated as an ordinary agent by other agents. We construct a control law for the shill so that it can synchronize the whole group to an objective heading. This control law is proved to be effective analytically and numerically. Note that soft control is different from the approach of distributed control. It is a natural way to intervene in the distributed systems. It may bring out many interesting issues and challenges on the control of complex systems. Index Terms Collective Behavior, Multi-agent System, Soft Control, Boid Model, Shill Agent This work was supported by the National Natural Science Foundation of China. Jing Han and Lei Guo are with the Institute of Systems Science, AMSS, Chinese Academy of Sciences, Beijing, 100080, China. Ming Li is with the Institute of Theoretical Physics, Chinese Academy of Sciences. Corresponding author: hanjing@amss.ac.cn. Thanks to John Holland For Suggesting it
  39. 39. The Flocking Model
  40. 40. The Flocking Model
  41. 41. The Flocking Model Take a few minutes and explore the model including these questions
  42. 42. The Flocking Model
  43. 43. The Flocking Model
  44. 44. The Flocking Model What is “Population”? It is a variable on the slider What is happening in the “To Setup”? create population set turtles to random shades of yellow set the size to 1.5 start with random x,y heading coordinates clear all
  45. 45. ask turtles [flock] The Flocking Model (We will get to [flock] in just a moment) to understand how “display” helps the interface remove it from code and then re-run the model interface notice it is giving the model the smooth movement
  46. 46. The Flocking Model What is [ask turtles [FD 0.2]? Turtles are moving FD .2 Immediately Updated using the “display” command .2 x (repeat 5) = 1 this is the same as [ fd 1] then the model “ticks” forward and does not stop until button is turned off
  47. 47. The Flocking Model back to ask turtles [flock] which is used in the “to go” “to flock” gateway to balance of the model
  48. 48. The Flocking Model flockmates = turtles-own agentset of nearby turtles We use the “Set” Command to assign it a value “Set” to an agentset of “other turtles in-radius vision”
  49. 49. What is “other turtles in-radius vision”? Other = All Turtles in Radius Except for the Calling Turtle Radius = Allows for an agentset that is defined by distance from a calling agent Vision = parameter value that was set on the slider
  50. 50. It is going to use an “if” springing condition If no flockmates than it is going to tick the model forward (rinse and repeat) If it does find a flockmate than notice there is also an “ifelse” within the “if” “To Flock” Procedure
  51. 51. “find-nearest-neighbor” First how does it do the “find-nearest-neighbor”? it has to “set” a value for this looks within the “flockmates” and selects “min one of” “flockmates” relative to distance from myself “min-one-of” handles ties by selecting at random
  52. 52. remember “ifelse” sets up two possible conditions ... the “ifelse” split in the road Take a look at how it is split up Notice the brackets If Condition is satisfied than [ separate ] If Condition is not satisfied (i.e. else) [ align cohere]
  53. 53. Cohere, Align & Separate If Condition is satisfied than [ separate ] If Condition is not satisfied (i.e. else) [ align cohere] Please Review the Cohere, align & Separate Procedures on your own
  54. 54. Cohere, Align & Separate relies upon other procedures as shown above = slider variable = nested procedure
  55. 55. The Hawk/Dove Model http://ccl.northwestern.edu/netlogo/models/community/
  56. 56. The Hawk/Dove Model In the Community Models it is called “game theory” http://ccl.northwestern.edu/netlogo/models/community/ Download the “gametheory.nlogo” file and save it to the desktop or to a folder of your choosing
  57. 57. The Hawk/Dove Model Easiest Thing is to simultaneously install 3.1.5 along with Netlogo 4.1 Current Version of “gametheory” is Implemented in Netlogo 3.1.5 you should be able run netlogo 3.1.5 and 4.1 on the same machine If you do not already have netlogo 3.1.5 as well as 4.1 --- please install it on your machine
  58. 58. How to Acquire Netlogo 3.1.5 http://ccl.northwestern.edu/netlogo/download.shtml
  59. 59. The Hawk/Dove Model After Installing, Open Version 3.1.5 on your desktop From within 3.1.5 File ---> Open Find the “gametheory.nlogo” file and open it from within netlogo version 3.1.5 (If necessary close any open version of netlogo 4.1)
  60. 60. The Hawk/Dove Model the interface is slightly different and some of the syntax is slightly different
  61. 61. The Hawk/Dove Model
  62. 62. The Hawk/Dove Model
  63. 63. The Hawk/Dove Model Can you identify instances where the “retaliator” behavioral strategy does not win out?
  64. 64. Parameter Sweeps? Thinking about “parameter sweeps” We would like to be able to evaluate all possible parameter values with all possible parameter values 100 doves 100 hawks 100 retaliators 10 values 10 costs 100 reproduce-thresholds 100 init-energies 100 energy-time-thresholds x at least say 50 values per parameter configuration to get some sort of a statistical distribution 100,000,000,000,000 Even with some of Netlogo’s Parallelization, this is going to be hard -- here is why
  65. 65. Parameter Sweeps? Perhaps we do not have to search the full space perhaps we can grid the analysis and interpolate between the spaces Even for a limited incursion into the space, we need to think about form of automation

×