wrap: Wrap a Simulation Environment

Description Usage Arguments Value See Also Examples

View source: R/wrap-methods.R

Description

This function extracts the monitored data from a simulation environment making it accessible through the same methods. Only useful if you want to parallelize heavy replicas (see the example below), because the C++ simulation backend is destroyed when the threads exit.

Usage

1
wrap(.env)

Arguments

.env

the simulation environment.

Value

Returns a simulation wrapper.

See Also

Methods for dealing with a simulation wrapper: get_mon_arrivals, get_mon_attributes, get_mon_resources, get_n_generated, get_capacity, get_queue_size, get_server_count, get_queue_count.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
library(parallel)

mm1 <- trajectory() %>%
  seize("server", 1) %>%
  timeout(function() rexp(1, 2)) %>%
  release("server", 1)

envs <- mclapply(1:4, function(i) {
  simmer("M/M/1 example") %>%
    add_resource("server", 1) %>%
    add_generator("customer", mm1, function() rexp(1, 1)) %>%
    run(100) %>%
    wrap()
})

## End(Not run)

r-simmer/simmer documentation built on Aug. 21, 2018, 2:47 a.m.