This is a force-based model from 1975 simulating crowd dynamics using social and environmental forces.
K. Hirai and K. Tarui, "A Simulation of the Behavior of a Crowd in Panic", Kobe University, 1975.
Interactive examples and experiments are provided in the notebooks. These include:
- Basic force tests (e.g., wall force, pairwise interaction)
- Overtaking scenarios
- Original scenario from the paper
- Room evacuation with obstacles
To run the notebooks, install the dependencies and open with Jupyter:
pip install -r requirements.txt
jupyter notebook
The motion of each individual
Where:
-
$x_i$ is the position vector -
$\dot{x}_i$ is the velocity -
$m_i$ is the mass -
$\nu_i$ is the viscosity (damping) coefficient -
$F_{11}$ : social forces -
$F_{21}$ : environmental forces -
$F_{31}$ : random force due to disturbances
In the Hirai and Tarui model, there are 9 forces explicitly defined, and they are grouped into three conceptual categories. Here's the full list:
Symbol | Name | Equation in Paper | Description |
---|---|---|---|
Self-driving force | (3) | Moves the agent forward at a constant desired speed. |
Symbol | Name | Equation | Description |
---|---|---|---|
Avoidance force | (4) | Repulsive force from nearby individuals. | |
Cohesion force | (5) | Attractive force toward group members. | |
Wall repulsion | (8) | Repulsion from walls; strength depends on distance and velocity component into the wall. |
Symbol | Name | Equation | Description |
---|---|---|---|
Visible sign attraction | (9) | Attraction toward visible signs within field of view. | |
Memorized sign force | (10) | Attraction to previously seen signs even when no longer visible. | |
Exit force | (4) | Attraction toward exit if agent is within exit's effective radius. |
Symbol | Name | Equation | Description |
---|---|---|---|
Herding force | (10) | External influence (e.g., crowd herding). | |
Random fluctuation | (11) | Randomized fluctuation force depending on wall proximity. |
Pushes the individual forward in the direction of motion.
This function alone leads to a constant acceleration.
However, with the damping parameter
The agent's velocity
Assuming motion in a fixed direction (i.e., constant direction of
This is a linear first-order ODE with solution:
where:
-
$a$ is the magnitude of the driving force, -
$\nu$ is the damping coefficient, -
$m$ is the mass of the agent.
Note: The similarity to the traditional driving force in force-based models, e.g. the social force model. Hereby,
$v^0 = \frac{a}{\mu}$ and$\tau = \frac{m}{\mu}$
Attracts agents at a moderate distance, repels those that are too close.
Encourages alignment of motion in local groups.
-
Wall Repulsion
$F_{wi}$ :
Repels agents from walls:

Where:
-
$\mathbf{e}_w$ is the unit vector pointing away from the wall -
$v_{wi}$ is the component of velocity along$-\mathbf{e}_w$ (i.e., into the wall is positive) -
$d_i$ is the actual distance from the agent to the wall -
$d$ is the cutoff distance: the maximum range in which the wall force acts
This force slows down the agent as they approach the wall, and acts only within a threshold distance.
-
Attraction to Signs
$F_{eik}$ :
Attracts the agent toward visible guiding signs
-
Memory-Based Attraction to Signs
$F_{fik}$ : Same as$F_{eik}$ , but persists after the sign is out of sight. -
Exit Attraction
$F_{gi}$ :
The model assumes that different forces act in mutually exclusive regions:
Region | Active Forces |
---|---|
Exit domain (near exit) | F_gi (goal/exit attraction only) |
Visible sign domain | F_eik (only if sign is visible) |
Memory domain | F_fik (only if sign was memorized) |
All other regions | Wall, social, cohesion, fluctuation forces |
Note:
F_gi
,F_eik
, andF_fik
are never active at the same time.
Each agent experiences only one of them depending on their location and memory state.
-
Panic Avoidance
$F_{hi}$ :
Pushes agents away from the panic origin.
Models stochastic disturbances:
Where rand()
is a unit vector in a random direction.
Parameter | Description | Used In |
---|---|---|
a |
Strength of the driving force | F_ai |
Parameter | Description | Used In |
---|---|---|
d |
Cutoff distance to consider wall repulsion | F_wi , F_31 |
w0 |
Wall repulsion strength when agent moves into the wall | F_wi |
w1 |
Constant wall repulsion strength | F_wi |
Parameter | Description | Used In |
---|---|---|
cn0 |
Minimum (negative) repulsion at zero distance | c1_func → F_bi |
cr0 |
Maximum repulsion plateau value | c1_func → F_bi |
beta |
Distance at which repulsion crosses from negative to 0 | c1_func → F_bi |
nu |
Distance at which repulsion reaches cr0 |
c1_func → F_bi |
gamma |
Start of decay from cr0 |
c1_func → F_bi |
epsilon |
Distance where repulsion drops to 0 | c1_func → F_bi |
Parameter | Description | Used In |
---|---|---|
cphi1 |
Max repulsion for aligned direction | c2_func → F_bi |
cphi2 |
Plateau value after initial drop | c2_func → F_bi |
phi1 -phi4 |
Transition angles for repulsion decay | c2_func → F_bi |
Parameter | Description | Used In |
---|---|---|
hr0 |
Maximum cohesion value | h1_func → F_ci |
lam |
Constant cohesion up to this distance | h1_func → F_ci |
sigma |
Distance where cohesion vanishes | h1_func → F_ci |
hphi1 |
Maximum cohesion for angular alignment | h2_func → F_ci |
hphi2 |
Intermediate angular cohesion | h2_func → F_ci |
Parameter | Description | Used In |
---|---|---|
eta_sign |
Strength of attraction toward visible signs | F_eik |
eta_mem |
Strength of attraction toward memorized signs | F_fik |
vision_radius |
Radius within which signs are visible to the agent | F_eik |
fov_angle |
Agent’s field of view angle | F_eik |
sign_fov |
Sign’s own directional “cone of influence” | F_eik |
exit_strength |
Strength of attraction toward exits | F_gi |
Parameter | Description | Used In |
---|---|---|
x_panic |
Position of panic center (dynamic) | F_hi |
strength |
Herding force magnitude | F_hi |
cutoff |
Radius beyond which herding force is not applied | F_hi |
note:
cutoff
andx_panic
were added in this implementation although not mentioned in the original paper.
Parameter | Description | Used In |
---|---|---|
q1 |
Random force strength if far from wall or not moving into wall | F_31 |
q2 |
Random force strength if moving into wall | F_31 |
- Forces are modular Python functions for testing and reuse
- Agents interact with each other and with walls (modeled via Shapely)
- Basic Euler integration is used to update agent positions
- Calibration
Screen.Recording.2025-03-28.at.17.32.16.mov
The paper shows simulations of a passage: