Re: [R] exiting mclapply early on error

2020-10-13 Thread Bert Gunter
This may be O/T. If so, either reply privately or not at all. "objective function diverges to infinity." How do you operationally define that? Detecting Inf -- e.g. 1/0, log(0), etc -- is straightforward. But how do you know other than via math whether iterations will continue to diverge or not?

Re: [R] exiting mclapply early on error

2020-10-13 Thread Giovanni Righi
Thanks for the response, Jeremie. I wholeheartedly agree about testing. In my case, this feature would be used purely to reduce computation time. I’m calculating an expensive (and embarrassingly parallel) likelihood function, and for some parameter combinations my objective function diverges to

Re: [R] exiting mclapply early on error

2020-10-09 Thread Jeremie Juste
Hello Giovanni, I don't know if my workflow would suit you but I tend to want the opposite when I launch a parallel process. I tend to want to keep the processes alive as long as they can. If the computation time is long I would not want to lose everything. lapply..8 <- function(X,FUN,...){ m

[R] exiting mclapply early on error

2020-10-09 Thread Giovanni Righi
Hey folks, Is there any way to exit an mclapply early on error? For example, in the following mclapply loop, I have to wait for all the processes to finish before the error is returned. ``` mclapply(X = 1:12, FUN = function(x) {Sys.sleep(0.1); if(x == 4) stop()}, mc.cores = 4, mc.preschedule