diff --git a/.vscode/settings.json b/.vscode/settings.json index 4a4643898..6ac87e9e5 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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" } \ No newline at end of file diff --git a/Makefile b/Makefile index 7e6e1e614..aea814b95 100644 --- a/Makefile +++ b/Makefile @@ -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}" \ No newline at end of file diff --git a/epiworld.hpp b/epiworld.hpp index 47dc1e24f..c263f4098 100644 --- a/epiworld.hpp +++ b/epiworld.hpp @@ -15269,6 +15269,9 @@ class ModelSIS : public epiworld::Model public: + static const int SUSCEPTIBLE = 0; + static const int INFECTED = 1; + ModelSIS() {}; ModelSIS( @@ -15310,7 +15313,7 @@ inline ModelSIS::ModelSIS( // Preparing the virus ------------------------------------------- epiworld::Virus virus(vname); - virus.set_state(1,0,0); + virus.set_state(ModelSIS::INFECTED, ModelSIS::SUSCEPTIBLE, ModelSIS::SUSCEPTIBLE); virus.set_prob_infecting(&model("Transmission rate")); virus.set_prob_recovery(&model("Recovery rate")); @@ -17193,14 +17196,12 @@ inline ModelSEIRD::ModelSEIRD( template class ModelSIRDCONN : public epiworld::Model { -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); diff --git a/include/epiworld/agent-meat.hpp b/include/epiworld/agent-meat.hpp index 4b5b5191c..47f696264 100644 --- a/include/epiworld/agent-meat.hpp +++ b/include/epiworld/agent-meat.hpp @@ -90,27 +90,27 @@ inline Agent::Agent(const Agent & 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>(*p.viruses[i]); - viruses[i]->set_agent(this, i); + viruses.emplace_back(std::make_shared>(*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>(*p.tools[i]); - tools[i]->set_agent(this, i); + tools.emplace_back(std::make_shared>(*p.tools[i])); + tools.back()->set_agent(this, i); } diff --git a/include/epiworld/models/sirdconnected.hpp b/include/epiworld/models/sirdconnected.hpp index d111d6470..4caa1cbfa 100644 --- a/include/epiworld/models/sirdconnected.hpp +++ b/include/epiworld/models/sirdconnected.hpp @@ -4,14 +4,12 @@ template class ModelSIRDCONN : public epiworld::Model { -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); diff --git a/include/epiworld/models/sis.hpp b/include/epiworld/models/sis.hpp index edbae17c2..3736b9e89 100644 --- a/include/epiworld/models/sis.hpp +++ b/include/epiworld/models/sis.hpp @@ -15,6 +15,9 @@ class ModelSIS : public epiworld::Model public: + static const int SUSCEPTIBLE = 0; + static const int INFECTED = 1; + ModelSIS() {}; ModelSIS( @@ -56,7 +59,7 @@ inline ModelSIS::ModelSIS( // Preparing the virus ------------------------------------------- epiworld::Virus virus(vname); - virus.set_state(1,0,0); + virus.set_state(ModelSIS::INFECTED, ModelSIS::SUSCEPTIBLE, ModelSIS::SUSCEPTIBLE); virus.set_prob_infecting(&model("Transmission rate")); virus.set_prob_recovery(&model("Recovery rate")); diff --git a/tests/01c-sir.cpp b/tests/01c-sir.cpp index 500103fb8..f7dc7864c 100644 --- a/tests/01c-sir.cpp +++ b/tests/01c-sir.cpp @@ -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",