I think this may be an R 2.14 vs R 2.13 difference: like you I get
different results for each run the beta of Revolution R Enterprise 6.0,
which has the R 2.14.2 engine (see below). In earlier versions of R, you
can manage parallel random number streams with the rsprng library.

By the way, you can always ask questions about Revolution R in the forum,
which is moderated by the tech support team:

http://forums.revolutionanalytics.com/forums/forum.php

HTH,
# David Smith

library(foreach)
library(doSNOW)
registerDoSNOW(makeCluster(8, type = "SOCK"))
getDoParWorkers()
getDoParName()
getDoParVersion()

mySamples <- foreach (jj = 1:4, .combine=cbind) %dopar%
{return(sample(1:10,10,replace=TRUE))}
mySamples
#
> mySamples
      result.1 result.2 result.3 result.4
 [1,]        9        4        2        1
 [2,]        1        4        6        5
 [3,]        6        1       10        4
 [4,]        4        2        2        4
 [5,]        9        1        4        8
 [6,]        2        1        4        8
 [7,]        3        2        3        3
 [8,]        1        3        6        7
 [9,]        8        8        7        5
[10,]        6        4        6        9




On Mon, May 7, 2012 at 6:18 PM, pdb <ph...@philbrierley.com> wrote:

> I know this is not a revolution support forum, but as anyone noticed the
> following?
>
> I have a foreach loop to generate random samples. If I run the exact code
> below in normal r (2.14.1) it works as expected, but if I run it from
> revolution 4.2.0 each loop returns the same numbers.
>
> The only way I can get revolution to give different numbers is using 1
> instead of 8 in
> registerDoSNOW(makeCluster(8, type = "SOCK"))
>
> but that seems to defeat the point.
>
>
>
>
> library(foreach)
> library(doSNOW)
> registerDoSNOW(makeCluster(8, type = "SOCK"))
> getDoParWorkers()
> getDoParName()
> getDoParVersion()
>
>
> mySamples <- foreach (jj = 1:4, .combine=cbind) %dopar% {
>                return(sample(1:10,10,replace=TRUE))
>                }
>
> mySamples
>
> ##########
> r 2.14.1
> ##########
>
> > library(foreach)
> > library(doSNOW)
> > registerDoSNOW(makeCluster(8, type = "SOCK"))
> > getDoParWorkers()
> [1] 8
> > getDoParName()
> [1] "doSNOW"
> > getDoParVersion()
> [1] "1.0.6"
> >
> >
> > mySamples <- foreach (jj = 1:4, .combine=cbind) %dopar% {
> + return(sample(1:10,10,replace=TRUE))
> + }
> >
> > mySamples
>      result.1 result.2 result.3 result.4
>  [1,]        5        3        1        4
>  [2,]        1       10       10        3
>  [3,]        7        9        4        9
>  [4,]        2        5        9        3
>  [5,]        2        7       10        1
>  [6,]        7        8       10       10
>  [7,]        6        9       10        4
>  [8,]        8        6        6        2
>  [9,]       10        7        9        4
> [10,]        2        4        1        9
> >
>
>
> ####################
> # revolution r
> ####################
>
> > library(foreach)
> Loading required package: iterators
> Loading required package: codetools
> foreach: simple, scalable parallel programming from REvolution Computing
> Use REvolution R for scalability, fault tolerance and more.
> http://www.revolution-computing.com
> > library(doSNOW)
> Loading required package: snow
> > registerDoSNOW(makeCluster(8, type = "SOCK"))
> > getDoParWorkers()
> [1] 8
> > getDoParName()
> [1] "doSNOW"
> > getDoParVersion()
> [1] "1.0.3"
> >
> >
> > mySamples <- foreach (jj = 1:4, .combine=cbind) %dopar% {
> +               return(sample(1:10,10,replace=TRUE))
> +               }
> >
> > mySamples
>      result.1 result.2 result.3 result.4
>  [1,]        4        4        4        4
>  [2,]       10       10       10       10
>  [3,]        4        4        4        4
>  [4,]       10       10       10       10
>  [5,]        5        5        5        5
>  [6,]        5        5        5        5
>  [7,]        9        9        9        9
>  [8,]        2        2        2        2
>  [9,]        6        6        6        6
> [10,]        9        9        9        9
> >
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/revolution-foreach-oddity-tp4616237.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
David M Smith <da...@revolutionanalytics.com>
VP of Marketing, Revolution Analytics  http://blog.revolutionanalytics.com
Tel: +1 (650) 646-9523 (Palo Alto, CA, USA)

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to