Skip to content

Commit

Permalink
Updating epiworld lib
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Sep 26, 2023
1 parent a0420f8 commit ad4363b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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

Expand Down
12 changes: 6 additions & 6 deletions inst/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 inst/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 inst/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

0 comments on commit ad4363b

Please sign in to comment.