[This article was first published on FishyOperations, 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.
We are proud to present simmer 3.5.0, a new release on CRAN of the Discrete-Event Simulator for R with a bunch of exciting features:
- Simpler logging. So far, if we wanted arrivals to print something into the console, we had, for instance, to make a custom function returning zero, with a
print()
inside, and to put it into atimeout()
activity. Now, withlog_()
it’s easier and, in addition, you get the simulation time and the arrival name:
library(simmer) sayer <- create_trajectory() %>% log_("hello world!") simmer() %>% add_generator("dummy", sayer, at(3, 6)) %>% run() %>% invisible ## 3: dummy0: hello world! ## 6: dummy1: hello world!
- New resource modifiers.
set_capacity()
andset_queue_size()
existed before, but they were not very useful. Now, these methods become activities and you can use them in your trajectories. They have their associatedset_capacity_selected()
andset_queue_size_selected()
, just likeseize()
andrelease()
, for a joint use with the resource selectorselect()
. - New generator modifiers. Activities
activate()
,deactivate()
allow us to start/stop generators from within trajectories. Activitiesset_trajectory()
,set_distribution()
allow us to change a generator’s assigned trajectory or distribution respectively. - New interarrival communication activities, allowing asynchronous programming.
send()
,trap()
,untrap()
andwait()
can be used to send signals, wait for signals, trap them and launch asynchronous handlers. Nothing better than an example to understand the possibilities of this mechanism:
library(simmer) t_blocked <- create_trajectory() %>% trap("you shall pass", handler = create_trajectory() %>% log_("ok, I'm packing...") %>% timeout(1)) %>% log_("waiting...") %>% wait() %>% log_("and I'm leaving!") t_signaler <- create_trajectory() %>% log_("you shall pass") %>% send("you shall pass") simmer() %>% add_generator("blocked", t_blocked, at(0)) %>% add_generator("signaler", t_signaler, at(5)) %>% run() %>% invisible ## 0: blocked0: waiting... ## 5: signaler0: you shall pass ## 5: blocked0: ok, I'm packing... ## 6: blocked0: and I'm leaving!
Other interesting new features from past releases since our last post include post-seize and reject optional trajectories when seizing resources, arrival cloning and synchronizing, arrival batching and separating or reneging.
Please, refer to the updated Advanced Trajectory Usage vignette for more information and examples. Also remember that you can participate in our simmer-devel mailing list to get help, discuss methodologies… any feedback is always welcome.
To leave a comment for the author, please follow the link and comment on their blog: FishyOperations.
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.