Skip to content

Commit

Permalink
Transition matrix getter
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Sep 1, 2024
1 parent 93895a8 commit 2313a9e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
29 changes: 23 additions & 6 deletions epiworld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -1018,7 +1019,7 @@ inline double gen_int_mean(
mean +=
static_cast<double>(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
);

}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -3822,6 +3827,18 @@ inline void DataBase<TSeq>::get_hist_tool(

}

template<typename TSeq>
inline void DataBase<TSeq>::get_today_transition_matrix(
std::vector< int > & counts
) const
{

counts = transition_matrix;

return;

}

template<typename TSeq>
inline void DataBase<TSeq>::get_hist_transition_matrix(
std::vector< std::string > & state_from,
Expand Down Expand Up @@ -18073,16 +18090,16 @@ inline std::vector< double > ModelSEIRCONN<TSeq>::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,
Expand Down
4 changes: 4 additions & 0 deletions include/epiworld/database-bones.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions include/epiworld/database-meat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,18 @@ inline void DataBase<TSeq>::get_hist_tool(

}

template<typename TSeq>
inline void DataBase<TSeq>::get_today_transition_matrix(
std::vector< int > & counts
) const
{

counts = transition_matrix;

return;

}

template<typename TSeq>
inline void DataBase<TSeq>::get_hist_transition_matrix(
std::vector< std::string > & state_from,
Expand Down

0 comments on commit 2313a9e

Please sign in to comment.