Skip to content

Commit 50cbf07

Browse files
committed
Add a bit more documentation for config
1 parent 61b83ec commit 50cbf07

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed

src/config/mod.rs

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,81 @@
1-
//! Configuration data structures for simulation setups.
1+
//! # Settings for the simulation binary
2+
//!
3+
//! Settings are used to configure the simulation when it is run as a program.
4+
//! These settings are read from a YAML file and are used to initialize and run
5+
//! the simulation. The settings are divided into two parts: parameters and
6+
//! schedule. The parameters define the simulation parameters, such as the
7+
//! mutation rate and the maximum virus population size. The schedule defines
8+
//! events that occur throughout the simulation, such as transmission between
9+
//! compartments, sampling of individuals, or environmental changes.
10+
//!
11+
//! ## Parameters
12+
//!
13+
//! The parameters define the simulation parameters and are given as a list of
14+
//! [`Parameters`]. Some of the parameters require single values, while others
15+
//! may require more complex structures. For example, the fitness model can
16+
//! either be a single host model or a multi-host model. The corresponding MFED
17+
//! may be a neutral model, a lognormal model, or a model based on a file.
18+
//!
19+
//! ```yaml
20+
//! parameters:
21+
//! - mutation_rate: 1e-6
22+
//! recombination_rate: 0
23+
//! host_population_size: 10000
24+
//! infection_fraction: 1.0
25+
//! basic_reproductive_number: 100.0
26+
//! max_population: 10000
27+
//! dilution: 0.02
28+
//! substitution_matrix:
29+
//! - [0.0, 1.0, 1.0, 1.0]
30+
//! - [1.0, 0.0, 1.0, 1.0]
31+
//! - [1.0, 1.0, 0.0, 1.0]
32+
//! - [1.0, 1.0, 1.0, 0.0]
33+
//! fitness_model: !SingleHost
34+
//! distribution: !Exponential
35+
//! weights:
36+
//! beneficial: 0.29
37+
//! deleterious: 0.51
38+
//! lethal: 0.2
39+
//! neutral: 0.0
40+
//! lambda_beneficial: 0.03
41+
//! lambda_deleterious: 0.21
42+
//! utility: !Algebraic
43+
//! upper: 1.5
44+
//! ```
45+
//!
46+
//! All available options can be found by looking at the type definition of the
47+
//! field. For example, one can find the available options for the
48+
//! `fitness_model` field by following the type definition to the corresponding
49+
//! enum: [`FitnessModelField`]. The available options can then be defined in
50+
//! YAML by using the corresponding tag, e.g., `!SingleHost` for a single host
51+
//! model.
52+
//!
53+
//! ```yaml
54+
//! fitness_model: !SingleHost
55+
//! distribution: !Neutral
56+
//! utility: !Linear
57+
//! ```
58+
//!
59+
//! ## Schedule
60+
//!
61+
//! The schedule is defined as a list of events that occur throughout the
62+
//! simulation. The events are defined by a generation expression, an event
63+
//! name, and a value. The generation expression is either the generation where
64+
//! the event should be executed, or in the case of recurring events an
65+
//! expression that will be executed every time the expression evaluates to 0.
66+
//! For example, the expression `{} % 200` will execute the event every 200
67+
//! generations.
68+
//!
69+
//! ```yaml
70+
//! schedule:
71+
//! - generation: "{} % 1"
72+
//! event: transmission
73+
//! value: "[[0.9, 0.1], [0.1, 0.9]]"
74+
//! - generation: "{} % 200"
75+
//! event: sample
76+
//! value: 1000
77+
//! ```
78+
//!
279
380
mod parameters;
481
mod schedule;

src/config/settings.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Settings module.
2+
13
use super::parameters::Parameters;
24
use super::schedule::Schedule;
35

0 commit comments

Comments
 (0)