rustsim-core 0.0.1

Core ABM engine: agents, models, stores, schedulers, stepping, data collection
Documentation
//! 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](https://github.com/JuliaDynamics/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.
//!
//! [`Agent`]: agent::Agent
//! [`Model`]: model::Model
//! [`StandardModel`]: standard::StandardModel
//! [`StandardModel::step`]: standard::StandardModel::step
//! [`StandardModel::step_n`]: standard::StandardModel::step_n
//! [`EventQueueModel`]: event_queue::EventQueueModel
//! [`AgentStore`]: store::AgentStore
//! [`HashMapStore`]: store::HashMapStore
//! [`VecStore`]: store::VecStore
//! [`Scheduler`]: scheduler::Scheduler
//! [`StepContext`]: step_context::StepContext
//! [`SoaExtractable`]: soa::SoaExtractable
//! [`collect_step`]: collect::collect_step
//! [`RefCell`]: std::cell::RefCell

pub mod agent;
pub mod avoidance;
pub mod collect;
pub mod event_queue;
pub mod interaction;
pub mod messaging;
pub mod model;
pub mod scheduler;
pub mod soa;
pub mod space;
pub mod standard;
pub mod step_context;
pub mod store;
pub mod two_phase;
pub mod types;

pub mod prelude {
    pub use crate::agent::Agent;
    pub use crate::avoidance::{
        desired_force_2d, desired_force_3d, integrate_euler_2d, integrate_euler_3d,
        social_repulsion_2d, social_repulsion_3d, wall_repulsion_2d, wall_repulsion_3d,
        SocialForceParams, WallSegment, WallSegment3D,
    };
    pub use crate::collect::collect_step;
    pub use crate::event_queue::{EventContext, EventQueueModel};
    pub use crate::interaction::{
        add_agent, add_agent_random, all_ids, move_agent, nearby_agents, nearby_agents_except,
        nearby_ids, nearby_ids_except, random_agent, random_id, remove_agent, InteractionError,
        PositionedAgent, SpaceInteraction,
    };
    pub use crate::messaging::{
        BruteForceMessages, MessageConfigError, MessagePhaseError, SpatialIter3D,
        SpatialMessages2D, SpatialMessages3D,
    };
    pub use crate::model::Model;
    pub use crate::scheduler::{ById, ByProperty, Fastest, PartiallyRandom, Randomly, Scheduler};
    pub use crate::soa::{SoaExtractable, SoaExtractableF64};
    pub use crate::space::Space;
    pub use crate::standard::{HasAgentIds, StandardModel};
    pub use crate::step_context::StepContext;
    pub use crate::store::{AgentStore, HashMapStore, VecStore};
    pub use crate::two_phase::{
        two_phase_brute_force, two_phase_spatial_2d, two_phase_spatial_3d, TwoPhaseResult,
    };
    pub use crate::types::{
        AgentId, Connective, ConnectorMetadata, ConnectorType, EdgeId, LevelId, LevelMetadata,
        LevelRelation, Leveled, NodeId, ProcessingPointMetadata, SemanticEntity, Time, ZoneId,
        ZoneMetadata, Zoned,
    };
}