snow: bnlearn - snow/parallel package integration

Description Parallel computing for constraint-based algorithms Author(s)

Description

How to use the bnlearn package with the parallel computing environment provided by the snow or parallel packages.

Parallel computing for constraint-based algorithms

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# load snow, bnlearn and rsprng (for parallel random number
# generation, just in case it's needed); start LAM/MPI via
# lamboot if using an MPI cluster.
> library(snow) # or library(parallel)
> library(bnlearn)
> library(rsprng)
# initialize the cluster ("socket" and "PVM" clusters are fine, too).
> cl <- makeCluster(2, type = "MPI")
Loading required package: Rmpi
        2 slaves are spawned successfully. 0 failed.
> clusterSetupSPRNG(cl)
# load the data.
> data(learning.test)
# call a learning function passing the cluster object (the
# return value of the previous makeCluster() call) as a
# parameter.
> res = gs(learning.test, cluster = cl)
# note that the number of test is evenly divided between
# the two nodes of the cluster.
> clusterEvalQ(cl, bnlearn:::.test.counter())
[[1]]
[1] 47

[[2]]
[1] 42
# a few tests are still executed by this process.
> bnlearn:::.test.counter()
[1] 4
# stop the cluster.
> stopCluster(cl)
[1] 1

Author(s)

Marco Scutari


vspinu/bnlearn documentation built on May 3, 2019, 7:08 p.m.