Skip to main content

Crate rustsim_core

Crate rustsim_core 

Source
Expand description

Core ABM engine for rustsim.

This crate provides the foundational abstractions for agent-based modelling:

  • Agent trait - the interface every agent type must implement.
  • Model trait - the abstract model interface exposing time, RNG, space, and agents.
  • StandardModel - discrete-time model with per-agent and per-model step functions.
  • EventQueueModel - continuous-time model driven by a deterministic event queue.
  • AgentStore - container trait with HashMapStore and VecStore implementations.
  • Scheduler - trait for controlling agent activation order each step.
  • StepContext - safe, borrow-checked context passed to agent step functions.
  • Core semantic types - shared identifiers and interfaces for nodes, edges, zones, levels, and connectors.
  • SoaExtractable - trait for extracting agent data into GPU-friendly SoA buffers.

§Architecture

The crate mirrors the design of Julia’s Agents.jl:

  1. Define agent types implementing Agent.
  2. Choose a space (from rustsim-spaces) and a scheduler.
  3. Wire up step functions and build a StandardModel or EventQueueModel.
  4. Call StandardModel::step / StandardModel::step_n to advance the simulation.
  5. Use collect_step to gather data at each step.

§Interior Mutability

Agent stores use RefCell-based interior mutability so that agent step functions can read other agents while mutating the current one. This means the model types are !Send and !Sync - see the top-level rustsim crate for compute-routing alternatives.

Modules§

agent
Agent trait - the fundamental interface for all simulation entities.
avoidance
Physical avoidance force primitives for pedestrian and agent dynamics.
collect
Data collection utilities.
event_queue
Continuous-time event-queue model.
interaction
Space interaction API - add, remove, move, and query agents in space.
messaging
Inter-agent messaging system inspired by FlameGPU2.
model
Abstract model trait - the interface shared by all model types.
prelude
scheduler
Scheduler trait and built-in implementations.
soa
SoA (Structure-of-Arrays) extraction for GPU-friendly data layout.
space
Space trait - marker for spatial structures in which agents exist.
standard
Discrete-time standard model.
step_context
Deferred actions and the step context passed to agent step functions.
store
Agent containers - storage backends for the agent population.
two_phase
Two-phase stepping utilities inspired by FlameGPU2.
types
Fundamental identity, semantic, and time types used throughout the ABM engine.