futureLapply {xegaPopulation} | R Documentation |
future.apply
.The lapply()
function is redefined as as
future.apply::future_lapply()
.
Henrik Bengtsson recommends that the configuration of the
parallel/distributed programming environment should be kept
outside the package and left to the user.
The advantage is that the user may take advantage of all
parallel/distributed available backends for the Future API.
futureLapply(pop, EvalGene, lF)
pop |
Population of genes. |
EvalGene |
Function for evaluating a gene. |
lF |
Local function factory which provides
all functions needed in |
Be aware that
future_lapply()
assumes that each function evaluation
need approximately the same time.
Best results are obtained
if popsize
modulo workers
is 0
.
Fitness vector.
Bengtsson H (2021). “A Unifying Framework for Parallel and Distributed Processing in R using Futures.” The R Journal, 13(2), 208–227. <doi:10.32614/RJ-2021-048>
Other Execution Model:
MClapply()
,
PparLapply()
pop<-xegaInitPopulation(1000, lFxegaGaGene)
library(future)
plan(multisession, workers=2)
popnew<-futureLapply(pop, lFxegaGaGene$EvalGene, lFxegaGaGene)
plan(sequential)