Microscopic crowd locomotion models for rustsim.
This crate implements the five microscopic pedestrian models catalogued at
https://pedestriandynamics.org/models/ in pure 2-D continuous space
plus a layered 2.5-D extension in the [threed] module for
multi-storey environments (stations, airports, stadiums, malls).
It is called rustsim-crowd rather than rustsim-pedestrian because
the same physics apply equally to cyclists, evacuees, queue-formers,
and generic self-propelled agents.
| Module | Model | Class | Primary references |
|---|---|---|---|
[social_force] |
Social Force | Force-based, 2nd order | Helbing & Molnár 1995; Helbing, Farkas & Vicsek 2000 |
[collision_free_speed] |
Collision-Free Speed | Velocity-based, 1st order | Tordeux, Chraibi & Seyfried 2016 |
[generalized_centrifugal_force] |
Generalized Centrifugal Force | Force-based, 2nd order | Chraibi, Seyfried & Schadschneider 2010 |
[optimal_steps] |
Optimal Steps | Discrete-step utility | Seitz & Köster 2012 |
[anticipation_velocity] |
Anticipation Velocity | Velocity-based, 1st order | Xu, Chraibi & Seyfried 2021 |
[threed] |
Layered 2.5-D Social Force | Per-floor 2-D physics + vertical connectors | Industry standard (JuPedSim, MassMotion, Legion) |
API shape
Every 2-D model shares the same three-type contract defined by the
[PedestrianModel] trait:
- [
Pedestrian] — the shared per-agent state (position, velocity, radius, desired speed, destination). - [
WallSegment] — a 2-D line segment describing a static obstacle. Params— a model-specific parameter bundle living inside each module.
Each model exposes:
- a
Paramsstruct with stable literature/engineering defaults. - explicit [
calibration] helpers for deployments that must enforce a published speed-density envelope such as Weidmann (1993). - a unit struct implementing [
PedestrianModel] so callers can swap models behind a trait object or generic bound. - a free
step(peds, walls, params, dt)function (deprecated since0.0.3; O(n²) reference path retained for parity tests). Production callers usestep_scratch(zero-alloc) orstep_with_grid(broadphase) instead.
use *;
let mut peds = vec!;
let walls: = Vecnew;
let params = default;
// Production hot path: zero-alloc, broadphase-accelerated.
let mut scratch = new;
step_scratch;
Design constraints
- Pure
f64, SoA-friendly internals, no interior mutability. step_scratch(peds, walls, params, dt, &mut scratch)is the zero-alloc hot path: allocate one [broadphase::Scratch] per simulation and reuse it tick-after-tick.step_with_gridtakes a caller-owned [NeighborGrid] and allocates oneVec<[f64; 2]>per tick;stepis the O(n²) reference path with no broadphase.- Determinism: every
step_*variant is a deterministic function of its inputs.