851 0585 04 L Modeling and Simulating Social
- Slides: 63
851 -0585 -04 L – Modeling and Simulating Social Systems with MATLAB Lecture 4 – Cellular Automata Giovanni Luca Ciampaglia, Stefano Balietti and Karsten Donnay Chair of Sociology, in particular of Modeling and Simulation © ETH Zürich | 2010 -10 -18
Lesson 4 – Contents § Cellular Automata § Neighborhood definitions § Models Game of Life § Highway Simulation § Disease Spreading, revisited § § Exercises 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 2
Cellular Automaton (plural: Automata) § A cellular automaton is a rule, defining how the state of a cell in a grid is updated, depending on the states of its neighbor cells. § They are represented as grids with arbitrary dimension. § Cellular-automata simulations are discrete both in time and space. 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 3
Cellular Automaton § The grid can have an arbitrary number of dimensions: 1 -dimensional cellular automaton 2010 -10 -18 2 -dimensional cellular automaton G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 4
Moore Neighborhood § The cells are interacting with each neighbor cells, and the neighborhood can be defined in different ways, e. g. the Moore neighborhood: 1 st order Moore neighborhood 2010 -10 -18 2 nd order Moore neighborhood G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 5
Von-Neumann Neighborhood § The cells are interacting with each neighbor cells, and the neighborhood can be defined in different ways, e. g. the Von-Neumann neighborhood: 1 st order Von-Neumann neighborhood 2010 -10 -18 2 nd order Von-Neumann neighborhood G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 6
Game of Life § Ni = Number of 1 st order Moore neighbors to cell i that are activated. § For each cell i: Deactivate: If Ni <2 or Ni >3. 2. Activate: if cell i is deactivated and Ni =3 1. www. mathworld. wolfram. com 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 7
Highway Simulation § As an example of a 1 -dimensional cellular automaton, we will present a highway simulation. For each car at cell i: Stay: If the cell directly to the right is occupied. 2. Move: Otherwise, move one step to the right, with probability p 1. Move to the next cell, with the probability p 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 8
Highway Simulation § We have prepared some files for the highway simulations: § draw_car. m : Draws a car, with the function draw_car(x 0, y 0, w, h) § simulate_cars. m: Runs the simulation, with the function simulate_cars(move. Prob, in. Flow, with. Graphics) 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 9
Highway Simulation § Running the simulation is done like this: simulate_cars(0. 9, 0. 2, true) 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 10
Kermack-Mc. Kendrick Model § In lesson 3, we introduced the Kermack. Mc. Kendrick model, used for simulating disease spreading. § We will now implement the model again, but this time within the cellular-automata framework. 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 11
Kermack-Mc. Kendrick Model § The Kermack-Mc. Kendrick model is specified as: S: Susceptible persons I: Infected persons R: Removed (immune) persons β: Infection rate γ: Immunity rate 2010 -10 -18 S β transmission R γ recovery G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch I 12
Kermack-Mc. Kendrick Model § The Kermack-Mc. Kendrick model is specified as: S: Susceptible persons I: Infected persons R: Removed (immune) persons β: Infection rate γ: Immunity rate 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 13
Kermack-Mc. Kendrick Model § The Kermack-Mc. Kendrick model is specified as: S: Susceptible persons I: Infected persons R: Removed (immune) persons β: Infection rate γ: Immunity rate 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 14
Kermack-Mc. Kendrick Model § The Kermack-Mc. Kendrick model is specified as: S: Susceptible persons I: Infected persons R: Removed (immune) persons β: Infection rate γ: Immunity rate 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 15
Kermack-Mc. Kendrick Model § The Kermack-Mc. Kendrick model is specified as: S: Susceptible persons I: Infected persons R: Removed (immune) persons β: Infection rate γ: Immunity rate 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 16
Kermack-Mc. Kendrick Model § The Kermack-Mc. Kendrick model is specified as: For the MATLAB implementation, we need to decode the states {S, I, R}={0, 1, 2} in a matrix x. S S S S 0 0 0 0 I I I S S 1 1 1 0 0 I I S S S 1 1 0 0 0 R I I I S S S 2 1 1 1 0 0 0 I I I S S 1 1 1 0 0 I S S S 1 0 0 0 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 17
Kermack-Mc. Kendrick Model § The Kermack-Mc. Kendrick model is specified as: We now define a 2 -dimensional cellularautomaton, by defining a grid (matrix) x, where each of the cells is in one of the states: 0: Susceptible § 1: Infected § 2: Recovered § 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 18
Kermack-Mc. Kendrick Model § The Kermack-Mc. Kendrick model is specified as: At each time step, the cells can change states according to: § A Susceptible individual can be infected by an Infected neighbor with probability β, i. e. State 0 -> 1, with probability β. § An individual can recover from an infection with probability γ, i. e. State 1 -> 2, with probability γ. 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 19
Cellular-Automaton Implementation § Implementation of a 2 -dimensional cellularautomaton model in MATLAB is done like this: Iterate the time variable, t Iterate over all cells, i=1. . N, j=1. . N Iterate over all neighbors, k=1. . M § The iteration over the cells can be done either sequentially, or randomly. 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 20
Cellular-Automaton Implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 21
Cellular-Automaton Implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 22
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 23
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 24
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 25
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 26
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 27
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 28
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 29
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 30
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 31
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 32
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 33
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 34
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 35
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 36
Cellular-automaton implementation § Sequential update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 37
Cellular-automaton implementation § Random update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 38
Cellular-automaton implementation § Random update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 39
Cellular-automaton implementation § Random update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 40
Cellular-automaton implementation § Random update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 41
Cellular-automaton implementation § Random update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 42
Cellular-automaton implementation § Random update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 43
Cellular-automaton implementation § Random update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 44
Cellular-automaton implementation § Random update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 45
Cellular-automaton implementation § Random update: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 46
Boundary Conditions § The boundary conditions can be any of the following: § Periodic: The grid is wrapped, so that what crosses a border is reappearing at the other side of the grid. § Fixed: Agents are not influenced by what happens at the other side of a border. 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 47
Boundary Conditions § The boundary conditions can be any of the following: Fixed boundaries 2010 -10 -18 Periodic boundaries G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 48
MATLAB Implementation of the Kermack. Mc. Kendrick Model 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 49
Set parameter values MATLAB implementation 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 50
Define grid, x MATLAB implementation 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 51
Define neighborhood MATLAB implementation 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 52
Main loop. Iterate the time variable, t MATLAB implementation 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 53
Iterate over all cells, i=1. . N, j=1. . N MATLAB implementation 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 54
For each cell i, j: Iterate over the neighbors MATLAB implementation 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 55
The model, i. e. updating rule goes here. MATLAB implementation 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 56
Breaking Execution § When running large computations or animations, the execution can be stopped by pressing Ctrl+C in the main window: 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 57
Projects 1. Find somebody to work with. 2. Have a look at the projects on: www. soms. ethz. ch/matlab/ 3. When you have found an interesting topic, inform us and we will put you on the projects list. 4. Within one week, send to: kdonnay@ethz. ch and sbalietti@ethz. ch a short plan about your project 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 58
Project Plan: § Small summary: half an A 4 page § This summary should include a brief plan which model to implement, what to simulate and which kind of results to expect. § Add additional references you have found (pdf) § The purpose is to get feedback and make sure that the project will develop in the right direction. 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 59
Projects – Suggested Topics 1 Artificial 7 Emergence of Financial Markets Culture 13 Language Formation 19 Specialization of Labor 2 Civil Violence 8 Emergence of Values 14 Learning 20 Traffic Dynamics 3 Collective Behavior 9 Evacuation Bottleneck 15 Opinion Formation 21 Trail Formation 4 Disaster Spreading 16 Pedestrian Dynamics 22 Wikipedia 5 Emergence of Conventions 10 Friendship Network Formation 11 Innovation Diffusion 17 Self-organized criticality ? 6 Emergence of Cooperation 12 Interstate Conflict 18 Social Networks ? Evolution 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 60
Exercise 1 § Download the files draw_car. m and simulate_cars. m from the course web page, www. soms. ethz. ch/matlab Investigate how the flow (moving vehicles per time step) depends on the density (occupancy 0%. . 100%) in the simulator. This relation is called the fundamental diagram in transportation engineering. 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 61
Exercise 2 § Download the file disease. m which is an implementation of the Kermack-Mc. Kendrick model as a Cellular Automaton. § Plot the relative fractions of the states S, I, R, as a function of time, and see if the curves look the same as for the old implementation. 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 62
Exercise 2 b § Modify the model in the following ways: Change from the 1 st order Moore neighborhood to a 2 nd and 3 rd order Moore neighborhood. § Make it possible for Removed individuals to change state back to Susceptible. § 2010 -10 -18 G. L. Ciampaglia, S. Balietti & K. Donnay / ciampagg@ethz. ch sbalietti@ethz. ch kdonnay@ethz. ch 63
- Late post mortem changes
- Conditions simulating rigor mortis
- Helen erickson biography
- 10 cfr 851
- Regulation 851
- 851
- Relational vs dimensional data modeling
- National general foundation health
- Ngic 888-781-0585
- Apa itu social thinking
- Social thinking social influence social relations
- Decision trees show the logic structure in a
- Linear quadratic function
- Typical process description tools include
- Social darwinism vs social gospel
- Simulation modeling and analysis law kelton
- Sequential decision analytics
- Modeling with exponential and logarithmic equations quiz
- Answers key
- Requirements modeling in system analysis and design
- Business process and functional modeling
- Business process and functional modeling
- Modeling and imitation training aba
- Imitation and modeling
- Algebra 1 bootcamp functions and modeling answer key
- 2019 algebra 1 bootcamp answers
- Algebra 1 bootcamp functions and modeling
- Agile modeling and prototyping
- Additive and subtractive modeling
- Agile modeling and prototyping
- Jackie buys 3 hot dogs and 1 pretzel
- Algebra bootcamp answers
- Object-oriented modeling and designs books
- Pharmaceutical simulation and modeling
- Introduction to modeling and simulation
- Data vault pros and cons
- Mathematical modeling and engineering problem solving
- Biomedical modeling and simulation
- Device modeling for analog and rf cmos circuit design
- Patched up prototype
- Solid modeling and additive manufacturing
- Contoh model simulasi
- Computational engineering and physical modeling
- Geometric modeling in probability and statistics
- Quantities and modeling algebra 1
- Job analysis vs competency modeling
- Merger and acquisition financial modeling
- Softwares can_ -in designing and modeling in every field
- Mathematical modeling and engineering problem solving
- Site:slidetodoc.com
- Image-based modeling and rendering
- Modeling and visualization of leaf venation patterns
- Health care risk adjustment and predictive modeling
- Manufacturing systems modeling and analysis
- Ksao job analysis example
- Predictive analytics risk adjustment healthcare examples
- Difference between social action and social interaction pdf
- Relationship between political science and social work
- Social thinking and social influence
- What was reform darwinism
- Social darwinism and social gospel venn diagram
- Social darwinism vs. social gospel
- Global agenda for social work and social development
- Social control theory