Hi,
I attempted some parallel simulation using mrgsolve in Windows. Kyle's example in one of his training materials (shown below) worked fine. I assume the below example simply replicated the simulation twice.
cl <- makeCluster(4)
registerDoParallel(cl)
clusterCall(cl, function() {
library(mrgsolve)
library(dplyr)
}
)
mod. <- mrgsolve:::house()
out. <- foreach(i=1:2) %dopar% {
mod. %>%
ev(amt=1000, ii=8, addl=3) %>%
mrgsim %>% mutate (irep=i)
} %>% bind_rows
stopCluster(cl)
I then tried another example where I compiled a model, and did the simulation using the same method as the above, but got the error message as below:
Error in { :
task 1 failed - "Model may not have been successfully compiled.
Source: C:/Users/YSU/mrgsolve_projects/doParallel/simplePK.cpp
Shared object (DLL): C:/Users/YSU/AppData/Local/Temp/RtmpYlKCuf/simplePK1cec4daa42bf.dll"The above message is from the below R code:
code <- '
$PARAM TVCL = 1, TVVC = 35, KA = 1.2, WT = 70, WTCL = 0.75
$CMT GUT CENT
$MAIN
double CL = TVCL*pow(WT/70, WTCL);
double V = TVVC*pow(WT/70, 1);
$ODE
dxdt_GUT = -KA*GUT;
dxdt_CENT = KA*GUT -(CL/V)*CENT;
$TABLE
table(CP) = CENT/V;
$CAPTURE CL
'
mod3 <- mread("simplePK", code=code)
cl <- makeCluster(4)
registerDoParallel(cl)
clusterCall(cl, function() {
library(mrgsolve)
library(dplyr)
}
)
out3 <- foreach(i=1:100) %dopar% {
mod3 %>%
ev(amt=1000, cmt=1, WT=70) %>%
mrgsim %>% mutate (irep=i)
} %>% bind_rows
I wonder if someone can help me to figure out why it failed.
Finally, a follow up question is if someone can show me the appropriate way to set up parallel simulation (i.e., set seeds etc.) when OMEGA and SIGMA are sampled in mrgsolve simulation under Windows OS. I saw some well documented examples in Kyle's training, but seems they were done under Linux OS.
Regards,
Yaming