From 0288a2eccd78e192096d21c3f86f9b7065ff8e0a Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Thu, 25 Apr 2024 09:24:08 -0600 Subject: [PATCH] Updating the rate daily --- include/epiworld/models/sirconnected.hpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/include/epiworld/models/sirconnected.hpp b/include/epiworld/models/sirconnected.hpp index ded2ae8a..65bf109e 100644 --- a/include/epiworld/models/sirconnected.hpp +++ b/include/epiworld/models/sirconnected.hpp @@ -85,6 +85,12 @@ inline void ModelSIRCONN::update_infected() } } + Model::set_rand_binom( + this->get_n_infected(), + static_cast(Model::par("Contact rate"))/ + static_cast(Model::size()) + ); + return; } @@ -109,13 +115,6 @@ inline void ModelSIRCONN::reset() this->update_infected(); - Model::set_rand_binom( - this->get_n_infected(), - static_cast( - Model::par("Contact rate"))/ - static_cast(Model::size()) - ); - return; } @@ -294,6 +293,17 @@ inline ModelSIRCONN::ModelSIRCONN( model.add_param(transmission_rate, "Transmission rate"); model.add_param(recovery_rate, "Recovery rate"); // model.add_param(prob_reinfection, "Prob. Reinfection"); + + // Adding update function + epiworld::GlobalFun update = [](epiworld::Model * m) -> void + { + ModelSIRCONN * model = dynamic_cast *>(m); + model->update_infected(); + + return; + }; + + model.add_globalevent(update, "Update infected individuals"); // Preparing the virus ------------------------------------------- epiworld::Virus virus(vname);