Skip to content

Commit

Permalink
Working on makefile. Soon to merge on main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
gvegayon committed Oct 20, 2023
1 parent ea8b883 commit a76ac7f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 40 deletions.
18 changes: 9 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .


Expand All @@ -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:
Expand Down
12 changes: 7 additions & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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) |>
Expand Down Expand Up @@ -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)
```
Expand Down
27 changes: 9 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |>
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
```
Expand Down
16 changes: 8 additions & 8 deletions playground/benchmark-seir.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
library(epiworldR)
library(epiworldRfaster)
# library(epiworldRdev)
# library(epiworldR)

library(microbenchmark)

Expand All @@ -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
)

Expand Down

0 comments on commit a76ac7f

Please sign in to comment.