Learn R Programming

simsalapar (version 1.0-2)

doApply: Functions for Iterating Over All Subjobs

Description

doLapply() iterates over all subjobs (using the non-parallel lapply()). Similarly, but in parallel, for doForeach (based on CRAN package foreach's foreach()), doRmpi (based on Rmpi's mpi.apply()), doMclapply (based on parallel's mclapply()), and doClusterApply (based on parallel's clusterApply()).

doRes.equal() is simple convenience wrapper for all.equal(), for comparing two results (from the same varlist and doOne arguments) of the do* lapply-like functions above.

Usage

doLapply(vList, seed="seq", repFirst=TRUE,
       sfile=NULL, check=TRUE, doAL=TRUE, subjob.=subjob, monitor=FALSE,
       doOne, ...)
doForeach(vList, doCluster = !(missing(spec) && missing(type)),
       spec=detectCores(),
       type = if(.Platform$OS.type == "windows") "PSOCK" else "MPI",
       block.size = 1, seed="seq", repFirst=TRUE, sfile=NULL,
       check=TRUE, doAL=TRUE, subjob.=subjob, monitor=FALSE,
       doOne, extraPkgs=character(), exports=character(), ...)
doRmpi(vList,
       nslaves = if((sz <- mpi.universe.size()) <= 1="" 1)="" detectcores()="" else="" sz,="" load.balancing="TRUE," block.size="1," seed="seq" ,="" repfirst="TRUE," sfile="NULL," check="TRUE," doal="TRUE," subjob.="subjob," monitor="FALSE," doone,="" exports="character()," ...)="" domclapply(vlist,="" cores="if(.Platform$OS.type" =="windows" )="" detectcores(),="" doclusterapply(vlist,="" spec="detectCores()," type="if(.Platform$OS.type" "psock"="" "mpi",="" initexpr,="" ...)<="" p="">

doRes.equal(x, y, tol = 1e-15, ...)

Arguments

vList
a list of variable specifications. Each variable spec is itself a named list which must contain a "value" component.
doCluster
logical indicating if makeCluster(spec, type) should be called and registered. If false as by default, spec is used to specify the number of cores to be used.
spec
a specification appropriate to the type of cluster (see type); if doCluster is false, and for the type = "MPI", the number of nodes.
type
the cluster type, see makeCluster() from package parallel. For reasons why we choose "MPI" as default if not on Windows, see the discussion starting at https://
cores
the number of cores.
nslaves
the number of slaves for doRmpi, passed to package Rmpi's mpi.spawn.Rslaves when no running slaves are found.
load.balancing
logical indicating whether load balancing is used: [object Object],[object Object],[object Object]
block.size
size of blocks of rows in the virtual grid which are computed simultaneously (load-balancing).
seed, repFirst
see subjob().
sfile, check, doAL
see saveSim().
subjob.
a function for computing a subjob (one row of the virtual grid). Typically subjob().
doOne
a user-supplied function for computing one row of the (physical) grid.
monitor
a logical or a function for producing monitoring output; the function argument list must contain the one of printInfo[["default"]]
extraPkgs
character vector of packages to be made available on the nodes.
exports
character vector of functions (for doForeach() and doClusterApply()) or objects (for
initExpr
expression initially evaluated on the cluster (can be missing).
...
additional arguments passed to subjob() (typically further passed on to doOne()), or, for doRes.equal(), to all.equal(*).
x,y
each a result of, say doLapply() which should be compared where sensible, i.e., the first three components "value","error","warning", using all.equal

Value

  • The result of applying subjob() to all subjobs, converted with saveSim().

newcommand

\CRANpkg

href

http://CRAN.R-project.org/package=#1

pkg

#1

Details

See the vignette or references in simsalapar-package for how to use these functions.

See Also

subjob() for computing a subjob. doCallWE() for the return value of doOne(). .Random.seed for information about random number generators and seeds.

Examples

Run this code
if(simsalapar:::doExtras()) { ## needs some CPU
   demo(robust.mean) # 512 simulations, differing block sizes, ...
 }

Run the code above in your browser using DataLab