modeling and simulating social systems with matlab · 2015-10-26 modelling and simulating social...

56
2015-10-26 ETH Zürich Modeling and Simulating Social Systems with MATLAB Lecture 5 – Cellular Automata Olivia Woolley, Stefano Balietti, Lloyd Sanders Computational Social Science (D GESS)

Upload: others

Post on 22-Jun-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26ETH Zürich

Modeling and Simulating Social Systemswith MATLAB

Lecture 5 – Cellular Automata

Olivia Woolley, Stefano Balietti, Lloyd Sanders

Computational Social Science (D GESS)

Page 2: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 2

Strategies for Research Projects

“Data project”: Choose a dataset for which you have an interesting

question Come up with a research question that can be tested

with that data Implement an existing model form the scientific literature Run simulations that either use the dataset as input or

that reproduce certain aspects of the data

Page 3: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 3

Strategies for Research Projects

“Paper project”: Choose a scientific paper (or several papers) on a

modeling and simulation approach that looks interesting Come up with a research question that builds upon the

paper but is different from their research questions Extend, simplify, modify, and/or combine existing models

for testing your research question Run simulations for your model and compare the results

to the ones for the original model

Page 4: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 4

Repetition

Dynamical systems described by a set of differentialequations; numerical solutions can be calculatediteratively using Euler's method (examples: Lotka-Volterra and Kermack-McKendrick)

The values and ranges of parameters critically matter for the system dynamics (Example 2, epidemiologicalthreshold)

Time resolution in Euler's method must be sufficientlyhigh to capture “fast” system dynamics (Example 3)

MATLAB provides the commands ode23 and ode45 forsolving differential equations (Example 3)

4

Page 5: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 55

Simulation Models

What do we mean when we speak of

(simulation) models?

Formalized (computational) representation of social

(or other kinds of) dynamics

Reduction of complexity, i.e. highly simplifying

assumptions

The goal is not to reproduce reality in general (only

very specific aspects of it)

Formal framework to test and evaluate causal

hypotheses against empirical data

Page 6: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 66

Simulation Models

Strength of (simulation) models?

Computational laboratory: test how micro dynamics

lead to macro patters

Experiments with computer models are particularly

useful in the social sciences, where experiments in

the real world are typically not possible

Suitable where analytical models fail or where

dynamics are too complex for analytical models

Page 7: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 77

Simulation Models

Weakness of (simulation) models? The choice of model parameters and implementation

details can have a strong influence on the simulation

outcome

We can only model aspects of a system, i.e. the

models are necessarily incomplete and reductionist

More complex models are generally not better (only

when simplification is not possible)

It can be hard to relate simulation results to a realistic

and relevant empirical question

Page 8: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 88

Simulation Models

How to we deal with the known limitations?

Simple models with only few parameters

Test whether simulation results depend on details of

the implementation or model

Validate the model mechanism with observations and

causal plausibility

Use empirical data to evaluate the predictive power of

the simulation model

Page 9: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 99

Cellular Automaton (plural: Automata)

Page 10: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 1010

Cellular Automaton (plural: Automata)

A cellular automaton is a set of rules, defining

how the state of a cell in a grid is updated,

depending on the states of its neighboring cells

Cellular-automata simulations are discrete in

time and space

Page 11: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 11

Cellular Automaton

The grid can have an arbitrary number of

dimensions:

1-dimensional cellularautomaton

2-dimensional cellularautomaton

Page 12: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 12

Moore Neighborhood

The cells are interacting with each neighbor

cells, and the neighborhood can be defined in

different ways, e.g. the Moore neighborhood:

1st order Moore neighborhood 2nd order Moore neighborhood

Page 13: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 13

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:

1st order Von-Neumann neighborhood

2nd order Von-Neumann neighborhood

Page 14: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 14

Game of Life

Ni = Number of 1st order Moore neighbors to cell i

that are activated.

For each cell i:1. Deactivate active cell iff Ni <2 or Ni >3.2. Activate inactive cell iff Ni =3

i

Page 15: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 1515

Game of Life

Ni = Number of 1st order Moore neighbors to cell i

that are activated.

For each cell i:1. Deactivate active cell if Ni <2 or Ni >3.2. Activate inactive cell if Ni =3

