Presentation is loading. Please wait.

Presentation is loading. Please wait.

2010-12-04 851-0585-04L – Modelling and Simulating Social Systems with MATLAB Lesson 7 – Continuous simulations Wenjian Yu © ETH Zürich |

Similar presentations


Presentation on theme: "2010-12-04 851-0585-04L – Modelling and Simulating Social Systems with MATLAB Lesson 7 – Continuous simulations Wenjian Yu © ETH Zürich |"— Presentation transcript:

1 2010-12-04 851-0585-04L – Modelling and Simulating Social Systems with MATLAB Lesson 7 – Continuous simulations Wenjian Yu © ETH Zürich |

2 2010-12-04 W. Yu / yuwen@ethz.ch 2 Lesson 6 - Contents  Micro-macro link  Some basis of motion dynamics  Pedestrian simulation

3 2010-12-04 W. Yu / yuwen@ethz.ch Drunkard’s Walk  The drunkard takes a series of steps away from the lamp post, each with a random angle. 3 (Figure Resource: Sethna JP, 2006)

4 2010-12-04 W. Yu / yuwen@ethz.ch Random Walk and Diffusion Equation 4  Consider a general, uncorrelated random walk where at each time step the particle’s position changes by a step :  The probability distribution for each step is, which has zero mean and standard deviation.

5 2010-12-04 W. Yu / yuwen@ethz.ch  For the particle to go from at time to at time, the step. Such event occurs with probability times the probability density. Therefore, we have 5

6 2010-12-04 W. Yu / yuwen@ethz.ch The Micro-Macro Link  Use Taylor expansion, we have 6 The following is the diffusion equation

7 2010-12-04 W. Yu / yuwen@ethz.ch The Continuous Assumption 7 Resources: Google

8 2010-12-04 W. Yu / yuwen@ethz.ch From discreet to continuous space  Cellular automaton (CA)  Continuous simulation

9 2010-12-04 W. Yu / yuwen@ethz.ch Modelling agent’s motion in a continuous space  Agents are characterized by  Their position -X (m) -Y (m)  Their velocity -Vx (m/s) -Vy (m/s) x y Vx Vy

10 2010-12-04 W. Yu / yuwen@ethz.ch Modelling agent’s motion in a continuous space  Next position after 1 second is given by:  x(t+1) = x(t) + Vx(t)  y(t+1) = y(t) + Vy(t) x y Vx Vy Time t Time t+1

11 2010-12-04 W. Yu / yuwen@ethz.ch Modelling agent’s motion in a continuous space  Time step dt is often different from 1:  x(t+dt) = x(t) + dt*Vx(t)  y(t+dt) = y(t) + dt*Vy(t) x y Vx Vy Time t Time t+dt dt<1 Time t+dt dt>1

12 2010-12-04 W. Yu / yuwen@ethz.ch Modelling agent’s motion in a continuous space  The velocity is also updated in time. x y

13 2010-12-04 W. Yu / yuwen@ethz.ch Modelling agent’s motion in a continuous space  The velocity changes as a result of inter-individual interactions  Repulsion  Attraction  Examples: atoms, planets, pedestrians, animals swarms…

14 2010-12-04 W. Yu / yuwen@ethz.ch Modelling agent’s motion in a continuous space  The changes of velocity vector is defined by an acceleration.

15 2010-12-04 W. Yu / yuwen@ethz.ch Modelling agent’s motion in a continuous space  The velocity changes as a result of interactions with the environment  Repulsion  Attraction  Examples: bacteria, ants, pedestrian trails …

16 2010-12-04 W. Yu / yuwen@ethz.ch Modelling agent’s motion in a continuous space  The velocity changes as a result of a random process  With or without bias  Examples: exploration behaviour in many species of animals

17 2010-12-04 W. Yu / yuwen@ethz.ch Modelling agent’s motion in a continuous space  How to define a random move?  Choose a random angle in a normal distribution  Rotate the velocity by this angle  In Matlab:  newAngle = randn() Mean=0 Variance=1

18 2010-12-04 W. Yu / yuwen@ethz.ch Modelling agent’s motion in a continuous space  How to define a random move?  Choose a random angle in a normal distribution  Rotate the velocity by this angle  In Matlab:  meanVal=2;  v=0.1;  newAngle = meanVal + v*randn()

19 2010-12-04 W. Yu / yuwen@ethz.ch Modelling agent’s motion in a continuous space  How to define a BIASED random move?  Unbalance the distribution toward positive or negative values  In Matlab:  meanVal=2;  v=0.1;  newAngle = meanVal + v*randn()

20 2010-12-04 W. Yu / yuwen@ethz.ch Programming the simulator X = [1 1 3 ]; Y = [2 1 1]; Vx = [0 0 0.1]; Vy = [1 1 0.5]; For t=1:dt:T For p=1:N [Vx(p) Vy(p)] = update( …) ; X(p) = X(p) + dt*Vx(p) ; Y(p) = Y(p) + dt*Vy(p) ; end  Initialization: Four elements are required to define the state of individuals  The velocity is updated first, and then the position as a function of the velocity and the time step

21 2010-12-04 W. Yu / yuwen@ethz.ch 21 Brownian Motion %Brownian Motion t = 100;n = 1000;dt=t/n; x = zeros(1,n);y = zeros(1,n); dx = zeros(1,n);dy = zeros(1,n); x(1) = 0;y(1) = 0; hold on; k = 1; for j=2:n x(j) = x(j-1) + sqrt(dt)*randn; y(j) = y(j-1) + sqrt(dt)*randn; plot([x(j-1),x(j)],[y(j-1),y(j)]); M(k) = getframe; k = k + 1; end

22 2010-12-04 W. Yu / yuwen@ethz.ch 22 Pedestrian Simulation  CA model  Many-particle model

23 2010-12-04 W. Yu / yuwen@ethz.ch 23 CA Model (A. Kirchner, A. Schadschneider, Phys. A, 2002)

24 2010-12-04 W. Yu / yuwen@ethz.ch 24 Many-particle Model (Helbing, Nature, 2000)  Desired velocity  Repulsive force


Download ppt "2010-12-04 851-0585-04L – Modelling and Simulating Social Systems with MATLAB Lesson 7 – Continuous simulations Wenjian Yu © ETH Zürich |"

Similar presentations


Ads by Google