generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Made basic-infection and births-deaths into libraries so they could s…
…hare code with the benchmarks.
- Loading branch information
1 parent
4963e92
commit 6f86acc
Showing
33 changed files
with
167 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"population": 100, | ||
"max_time": 780.0, | ||
"seed": 123, | ||
"birth_rate": 0.1, | ||
"death_rate": 0.1, | ||
"foi_groups": [ | ||
{"group_name": "NewBorn", "foi": 0.2}, | ||
{"group_name": "General", "foi": 0.1}, | ||
{"group_name": "OldAdult", "foi": 0.15} | ||
], | ||
"infection_duration": 5.0, | ||
"output_file": "incidence", | ||
"demographic_output_file": "people_report.csv" | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
[package] | ||
name = "ixa_example_basic_infection" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
publish = false | ||
|
||
[dependencies] | ||
|
||
ixa = { path = "../../../ixa" } | ||
ixa-derive = { path = "../../ixa-derive" } | ||
|
||
csv = "^1.3.1" | ||
serde = "^1.0.217" | ||
rand = "^0.8.5" | ||
rand_distr = "^0.4.3" | ||
paste = "^1.0.15" | ||
|
||
[[bin]] | ||
name = "basic_infection" | ||
path = "main.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use ixa::context::Context; | ||
use ixa::error::IxaError; | ||
use ixa::random::ContextRandomExt; | ||
|
||
pub mod incidence_report; | ||
pub mod infection_manager; | ||
pub mod people; | ||
pub mod transmission_manager; | ||
|
||
static POPULATION: u64 = 1000; | ||
static SEED: u64 = 123; | ||
static MAX_TIME: f64 = 303.0; | ||
static FOI: f64 = 0.1; | ||
static INFECTION_DURATION: f64 = 5.0; | ||
|
||
pub fn initialize() -> Result<Context, IxaError> { | ||
let mut context = Context::new(); | ||
|
||
context.init_random(SEED); | ||
|
||
people::init(&mut context); | ||
transmission_manager::init(&mut context); | ||
infection_manager::init(&mut context); | ||
incidence_report::init(&mut context)?; | ||
|
||
context.add_plan(MAX_TIME, |context| { | ||
context.shutdown(); | ||
}); | ||
Ok(context) | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "ixa_example_births_deaths" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
publish = false | ||
|
||
[dependencies] | ||
|
||
ixa = { path = "../../../ixa" } | ||
ixa-derive = { path = "../../ixa-derive" } | ||
|
||
csv = "^1.3.1" | ||
ctor = "^0.2.8" | ||
serde = "^1.0.217" | ||
rand = "^0.8.5" | ||
rand_distr = "^0.4.3" | ||
paste = "^1.0.15" | ||
|
||
[[bin]] | ||
name = "births_deaths" | ||
path = "main.rs" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,6 @@ | ||
use ixa::error::IxaError; | ||
use ixa::random::ContextRandomExt; | ||
use ixa::{context::Context, global_properties::ContextGlobalPropertiesExt}; | ||
use std::path::Path; | ||
|
||
mod demographics_report; | ||
mod incidence_report; | ||
mod infection_manager; | ||
mod parameters_loader; | ||
mod population_manager; | ||
mod transmission_manager; | ||
|
||
use crate::parameters_loader::Parameters; | ||
|
||
fn initialize() -> Result<Context, IxaError> { | ||
let mut context = Context::new(); | ||
let current_dir = Path::new(file!()).parent().unwrap(); | ||
let file_path = current_dir.join("input.json"); | ||
|
||
parameters_loader::init_parameters(&mut context, &file_path)?; | ||
|
||
let parameters = context | ||
.get_global_property_value(Parameters) | ||
.unwrap() | ||
.clone(); | ||
context.init_random(parameters.seed); | ||
|
||
demographics_report::init(&mut context)?; | ||
incidence_report::init(&mut context)?; | ||
|
||
population_manager::init(&mut context); | ||
transmission_manager::init(&mut context); | ||
infection_manager::init(&mut context); | ||
|
||
context.add_plan(parameters.max_time, |context| { | ||
context.shutdown(); | ||
}); | ||
println!("{parameters:?}"); | ||
Ok(context) | ||
} | ||
use ixa_example_births_deaths::initialize; | ||
|
||
fn main() { | ||
let mut context = initialize().expect("Could not initialize context."); | ||
|
||
context.execute(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.