[This article was first published on R – Enchufa2, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
The 4.1.0 release of simmer, the Discrete-Event Simulator for R, is on CRAN. As per request in the mailing list, now get_global()
is able to work inside a generator function. Moreover, the new add_global()
method attaches a global attribute to a simulator.
library(simmer) env <- simmer() hello_sayer <- trajectory() %>% log_("hello world!") %>% set_global("interarrival", 1, mod="+") generator <- function() get_global(env, "interarrival") env %>% add_global("interarrival", 1) %>% add_generator("dummy", hello_sayer, generator) %>% run(7) %>% get_global("interarrival") ## 1: dummy0: hello world! ## 3: dummy1: hello world! ## 6: dummy2: hello world! ## [1] 4
Compared to plain global variables, these ones are automatically managed and thus reinitialised if the environment is reset.
env %>% reset() %>% get_global("interarrival") ## [1] 1 env %>% run(7) %>% get_global("interarrival") ## 1: dummy0: hello world! ## 3: dummy1: hello world! ## 6: dummy2: hello world! ## [1] 4
There has been a small refactoring of some parts of the C++ core, which motivates the minor version bump, but this shouldn’t be noticeable to the users. Finally, several bug fixes and improvements complete this release. See below for a complete list.
New features:
- New getter
get_selected()
retrieves names of selected resources via theselect()
activity (#172 addressing #171). - Source and resource getters have been vectorised to retrieve parameters from multiple entities (as part of #172).
- Simplify C++
Simulator
interface for adding processes and resources (#162). The responsibility of building the objects has been moved to the caller. - New
add_global()
method to attach global attributes to a simulation environment (#174 addressing #158).
Minor changes and fixes:
- Remove 3.8.0 and 4.0.1 deprecations (#170 addressing #165).
- Fix
get_global()
to work outside trajectories (#170 addressing #165). - Fix
rollback()
with an infinite amount (#173). - Fix and improve schedules and managers (as part of #174).
- Fix
reset()
to avoid overwriting the simulation environment (#175).
To leave a comment for the author, please follow the link and comment on their blog: R – Enchufa2.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.