Skip to main content

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//! - **`logging`**: enables structured logging for native and wasm targets.
33//! - **`profiling`**: enables collection and reporting of execution profiling statistics. Disabled by default.
34//!
35//! ## Events
36//!
37//! Event types can derive [`IxaEvent`] with the same import used for the trait:
38//!
39//! ```
40//! use ixa::IxaEvent;
41//!
42//! #[derive(IxaEvent)]
43//! struct MyEvent;
44//!
45//! fn assert_event<E: IxaEvent>() {}
46//! assert_event::<MyEvent>();
47//! ```
48
49#![doc = include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/docs/book/src/cli-usage.md"))]
50
51pub mod context;
52pub use context::{Context, ContextBase, EventListenerId, ExecutionPhase, IxaEvent};
53pub use ixa_derive::IxaEvent;
54
55mod plugin_context;
56pub use plugin_context::PluginContext;
57
58mod data_plugin;
59pub use data_plugin::*;
60
61pub mod error;
62pub use error::IxaError;
63
64pub mod global_properties;
65pub use global_properties::{ContextGlobalPropertiesExt, GlobalProperty};
66
67pub mod network;
68pub use network::{ContextNetworkExt, Edge, EdgeType};
69
70pub mod macros;
71
72pub mod plan_queue;
73pub use plan_queue::PlanId;
74
75/// Compatibility re-exports for plan-related public API.
76///
77/// This module is retained so existing `ixa::plan::PlanId` imports continue to
78/// work. Use [`crate::PlanId`] instead.
79#[deprecated(note = "use `ixa::PlanId` instead")]
80pub mod plan {
81    pub use crate::plan_queue::PlanId;
82}
83pub mod random;
84pub use random::{ContextRandomExt, RngId};
85
86pub mod report;
87pub use report::{ConfigReportOptions, ContextReportExt, Report};
88
89pub mod runner;
90pub use runner::{run_with_args, run_with_custom_args, run_with_merged_args, BaseArgs, RunnerArgs};
91
92pub mod log;
93pub use log::{
94    debug, disable_logging, enable_logging, error, info, set_log_level, set_module_filter,
95    set_module_filters, trace, warn, LevelFilter,
96};
97
98pub mod hashing;
99pub mod numeric;
100
101// Re-export for macros
102pub use csv;
103pub use ctor;
104pub use paste;
105pub use rand;
106pub use rkyv;
107
108// Deterministic hashing data structures
109pub use crate::hashing::{HashMap, HashMapExt, HashSet, HashSetExt};
110
111// Preludes
112pub mod prelude;
113
114pub mod prelude_for_plugins {
115    pub use crate::error::IxaError;
116    pub use crate::prelude::*;
117    pub use crate::{define_data_plugin, ContextBase, IxaEvent};
118}
119
120pub mod entity;
121pub use entity::{ContextEntitiesExt, EntityPropertyTuple};
122
123pub mod execution_stats;
124pub mod profiling;
125
126pub mod data_structures;
127pub mod triggers;