Download presentation
Presentation is loading. Please wait.
Published byGervais Miles Modified over 6 years ago
1
851-0585-04L – Modeling and Simulating Social Systems with MATLAB
L – Modeling and Simulating Social Systems with MATLAB Lecture 7 – Continuous Simulations Giovanni Luca Ciampaglia, Stefano Balietti and Karsten Donnay Chair of Sociology, in particular of Modeling and Simulation © ETH Zürich | © ETH Zürich |
2
Lesson 7 - Contents Micro-macro link Some basis of motion dynamics
Lesson 7 - Contents Micro-macro link Some basis of motion dynamics Pedestrian simulation
3
Drunkard’s Walk The drunkard takes a series of steps away from the lamp post, each with a random angle. (Figure Resource: Sethna JP, 2006)
4
Random Walk and Diffusion Equation
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
For the particle to go from at time to at time , the step
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
6
The Micro-Macro Link Using Taylor expansion, we have
The following is the diffusion equation
7
The Continuous Assumption
Resources: Google
8
From discrete to continuous space
Cellular automaton (CA) Continuous simulation
9
Modelling motion in continuous space
Agents are characterized by position X (m) Y (m) velocity Vx (m/s) Vy (m/s) Vy y x Vx
10
Modelling motion in continuous space
Next position after 1 second is given by: x(t+1) = x(t) + Vx(t) y(t+1) = y(t) + Vy(t) Vy Time t+1 y Time t x Vx
11
Modelling motion in 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) Time t+dt dt>1 Vy y Time t+dt dt<1 Time t x Vx
12
Modelling motion in continuous space
The velocity is also updated in time. y x
13
Modelling motion in continuous space
The velocity changes as a result of inter-individual interactions Repulsion Attraction Examples: atoms, planets, pedestrians, animals swarms…
14
Modelling motion in continuous space
The changes of velocity vector is defined by an acceleration.
15
Modelling motion in continuous space
The velocity changes as a result of interactions with the environment Repulsion Attraction Examples: bacteria, ants, pedestrian trails …
16
Modelling motion in continuous space
The velocity changes as a result of a random process With or without bias Example: exploration behaviour in many species of animals
17
Modelling motion in continuous space
How to define a random move? Choose a random angle in a normal distribution Rotate the velocity by this angle Variance=1 In Matlab: newAngle = randn() Mean=0
18
Modelling motion in 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
Modelling motion in 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
Programming the simulator
Initialization: Four elements are required to define the state of individuals X = [1 1 3 ]; Y = [2 1 1]; Vx = [ ]; Vy = [ ]; 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 The velocity is updated first, and then the position as a function of the velocity and the time step
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 21
22
Pedestrian Simulation
CA model Many-particle model
23
CA Model (A. Kirchner, A. Schadschneider, Phys. A, 2002)
24
Many-particle Model (Helbing, Nature, 2000)
Desired velocity Repulsive force
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.