RcppAlgos icon indicating copy to clipboard operation
RcppAlgos copied to clipboard

Combinatorial Iterators not working parallel

Open elephann opened this issue 4 years ago • 2 comments

I was working a full search of Combinatorial caculation, the population about 4000, and I want to find 2 or 3 Combinatorial that satisfy certain condition. I thought RcppAlgos might help, but when I parallel , it not working! example: select_n_shr=2 shrs=1:4000 itc <- comboIter(shrs, select_n_shr)

AllPairs <- foreach(i = itc, .packages = c("data.table","urca","vars"), .combine = 'rbind') %dopar% {
print(i)}
the output:

AllPairs [1] 1 2

elephann avatar Mar 13 '22 17:03 elephann

Hello @elephann,

In order for a general iterator to be compatible with the foreach package, the iterator must be set up with special classes.

Currently the iterators in RcppAlgos are not compatible with foreach and the like. There is ongoing research to address this topic in later releases.

See for example: https://cran.r-project.org/web/packages/iterators/vignettes/writing.pdf

Thanks, Joseph

jwood000 avatar Mar 15 '22 03:03 jwood000

Oh! Anyway, thanks, great work!~~

elephann avatar Mar 18 '22 15:03 elephann