Skip to content

Commit e890713

Browse files
committed
initial age-specific params
1 parent dad1fc0 commit e890713

File tree

3 files changed

+36
-8
lines changed

3 files changed

+36
-8
lines changed

input/input.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@
1313
"duration": 5.0
1414
}
1515
},
16+
"symptom_age_groups": {"Young": 0, "Old": 50},
1617
"probability_mild_given_infect": 0.7,
1718
"infect_to_mild_mu": 0.1,
1819
"infect_to_mild_sigma": 0.0,
19-
"probability_severe_given_mild": 0.2,
20+
"probability_severe_given_mild": {"Young": 0.05, "Old": 0.3},
2021
"mild_to_severe_mu": 0.1,
2122
"mild_to_severe_sigma": 0.1,
2223
"mild_to_resolved_mu": 0.1,

src/parameters.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{fmt::Debug, path::PathBuf};
55
use crate::infection_importation::ImportCasesFromFile;
66
use crate::reports::ReportParams;
77
use crate::settings::SettingProperties;
8+
use crate::symptom_status_manager::{SymptomAgeGroupNames};
89

910
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
1011
pub enum RateFnType {
@@ -36,14 +37,16 @@ pub struct Params {
3637
pub imported_cases_timeseries: ImportCasesFromFile,
3738
/// A library of infection rates to assign to infected people.
3839
pub infectiousness_rate_fn: RateFnType,
40+
/// age thresholds
41+
pub symptom_age_groups: HashMap<SymptomAgeGroupNames, u8>,
3942
/// Probability an infected person develops mild illness
4043
pub probability_mild_given_infect: f64,
4144
/// Mu parameter for log normal delay distribution from infection to mild illness
4245
pub infect_to_mild_mu: f64,
4346
/// Sigma parameter for log normal delay distribution from infection to mild illness
4447
pub infect_to_mild_sigma: f64,
4548
/// Probability a person with mild illness develops severe illness
46-
pub probability_severe_given_mild: f64,
49+
pub probability_severe_given_mild: HashMap<SymptomAgeGroupNames, f64>,
4750
/// Mu parameter for log normal delay distribution from mild to severe illness
4851
pub mild_to_severe_mu: f64,
4952
/// Sigma parameter for log normal delay distribution from mild to severe illness
@@ -120,10 +123,13 @@ fn validate_inputs(parameters: &Params) -> Result<(), IxaError> {
120123
));
121124
}
122125

123-
if !(0.0..=1.0).contains(&parameters.probability_severe_given_mild) {
124-
return Err(IxaError::IxaError(
125-
"The probability of severe illness given mild illness must be between 0 and 1, inclusive.".to_string(),
126-
));
126+
for (age_group, probability) in &parameters.probability_severe_given_mild {
127+
// we also want to check whether all of the values for age_group from the enum SymptomAgeGroupNames is specified
128+
if !(0.0..=1.0).contains(probability) {
129+
return Err(IxaError::IxaError(
130+
format!("The probability of severe illness given mild illness among {:?} must be between 0 and 1, inclusive.", age_group).to_string()
131+
));
132+
}
127133
}
128134

129135
if !(0.0..=1.0).contains(&parameters.probability_critical_given_severe) {
@@ -222,6 +228,7 @@ impl Default for Params {
222228
rate: 1.0,
223229
duration: 5.0,
224230
},
231+
symptom_age_groups: HashMap::new(),
225232
probability_mild_given_infect: 0.0,
226233
infect_to_mild_mu: 0.0,
227234
infect_to_mild_sigma: 0.0,

src/symptom_status_manager.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use ixa::{Context, ContextEntitiesExt, ContextRandomExt, IxaError, define_rng, impl_property, prelude::PropertyChangeEvent};
1+
use ixa::{Context, ContextEntitiesExt, ContextRandomExt, IxaError, define_property, define_rng, impl_property, prelude::PropertyChangeEvent};
22
use rand_distr::{LogNormal};
33
use serde::{Deserialize, Serialize};
44

@@ -24,6 +24,17 @@ impl_property!(
2424
default_const = SymptomStatus::NoSymptoms
2525
);
2626

27+
#[derive(Serialize, Deserialize, Debug, Clone, Copy, Hash, PartialEq, Eq)]
28+
pub enum SymptomAgeGroupNames {
29+
Young,
30+
Old
31+
}
32+
33+
define_property!(
34+
SymptomAgeGroupNames,
35+
Person,
36+
);
37+
2738
pub fn init(context: &mut Context) -> Result<(), IxaError> {
2839
let &Params{
2940
probability_mild_given_infect,
@@ -47,6 +58,12 @@ pub fn init(context: &mut Context) -> Result<(), IxaError> {
4758
..
4859
} = context.get_params();
4960

61+
let Params{
62+
symptom_age_groups, ..
63+
} = context.get_params();
64+
65+
println!("{:?}", symptom_age_groups.clone());
66+
5067
context.subscribe_to_event(
5168
move|context, event: PropertyChangeEvent<Person, InfectionStatus>|{
5269
if event.current == InfectionStatus::Infectious {
@@ -121,4 +138,7 @@ pub fn init(context: &mut Context) -> Result<(), IxaError> {
121138
// -set up parameters (essential to make it run) [DONE]
122139
// -add SymptomStatusData or some other mechanism to track what most symptom statuses a person had, even after resolved (and maybe track timing, too)
123140
// -make probabilities age (category) specific
124-
// -finish validation for parameters
141+
// -finish validation for parameters
142+
// -Take one of the parameters and make it a hashmap; how to validate this? (do you need to specify all groups)
143+
// how to implement a derived property to know what their age group is?
144+
// get the probability in the transitions

0 commit comments

Comments
 (0)