Skip to content

Commit

Permalink
Updating the rate daily
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Apr 25, 2024
1 parent 4346222 commit 0288a2e
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions include/epiworld/models/sirconnected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ inline void ModelSIRCONN<TSeq>::update_infected()
}
}

Model<TSeq>::set_rand_binom(
this->get_n_infected(),
static_cast<double>(Model<TSeq>::par("Contact rate"))/
static_cast<double>(Model<TSeq>::size())
);

return;

}
Expand All @@ -109,13 +115,6 @@ inline void ModelSIRCONN<TSeq>::reset()

this->update_infected();

Model<TSeq>::set_rand_binom(
this->get_n_infected(),
static_cast<double>(
Model<TSeq>::par("Contact rate"))/
static_cast<double>(Model<TSeq>::size())
);

return;

}
Expand Down Expand Up @@ -294,6 +293,17 @@ inline ModelSIRCONN<TSeq>::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<TSeq> update = [](epiworld::Model<TSeq> * m) -> void
{
ModelSIRCONN<TSeq> * model = dynamic_cast<ModelSIRCONN<TSeq> *>(m);
model->update_infected();

return;
};

model.add_globalevent(update, "Update infected individuals");

// Preparing the virus -------------------------------------------
epiworld::Virus<TSeq> virus(vname);
Expand Down

0 comments on commit 0288a2e

Please sign in to comment.