From a76ac7f37110e2cf777b64cca882ea7b956a3217 Mon Sep 17 00:00:00 2001 From: "George G. Vega Yon" Date: Fri, 20 Oct 2023 14:11:07 -0600 Subject: [PATCH] Working on makefile. Soon to merge on main branch --- Makefile | 18 +++++++++--------- README.Rmd | 12 +++++++----- README.md | 27 +++++++++------------------ playground/benchmark-seir.R | 16 ++++++++-------- 4 files changed, 33 insertions(+), 40 deletions(-) diff --git a/Makefile b/Makefile index d73f4ded..beeac088 100644 --- a/Makefile +++ b/Makefile @@ -12,14 +12,15 @@ docker-debug: --no-docs --build . install-dev: clean - sed -i -E 's/^useDynLib\([a-zA-Z]+/useDynLib(epiworldRdev/g' NAMESPACE + sed -i -E 's/@useDynLib\s+[a-zA-Z]+/@useDynLib epiworldRdev/g' R/epiworldR-package.R + sed -i -E 's/useDynLib\(+[a-zA-Z]+/useDynLib(epiworldRdev/g' NAMESPACE sed -i -E 's/^Package:.+/Package: epiworldRdev/g' DESCRIPTION - sed -i -E 's/^\\(name|alias|title)\{[a-zA-Z]+/\\\1{epiworldRdev/g' man/epiworldR-package.Rd sed -i -E 's/^library\([a-zA-Z]+\)/library(epiworldRdev)/g' README.* - EPI_DEV=yes R CMD INSTALL . - $(MAKE) clean + Rscript --vanilla -e 'roxygen2::roxygenize()' + EPI_DEV=yes R CMD INSTALL .& $(MAKE) clean -install: clean +install: + $(MAKE) clean R CMD INSTALL . @@ -37,11 +38,10 @@ check: build clean: Rscript --vanilla -e 'devtools::clean_dll()' - sed -i -E 's/^useDynLib\([a-zA-Z]+/useDynLib(epiworldR/g' NAMESPACE + sed -i -E 's/@useDynLib\s+[a-zA-Z]+/@useDynLib epiworldR/g' R/epiworldR-package.R + sed -i -E 's/useDynLib\(+[a-zA-Z]+/useDynLib(epiworldR/g' NAMESPACE sed -i -E 's/^Package:.+/Package: epiworldR/g' DESCRIPTION - sed -i -E 's/^\\(name|alias|title)\{[a-zA-Z]+/\\\1{epiworldR/g' man/epiworldR-package.Rd - sed -i -E 's/^\\(name|alias|title)\{[a-zA-Z]+/\\\1{epiworldR/g' R/epiworldR-package.Rd - + # sed -i -E 's/^\\(name|alias|title)\{[a-zA-Z]+/\\\1{epiworldR/g' man/epiworldR-package.Rd sed -i -E 's/^library\([a-zA-Z]+\)/library(epiworldR)/g' README.* docs: diff --git a/README.Rmd b/README.Rmd index 43f0464c..fffefcb1 100644 --- a/README.Rmd +++ b/README.Rmd @@ -71,10 +71,10 @@ library(epiworldR) # Creating a SIR model sir <- ModelSIR( - name = "COVID-19", - prevalence = .01, + name = "COVID-19", + prevalence = .01, transmission_rate = .7, - recovery = .3 + recovery = .3 ) |> # Adding a Small world population agents_smallworld(n = 100000, k = 10, d = FALSE, p = .01) |> @@ -205,8 +205,10 @@ net <- get_transmissions(sir) # Plotting library(epiworldR) -library(epiworldR) -x <- graph_from_edgelist(as.matrix(net[,2:3]) + 1) +library(netplot) +x <- igraph::graph_from_edgelist( + as.matrix(net[,2:3]) + 1 + ) nplot(x, edge.curvature = 0, edge.color = "gray", skip.vertex=TRUE) ``` diff --git a/README.md b/README.md index 143f5831..05625989 100644 --- a/README.md +++ b/README.md @@ -91,10 +91,10 @@ library(epiworldR) # Creating a SIR model sir <- ModelSIR( - name = "COVID-19", - prevalence = .01, + name = "COVID-19", + prevalence = .01, transmission_rate = .7, - recovery = .3 + recovery = .3 ) |> # Adding a Small world population agents_smallworld(n = 100000, k = 10, d = FALSE, p = .01) |> @@ -127,8 +127,8 @@ summary(sir) #> Number of entities : 0 #> Days (duration) : 50 (of 50) #> Number of viruses : 1 -#> Last run elapsed t : 170.00ms -#> Last run speed : 29.29 million agents x day / second +#> Last run elapsed t : 166.00ms +#> Last run speed : 30.01 million agents x day / second #> Rewiring : off #> #> Global actions: @@ -346,20 +346,11 @@ net <- get_transmissions(sir) # Plotting library(epiworldR) +library(netplot) #> Loading required package: grid -library(epiworldR) -#> -#> Attaching package: 'igraph' -#> The following object is masked from 'package:netplot': -#> -#> ego -#> The following objects are masked from 'package:stats': -#> -#> decompose, spectrum -#> The following object is masked from 'package:base': -#> -#> union -x <- graph_from_edgelist(as.matrix(net[,2:3]) + 1) +x <- igraph::graph_from_edgelist( + as.matrix(net[,2:3]) + 1 + ) nplot(x, edge.curvature = 0, edge.color = "gray", skip.vertex=TRUE) ``` diff --git a/playground/benchmark-seir.R b/playground/benchmark-seir.R index 807de96d..0c860d18 100644 --- a/playground/benchmark-seir.R +++ b/playground/benchmark-seir.R @@ -1,5 +1,5 @@ -library(epiworldR) -library(epiworldRfaster) +# library(epiworldRdev) +# library(epiworldR) library(microbenchmark) @@ -22,23 +22,23 @@ for (n in ns) { epiworldR::verbose_off() - sirfast <- epiworldRfaster::ModelSEIR( + sirfast <- epiworldRdev::ModelSEIR( name = "COVID-19", prevalence = 0.01, incubation_days = 7, transmission_rate = 0.6, recovery_rate = 0.5 ) |> - epiworldRfaster::agents_smallworld(n = n, k = 20, p = 0, d = FALSE) |> - epiworldRfaster::add_virus( - epiworldRfaster::virus("COVID-19-beta", 0.01, 0.6, 0.5, 7), .2 + epiworldRdev::agents_smallworld(n = n, k = 20, p = 0, d = FALSE) |> + epiworldRdev::add_virus( + epiworldRdev::virus("COVID-19-beta", 0.01, 0.6, 0.5, 7), .2 ) |> - epiworldRfaster::verbose_off() + epiworldRdev::verbose_off() ans[[as.character(n)]] <- microbenchmark( old = epiworldR::run(sir, ndays = 100, seed = 1912), - new = epiworldRfaster::run(sirfast, ndays = 100, seed = 1912), + new = epiworldRdev::run(sirfast, ndays = 100, seed = 1912), times = 10 )