Page 16: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 1616

Game of Life Want to see the Game of Life in action? Type:

life

Page 17: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 17

Complex Patterns

17

“Gosper Glider Gun”:

Page 18: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 18

Game of Life: Some Bits of History1970: Conway presents the Game of Life; discovery of the glider(speed c/4) and the standard spaceships (speed c/2); discovery of theGosper glider gun (first pattern found with indefinite growth)

1971: First garden of eden (pattern that has no parent pattern and canonly occur at generation 0) was discovered; first patter with quadraticgrowth (breeder)

1989: Discovery of the first spaceships with velocities c/3 and c/4

1996: Game of Life simulated in Game of Life

2000: A Turing machine was built in Game of Life

2004: Construction of the largest interesting pattern so far: caterpillarspaceship with speed 17c/45 consisting of 11,880,063 alive cells

2013: The first complete replicator (a pattern that produces an exactcopy of itself) was built

2014: Game of Life wiki contains more than 3000 interesting patterns

Page 19: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 19

Surprising discoveries continue

“The loafer” is a very small spaceship

It is the slowest known orthogonal spaceship

(speed of c/7)

It was discovered only in 2013

Page 20: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 20

Life in Life

20

The Game of Life can be used to simulate the

Game of Life:

http://www.youtube.com/watch?v=xP5-iIeKXE8

Page 21: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 21

Life in Life

21

The Game of Life can be used to calculate

everything (if a Turing machine can):

http://www.youtube.com/watch?v=My8AsV7bA94

Page 22: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 2222

1-dimensional Cellular Automata

Page 23: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 2323

Cellular Automaton: Principles

1. Self Organization: Patterns appear from

random start patterns

2. Emergence: High-level phenomena can

appear such as gliders, glider guns, etc.

3. Complexity: Simple rules produce complex

phenomena

Page 24: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 2424

Highway Simulation

Simple example of a 1-dimensional cellular

automaton

Rules for each car at cell i:

1. Stay: If the cell directly to the right is occupied.

2. Move: Otherwise, move one step to the right, with

probability p

Move to the next cell, withthe probability p

Page 25: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 2525

Highway Simulation

We have prepared some files for the highway

simulations: draw_car.m : Draws a car, with the function

draw_car(x0, y0, w, h)

simulate_cars.m: Runs the simulation, with the

function

simulate_cars(moveProb, inFlow,

withGraphics)

Page 26: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 2626

Highway Simulation

Running the simulation is done like this:

simulate_cars(0.9, 0.2, true)

Page 27: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 2727

Kermack-McKendrick Model

In lecture 4, we introduced the Kermack-

McKendrick model, used for simulating disease

spreading

We will now implement the model again, but this

time instead of using differential equations we

use the approach of cellular automata

Page 28: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 28

Kermack-McKendrick model

Page 29: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 2929

Kermack-McKendrick Model

The Kermack-McKendrick model is specified as:

S: Susceptible persons

I: Infected persons

R: Removed (immune)

persons

β: Infection rate

γ: Immunity rate

Page 30: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 3030

Kermack-McKendrick Model

The Kermack-McKendrick model is specified as:

S: Susceptible persons

I: Infected persons

R: Removed (immune)

persons

β: Infection rate

