Skip to content

Commit

Permalink
Emplacing when copy agent
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Sep 26, 2023
1 parent 3fe5d6a commit bf344f7
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@
"typeinfo": "cpp",
"variant": "cpp",
"semaphore": "cpp"
}
},
"intel-corporation.oneapi-analysis-configurator.binary-path": "/home/george/Documents/development/epiworld/tests/01c.o"
}
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ helloworld.o: helloworld.cpp epiworld.hpp
g++ -std=c++17 -O2 helloworld.cpp -o helloworld.o

.PHONY: examples all-examples epiworld.hpp

image=intel/oneapi-basekit:devel-ubuntu22.04
# --device=/dev/dri enables the gpu (if available). May not be available in Linux VM or Windows
oneapi:
docker run --cap-add=SYS_ADMIN --cap-add=SYS_PTRACE \
--device=/dev/dri -it "${image}"
11 changes: 6 additions & 5 deletions epiworld.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15269,6 +15269,9 @@ class ModelSIS : public epiworld::Model<TSeq>

public:

static const int SUSCEPTIBLE = 0;
static const int INFECTED = 1;

ModelSIS() {};

ModelSIS(
Expand Down Expand Up @@ -15310,7 +15313,7 @@ inline ModelSIS<TSeq>::ModelSIS(

// Preparing the virus -------------------------------------------
epiworld::Virus<TSeq> virus(vname);
virus.set_state(1,0,0);
virus.set_state(ModelSIS<TSeq>::INFECTED, ModelSIS<TSeq>::SUSCEPTIBLE, ModelSIS<TSeq>::SUSCEPTIBLE);

virus.set_prob_infecting(&model("Transmission rate"));
virus.set_prob_recovery(&model("Recovery rate"));
Expand Down Expand Up @@ -17193,14 +17196,12 @@ inline ModelSEIRD<TSeq>::ModelSEIRD(
template<typename TSeq = EPI_DEFAULT_TSEQ>
class ModelSIRDCONN : public epiworld::Model<TSeq>
{
private:
public:
static const int SUSCEPTIBLE = 0;
static const int INFECTED = 1;
static const int RECOVERED = 2;
static const int RECOVERED = 2;
static const int DECEASED = 3;

public:

ModelSIRDCONN() {

// tracked_agents_infected.reserve(1e4);
Expand Down
12 changes: 6 additions & 6 deletions include/epiworld/agent-meat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,27 +90,27 @@ inline Agent<TSeq>::Agent(const Agent<TSeq> & p) :
id = p.id;

// Dealing with the virus
viruses.resize(p.get_n_viruses(), nullptr);
viruses.reserve(p.get_n_viruses());
n_viruses = viruses.size();
for (size_t i = 0u; i < n_viruses; ++i)
{

// Will create a copy of the virus, with the exeption of
// the virus code
viruses[i] = std::make_shared<Virus<TSeq>>(*p.viruses[i]);
viruses[i]->set_agent(this, i);
viruses.emplace_back(std::make_shared<Virus<TSeq>>(*p.viruses[i]));
viruses.back()->set_agent(this, i);

}

tools.resize(p.get_n_tools(), nullptr);
tools.reserve(p.get_n_tools());
n_tools = tools.size();
for (size_t i = 0u; i < n_tools; ++i)
{

// Will create a copy of the virus, with the exeption of
// the virus code
tools[i] = std::make_shared<Tool<TSeq>>(*p.tools[i]);
tools[i]->set_agent(this, i);
tools.emplace_back(std::make_shared<Tool<TSeq>>(*p.tools[i]));
tools.back()->set_agent(this, i);

}

Expand Down
6 changes: 2 additions & 4 deletions include/epiworld/models/sirdconnected.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
template<typename TSeq = EPI_DEFAULT_TSEQ>
class ModelSIRDCONN : public epiworld::Model<TSeq>
{
private:
public:
static const int SUSCEPTIBLE = 0;
static const int INFECTED = 1;
static const int RECOVERED = 2;
static const int RECOVERED = 2;
static const int DECEASED = 3;

public:

ModelSIRDCONN() {

// tracked_agents_infected.reserve(1e4);
Expand Down
5 changes: 4 additions & 1 deletion include/epiworld/models/sis.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ class ModelSIS : public epiworld::Model<TSeq>

public:

static const int SUSCEPTIBLE = 0;
static const int INFECTED = 1;

ModelSIS() {};

ModelSIS(
Expand Down Expand Up @@ -56,7 +59,7 @@ inline ModelSIS<TSeq>::ModelSIS(

// Preparing the virus -------------------------------------------
epiworld::Virus<TSeq> virus(vname);
virus.set_state(1,0,0);
virus.set_state(ModelSIS<TSeq>::INFECTED, ModelSIS<TSeq>::SUSCEPTIBLE, ModelSIS<TSeq>::SUSCEPTIBLE);

virus.set_prob_infecting(&model("Transmission rate"));
virus.set_prob_recovery(&model("Recovery rate"));
Expand Down
8 changes: 4 additions & 4 deletions tests/01c-sir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ EPIWORLD_TEST_CASE("SIR-omp", "[OMP-SIR]") {
);

model_0.seed(1231);
model_0.agents_smallworld(1000, 5, false, 0.01);
model_0.agents_smallworld(10000, 5, false, 0.01);
model_0.verbose_off();
model_0.run_multiple(100, 10, 1231, saver_0, true, true, 1);
model_0.run_multiple(100, 100, 1231, saver_0, true, true, 1);

epimodels::ModelSIR<> model_1(
"a virus", 0.01, .9, .3
);

model_1.seed(1231);
model_1.agents_smallworld(1000, 5, false, 0.01);
model_1.agents_smallworld(10000, 5, false, 0.01);
model_1.verbose_off();
model_1.run_multiple(100, 10, 1231, saver_1, true, true, 2);
model_1.run_multiple(100, 100, 1231, saver_1, true, true, 2);

std::vector< std::string > files = {
"reproductive.csv",
Expand Down

0 comments on commit bf344f7

Please sign in to comment.