diff --git a/README.md b/README.md index c488d99f..27c9e45e 100644 --- a/README.md +++ b/README.md @@ -125,8 +125,8 @@ summary(sir) #> Number of entities : 0 #> Days (duration) : 50 (of 50) #> Number of viruses : 1 -#> Last run elapsed t : 190.00ms -#> Last run speed : 26.22 million agents x day / second +#> Last run elapsed t : 241.00ms +#> Last run speed : 20.67 million agents x day / second #> Rewiring : off #> #> Global actions: @@ -427,14 +427,14 @@ through agent-based modeling. Below is a manually curated table of existing alternatives including ABM \[@ABM\], abmR \[@abmR\], cystiSim \[@cystiSim\], villager \[@villager\], and RNetLogo \[@RNetLogo\]. -| Package | Multiple Viruses | Multiple Tools | Multiple Runs | Global Actions | Built-In Epi Models | Dependencies | Activity | -|:----------------------------------------------------------------------------|:-----------------|:---------------|:--------------|:---------------|---------------------|:---------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------| -| [**epiworldR**](https://cran.r-project.org/package=epiworldR) | yes | yes | yes | yes | yes | [![status](https://tinyverse.netlify.com/badge/epiworldR)](https://CRAN.R-project.org/package=epiworldR) | [![Activity](https://img.shields.io/github/last-commit/UofUEpiBio/epiworldR)](https://github.com/UofUEpiBio/epiworldR) | -| [**ABM**](https://cran.r-project.org/package=ABM) | \- | \- | \- | yes | yes | [![status](https://tinyverse.netlify.com/badge/ABM)](https://CRAN.R-project.org/package=ABM) | [![Activity](https://img.shields.io/github/last-commit/junlingm/ABM)](https://github.com/junlingm/ABM) | -| [**abmR**](https://cran.r-project.org/package=abmR) | \- | \- | yes | \- | \- | [![status](https://tinyverse.netlify.com/badge/abmR)](https://CRAN.R-project.org/package=abmR) | [![Activity](https://img.shields.io/github/last-commit/bgoch5/abmR)](https://github.com/bgoch5/abmR) | -| [**cystiSim**](https://cran.r-project.org/package=cystiSim) | \- | yes | yes | \- | \- | [![status](https://tinyverse.netlify.com/badge/cystiSim)](https://CRAN.R-project.org/package=cystiSim) | [![Activity](https://img.shields.io/github/last-commit/brechtdv/cystiSim)](https://github.com/brechtdv/cystiSim) | -| [**villager**](https://cran.r-project.org/package=villager) | \- | \- | \- | yes | \- | [![status](https://tinyverse.netlify.com/badge/villager)](https://CRAN.R-project.org/package=villager) | [![Activity](https://img.shields.io/github/last-commit/zizroc/villager)](https://github.com/zizroc/villager) | -| [**RNetLogo**](https://cran.r-project.org/package=RNetLogo) | \- | yes | yes | yes | \- | [![status](https://tinyverse.netlify.com/badge/RNetLogo)](https://CRAN.R-project.org/package=RNetLogo) | [![Activity](https://img.shields.io/github/last-commit/cran/RNetLogo)](https://github.com/cran/RNetLogo) | +| Package | Multiple Viruses | Multiple Tools | Multiple Runs | Global Actions | Built-In Epi Models | Dependencies | Activity | +|:--------------------------------------------------------------|:-----------------|:---------------|:--------------|:---------------|---------------------|:---------------------------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------------------------| +| [**epiworldR**](https://cran.r-project.org/package=epiworldR) | yes | yes | yes | yes | yes | [![status](https://tinyverse.netlify.com/badge/epiworldR)](https://CRAN.R-project.org/package=epiworldR) | [![Activity](https://img.shields.io/github/last-commit/UofUEpiBio/epiworldR)](https://github.com/UofUEpiBio/epiworldR) | +| [**ABM**](https://cran.r-project.org/package=ABM) | \- | \- | \- | yes | yes | [![status](https://tinyverse.netlify.com/badge/ABM)](https://CRAN.R-project.org/package=ABM) | [![Activity](https://img.shields.io/github/last-commit/junlingm/ABM)](https://github.com/junlingm/ABM) | +| [**abmR**](https://cran.r-project.org/package=abmR) | \- | \- | yes | \- | \- | [![status](https://tinyverse.netlify.com/badge/abmR)](https://CRAN.R-project.org/package=abmR) | [![Activity](https://img.shields.io/github/last-commit/bgoch5/abmR)](https://github.com/bgoch5/abmR) | +| [**cystiSim**](https://cran.r-project.org/package=cystiSim) | \- | yes | yes | \- | \- | [![status](https://tinyverse.netlify.com/badge/cystiSim)](https://CRAN.R-project.org/package=cystiSim) | [![Activity](https://img.shields.io/github/last-commit/brechtdv/cystiSim)](https://github.com/brechtdv/cystiSim) | +| [**villager**](https://cran.r-project.org/package=villager) | \- | \- | \- | yes | \- | [![status](https://tinyverse.netlify.com/badge/villager)](https://CRAN.R-project.org/package=villager) | [![Activity](https://img.shields.io/github/last-commit/zizroc/villager)](https://github.com/zizroc/villager) | +| [**RNetLogo**](https://cran.r-project.org/package=RNetLogo) | \- | yes | yes | yes | \- | [![status](https://tinyverse.netlify.com/badge/RNetLogo)](https://CRAN.R-project.org/package=RNetLogo) | [![Activity](https://img.shields.io/github/last-commit/cran/RNetLogo)](https://github.com/cran/RNetLogo) | # Other ABM R packages diff --git a/inst/include/epiworld/agent-meat.hpp b/inst/include/epiworld/agent-meat.hpp index 4b5b5191..47f69626 100644 --- a/inst/include/epiworld/agent-meat.hpp +++ b/inst/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/inst/include/epiworld/models/sirdconnected.hpp b/inst/include/epiworld/models/sirdconnected.hpp index d111d647..4caa1cbf 100644 --- a/inst/include/epiworld/models/sirdconnected.hpp +++ b/inst/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/inst/include/epiworld/models/sis.hpp b/inst/include/epiworld/models/sis.hpp index edbae17c..3736b9e8 100644 --- a/inst/include/epiworld/models/sis.hpp +++ b/inst/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"));