Expand description
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
calibrationhelpers for deployments that must enforce a published speed-density envelope such as Weidmann (1993). - a unit struct implementing
PedestrianModelso 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 rustsim_crowd::prelude::*;
let mut peds = vec![Pedestrian::new(
[0.0, 0.0],
[0.0, 0.0],
0.25,
1.34,
[10.0, 0.0],
)];
let walls: Vec<WallSegment> = Vec::new();
let params = social_force::Params::default();
// Production hot path: zero-alloc, broadphase-accelerated.
let mut scratch = Scratch::new(recommended_cell_size(
social_force::neighbor_cutoff(¶ms),
));
social_force::step_scratch(&mut peds, &walls, ¶ms, 0.05, &mut 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 onebroadphase::Scratchper simulation and reuse it tick-after-tick.step_with_gridtakes a caller-ownedNeighborGridand 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.
Re-exports§
pub use broadphase::recommended_cell_size;pub use broadphase::NeighborGrid;pub use broadphase::Scratch;pub use calibration::apply_weidmann_speed_cap;pub use calibration::apply_weidmann_speed_target;pub use calibration::density_for_area;pub use calibration::mean_speed;pub use calibration::CalibrationPoint;pub use calibration::CalibrationReport;pub use calibration::WeidmannCurve;pub use common::Pedestrian;pub use common::PedestrianModel;pub use common::WallSegment;pub use error::CrowdError;pub use integration::pack_columns_from;pub use integration::step_columns_f64;pub use integration::step_scratch_store;pub use integration::step_scratch_store_observed;pub use integration::unpack_columns_into;pub use integration::AnticipationVelocityModel;pub use integration::CollisionFreeSpeedModel;pub use integration::CrowdAgent;pub use integration::CrowdObserver;pub use integration::CrowdStep;pub use integration::GeneralizedCentrifugalForceModel;pub use integration::OptimalStepsModel;pub use integration::SocialForceModel;pub use threed::LayeredObserver;pub use threed::LayeredScratch;pub use threed::Pedestrian3D;pub use threed::WallPolygon3D;
Modules§
- anticipation_
velocity - Anticipation Velocity Model (Xu, Chraibi & Seyfried 2021).
- broadphase
- Broadphase acceleration for crowd models.
- calibration
- Scientific calibration helpers for pedestrian fundamental diagrams.
- collision_
free_ speed - Collision-Free Speed Model (Tordeux, Chraibi & Seyfried 2016).
- common
- Shared types and trait for all pedestrian models in this crate.
- error
- Parameter and runtime errors for
rustsim-crowd. - generalized_
centrifugal_ force - Generalized Centrifugal Force Model (Chraibi, Seyfried & Schadschneider 2010).
- integration
rustsim-coreintegration for the crowd models.- optimal_
steps - Optimal Steps Model (Seitz & Köster 2012).
- prelude
- Convenience re-exports for the common consumer path.
- social_
force - Social Force Model (Helbing & Molnár 1995; Helbing, Farkas & Vicsek 2000).
- threed
- Layered 2.5-D crowd locomotion for multi-storey environments.