Complexity Science: Modeling Complex Systems Complexity Science (VU) (706.723) Elisabeth Lex ISDS, TU Graz November 22, 2018 Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 1 / 44
Complexity Science: Modeling Complex SystemsComplexity Science (VU) (706.723)
Elisabeth Lex
ISDS, TU Graz
November 22, 2018
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 1 / 44
Repetition
Repetition
Basic concepts of complexity science: Self-organisation, emergence,non-linearity
Logistic model to study population growth
Measuring complexity:
Fractal dimension for fractal like systemsEntropy and statistical complexity if we focus on message exchangeComputing resources AIC, effective complexity, logical depthSystem properties complexity as sizeEvolution of the system thermodynamic depth, degree of hierarchy
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 2 / 44
Introduction
Modeling Systems
Agent-based Modeling
Cellular Automata
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 3 / 44
Introduction
What is Agent-based Modeling (ABM)?
Approach to modeling systems that consist of autonomous,interacting agents
Dynamic processes of agent interaction simulated repeatedly over time
Thus, an ABM is a model in which agents interact repeatedly
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 4 / 44
Introduction
Why do we need Agent-based Modeling?
We live in an increasingly complex world
Our systems are increasingly complex and interdependent: e.gelectrical infrastructures, telecommunication networks, transportationnetworks, social systems, social networks
Some systems have always been too complex to model realistically:e.g models for economic markets
We need tools and modeling approaches available that help usanalyze complex systems
Lots of empirical data available and computational power
Example use cases for ABM: modeling agent behaviour in the stockmarket, supply chains, consumer markets, spreading of epidemics,understanding social systems,..
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 5 / 44
Agents
Agent-based models
Agents are autonomous and model intelligent behavior with a simpleset of rules
The agents are situated in space (e.g. a grid or a network)
The agents interact with each other locally (i.e., they are social)
The agents have only a partial local information
There are often different types of agents following different set of rules
The rules may be deterministic or probabilistic
There are often random elements in the world
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 6 / 44
Agents
Agents
Agents are self-contained: identifiable, discrete, has set ofcharacteristics / attributes, behaviours and decision-making capability
Agents can have memory - then, they can learn and adapt theirbehaviour (dynamic agent attribute)
Examples for agents: people, groups, organizations, insects, swarms,robots, biological entities,..
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 7 / 44
Agents
Agent-based models
Argent-based models are used to simulate actions and interactions ofautonomous agents and to assess their effects on system as a whole
Understanding relations between individual decisions and systembehavior
Micromotives vs. Macrobehavior (Schelling’s book)
They are always computational, i.e., simulations
They are intuitive for implementation, experiments, interpretation
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 8 / 44
Agents
Advantages of Agent-based models
ABMs are extensible
ABM are interpretable: one can use them to transparently planreal-world concepts
Holistic modeling approach: can be used to answer multiple questions(“many question models”)
Typically, individual-level behavior better understood than aggregate(population) level. One can start with sth that is better understoodto understand macro behavior
ABMs help tackle complexity and well suited to model behavior
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 9 / 44
Agents
Tools to build ABM
Agent-based modeling and simulation toolkits: Repast (Java), Swarm(Objective C, Java), NetLogo, StarLogo, MASON, AnyLogix
Generall tools: e.g. MATLAB, spreadsheets, ABM with programminglanguages (Python, Java,...)
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 10 / 44
Agents
Cellular Automata
E.F. Codd and John von Neuman were the first ones to propose CAsin 1950s
Became popular when John Conway introduced Life Game
Book by Stephen Wolfram: A New Kind of Science
A type of agent based models
Dynamical system that is discrete in both space and time
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 11 / 44
Agents
Cellular Automata
Basis: collection of cells arranged in a grid, i.e. spatial structure
Each cell c has a state s (out of a finite number of possible states):e.g. 1 or 0, one or off, alive or dead
Each cell has a neighborhood: typically a list of adjacent cells
Set of rules uniformly applied to the contents of each cell at eachiteration of the automaton
structure of the cellular automaton evolves through a number of timesteps based on application of rules and contents of cells and theirneighbors
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 12 / 44
Agents
Example for Cellular Automaton
Screenshot fromhttps://natureofcode.com/book/chapter-7-cellular-automata/
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 13 / 44
Life
Conways’s Game of Life (1/3)
Developed by mathematician John Conway in 1970
Early example of emergent complexity
That means: based on which rules on chooses, one gets differentoutcomes with interesting properties
Implemented as 2-dimensional infinite grid partitioned into cells
Basis idea:
Life is played on grid of square cellsEach cell is either alive or deadAn alive cell is colored, a dead one notEach cell in the grid has a neighborhood consisting of the eight cells inevery direction including diagonals
Rules:
An agent stays alive if 2 or 3 neighbors are alive, otherwise it dies (as ifby loneliness or overcrowding if more neighbors are alive)New agent is born if exactly 3 neighbors are alive
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 14 / 44
Life
Life (2/3)
Let’s apply the rules:
To apply one step of the rules, we count the number of live neighborsfor each cell
The number of live neighbors is always based on the cells before therule was applied. In other words, we must first find all of the cellsthat change before changing any of them
A dead cell with exactly three live neighbors becomes a live cell (birth)
A live cell with two or three live neighbors stays alive (survival)
In all other cases, a cell dies or remains dead (overcrowding orloneliness)
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 15 / 44
Life
Example of Life
(a) Initial stage (b) After 40 times
Figure: Life simulation: (a) initial random layout of cells in the On state, (b) afterall cells updated 40 times
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 16 / 44
Life
Netlogo Example of the Life Model
http://ccl.northwestern.edu/netlogo/
Go to File/Model Library/Computer Science/Cellular Automata/Life
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 17 / 44
Life
Why is Game of Life interesting?
Rules are simple and use only local information as each cell’s state isbased on its current state and the state of its immediate neighbors
Resulting patterns of Life depend on initial conditions - eachsimulation gives different patterns of On and Off cells
Patterns can emerge in systems that are completely described bysimple, deterministic rules based on only local information
Based on simple rules of behavior and nature of agent interactions,systems can show collective intelligence, even without existence of acentral authority
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 18 / 44
Fractals
Elementary Cellular Automaton (Wolfram, 2002)1
Simplest grid: 1-dimensional line of cells
Simplest set of states s: 0 or 1
Simplest neighborhood in 1 dimensions for any given cell: cell plus itsneighbor on the left and its neighbor on the right
Cellular automaton lives over a period of time t
Init: st=0
Question: How can we compute the states for cells at st+1?
A cell’s new state at st+1 is a function of all states in the cell’sneighborhood at previous time step st−1
1https://www.wolframscience.com/nks/Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 19 / 44
Fractals
Elementary Cellular Automaton (Wolfram, 2002)1
Simplest grid: 1-dimensional line of cells
Simplest set of states s: 0 or 1
Simplest neighborhood in 1 dimensions for any given cell: cell plus itsneighbor on the left and its neighbor on the right
Cellular automaton lives over a period of time t
Init: st=0
Question: How can we compute the states for cells at st+1?
A cell’s new state at st+1 is a function of all states in the cell’sneighborhood at previous time step st−1
1https://www.wolframscience.com/nks/Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 19 / 44
Fractals
Example: Rule 90 Elementary Cellular Automaton (1/3)
We assume an infinite grid of cells
Each cell can have a state of 0 or 1
Initially, some cells in a row are set to 1, the others are 0
The state of a cell in the subsequent row is determined by the state of3 cells: the state of the cell directly above and the two cellsdiagonally above on each side, combined via an exclusive OR function
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 20 / 44
Fractals
Example: Rule 90 Elementary Cellular Automaton (2/3)
How many state configurations can we have for these 3 cells?
23 = 8: 000, 001, 010, 011, 100, 101, 110, 111
States of three consecutive cells correspond to a 3-bit binary number
The cellular automaton is determined by what bit we assign to eachof the 8 possible 3-bit states, i.e. the automaton corresponds to an8-bit number
We apply the Rule 90 elementary cellular automaton
90 in binary is 01011010, i.e., we assign these bits to the 3-bit state:
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 21 / 44
Fractals
Example: Rule 90 Elementary Cellular Automaton (2/3)
How many state configurations can we have for these 3 cells?23 = 8: 000, 001, 010, 011, 100, 101, 110, 111
States of three consecutive cells correspond to a 3-bit binary number
The cellular automaton is determined by what bit we assign to eachof the 8 possible 3-bit states, i.e. the automaton corresponds to an8-bit number
We apply the Rule 90 elementary cellular automaton
90 in binary is 01011010, i.e., we assign these bits to the 3-bit state:
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 21 / 44
Fractals
Example: Rule 90 Elementary Cellular Automaton (2/3)
How many state configurations can we have for these 3 cells?23 = 8: 000, 001, 010, 011, 100, 101, 110, 111
States of three consecutive cells correspond to a 3-bit binary number
The cellular automaton is determined by what bit we assign to eachof the 8 possible 3-bit states, i.e. the automaton corresponds to an8-bit number
We apply the Rule 90 elementary cellular automaton
90 in binary is 01011010, i.e., we assign these bits to the 3-bit state:
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 21 / 44
Fractals
Example: Rule 90 Elementary Cellular Automaton (3/3)
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 22 / 44
Fractals
Example: Rule 90 Elementary Cellular Automaton (3/3)
Result: Sierpinski triangle. What can you observe?
Selfsimilarity, fractal patternCode:https://natureofcode.com/book/chapter-7-cellular-automata/
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 23 / 44
Fractals
Example: Rule 90 Elementary Cellular Automaton (3/3)
Result: Sierpinski triangle. What can you observe?Selfsimilarity, fractal patternCode:https://natureofcode.com/book/chapter-7-cellular-automata/
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 23 / 44
The Schelling Model
Applying CAs to study social phenomena: The SchellingModel
T. Schelling (1971): A small preference for a specific kind ofneighbors lead to total segregation
Placed pennies and dimes on a chess board and moved them aroundaccording to various rulesInterpreted board as a city, each square represents a housePennies and dimes represented agents, e.g. two racesNeighborhood of an agent was the squares adjacent to the square inwhich the agent residedRules determined whether an agent was happy in its current locationIf unhappy it could move to another location or exit the board entirely
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 24 / 44
The Schelling Model
Applying CAs to study social phenomena: The SchellingModel
Result:
Board became segregated even if the agents did not prefer segregation
Board became segregated if an initially integrated board hadhappiness rules that expressed mild preference for neighbors of theirown type
I.e., model shows how global patterns (spatial segregation) canemerge from local preferences
A simple interaction mechanism leads to segregation
Segregation achieved even if no one explicitly aims for it - i.e. nocentral control
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 25 / 44
The Schelling Model
How does the Schelling Model work? (1/2)
Assume a population of individuals (aka agents) of type X or OTypes represent immutable characteristics (e.g., age)Two populations are initially placed into random locations of aneighborhood gridAfter placing all agents, each cell is either occupied by an agent oremptyThe neighbor relationships among the cells can be represented verysimply as a graph: cells are the nodes, edges are inserted between twocells that are neighbors on the grid
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 26 / 44
The Schelling Model
How does the Schelling Model work? (2/2)
Now, determine if each agent is satisfied with its current location
Agent is satisfied if is surrounded by at least t of its own type ofneighboring agents
Threshold t applies to all agents in the model (in reality everyonemight have a different threshold they are satisfied with)
The higher t, the higher the likelihood that agents will not besatisfied with their current location
Example:
For example, if t = 3, agent X is satisfied if at least 3 of its neighborsare also XIf fewer than 3 are X, then the agent is not satisfied, and it will want tochange its location in the gridAny algorithm can be used to choose new location (e.g., randomselection, nearest available location, 1 row at a time)
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 27 / 44
The Schelling Model
Example
(a) Initial stage (b) After one round
Figure: Left image: all dissatisfied agents have an asterisk next to them. Rightimage: shows new configuration after all dissatisfied agents have been moved tounoccupied cells (1 row at a time) where they are satisfied. May cause otheragents to become unsatisfied, then new round of movement begins
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 28 / 44
The Schelling Model
Netlogo Example of the Schelling Model
http://ccl.northwestern.edu/netlogo/
Go to File/Model Library/Social Science/Segregation
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 29 / 44
The Schelling Model
Observations from Schelling’s Model
Spatial segregation takes place even though no individual agentactively wants it
Segregation doesn’t happen due to built-in model agents that arewilling to be in the minority
Ideally, all agents are carefully arranged in an integrated pattern
However, from random start hard for agents to find such integratedpatterns
At more general level, Schelling model is an example of how fixedcharacteristics (e.g., ethnicity) can become highly correlated withmutable characteristics
E.g. decision where to live, which over time conforms to similarities inagents immutable types, producing segregation
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 30 / 44
Forest Fire
CAs: Simulation of forest fires
We model a forest as a grid of cells
A cell is either occupied by a tree or empty
The fire starts on the left edge of the forest
It spreads to the neighboring trees in all four directions
North, south, east, west
Fire can not skip an empty cell
There is no wind
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 31 / 44
Forest Fire
Netlogo Example of the Forest Fire model
http://ccl.northwestern.edu/netlogo/
Go to File/Model Library/Earth Science/Fire
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 32 / 44
Forest Fire
Questions
With density around 50% how much of the forest burns
With different initial settings do the same tree burn?
Each point that represents a tree burning is born and then dies
It never moves whatsoever
The fire is made of burning trees that do not move
But the fire itself moves!
Local vs. global level
Emergence of properties at a global level that do not exist on thelocal level
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 33 / 44
Forest Fire
Phase transition
Often there is a very small margin for parameters and the networkstructure where the system goes quickly from one state into another
This is called phase transition
We can observe a phase transition around 59%
Reaching the other edge of the grid
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 34 / 44
Ising
Simulate physical processes: The Ising model
The model originally comes from physics
It models the magnetization of a material
The cells are organized in a grid
Each cell has a spin si: it is represented by +1 or -1
The cells can flip their spin
The energy of a cell is calculated from its four neighbors (north,south, east, west) as Ei =
∑j sisj
The total energy is E =∑
iEi
The system always tries to reach the state of the minimal energy withsome randomness, which increases with temperature
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 35 / 44
Ising
Netlogo Example of the Ising model
http://ccl.northwestern.edu/netlogo/
Go to File/Model Library/Chemistry & Physics/Ising
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 36 / 44
Ising
Questions
What happens when the temperature is low?
The cells will align their spins
What happens when the temperature is high?
The alignment is not likely anymore
There is a specific temperature, which separates those two modes:2
ln(1+√2)
on an infinite grid
Phase transition
Ising model can be used to model also other types of processes - anyideas?
Opinion dynamics, consensus reaching, etc.
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 37 / 44
Ising
Questions
What happens when the temperature is low?
The cells will align their spins
What happens when the temperature is high?
The alignment is not likely anymore
There is a specific temperature, which separates those two modes:2
ln(1+√2)
on an infinite grid
Phase transition
Ising model can be used to model also other types of processes - anyideas?
Opinion dynamics, consensus reaching, etc.
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 37 / 44
Ising
Questions
What happens when the temperature is low?
The cells will align their spins
What happens when the temperature is high?
The alignment is not likely anymore
There is a specific temperature, which separates those two modes:2
ln(1+√2)
on an infinite grid
Phase transition
Ising model can be used to model also other types of processes - anyideas?
Opinion dynamics, consensus reaching, etc.
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 37 / 44
Ising
Questions
What happens when the temperature is low?
The cells will align their spins
What happens when the temperature is high?
The alignment is not likely anymore
There is a specific temperature, which separates those two modes:2
ln(1+√2)
on an infinite grid
Phase transition
Ising model can be used to model also other types of processes - anyideas?
Opinion dynamics, consensus reaching, etc.
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 37 / 44
Wealth Distribution
How does the wealth distribution work?
We have population living on a grid of cells
Each cell has an amount of grain and an grain capacity
People collect grain from the cells and eat (some of) the grain tosurvive
How much grain each person accumulates is her wealth
Initially, a roughly equal distribution
Each person attempts to move to a cell with more grain (if free)
People have a life expectancy and can die and can also die if theyhave no grain
If a person dies an offspring is born with a random amount of grain(no inheritance)
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 38 / 44
Wealth Distribution
Netlogo Example of the Wealth Distribution model
http://ccl.northwestern.edu/netlogo/
Go to File/Model Library/Social Science/Wealth Distribution
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 39 / 44
Wealth Distribution
Questions
What kind of wealth distribution do we expect to see?
A power-law distribution! Why?
Because agents are heterogeneous
They have different visions, metabolism, life expectancy, and so on
Those agents who gain an initial advantage will keep that advantage
Preferential attachment
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 40 / 44
Wealth Distribution
Questions
What kind of wealth distribution do we expect to see?
A power-law distribution! Why?
Because agents are heterogeneous
They have different visions, metabolism, life expectancy, and so on
Those agents who gain an initial advantage will keep that advantage
Preferential attachment
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 40 / 44
Wealth Distribution
Questions
What kind of wealth distribution do we expect to see?
A power-law distribution! Why?
Because agents are heterogeneous
They have different visions, metabolism, life expectancy, and so on
Those agents who gain an initial advantage will keep that advantage
Preferential attachment
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 40 / 44
Wealth Distribution
Summary
Agent-based modeling to model complex systems and to studyemergent phenomena, e.g. from animal behavior, social sciences,ecology, ...
Special case of ABMs: Cellular Automata
Examples for ABM: Life, Schelling, Forest Fire, Ising Model, Wealthdistribution
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 41 / 44
Wealth Distribution
Take away
We can model and understand real-world phenomena by constructingmodels that exhibit complex emergent behavior resulting from local,simplified agent interaction.
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 42 / 44
Wealth Distribution
How would you build an ABM?
Pro tip: Take an established model and see whether you can buildupon it
Requires model literacy!
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 43 / 44
Wealth Distribution
How would you build an ABM?
Pro tip: Take an established model and see whether you can buildupon it
Requires model literacy!
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 43 / 44
Wealth Distribution
Questions?
Elisabeth Lex (ISDS, TU Graz) Complexity Science November 22, 2018 44 / 44