From 22ecc647aca27b07d4b424325ae15a8f0b82a383 Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Sun, 7 Apr 2024 16:34:28 -0600 Subject: [PATCH] Updating single-header --- epiworld.hpp | 59 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 13 deletions(-) diff --git a/epiworld.hpp b/epiworld.hpp index 8ad5ef54..e32dd42c 100644 --- a/epiworld.hpp +++ b/epiworld.hpp @@ -1467,6 +1467,13 @@ inline LFMCMCProposalFun make_proposal_norm_reflective( } + #ifdef EPI_DEBUG + for (auto & p : params_now) + if (p < lb || p > ub) + throw std::range_error("The parameter is out of bounds."); + #endif + + return; }; @@ -8749,21 +8756,19 @@ inline void Model::reset() { } #endif - } - else - { - for (auto & p : population) - p.reset(); + } - #ifdef EPI_DEBUG - for (auto & a: population) - { - if (a.get_state() != 0u) - throw std::logic_error("Model::reset population doesn't match." - "Some agents are not in the baseline state."); - } - #endif + for (auto & p : population) + p.reset(); + + #ifdef EPI_DEBUG + for (auto & a: population) + { + if (a.get_state() != 0u) + throw std::logic_error("Model::reset population doesn't match." + "Some agents are not in the baseline state."); } + #endif if (entities_backup.size() != 0) { @@ -18405,6 +18410,34 @@ inline ModelSEIRDCONN & ModelSEIRDCONN::initial_states( #ifndef EPIWORLD_MODELS_SIRLOGIT_HPP #define EPIWORLD_MODELS_SIRLOGIT_HPP + +/** + * @brief Template for a Susceptible-Infected-Removed (SIR) model + * + * @details + * In this model, infection and recoveru probabilities are computed + * using a logit model. Particularly, the probability of infection + * is computed as: + * + * \f[ + * \frac{1}{1 + \exp\left(-\left(\beta_0 E_i + \sum_{i=1}^{n} \beta_i x_i\right)\right)} + * \f] + * + * where \f$\beta_0\f$ is the exposure coefficient and \f$E_i\f$ is the exposure + * number, \f$\beta_i\f$ are the + * coefficients for the features \f$x_i\f$ of the agents, and \f$n\f$ is the + * number of features. The probability of recovery is computed as: + * + * \f[ + * \frac{1}{1 + \exp\left(-\left(\sum_{i=1}^{n} \beta_i x_i\right)\right)} + * \f] + * + * where \f$\beta_i\f$ are the coefficients for the features \f$x_i\f$ of the agents, + * and \f$n\f$ is the number of features. + * + * @param TSeq Type of the sequence (e.g. std::vector, std::deque) + +*/ template class ModelSIRLogit : public epiworld::Model {