Expand description
A framework for building discrete-event simulations
Ixa is a framework designed to support the creation of large-scale discrete event simulations. The primary use case is the construction of agent-based models for disease transmission, but the approach is applicable in a wide array of circumstances.
The central object of an Ixa simulation is the Context that is
responsible for managing all the behavior of the simulation. All of the
simulation-specific logic is embedded in modules that rely on the Context
for core services such as:
- Maintaining a notion of time for the simulation
- Scheduling events to occur at some point in the future and executing them at that time
- Holding module-specific data so that the module and other modules can access it
In practice, a simulation usually consists of a set of modules that work together to provide all of the functions of the simulation. For instance, a simple disease transmission model might consist of the following modules:
- A population loader that initializes the set of people represented by the simulation.
- An infection seeder that introduces the pathogen into the population.
- A disease progression manager that transitions infected people through stages of disease until recovery.
- A transmission manager that models the process of an infected person trying to infect susceptible people in the population.
§Features
logging: enables structured logging for native and wasm targets.progress_bar: enables the timeline progress bar for long-running simulations.profiling: enables collection and reporting of execution profiling statistics.
§Command Line Usage
This document contains the help content for the ixa command-line program.
§ixa
Default cli arguments for ixa runner
Usage: ixa [OPTIONS]
§Options:
-
-r,--random-seed <RANDOM_SEED>— Random seedDefault value:
0 -
-c,--config <CONFIG>— Optional path for a global properties config file -
-o,--output <OUTPUT_DIR>— Optional path for report output -
--prefix <FILE_PREFIX>— Optional prefix for report files -
-f,--force-overwrite— Overwrite existing report files? -
-l,--log-level <LOG_LEVEL>— Enable logging -
-v,--verbose— Increase logging verbosity (-v, -vv, -vvv, etc.)Level ERROR WARN INFO DEBUG TRACE Default ✓ -v ✓ ✓ ✓ -vv ✓ ✓ ✓ ✓ -vvv ✓ ✓ ✓ ✓ ✓ -
--warn— Set logging to WARN level. Shortcut for--log-level warn -
--debug— Set logging to DEBUG level. Shortcut for--log-level DEBUG -
--trace— Set logging to TRACE level. Shortcut for--log-level TRACE -
-t,--timeline-progress-max <TIMELINE_PROGRESS_MAX>— Enable the timeline progress bar with a maximum time -
--no-stats— Suppresses the printout of summary statistics at the end of the simulation
Re-exports§
pub use context::Context;pub use context::ContextBase;pub use context::ExecutionPhase;pub use context::IxaEvent;pub use error::IxaError;pub use global_properties::ContextGlobalPropertiesExt;pub use global_properties::GlobalProperty;pub use network::ContextNetworkExt;pub use network::Edge;pub use network::EdgeType;pub use random::ContextRandomExt;pub use random::RngId;pub use report::ConfigReportOptions;pub use report::ContextReportExt;pub use report::Report;pub use runner::run_with_args;pub use runner::run_with_custom_args;pub use runner::BaseArgs;pub use log::disable_logging;pub use log::enable_logging;pub use log::set_log_level;pub use log::set_module_filter;pub use log::set_module_filters;pub use crate::hashing::HashMapExt;pub use crate::hashing::HashSetExt;pub use entity::ContextEntitiesExt;pub use entity::EntityPropertyTuple;pub use bincode;pub use csv;pub use ctor;pub use paste;pub use rand;
Modules§
- context
- A manager for the state of a discrete-event simulation
- entity
- A “person” is represented by a
PersonIdand has multiplePersonPropertyvalues associated with it. Entities generalize this: AnEntityis analogous to a table in a relationship database, and the properties of an entity are analogous to the columns that exist on the table. A row in the table is addressable with anEntityId<Entity>(implemented as a newtype of ausize). In this new paradigm,Personis a particular entity, possibly one of several, andPersonIdis a type alias forEntityId<Person>. - error
- Provides
IxaErrorand wraps other errors. - execution_
stats - global_
properties - A generic mechanism for storing context-wide data.
- hashing
- This module provides a deterministic hasher and
HashMapandHashSetvariants that use it. The hashing data structures in the standard library are not deterministic: - log
- The
logmodule defines an interface to Ixa’s internal logging facilities. Logging messages about internal behavior of Ixa. This is not to be confused with reporting, which is model-level concept for Ixa users to record data about running models. - macros
- network
- A module for modeling contact networks.
- numeric
- Vendored from statrs@0.18.0 (prec.rs), convenience wrappers around methods from the approx crate. Provides utility functions for working with floating point precision.
- plan
- A priority queue that stores arbitrary data sorted by time and priority
- prelude
- prelude_
for_ plugins - profiling
- This module provides a lightweight, feature-gated profiling interface for simulations. It tracks event counts and measures elapsed time for named operations (“spans”), and can export the results to the console and to a JSON file together with execution statistics. It supports:
- progress
- Provides functions to set up and update a progress bar.
- random
- report
- runner
Macros§
- __
define_ data_ plugin - Helper for
define_data_plugin - assert_
almost_ eq - debug
- Logs a message at the debug level.
- define_
data_ plugin - Defines a new type for storing data in Context.
- define_
derived_ property - The “derived” variant of
define_property!for defining simple derived property types. Defines astructorenumwith a standard set of derives and automatically invokesimpl_derived_property!for it. - define_
edge_ type - define_
entity - Defines a zero-sized struct with the right derived traits and implements the
Entitytrait. If you already have a type defined (struct, enum, etc.), you can use theimpl_entity!macro instead. - define_
global_ property - Defines a global property with the following parameters:
- define_
multi_ property - Defines a derived property consisting of a (named) tuple of other properties. The primary use case is for indexing and querying properties jointly.
- define_
property - Defines a
structorenumwith a standard set of derives and automatically invokesimpl_property!for it. This macro provides a concise shorthand for defining simple property types that follow the same derive and implementation pattern. - define_
report - Use this macro to define a unique report type
- define_
rng - Use this to define a unique type which will be used as a key to retrieve
an independent rng instance when calling
Context::get_rng. - error
- Logs a message at the error level.
- impl_
derived_ property - Implements the
Propertytrait for an existing type as a derived property. - impl_
edge_ type - impl_
entity - Implements the
Entitytrait for the given existing type and defines a type alias of the formMyEntityId = EntityId<MyEntity>. For simple zero-sized types, use thedefine_entity!macro instead, which will define the struct and derive all the super traits. - impl_
make_ canonical - impl_
people_ make_ canonical - impl_
property - Implements the
Propertytrait for the given property type and entity. - info
- Logs a message at the info level.
- reorder_
closure - sorted_
tag - sorted_
value_ type - trace
- Logs a message at the trace level.
- unreorder_
closure - warn
- Logs a message at the warn level.
- with
- Creates a query matching all entities of a given type, optionally filtered by properties.
Enums§
- Level
Filter - An enum representing the available verbosity level filters of the logger.
Traits§
- Data
Plugin - A trait for objects that can provide data containers to be held by
Context - Plugin
Context - A supertrait that exposes useful methods from
Contextfor plugins implementingContextextensions.
Functions§
- add_
data_ plugin_ to_ registry - get_
data_ plugin_ count - get_
data_ plugin_ ids - initialize_
data_ plugin_ index - Acquires a global lock on the next available plugin index, but only increments it if we
successfully initialize the provided index. (Must be
pub, as it’s called from within a macro.)