Created
August 11, 2016 16:40
-
-
Save dpastoor/e83a48c7646a72f5b4644560ef366f1e to your computer and use it in GitHub Desktop.
working parallel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(future) | |
| library(mrgsolve) | |
| library(dplyr) | |
| data(extran3) | |
| ipar <- extran3 %>% dplyr::select(ID,CL,VC,KA) %>% distinct(ID) | |
| mod <- mrgsolve:::house() | |
| plan(multiprocess) | |
| f <- list() | |
| for (ii in 1:2) { | |
| f[[ii]] <- future({ | |
| data <- extran3 | |
| mod %>% Req(CP) %>% | |
| data_set(data) %>% | |
| mrgsim %>% as.data.frame %>% | |
| mutate(rep = ii) | |
| }) | |
| } | |
| v <- lapply(f, FUN = value) | |
| bind_rows(v) |
> library(future)
> library(mrgsolve)
> library(dplyr)
> data(extran3)
> ipar <- extran3 %>% dplyr::select(ID,CL,VC,KA) %>% distinct(ID)
> mod <- mrgsolve:::house()
>
> plan(multiprocess)
> f <- list()
>
> system.time({
+ for (ii in 1:2) {
+ f[[ii]] <- future({
+ data <- expand.ev(amt=100,ID=1:200)
+ mod %>%
+ Req(CP) %>%
+ data_set(data) %>%
+ mrgsim %>%
+ mutate(rep = ii)
+ })
+ }
+ })
user system elapsed
0.016 0.007 0.023
> v <- lapply(f, FUN = value)
> bind_rows(v)
# A tibble: 192,800 x 4
ID time CP rep
<dbl> <dbl> <dbl> <int>
1 1 0.00 0.000000 1
2 1 0.00 0.000000 1
3 1 0.25 1.287441 1
4 1 0.50 2.225208 1
5 1 0.75 2.904129 1
6 1 1.00 3.391488 1
7 1 1.25 3.737128 1
8 1 1.50 3.977972 1
9 1 1.75 4.141369 1
10 1 2.00 4.247580 1
# ... with 192,790 more rowsSession info ----------------------------------------------------------------------------------------------------------------------------
setting value
version R version 3.3.0 (2016-05-03)
system x86_64, darwin13.4.0
ui RStudio (0.99.902)
language (EN)
collate en_US.UTF-8
tz America/Chicago
date 2016-08-11
Packages --------------------------------------------------------------------------------------------------------------------------------
package * version date source
assertthat 0.1 2013-11-08 local
codetools 0.2-14 2015-07-15 CRAN (R 3.2.3)
DBI 0.4-1 2016-05-08 CRAN (R 3.3.0)
devtools 1.12.0 2016-06-24 CRAN (R 3.3.0)
digest 0.6.9 2016-01-08 CRAN (R 3.2.1)
dplyr * 0.5.0 2016-06-24 CRAN (R 3.3.0)
future * 1.0.1 2016-07-04 CRAN (R 3.3.0)
globals 0.6.1 2016-02-03 CRAN (R 3.3.0)
lazyeval 0.2.0 2016-06-12 CRAN (R 3.3.0)
listenv 0.6.0 2015-12-28 CRAN (R 3.3.0)
magrittr 1.5 2014-11-22 CRAN (R 3.1.2)
memoise 1.0.0 2016-01-29 CRAN (R 3.2.1)
mrgsolve * 0.7.5.9000 2016-08-06 local
R6 2.1.2 2016-01-26 CRAN (R 3.2.3)
Rcpp 0.12.6 2016-07-19 CRAN (R 3.3.0)
RcppArmadillo 0.7.200.2.0 2016-07-24 CRAN (R 3.3.0)
rsconnect 0.4.3 2016-05-02 CRAN (R 3.3.0)
tibble 1.1 2016-07-04 CRAN (R 3.3.0)
withr 1.0.2 2016-06-20 CRAN (R 3.3.0)
Author
> devtools::session_info()
Session info ------------------------------------------------------------
setting value
version R version 3.3.0 (2016-05-03)
system x86_64, darwin15.4.0
ui RStudio (0.99.1198)
language (EN)
collate en_US.UTF-8
tz America/Detroit
date 2016-08-11
Packages ----------------------------------------------------------------
package * version date
assertthat 0.1 2013-12-06
codetools 0.2-14 2015-07-15
DBI 0.4-1 2016-05-08
devtools 1.11.1 2016-04-21
digest 0.6.10 2016-08-02
dplyr * 0.5.0 2016-06-24
future * 1.0.1 2016-08-11
globals 0.6.1 2016-02-03
lazyeval 0.2.0 2016-06-12
listenv 0.6.0 2015-12-28
magrittr 1.5 2014-11-22
memoise 1.0.0 2016-01-29
mrgsolve * 0.7.5.9000 2016-08-09
R6 2.1.2 2016-01-26
Rcpp 0.12.6 2016-07-19
RcppArmadillo 0.7.200.2.0 2016-07-24
rsconnect 0.4.3 2016-05-02
tibble 1.1 2016-07-04
withr 1.0.1 2016-02-04
source
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
Github (HenrikBengtsson/future@771d11b)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
Github (metrumresearchgroup/mrgsolve@777ba41)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
CRAN (R 3.3.0)
.libPaths("lib")
library(future)
library(future.BatchJobs)
library(mrgsolve)
library(dplyr)
mod <- mrgsolve:::house()
data <- expand.ev(amt=100,ID=1:20)
plan(batchjobs_sge, pathname="simple.tmpl")
f <- lapply(1:10, function(i) {
future({
mod %>%
Req(CP) %>%
data_set(data) %>%
mrgsim %>%
mutate(rep = i)
})
})
data <- lapply(f,value) %>% bind_rows
simple.tmpl
#!/bin/bash
#$ -N <%= job.name %>
#$ -j y
#$ -o <%= log.file %>
#$ -cwd
#$ -V
# we merge R output with stdout from SGE, which gets then logged via -o option
R CMD BATCH --no-save --no-restore "<%= rscript %>" /dev/stdout
exit 0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This crumps for you?