This method initialises a simulation environment.
Usage
simmer(name = "anonymous", verbose = FALSE, mon = monitor_mem(),
log_level = 0)
See also
Available methods by category:
Resources:
add_resource
,get_resources
,get_capacity
,get_capacity_selected
,get_queue_size
,get_queue_size_selected
,get_server_count
,get_server_count_selected
,get_queue_count
,get_queue_count_selected
,get_seized
,get_seized_selected
,get_activity_time
,get_activity_time_selected
,get_selected
Sources:
add_generator
,add_dataframe
,get_sources
,get_n_generated
,get_trajectory
Arrivals:
get_name
,get_start_time
,get_attribute
,get_prioritization
,get_batch_size
Globals:
add_global
,get_global
Data retrieval:
get_mon_arrivals
,get_mon_attributes
,get_mon_resources
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 }