Skip to content

Commit

Permalink
Renaming model
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Apr 23, 2024
1 parent 93be22d commit f6f8a48
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 68 deletions.
2 changes: 1 addition & 1 deletion examples/11-entities/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int main() {
0.05, 0.1, 0.7
};

epimodels::ModelSEIREntitiesConn model(
epimodels::ModelSEIRMixing model(
"Flu", // std::string vname,
100000, // epiworld_fast_uint n,
0.01,// epiworld_double prevalence,
Expand Down
2 changes: 1 addition & 1 deletion include/epiworld/agent-meat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ inline void Agent<TSeq>::add_entity(
-1, -1
);

// default_add_entity(a, model); /* passing model makes nothing */
default_add_entity(a, model); /* passing model makes nothing */

}

Expand Down
34 changes: 3 additions & 31 deletions include/epiworld/model-meat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,6 @@ inline void Model<TSeq>::load_agents_entities_ties(
throw std::logic_error("The file " + fn + " was not found.");

int linenum = 0;
std::vector< epiworld_fast_uint > source_;
std::vector< std::vector< epiworld_fast_uint > > target_(entities.size());

target_.reserve(1e5);
Expand Down Expand Up @@ -1361,34 +1360,6 @@ inline void Model<TSeq>::load_agents_entities_ties(

}

// // Iterating over entities
// for (size_t e = 0u; e < entities.size(); ++e)
// {

// // This entity will have individuals assigned to it, so we add it
// if (target_[e].size() > 0u)
// {

// // Filling in the gaps
// prevalence_entity[e] = static_cast<epiworld_double>(target_[e].size());
// prevalence_entity_as_proportion[e] = false;

// // Generating the assignment function
// auto who = target_[e];
// entities_dist_funs[e] =
// [who](Entity<TSeq> & e, Model<TSeq>* m) -> void {

// for (auto w : who)
// m->population[w].add_entity(e, m, e.state_init, e.queue_init);

// return;

// };

// }

// }

return;

}
Expand All @@ -1413,7 +1384,7 @@ inline void Model<TSeq>::load_agents_entities_ties(
for (size_t i = 0u; i < n_entries; ++i)
{

if (agents_id[i] >= this->population.size())
if (agents_ids[i] >= this->population.size())
throw std::length_error(
std::string("agents_ids[") +
std::to_string(i) +
Expand All @@ -1436,9 +1407,10 @@ inline void Model<TSeq>::load_agents_entities_ties(
std::string(").")
);

// Adding the entity to the agent
this->population[agents_ids[i]].add_entity(
this->entities[entities_ids[i]],
nullptr
nullptr /* Immediately add it to the agent */
);

}
Expand Down
2 changes: 1 addition & 1 deletion include/epiworld/models/models.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace epimodels {
#include "seirdconnected.hpp"
#include "sirlogit.hpp"
#include "diffnet.hpp"
#include "seirentitiesconnected.hpp"
#include "seirmixing.hpp"


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

/**
* @file seirentitiesconnected.hpp
* @brief Template for a Susceptible-Exposed-Infected-Removed (SEIR) model with entities
* @brief Template for a Susceptible-Exposed-Infected-Removed (SEIR) model with mixing
*/
template<typename TSeq = EPI_DEFAULT_TSEQ>
class ModelSEIREntitiesConn : public epiworld::Model<TSeq>
class ModelSEIRMixing : public epiworld::Model<TSeq>
{
public:

Expand All @@ -18,14 +18,14 @@ class ModelSEIREntitiesConn : public epiworld::Model<TSeq>

std::shared_ptr< epiworld::GroupSampler<TSeq> > group_sampler;

ModelSEIREntitiesConn() {};
ModelSEIRMixing() {};


/**
* @brief Constructs a ModelSEIREntitiesConn object.
* @brief Constructs a ModelSEIRMixing object.
*
* @param model A reference to an existing ModelSEIREntitiesConn object.
* @param vname The name of the ModelSEIREntitiesConn object.
* @param model A reference to an existing ModelSEIRMixing object.
* @param vname The name of the ModelSEIRMixing object.
* @param n The number of entities in the model.
* @param prevalence The initial prevalence of the disease in the model.
* @param contact_rate The contact rate between entities in the model.
Expand All @@ -35,8 +35,8 @@ class ModelSEIREntitiesConn : public epiworld::Model<TSeq>
* @param entities A vector of entity values.
* @param entities_names A vector of entity names.
*/
ModelSEIREntitiesConn(
ModelSEIREntitiesConn<TSeq> & model,
ModelSEIRMixing(
ModelSEIRMixing<TSeq> & model,
std::string vname,
epiworld_fast_uint n,
epiworld_double prevalence,
Expand All @@ -50,9 +50,9 @@ class ModelSEIREntitiesConn : public epiworld::Model<TSeq>
);

/**
* @brief Constructs a ModelSEIREntitiesConn object.
* @brief Constructs a ModelSEIRMixing object.
*
* @param vname The name of the ModelSEIREntitiesConn object.
* @param vname The name of the ModelSEIRMixing object.
* @param n The number of entities in the model.
* @param prevalence The initial prevalence of the disease in the model.
* @param contact_rate The contact rate between entities in the model.
Expand All @@ -61,7 +61,7 @@ class ModelSEIREntitiesConn : public epiworld::Model<TSeq>
* @param recovery_rate The recovery rate of the disease in the model.
* @param entities A vector of entity values.
*/
ModelSEIREntitiesConn(
ModelSEIRMixing(
std::string vname,
epiworld_fast_uint n,
epiworld_double prevalence,
Expand All @@ -74,7 +74,7 @@ class ModelSEIREntitiesConn : public epiworld::Model<TSeq>
std::vector< double > contact_matrix
);

ModelSEIREntitiesConn<TSeq> & run(
ModelSEIRMixing<TSeq> & run(
epiworld_fast_uint ndays,
int seed = -1
);
Expand All @@ -88,15 +88,15 @@ class ModelSEIREntitiesConn : public epiworld::Model<TSeq>
* @param proportions_ Double vector with a single element:
* - The proportion of non-infected individuals who have recovered.
*/
ModelSEIREntitiesConn<TSeq> & initial_states(
ModelSEIRMixing<TSeq> & initial_states(
std::vector< double > proportions_,
std::vector< int > queue_ = {}
);

};

template<typename TSeq>
inline ModelSEIREntitiesConn<TSeq> & ModelSEIREntitiesConn<TSeq>::run(
inline ModelSEIRMixing<TSeq> & ModelSEIRMixing<TSeq>::run(
epiworld_fast_uint ndays,
int seed
)
Expand All @@ -109,7 +109,7 @@ inline ModelSEIREntitiesConn<TSeq> & ModelSEIREntitiesConn<TSeq>::run(
}

template<typename TSeq>
inline void ModelSEIREntitiesConn<TSeq>::reset()
inline void ModelSEIRMixing<TSeq>::reset()
{

Model<TSeq>::reset();
Expand All @@ -126,11 +126,11 @@ inline void ModelSEIREntitiesConn<TSeq>::reset()
}

template<typename TSeq>
inline Model<TSeq> * ModelSEIREntitiesConn<TSeq>::clone_ptr()
inline Model<TSeq> * ModelSEIRMixing<TSeq>::clone_ptr()
{

ModelSEIREntitiesConn<TSeq> * ptr = new ModelSEIREntitiesConn<TSeq>(
*dynamic_cast<const ModelSEIREntitiesConn<TSeq>*>(this)
ModelSEIRMixing<TSeq> * ptr = new ModelSEIRMixing<TSeq>(
*dynamic_cast<const ModelSEIRMixing<TSeq>*>(this)
);

return dynamic_cast< Model<TSeq> *>(ptr);
Expand All @@ -149,8 +149,8 @@ inline Model<TSeq> * ModelSEIREntitiesConn<TSeq>::clone_ptr()
* @param recovery_rate Probability of recovery
*/
template<typename TSeq>
inline ModelSEIREntitiesConn<TSeq>::ModelSEIREntitiesConn(
ModelSEIREntitiesConn<TSeq> & model,
inline ModelSEIRMixing<TSeq>::ModelSEIRMixing(
ModelSEIRMixing<TSeq> & model,
std::string vname,
epiworld_fast_uint n,
epiworld_double prevalence,
Expand Down Expand Up @@ -180,8 +180,8 @@ inline ModelSEIREntitiesConn<TSeq>::ModelSEIREntitiesConn(

// Downcasting to retrieve the sampler attached to the
// class
ModelSEIREntitiesConn<TSeq> * m_down =
dynamic_cast<ModelSEIREntitiesConn<TSeq> *>(m);
ModelSEIRMixing<TSeq> * m_down =
dynamic_cast<ModelSEIRMixing<TSeq> *>(m);

// Sampling from the agent's entities
auto & samples = m->array_int_tmp;
Expand All @@ -205,7 +205,7 @@ inline ModelSEIREntitiesConn<TSeq>::ModelSEIREntitiesConn(
continue;

// If the neighbor is infected, then proceed
if (neighbor.get_state() == ModelSEIREntitiesConn<TSeq>::INFECTED)
if (neighbor.get_state() == ModelSEIRMixing<TSeq>::INFECTED)
{

auto & v = neighbor.get_virus();
Expand Down Expand Up @@ -240,7 +240,7 @@ inline ModelSEIREntitiesConn<TSeq>::ModelSEIREntitiesConn(
p->set_virus(
*m->array_virus_tmp[which],
m,
ModelSEIREntitiesConn<TSeq>::EXPOSED
ModelSEIRMixing<TSeq>::EXPOSED
);

return;
Expand All @@ -253,7 +253,7 @@ inline ModelSEIREntitiesConn<TSeq>::ModelSEIREntitiesConn(

auto state = p->get_state();

if (state == ModelSEIREntitiesConn<TSeq>::EXPOSED)
if (state == ModelSEIRMixing<TSeq>::EXPOSED)
{

// Getting the virus
Expand All @@ -263,13 +263,13 @@ inline ModelSEIREntitiesConn<TSeq>::ModelSEIREntitiesConn(
if (m->runif() < 1.0/(v->get_incubation(m)))
{

p->change_state(m, ModelSEIREntitiesConn<TSeq>::INFECTED);
p->change_state(m, ModelSEIRMixing<TSeq>::INFECTED);
return;

}


} else if (state == ModelSEIREntitiesConn<TSeq>::INFECTED)
} else if (state == ModelSEIRMixing<TSeq>::INFECTED)
{


Expand Down Expand Up @@ -330,9 +330,9 @@ inline ModelSEIREntitiesConn<TSeq>::ModelSEIREntitiesConn(
// Preparing the virus -------------------------------------------
epiworld::Virus<TSeq> virus(vname);
virus.set_state(
ModelSEIREntitiesConn<TSeq>::EXPOSED,
ModelSEIREntitiesConn<TSeq>::RECOVERED,
ModelSEIREntitiesConn<TSeq>::RECOVERED
ModelSEIRMixing<TSeq>::EXPOSED,
ModelSEIRMixing<TSeq>::RECOVERED,
ModelSEIRMixing<TSeq>::RECOVERED
);

virus.set_prob_infecting(&model("Prob. Transmission"));
Expand All @@ -346,14 +346,14 @@ inline ModelSEIREntitiesConn<TSeq>::ModelSEIREntitiesConn(
// Adding the empty population
model.agents_empty_graph(n);

model.set_name("Susceptible-Exposed-Infected-Removed (SEIR) (connected)");
model.set_name("Susceptible-Exposed-Infected-Removed (SEIR) with Mixing");

return;

}

template<typename TSeq>
inline ModelSEIREntitiesConn<TSeq>::ModelSEIREntitiesConn(
inline ModelSEIRMixing<TSeq>::ModelSEIRMixing(
std::string vname,
epiworld_fast_uint n,
epiworld_double prevalence,
Expand Down Expand Up @@ -385,7 +385,7 @@ inline ModelSEIREntitiesConn<TSeq>::ModelSEIREntitiesConn(
group_sizes
);

ModelSEIREntitiesConn(
ModelSEIRMixing(
*this,
vname,
n,
Expand All @@ -404,7 +404,7 @@ inline ModelSEIREntitiesConn<TSeq>::ModelSEIREntitiesConn(
}

template<typename TSeq>
inline ModelSEIREntitiesConn<TSeq> & ModelSEIREntitiesConn<TSeq>::initial_states(
inline ModelSEIRMixing<TSeq> & ModelSEIRMixing<TSeq>::initial_states(
std::vector< double > proportions_,
std::vector< int > /* queue_ */
)
Expand Down

0 comments on commit f6f8a48

Please sign in to comment.