blog
blog copied to clipboard
could not find function "init_status.icm"
In the project modelling-the-effects-of-public-health-interventions-on-covid-19-transmission-part-2
When I run the command
baseline_sim <- simulate(ncores=4)
I get the error
Error in { : task 1 failed - "could not find function "init_status.icm""
I'm using Windows. Please, what could I do to fix?
Changing ncores to 1 prevents the error to happen.
I believe that the issue here is the way the code handles the parallelization process in "_icm.icm.seiqhrf". While I'm no expert, I think this comes from the fact that Tim has a Mac computer which allows to use some packages that we cannot use in Windows. The solution I found was to use the "doFuture" package en change the doParallel part with
library("doFuture") registerDoFuture() plan(multiprocess)
Elaborating on my previous post, since doFuture is quite slow you can actually use the following expansion to the doParallel call
sout <- foreach(s = 1:nsims, .export = c('infection.seiqhrf.icm','arrivals.seiqhrf.icm',
'control.icm','cum_discr_si','departures.seiqhrf.icm',
'get_prev.seiqhrf.icm','init_status.icm','initialize.icm',
'saveout.seiqhrf.icm','infection.seiqhrf.icm','progress.seiqhrf.icm'),
.packages = 'EpiModel') %dopar% {
same problem. Windows users Just change or add ncores=1 when running simulate function, it might take time but it works!