Skip to content

Commit

Permalink
Fixing ModelSISD
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Aug 2, 2023
1 parent c262adb commit 22adffe
Show file tree
Hide file tree
Showing 14 changed files with 150 additions and 10 deletions.
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,14 @@ S3method(plot,epiworld_multiple_save_reproductive_number)
S3method(plot,epiworld_repnum)
S3method(plot,epiworld_seir)
S3method(plot,epiworld_seirconn)
S3method(plot,epiworld_seirdconn)
S3method(plot,epiworld_sir)
S3method(plot,epiworld_sirconn)
S3method(plot,epiworld_sird)
S3method(plot,epiworld_sis)
S3method(plot,epiworld_sisd)
S3method(plot,epiworld_surv)
S3method(plot,epiworld_survd)
S3method(print,epiworld_agent)
S3method(print,epiworld_agents)
S3method(print,epiworld_agents_tools)
Expand Down Expand Up @@ -74,12 +77,15 @@ S3method(verbose_on,epiworld_model)
export(ModelDiffNet)
export(ModelSEIR)
export(ModelSEIRCONN)
export(ModelSEIRDCONN)
export(ModelSIR)
export(ModelSIRCONN)
export(ModelSIRD)
export(ModelSIRLogit)
export(ModelSIS)
export(ModelSISD)
export(ModelSURV)
export(ModelSURVD)
export(add_global_action)
export(add_tool)
export(add_tool_agent)
Expand Down
16 changes: 16 additions & 0 deletions R/cpp11.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,22 @@ ModelSIRD_cpp <- function(name, prevalence, transmission_rate, recovery_rate, de
.Call(`_epiworldR_ModelSIRD_cpp`, name, prevalence, transmission_rate, recovery_rate, death_rate)
}

ModelSISD_cpp <- function(name, prevalence, transmission_rate, recovery_rate, death_rate) {
.Call(`_epiworldR_ModelSISD_cpp`, name, prevalence, transmission_rate, recovery_rate, death_rate)
}

ModelSURVD_cpp <- function(name, prevalence, efficacy_vax, latent_period, prob_symptoms, prop_vaccinated, prop_vax_redux_transm, infect_period, prop_vax_redux_infect, surveillance_prob, transmission_rate, prob_death, prob_noreinfect) {
.Call(`_epiworldR_ModelSURVD_cpp`, name, prevalence, efficacy_vax, latent_period, prob_symptoms, prop_vaccinated, prop_vax_redux_transm, infect_period, prop_vax_redux_infect, surveillance_prob, transmission_rate, prob_death, prob_noreinfect)
}

ModelSIRDCONN_cpp <- function(name, n, prevalence, contact_rate, transmission_rate, recovery_rate, death_rate) {
.Call(`_epiworldR_ModelSIRDCONN_cpp`, name, n, prevalence, contact_rate, transmission_rate, recovery_rate, death_rate)
}

ModelSEIRDCONN_cpp <- function(name, n, prevalence, contact_rate, transmission_rate, incubation_days, recovery_rate, death_rate) {
.Call(`_epiworldR_ModelSEIRDCONN_cpp`, name, n, prevalence, contact_rate, transmission_rate, incubation_days, recovery_rate, death_rate)
}

ModelSEIRCONN_cpp <- function(name, n, prevalence, contact_rate, transmission_rate, incubation_days, recovery_rate) {
.Call(`_epiworldR_ModelSEIRCONN_cpp`, name, n, prevalence, contact_rate, transmission_rate, incubation_days, recovery_rate)
}
Expand Down
20 changes: 12 additions & 8 deletions inst/include/epiworld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3183,8 +3183,10 @@ inline void DataBase<TSeq>::record()
// Now the diagonal must reflect the state
for (size_t s_i = 0u; s_i < model->nstates; ++s_i)
{

for (size_t s_j = 0u; s_j < model->nstates; ++s_j)
{

if ((s_i != s_j) && (transition_matrix[s_i + s_j * model->nstates] > 0))
{
transition_matrix[s_j + s_j * model->nstates] +=
Expand All @@ -3195,15 +3197,18 @@ inline void DataBase<TSeq>::record()

}

#ifdef EPI_DEBUG
}

#ifdef EPI_DEBUG
for (size_t s_i = 0u; s_i < model->nstates; ++s_i)
{
if (transition_matrix[s_i + s_i * model->nstates] !=
today_total[s_i])
throw std::logic_error(
"The diagonal of the updated transition Matrix should match the daily totals"
);
#endif
}

#endif

}

Expand Down Expand Up @@ -6949,7 +6954,6 @@ inline void Model<TSeq>::actions_run()
for (size_t t = 0u; t < p->n_tools; ++t)
db.update_tool(p->tools[t]->id, p->state, a.new_state);


// Saving the last state and setting the new one
p->state_prev = p->state;
p->state = a.new_state;
Expand Down Expand Up @@ -16902,16 +16906,16 @@ inline ModelSISD<TSeq>::ModelSISD(
// Adding statuses
model.add_state("Susceptible", epiworld::default_update_susceptible<TSeq>);
model.add_state("Infected", epiworld::default_update_exposed<TSeq>);
model.add_state("Deceased")
model.add_state("Deceased");

// Setting up parameters
model.add_param(transmission_rate, "Transmission rate");
model.add_param(recovery_rate, "Recovery rate");
model.add_param(death_rate, "Death rate")
model.add_param(death_rate, "Death rate");

// Preparing the virus -------------------------------------------
epiworld::Virus<TSeq> virus(vname);
virus.set_state(1,0,0);
virus.set_state(1,0,2);

This comment has been minimized.

Copy link
@gvegayon

gvegayon Aug 2, 2023

Author Member

Hey @derekmeyer37. This was the issue with the model. It is now fixed

This comment has been minimized.

Copy link
@gvegayon

gvegayon Aug 2, 2023

Author Member

I also fixed this in UofUEpiBio/epiworld


virus.set_prob_infecting(&model("Transmission rate"));
virus.set_prob_recovery(&model("Recovery rate"));
Expand All @@ -16929,7 +16933,7 @@ inline ModelSISD<TSeq>::ModelSISD(
epiworld_double prevalence,
epiworld_double transmission_rate,
epiworld_double recovery_rate,
epiworld_double death_rate,
epiworld_double death_rate
)
{

Expand Down
3 changes: 3 additions & 0 deletions man/ModelDiffNet.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/ModelSEIR.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/ModelSEIRCONN.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/ModelSIR.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 56 additions & 1 deletion man/ModelSIRCONN.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/ModelSIRD.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/ModelSIRLogit.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/ModelSIS.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/ModelSURV.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/epiworld-data.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 22adffe

Please sign in to comment.