GA icon indicating copy to clipboard operation
GA copied to clipboard

Is the default parallel execution prescheduled?

Open mosscoder opened this issue 4 years ago • 3 comments

Greetings, I appreciate the work you have contributed to this package. The execution time of my fitness function varies greatly depending on the input values, and for parallel execution I think it would make the most sense to not preschedule the work done by my cluster. Is ga() prescheduled by default? If so, how would I go about forking work in a unscheduled way?

My understanding is that the preschedule=FALSE argument is supplied to foreach, but I'm not sure how to pass this to ga().

mosscoder avatar Apr 15 '20 17:04 mosscoder

I'm guessing this would need to be added here: https://github.com/luca-scr/GA/blob/c87a2a1d7f85affc470aae0380085a6e9eff2644/R/ga.R#L235-L242

The foreach call could be change as follows: foreach(i. = seq_len(popSize), .combine = "c", .options.multicore = list(preschedule = FALSE)

mosscoder avatar Apr 15 '20 18:04 mosscoder

What about if a user want to set preschedule = TRUE (which I think is the default, see help("mclapply", package = "parallel") ? And what happens if a different backend is used? And if a cluster is set up by a user and then passed to the parallel argument of ga() function call? Your proposal should work but I'm worrying about backwards compatibility.

luca-scr avatar Apr 15 '20 20:04 luca-scr

Well here is one possible implementation here, simply adding a preschedule argument to ga(), defaulted to TRUE:

https://github.com/mosscoder/GA/blob/4d2853f2ecb0de78fed035d77b5c61f49d28e033/R/ga.R#L7-L35

https://github.com/mosscoder/GA/blob/4d2853f2ecb0de78fed035d77b5c61f49d28e033/R/ga.R#L237-L243

mosscoder avatar Apr 16 '20 00:04 mosscoder