
Parallel simulation of a Whittle-Matérn field on a metric graph
Source:R/graph_simulate.R
simulate_parallel.RdCalls simulate.metric_graph() with parallel = TRUE. The edge loop is
distributed over a doParallel/foreach cluster.
Arguments
- graph
A
metric_graphobject.- ...
Further arguments passed to
simulate.metric_graph(), includingalpha,method,kappa/tauorrange/sigma,PtE,type,BC,nsim, andseed.- n_cores
Number of parallel workers.
- cluster
An already-registered
doParallelcluster.
Examples
# \donttest{
V <- rbind(c(0,0), c(1,0), c(1,1), c(0,1))
E <- rbind(c(1,2), c(2,3), c(3,4), c(4,1))
g <- metric_graph$new(V = V, E = E)
#> Starting graph creation...
#> LongLat is set to FALSE
#> Creating edges...
#> Setting edge weights...
#> Computing bounding box...
#> Setting up edges
#> Merging close vertices
#> Total construction time: 0.72 secs
#> Creating and updating vertices...
#> Storing the initial graph...
#> Computing the relative positions of the edges...
t_norm <- seq(0.1, 0.9, by = 0.2)
PtE <- do.call(rbind, lapply(1:4, function(e) cbind(e, t_norm)))
u <- simulate_parallel(g, alpha = 1, method = "kriging",
kappa = 1, tau = 1, PtE = PtE, n_cores = 2)
# }