Expand description
rustsim-core integration for the crowd models.
The pedestrian models in this crate operate on bare
Pedestrian structs with no identity
or lifecycle. This module adapts them to the core ABM engine so
that crowd agents can participate in [StandardModel] simulations,
be logged through the telemetry pipeline, and be extracted into
SoA f64 buffers suitable for the GPU batch / persistent-store
paths in the rustsim umbrella crate.
§Shape
CrowdAgentpairs aPedestrianwith anAgentId. It implementsAgentandSoaExtractableF64with an 8-column layout:pos.x, pos.y, vel.x, vel.y, radius, desired_speed, dest.x, dest.y.step_scratch_storedrives one tick of any 2-D pedestrian model over a [VecStore<CrowdAgent>], using a caller-ownedScratch. The store’s interior mutability is respected — each agent is borrowed immutably for the read phase and mutably for the write-back phase.
The adapter is intentionally a thin sync layer rather than a
re-implementation of the physics: the source of truth for crowd
dynamics stays in the model modules, and this file only shuffles
data between AgentStore and &mut [Pedestrian].
§Example
ⓘ
use rustsim_core::prelude::*;
use rustsim_crowd::prelude::*;
use rustsim_crowd::integration::{step_scratch_store, CrowdAgent, SocialForceModel};
let mut store: VecStore<CrowdAgent> = VecStore::new();
store.insert(CrowdAgent {
id: 0,
ped: Pedestrian {
pos: [0.0, 0.0],
vel: [0.0, 0.0],
radius: 0.25,
desired_speed: 1.34,
destination: [10.0, 0.0],
},
});
let params = social_force::Params::default();
let mut scratch = Scratch::with_capacity(1, social_force::neighbor_cutoff(¶ms));
let mut peds = Vec::with_capacity(1);
for _ in 0..100 {
step_scratch_store(&SocialForceModel, &mut store, &[], ¶ms, 0.05, &mut scratch, &mut peds);
}Structs§
- Anticipation
Velocity Model CrowdStepadapter for theanticipation_velocitymodel.- Collision
Free Speed Model CrowdStepadapter for thecollision_free_speedmodel.- Crowd
Agent - Identified pedestrian record for use with
rustsim-coreagent stores. - Generalized
Centrifugal Force Model CrowdStepadapter for thegeneralized_centrifugal_forcemodel.- Optimal
Steps Model CrowdStepadapter for theoptimal_stepsmodel.- Social
Force Model CrowdStepadapter for thesocial_forcemodel.
Constants§
- COL_
DESIRED_ SPEED - Column index of
desired_speed. - COL_
DEST_ X - Column index of
dest.x. - COL_
DEST_ Y - Column index of
dest.y. - COL_
POS_ X - Column index of
pos.xin theCrowdAgentSoA layout. - COL_
POS_ Y - Column index of
pos.y. - COL_
RADIUS - Column index of
radius. - COL_
VEL_ X - Column index of
vel.x. - COL_
VEL_ Y - Column index of
vel.y. - NUM_
COLUMNS - Number of SoA columns in the
CrowdAgentlayout.
Traits§
- Crowd
Observer - Per-agent post-step observation hook.
- Crowd
Step - Abstract 2-D crowd model with a zero-alloc step entry point.
Functions§
- pack_
columns_ from - Write a
Pedestrianbuffer back into theCrowdAgentSoA columns. - step_
columns_ f64 - Zero-alloc SoA step over
CrowdAgentcolumns. - step_
scratch_ store - Zero-allocation
AgentStoreadapter for any 2-D crowd model. - step_
scratch_ store_ observed - Observed variant of
step_scratch_store: identical semantics, plus a post-writeback callback for every agent. - unpack_
columns_ into - Unpack the
CrowdAgentSoA layout into aPedestrianbuffer.