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 a
timeout()activity. Now, with
log_()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_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 associated
set_queue_size_selected(), just like
release(), for a joint use with the resource selector
- New generator modifiers. Activities
deactivate()allow us to start/stop generators from within trajectories. Activities
set_distribution()allow us to change a generator’s assigned trajectory or distribution respectively.
- New interarrival communication activities, allowing asynchronous programming.
wait()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.