Comparative Analysis of Pedestrian Dynamics Models#
Objective#
This notebook compares four pedestrian dynamics models by simulating agent behavior in a
structured environment. Using simplified scenarios, we analyze how each model handles
navigation, obstacle avoidance, and agent interactions. This comparison reveals the strengths
and weaknesses of each approach, helping inform model selection when using JuPedSim.
When choosing a pedestrian dynamics model in JuPedSim, the decision largely depends on the
specific scenario you want to simulate or the behavior you want to reproduce. The available
models can be divided into two main categories: force-based and velocity-based models,
each with their own strengths and limitations.
Force-Based Models#
Force-based models, which include the Social Force Model (SFM) and the Generalized
Centrifugal Force Model (GCFM), excel at simulating physical interactions between pedestrians.
These models are particularly effective at capturing pushing behavior in dense crowds, making
them ideal for evacuation scenarios or situations where physical contact between pedestrians
is common. The GCFM offers some improvements over the basic SFM, particularly in handling
body shape effects.
Velocity-Based Models#
On the other hand, velocity-based models like the Collision-Free Model (CFM) and the
Anticipation Velocity Model (AVM) are better suited for normal walking situations where
collision avoidance is the primary concern. These models typically produce smoother, more
realistic trajectories in regular-density scenarios. The AVM, in particular, stands out for
its superior collision avoidance capabilities and ability to reproduce lane formation behavior,
as demonstrated in recent research.
Computational Efficiency#
When it comes to computational efficiency, velocity-based models generally have an advantage.
The CFM offers the fastest execution times, while the AVM provides a good balance between
computational efficiency and realistic behavior simulation. Force-based models, while more
computationally intensive, are necessary when accurate physical interaction modeling is crucial.
Model Selection Guidance#
The choice of model ultimately comes down to your specific requirements:
Force-based models (SFM, GCFM): Best for emergency evacuations or crowded environments
with significant physical interactions.Velocity-based models (AVM): Ideal for typical pedestrian scenarios requiring smooth
navigation and realistic avoidance behavior.Collision-Free Model (CFM): Suitable when computational resources are limited and
physical interactions are not critical.
The key is to understand that no single model is universally superior—each has its place
depending on the specific requirements of your simulation scenario.
So as a final facit, which model to use? The answer is: it depends.
Models Under Investigation#
In this notebooks the models compared are:
Collision-Free Speed Model (CSM):
A velocity-based model focused on ensuring agents move without collisions
by dynamically adjusting their speeds.Anticipation Velocity Model (AVM):
A model that incorporates anticipation and reaction times, allowing agents
to predict and avoid potential collisions.Social Force Model (SFM): A force-based model where agents are influenced
by attractive forces toward goals and repulsive forces from obstacles and other agents.Generalized Centrifugal Force Model (GCFM):
An enhanced force-based model where agents experience centrifugal forces
to better simulate realistic avoidance behavior.
Note:
All models are utilized with their default parameter settings as defined in JuPedSim.
Scenario 1: Crossing Paths in Rooms#
Four agents navigate between interconnected rooms with obstacles. Each agent aims to reach the diagonally opposite goal. Agents are expected to plan paths around obstacles while interacting with other agents in the corridors.
CSM Simulation#
model = "CFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.CollisionFreeSpeedModelV2(),
jps.CollisionFreeSpeedModelV2AgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=5000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 12.92 s
AVM Simulation#
model = "AVM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.AnticipationVelocityModel(),
jps.AnticipationVelocityModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=5000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 14.05 s
SFM Simulation#
model = "SFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.SocialForceModel(),
jps.SocialForceModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=5000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
/tmp/ipykernel_3216/1762482793.py:49: DeprecationWarning:
'desiredSpeed' is deprecated, use 'desired_speed' instead.
SocialForceModelAgentParameters(position=(1, 1), orientation=array([8., 8.]), journey_id=3, stage_id=9, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
SocialForceModelAgentParameters(position=(9, 9), orientation=array([-8., -8.]), journey_id=3, stage_id=10, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
SocialForceModelAgentParameters(position=(1, 9), orientation=array([ 8., -8.]), journey_id=3, stage_id=11, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
SocialForceModelAgentParameters(position=(9, 1), orientation=array([-8., 8.]), journey_id=3, stage_id=12, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
Evacuation time: 31.18 s
GCFM Simulation#
model = "GCFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.GeneralizedCentrifugalForceModel(),
jps.GeneralizedCentrifugalForceModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=5000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 50.00 s
Evacuation times#
Scenario 2: Following Behavior#
A single-line setup where one agent follows another slower-moving agent, testing how the models handle speed adjustments and eventually overtaking.
CSM Simulation#
model = "CFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.CollisionFreeSpeedModelV2(),
jps.CollisionFreeSpeedModelV2AgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 20.00 s
AVM Simulation#
model = "AVM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.AnticipationVelocityModel(),
jps.AnticipationVelocityModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 20.00 s
SFM Simulation#
model = "SFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.SocialForceModel(),
jps.SocialForceModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
/tmp/ipykernel_3216/1762482793.py:49: DeprecationWarning:
'desiredSpeed' is deprecated, use 'desired_speed' instead.
SocialForceModelAgentParameters(position=(-2, 0), orientation=array([15.5, -0. ]), journey_id=7, stage_id=21, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
SocialForceModelAgentParameters(position=(2, 0), orientation=array([11.5, -0. ]), journey_id=7, stage_id=22, velocity=(0.0, 0.0), mass=80.0, desired_speed=0.8, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
Evacuation time: 14.51 s
GCFM Simulation#
model = "GCFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.GeneralizedCentrifugalForceModel(),
jps.GeneralizedCentrifugalForceModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 20.00 s
Scenario 3: Head-on Encounter#
Two agents approach each other on a straight line, evaluating how different models resolve direct confrontation and determine which agent yields or how they negotiate passing space.
CSM Simulation#
model = "CFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.CollisionFreeSpeedModelV2(),
jps.CollisionFreeSpeedModelV2AgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 20.00 s
AVM Simulation#
model = "AVM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.AnticipationVelocityModel(),
jps.AnticipationVelocityModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 8.22 s
SFM Simulation#
model = "SFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.SocialForceModel(),
jps.SocialForceModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
/tmp/ipykernel_3216/1762482793.py:49: DeprecationWarning:
'desiredSpeed' is deprecated, use 'desired_speed' instead.
SocialForceModelAgentParameters(position=(-2, 0), orientation=array([ 9.5, -0. ]), journey_id=11, stage_id=29, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
SocialForceModelAgentParameters(position=(2, 0), orientation=array([-9.5, -0. ]), journey_id=11, stage_id=30, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
Evacuation time: 20.00 s
GCFM Simulation#
model = "GCFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.GeneralizedCentrifugalForceModel(),
jps.GeneralizedCentrifugalForceModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=5000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 26.77 s
Evacuation times#
Scenario 4: Perpendicular Crossing#
Two agents move on intersecting paths - one traveling upward and another moving left to right - creating a potential collision point. This tests how models handle collision avoidance when agents approach at right angles.
CSM Simulation#
model = "CFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.CollisionFreeSpeedModelV2(),
jps.CollisionFreeSpeedModelV2AgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 9.33 s
AVM Simulation#
model = "AVM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.AnticipationVelocityModel(),
jps.AnticipationVelocityModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 7.51 s
SFM Simulation#
model = "SFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.SocialForceModel(),
jps.SocialForceModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
/tmp/ipykernel_3216/1762482793.py:49: DeprecationWarning:
'desiredSpeed' is deprecated, use 'desired_speed' instead.
SocialForceModelAgentParameters(position=(-2, 0), orientation=array([ 7.5, -0. ]), journey_id=15, stage_id=37, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
SocialForceModelAgentParameters(position=(0, -2), orientation=array([-0. , 7.5]), journey_id=15, stage_id=38, velocity=(0.0, 0.0), mass=80.0, desired_speed=0.99, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
Evacuation time: 10.20 s
GCFM Simulation#
model = "GCFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.GeneralizedCentrifugalForceModel(),
jps.GeneralizedCentrifugalForceModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 12.99 s
Evacuation times#
Scenario 5: Movement of individuals in a bottleneck#
Agents are initialized in a semicircular formation surrounding a bottleneck. For reference, see this experiment.
CSM Simulation#
model = "CFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.CollisionFreeSpeedModelV2(),
jps.CollisionFreeSpeedModelV2AgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 10.18 s
AVM Simulation#
model = "AVM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.AnticipationVelocityModel(),
jps.AnticipationVelocityModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 12.21 s
SFM Simulation#
model = "SFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.SocialForceModel(),
jps.SocialForceModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
/tmp/ipykernel_3216/1762482793.py:49: DeprecationWarning:
'desiredSpeed' is deprecated, use 'desired_speed' instead.
SocialForceModelAgentParameters(position=(-4, -0.5), orientation=array([4. , 2.25]), journey_id=19, stage_id=55, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
SocialForceModelAgentParameters(position=(-3.5, -2), orientation=array([3.5 , 3.75]), journey_id=19, stage_id=56, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
SocialForceModelAgentParameters(position=(-2, -3.5), orientation=array([2. , 5.25]), journey_id=19, stage_id=57, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
SocialForceModelAgentParameters(position=(0, -4), orientation=array([-0. , 5.75]), journey_id=19, stage_id=58, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
SocialForceModelAgentParameters(position=(2, -3.5), orientation=array([-2. , 5.25]), journey_id=19, stage_id=59, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
SocialForceModelAgentParameters(position=(3.5, -2), orientation=array([-3.5 , 3.75]), journey_id=19, stage_id=60, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
SocialForceModelAgentParameters(position=(4, -0.5), orientation=array([-4. , 2.25]), journey_id=19, stage_id=61, velocity=(0.0, 0.0), mass=80.0, desired_speed=1.0, reaction_time=0.5, agent_scale=2000, obstacle_scale=2000, force_distance=0.08, radius=0.3)
Evacuation time: 20.00 s
GCFM Simulation#
model = "GCFM"
trajectory_file = f"{model}.sqlite"
simulation = initialize_simulation(
jps.GeneralizedCentrifugalForceModel(),
jps.GeneralizedCentrifugalForceModelAgentParameters,
geometry,
goals,
positions,
speeds,
trajectory_file,
)
times_dict[model] = run_simulation(simulation, max_iterations=2000)
trajectories, walkable_area = read_sqlite_file(trajectory_file)
animate(
trajectories,
walkable_area,
title_note=model,
every_nth_frame=5,
width=width,
height=height,
)
Evacuation time: 20.00 s
Evacuation times#