Skip to contents

This method initialises a simulation environment.

Usage

simmer(name = "anonymous", verbose = FALSE, mon = monitor_mem(),
  log_level = 0)

Arguments

name

the name of the simulator.

verbose

enable showing activity information.

mon

monitor (in memory by default); see monitor for other options.

log_level

debugging level (see log_).

Value

Returns a simulation environment.

Examples

## a simple trajectory that prints a message
t0 <- trajectory("my trajectory") %>%
  log_("arrival generated")

## create an empty simulation environment
env <- simmer("SuperDuperSim")
env
#> simmer environment: SuperDuperSim | now: 0 | next: 
#> { Monitor: in memory }

## add a generator and attach it to the trajectory above
env %>% add_generator("dummy", t0, function() 1)
#> simmer environment: SuperDuperSim | now: 0 | next: 0
#> { Monitor: in memory }
#> { Source: dummy | monitored: 1 | n_generated: 0 }

## run for some time
env %>% run(until=4.5)
#> 1: dummy0: arrival generated
#> 2: dummy1: arrival generated
#> 3: dummy2: arrival generated
#> 4: dummy3: arrival generated
#> simmer environment: SuperDuperSim | now: 4.5 | next: 5
#> { Monitor: in memory }
#> { Source: dummy | monitored: 1 | n_generated: 5 }
env %>% now()           # current simulation time
#> [1] 4.5
env %>% peek()          # time for the next event
#> [1] 5
env %>% stepn()         # execute next event
#> 5: dummy4: arrival generated
#> simmer environment: SuperDuperSim | now: 5 | next: 5
#> { Monitor: in memory }
#> { Source: dummy | monitored: 1 | n_generated: 5 }