From 2313a9ee555df24bf618d50f111c24d23362c3ae Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Sun, 1 Sep 2024 06:59:31 -0600 Subject: [PATCH] Transition matrix getter --- epiworld.hpp | 29 +++++++++++++++++++++++------ include/epiworld/database-bones.hpp | 4 ++++ include/epiworld/database-meat.hpp | 12 ++++++++++++ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/epiworld.hpp b/epiworld.hpp index fc212167..2d906096 100644 --- a/epiworld.hpp +++ b/epiworld.hpp @@ -939,7 +939,8 @@ inline double dgenint( int max_days = 200 ) { - g += 1; + if ((g < 1) || (g > max_days)) + return 0.0; if (p_0_approx < 0.0) { @@ -1018,7 +1019,7 @@ inline double gen_int_mean( mean += static_cast(i) * dgenint( - i, S, p_c, p_i, p_r, p_0_approx, normalizing, max_n + i, S, p_c, p_i, p_r, p_0_approx, normalizing, max_n, max_days ); } @@ -3027,6 +3028,10 @@ class DataBase { std::vector< int > & counts ) const; + void get_today_transition_matrix( + std::vector< int > & counts + ) const; + void get_hist_total( std::vector< int > * date, std::vector< std::string > * state, @@ -3822,6 +3827,18 @@ inline void DataBase::get_hist_tool( } +template +inline void DataBase::get_today_transition_matrix( + std::vector< int > & counts +) const +{ + + counts = transition_matrix; + + return; + +} + template inline void DataBase::get_hist_transition_matrix( std::vector< std::string > & state_from, @@ -18073,16 +18090,16 @@ inline std::vector< double > ModelSEIRCONN::generation_time_expected( // spend at least one day in the exposed state, and 1 day in the // infectious state before starting transmitting. std::vector< double > gen_times( - this_const->get_ndays(), 2.0 + days_exposed + this_const->get_ndays(), 1.0 + days_exposed ); double p_c = this_const->par("Contact rate")/this_const->size(); - double p_i = this_const->par("Transmission rate"); - double p_r = this_const->par("Recovery rate"); + double p_i = this_const->par("Prob. Transmission"); + double p_r = this_const->par("Prob. Recovery"); for (size_t i = 0u; i < this_const->get_ndays(); ++i) { - gen_times[i] = gen_int_mean( + gen_times[i] += gen_int_mean( S[i], p_c, p_i, diff --git a/include/epiworld/database-bones.hpp b/include/epiworld/database-bones.hpp index 218242b8..152ee1a4 100644 --- a/include/epiworld/database-bones.hpp +++ b/include/epiworld/database-bones.hpp @@ -178,6 +178,10 @@ class DataBase { std::vector< int > & counts ) const; + void get_today_transition_matrix( + std::vector< int > & counts + ) const; + void get_hist_total( std::vector< int > * date, std::vector< std::string > * state, diff --git a/include/epiworld/database-meat.hpp b/include/epiworld/database-meat.hpp index 95e641bb..36452944 100644 --- a/include/epiworld/database-meat.hpp +++ b/include/epiworld/database-meat.hpp @@ -639,6 +639,18 @@ inline void DataBase::get_hist_tool( } +template +inline void DataBase::get_today_transition_matrix( + std::vector< int > & counts +) const +{ + + counts = transition_matrix; + + return; + +} + template inline void DataBase::get_hist_transition_matrix( std::vector< std::string > & state_from,