ixa/lib.rs
1//! A framework for building discrete-event simulations
2//!
3//! Ixa is a framework designed to support the creation of large-scale
4//! discrete event simulations. The primary use case is the construction of
5//! agent-based models for disease transmission, but the approach is applicable
6//! in a wide array of circumstances.
7//!
8//! The central object of an Ixa simulation is the `Context` that is
9//! responsible for managing all the behavior of the simulation. All of the
10//! simulation-specific logic is embedded in modules that rely on the `Context`
11//! for core services such as:
12//! * Maintaining a notion of time for the simulation
13//! * Scheduling events to occur at some point in the future and executing them
14//! at that time
15//! * Holding module-specific data so that the module and other modules can
16//! access it
17//!
18//! In practice, a simulation usually consists of a set of modules that work
19//! together to provide all of the functions of the simulation. For instance,
20//! a simple disease transmission model might consist of the
21//! following modules:
22//! * A population loader that initializes the set of people represented
23//! by the simulation.
24//! * An infection seeder that introduces the pathogen into the population.
25//! * A disease progression manager that transitions infected people through
26//! stages of disease until recovery.
27//! * A transmission manager that models the process of an infected
28//! person trying to infect susceptible people in the population.
29//!
30//! ## Features
31//!
32//! - **`debugger`**: enables the interactive debugger, an interactive console-based REPL
33//! (Read-Eval-Print Loop) that allows you to pause simulation execution, inspect state, and
34//! control simulation flow through commands like breakpoints, population queries, and
35//! step-by-step execution.
36//! - **`web_api`**: enables the web API, an HTTP-based remote control interface that allows
37//! external applications to monitor simulation state, control execution, and query data through
38//! REST endpoints. This feature implies the `debugger` feature.
39//!
40pub mod context;
41pub use context::{Context, ExecutionPhase, IxaEvent, PluginContext};
42
43pub mod error;
44pub use error::IxaError;
45
46pub mod global_properties;
47pub use global_properties::{ContextGlobalPropertiesExt, GlobalProperty};
48
49pub mod network;
50pub use network::{ContextNetworkExt, Edge, EdgeType};
51
52pub mod people;
53pub use people::{
54 ContextPeopleExt, PersonCreatedEvent, PersonId, PersonProperty, PersonPropertyChangeEvent,
55};
56
57pub mod plan;
58pub mod random;
59pub use random::{ContextRandomExt, RngId};
60
61pub mod tabulator;
62pub use tabulator::Tabulator;
63
64pub mod report;
65pub use report::{ConfigReportOptions, ContextReportExt, Report};
66
67pub mod runner;
68pub use runner::{run_with_args, run_with_custom_args, BaseArgs};
69
70#[cfg(feature = "debugger")]
71pub mod debugger;
72
73pub mod log;
74pub use log::{
75 debug, disable_logging, enable_logging, error, info, set_log_level, set_module_filter,
76 set_module_filters, trace, warn, LevelFilter,
77};
78
79#[cfg(feature = "progress_bar")]
80pub mod progress;
81
82#[cfg(feature = "debugger")]
83pub mod external_api;
84mod hashing;
85
86#[cfg(feature = "web_api")]
87pub mod web_api;
88
89// Re-export for macros
90pub use csv;
91pub use ctor;
92pub use paste;
93pub use rand;
94
95// Deterministic hashing data structures
96pub use crate::hashing::{HashMap, HashMapExt, HashSet, HashSetExt};
97
98// Preludes
99pub mod prelude;
100pub mod prelude_for_plugins {
101 pub use crate::context::PluginContext;
102 pub use crate::define_data_plugin;
103 pub use crate::error::IxaError;
104 pub use crate::prelude::*;
105 pub use crate::IxaEvent;
106 pub use ixa_derive::IxaEvent;
107}
108
109#[cfg(all(target_arch = "wasm32", feature = "debugger"))]
110compile_error!(
111 "Target `wasm32` and feature `debugger` are mutually exclusive — enable at most one."
112);
113
114#[cfg(all(target_arch = "wasm32", feature = "progress_bar"))]
115compile_error!(
116 "Target `wasm32` and feature `progress_bar` are mutually exclusive — enable at most one."
117);