[Deoptim-commits] r102 - in pkg/DEoptim: R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed May 16 14:29:51 CEST 2012


Author: braverock
Date: 2012-05-16 14:29:51 +0200 (Wed, 16 May 2012)
New Revision: 102

Modified:
   pkg/DEoptim/R/DEoptim.R
   pkg/DEoptim/man/DEoptim.control.Rd
Log:
- add support for parallelType='auto' to detect parallel engine, not the default, but maybe it should be

Modified: pkg/DEoptim/R/DEoptim.R
===================================================================
--- pkg/DEoptim/R/DEoptim.R	2012-05-15 20:22:49 UTC (rev 101)
+++ pkg/DEoptim/R/DEoptim.R	2012-05-16 12:29:51 UTC (rev 102)
@@ -4,7 +4,7 @@
                             storepopfreq = 1,  p = 0.2, c = 0, 
                             ...,
                             reltol, steptol, 
-                            parallelType = c('auto','none','parallel','foreach'),
+                            parallelType = c('none','auto','parallel','foreach'),
                             parallelArgs) 
 { #begin function
   
@@ -64,8 +64,20 @@
   if(missing(parallelType) | length(parallelType)>1){
       parallelType<-parallelType[1]
   }  
-  
-
+  # handle 'auto' auto-detect
+  if(parallelType='auto'){
+     pkgs<-.packages()
+     rv<-R.version()
+     if('foreach' %in% pkgs){
+         parallelType='foreach'
+     } else if (('parallel' %in% pkgs) ||
+                (rv$major>=2 && rv$minor>=14.2)
+                ){
+         parallelType='parallel'
+     } else {
+         parallelType='none'
+     }
+  }
   #support old deprecated parallelType arguments
   switch(parallelType,
           0 = {
@@ -76,10 +88,9 @@
           },
           2 = {
               parallelType='foreach' 
-              # handle deprecated foreachArgs
-   
           }
   )
+  #handle deptrecated parallel arguments, set sensible defaults, etc.
   switch(parallelType,
           foreach = {
               if(missing(parallelArgs) && hasArg(foreachArgs)){

Modified: pkg/DEoptim/man/DEoptim.control.Rd
===================================================================
--- pkg/DEoptim/man/DEoptim.control.Rd	2012-05-15 20:22:49 UTC (rev 101)
+++ pkg/DEoptim/man/DEoptim.control.Rd	2012-05-16 12:29:51 UTC (rev 102)
@@ -78,7 +78,8 @@
  \item{steptol}{see \code{reltol}. Defaults to \code{itermax}.}
  \item{parallelType}{Defines the type of parallelization to employ, if
    any.
-    \code{none}: The default, this uses \code{DEoptim} one only one core.
+    \code{none}: The default, this uses \code{DEoptim} on only one core.
+    \code{auto}: will attempt to auto-detect \code{foreach}, or \code{parallel}.
     \code{parallel}: This uses all available cores, via the \pkg{parallel}
     package, to run \code{DEoptim}.  
     \code{foreach}: This uses the \pkg{foreach} package for parallelism; see



More information about the Deoptim-commits mailing list