γ: Immunity rate )(

)( )()(

)()(

tIdt

dR

tItStIdt

dI

tStIdt

dS

Page 31: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 3131

Kermack-McKendrick Model

The Kermack-McKendrick model is specified as:

S: Susceptible persons

I: Infected persons

R: Removed (immune)

persons

β: Infection rate

γ: Immunity rate )(

)( )()(

)()(

tIdt

dR

tItStIdt

dI

tStIdt

dS

Page 32: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 3232

Kermack-McKendrick Model

The Kermack-McKendrick model is specified as:

S: Susceptible persons

I: Infected persons

R: Removed (immune)

persons

β: Infection rate

γ: Immunity rate

Page 33: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 3333

Kermack-McKendrick Model

The Kermack-McKendrick 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 S S S

I I I S S S S

I I I I S S S

R I I I S S S

R I I I S S S

I I I S S S S

I S S S S S S

0 0 0 0 0 0 0

1 1 1 0 0 0 0

1 1 1 1 0 0 0

2 1 1 1 0 0 0

2 1 1 1 0 0 0

1 1 1 0 0 0 0

1 0 0 0 0 0 0

Page 34: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 3434

Kermack-McKendrick Model

The Kermack-McKendrick model is specified as:

We now define a 2-dimensional cellular-

automaton, by defining a grid (matrix) x, where

each of the cells is in one of the states: 0: Susceptible

1: Infected

2: Recovered

Page 35: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 3535

Kermack-McKendrick Model

Define microscopic rules for Kermack-

McKendrick model:

In every 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 γ.

Page 36: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 3636

Cellular-Automaton Implementation

Implementation of a 2-dimensional cellular

automaton in MATLAB can be done like this:

The iteration over the cells can be done either

sequentially, in parallel, or randomly

Iterate the time variable, tIterate over all cells, i=1..N, j=1..N

Iterate over all neighbors, k=1..M

End k-iterationEnd i-iteration

End t-iteration

Page 37: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 3737

Cellular-automaton implementation

Sequential update:

...

Page 38: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 38

Cellular-automaton implementation

Parallel update (use a copy of the grid):

... ...

data from last iteration: working copy:

Page 39: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 3939

Cellular-automaton implementation

Random update:

...

Page 40: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 4040

Cellular-automaton implementation

Attention: Simulation results can be very sensitive to the type of

update used

Random update is usually preferable for social

simulations (but also not always the best solution)

Just be aware of this potential complication and

check your results for dependency on the

updating scheme!

Page 41: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 4141

Boundary Conditions

The boundary conditions can be: Periodic: The grid is wrapped, so that what exits on

one side reappears at the other side of the grid.

Fixed: Agents are not influenced by what happens at

the other side of a border.

Page 42: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 4242

Boundary Conditions

Periodic boundaries are usually preferable:

Fixed boundaries Periodic boundaries

Page 43: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 4343

MATLAB Implementation of the Kermack-McKendrick Model

Page 44: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 4444

MATLAB implementation

Set parameter values

Page 45: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 4545

MATLAB implementation

Define grid, x

Page 46: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 4646

MATLAB implementation

Define neighborhood

Page 47: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 4747

MATLAB implementation

Main loop. Iterate thetime variable, t

Page 48: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 4848

MATLAB implementation

Iterate over all cells,i=1..N, j=1..N

Page 49: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 4949

MATLAB implementation

For each cell i, j: Iterateover the neighbors

Page 50: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 5050

MATLAB implementation

The model, i.e. updatingrule goes here.

Page 51: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 5151

Aborting Execution

When running large computations or animations, the

execution can be aborted by pressing Ctrl+C in the main

window:

Page 52: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 52

References

Wolfram, Stephen, A New Kind of Science. Wolfram

Media, Inc., May 14, 2002.

http://www.conwaylife.com/wiki/

Martin Gardner. The fantastic combinations of John

Conway's new solitaire game "life". Scientific American

223 (October 1970): 120-123.

Schelling, Thomas C. (1971). Dynamic Models of

Segregation. Journal of Mathematical Sociology 1:143-

186.

Page 53: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 53

Exercise 1

Get draw_car.m and simulate_cars.m from

www.soms.ethz.ch/matlab or from

https://github.com/msssm/lecture_files

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.

Page 54: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 54

Exercise 1b

Generate a video of an interesting case in your

traffic simulation.

We have uploaded an example file:

simulate_cars_video.m

Page 55: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 55

Exercise 2

Download the file disease.m which is an

implementation of the Kermack-McKendrick

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

implementation last class

Page 56: Modeling and Simulating Social Systems with MATLAB · 2015-10-26 Modelling and Simulating Social Systems with Matlab 7 Simulation Models Weakness of (simulation) models? The choice

2015-10-26 Modelling and Simulating Social Systems with Matlab 56

Exercise 3

Modify the model Kermack-McKendrick model in

the following ways: Change from the 1st order Moore neighborhood to a

2nd and 3rd order Moore neighborhood.

Make it possible for

Removed individuals

to change back to

Susceptible

What changes?