Skip to content

Commit

Permalink
Fixing ambiguous const
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Jun 18, 2024
1 parent 99439b6 commit 9472fc0
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 96 deletions.
51 changes: 4 additions & 47 deletions epiworld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6518,8 +6518,6 @@ class Model {
virtual void reset();
const Model<TSeq> & print(bool lite = false) const;

Model<TSeq> && clone() const;

/**
* @name Manage state (states) in the model
*
Expand Down Expand Up @@ -9002,47 +9000,6 @@ inline const Model<TSeq> & Model<TSeq>::print(bool lite) const



template<typename TSeq>
inline Model<TSeq> && Model<TSeq>::clone() const {

// Step 1: Regen the individuals and make sure that:
// - Neighbors point to the right place
// - DB is pointing to the right place
Model<TSeq> res(*this);

// Removing old neighbors
for (auto & p: res.population)
p.neighbors.clear();

// Rechecking individuals
for (epiworld_fast_uint p = 0u; p < size(); ++p)
{
// Making room
const Agent<TSeq> & agent_this = population[p];
Agent<TSeq> & agent_res = res.population[p];

// Agent pointing to the right model and agent
agent_res.model = &res;
agent_res.viruses.agent = &agent_res;
agent_res.tools.agent = &agent_res;

// Readding
std::vector< Agent<TSeq> * > neigh = agent_this.neighbors;
for (epiworld_fast_uint n = 0u; n < neigh.size(); ++n)
{
// Point to the right neighbors
int loc = res.population_ids[neigh[n]->get_id()];
agent_res.add_neighbor(res.population[loc], true, true);

}

}

return res;

}



template<typename TSeq>
inline void Model<TSeq>::add_state(
Expand Down Expand Up @@ -9995,9 +9952,9 @@ class Virus {
Virus(std::string name = "unknown virus");

Virus(
std::string name = "unknown virus",
epiworld_double prevalence = 0.0,
bool as_proportion = true
std::string name,
epiworld_double prevalence,
bool as_proportion
);

void mutate(Model<TSeq> * model);
Expand Down Expand Up @@ -10322,7 +10279,7 @@ inline VirusFun<TSeq> virus_fun_logit(
for (auto c: coefs)
coefs_f.push_back(static_cast<epiworld_double>(c));

VirusFun<TSeq> fun_infect = [coefs_f,vars,logit](
VirusFun<TSeq> fun_infect = [coefs_f,vars](
Agent<TSeq> * agent,
Virus<TSeq> & virus,
Model<TSeq> * model
Expand Down
4 changes: 2 additions & 2 deletions examples/00-hello-world/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ int main()
model.add_state("Removed");

// Adding the tool and virus
epiworld::Virus<int> virus(
"covid 19",
epiworld::Virus<int> virus("covid 19");
virus.set_distribution(
distribute_virus_randomly<int>(50, false)
);

Expand Down
2 changes: 0 additions & 2 deletions include/epiworld/model-bones.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,8 +533,6 @@ class Model {
virtual void reset();
const Model<TSeq> & print(bool lite = false) const;

Model<TSeq> && clone() const;

/**
* @name Manage state (states) in the model
*
Expand Down
41 changes: 0 additions & 41 deletions include/epiworld/model-meat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1929,47 +1929,6 @@ inline void Model<TSeq>::reset() {
// Too big to keep here
#include "model-meat-print.hpp"

template<typename TSeq>
inline Model<TSeq> && Model<TSeq>::clone() const {

// Step 1: Regen the individuals and make sure that:
// - Neighbors point to the right place
// - DB is pointing to the right place
Model<TSeq> res(*this);

// Removing old neighbors
for (auto & p: res.population)
p.neighbors.clear();

// Rechecking individuals
for (epiworld_fast_uint p = 0u; p < size(); ++p)
{
// Making room
const Agent<TSeq> & agent_this = population[p];
Agent<TSeq> & agent_res = res.population[p];

// Agent pointing to the right model and agent
agent_res.model = &res;
agent_res.viruses.agent = &agent_res;
agent_res.tools.agent = &agent_res;

// Readding
std::vector< Agent<TSeq> * > neigh = agent_this.neighbors;
for (epiworld_fast_uint n = 0u; n < neigh.size(); ++n)
{
// Point to the right neighbors
int loc = res.population_ids[neigh[n]->get_id()];
agent_res.add_neighbor(res.population[loc], true, true);

}

}

return res;

}



template<typename TSeq>
inline void Model<TSeq>::add_state(
Expand Down
6 changes: 3 additions & 3 deletions include/epiworld/virus-bones.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ class Virus {
Virus(std::string name = "unknown virus");

Virus(
std::string name = "unknown virus",
epiworld_double prevalence = 0.0,
bool as_proportion = true
std::string name,
epiworld_double prevalence,
bool as_proportion
);

void mutate(Model<TSeq> * model);
Expand Down
2 changes: 1 addition & 1 deletion include/epiworld/virus-meat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ inline VirusFun<TSeq> virus_fun_logit(
for (auto c: coefs)
coefs_f.push_back(static_cast<epiworld_double>(c));

VirusFun<TSeq> fun_infect = [coefs_f,vars,logit](
VirusFun<TSeq> fun_infect = [coefs_f,vars](
Agent<TSeq> * agent,
Virus<TSeq> & virus,
Model<TSeq> * model
Expand Down

0 comments on commit 9472fc0

Please sign in to comment.