Skip to main content

Module integration

Module integration 

Source
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

  • CrowdAgent pairs a Pedestrian with an AgentId. It implements Agent and SoaExtractableF64 with an 8-column layout: pos.x, pos.y, vel.x, vel.y, radius, desired_speed, dest.x, dest.y.
  • step_scratch_store drives one tick of any 2-D pedestrian model over a [VecStore<CrowdAgent>], using a caller-owned Scratch. 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(&params));
let mut peds = Vec::with_capacity(1);
for _ in 0..100 {
    step_scratch_store(&SocialForceModel, &mut store, &[], &params, 0.05, &mut scratch, &mut peds);
}

Structs§

AnticipationVelocityModel
CrowdStep adapter for the anticipation_velocity model.
CollisionFreeSpeedModel
CrowdStep adapter for the collision_free_speed model.
CrowdAgent
Identified pedestrian record for use with rustsim-core agent stores.
GeneralizedCentrifugalForceModel
CrowdStep adapter for the generalized_centrifugal_force model.
OptimalStepsModel
CrowdStep adapter for the optimal_steps model.
SocialForceModel
CrowdStep adapter for the social_force model.

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.x in the CrowdAgent SoA 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 CrowdAgent layout.

Traits§

CrowdObserver
Per-agent post-step observation hook.
CrowdStep
Abstract 2-D crowd model with a zero-alloc step entry point.

Functions§

pack_columns_from
Write a Pedestrian buffer back into the CrowdAgent SoA columns.
step_columns_f64
Zero-alloc SoA step over CrowdAgent columns.
step_scratch_store
Zero-allocation AgentStore adapter 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 CrowdAgent SoA layout into a Pedestrian buffer.