I’m very pleased to announce the first CRAN release of simmer. (https://cran.rstudio.com/web/packages/simmer/). This release has been realised thanks to the efforts made by Iñaki.

To reiterate a bit, simmer is a discrete-event simulation (DES) package for R. It is the first R package that focuses on creating a robust DES framework for R. It provides a framework somewhat similar as e.g SimPy and SimJulia but is arguably written from a bit more of an applied angle.

R might not be the most efficient language to implement a DES framework due to its method of memory allocation. Therefore, simmer implements a C++ backend by making use of Rcpp.

This release follows the philosophy and workflow of the pre-release version but adds a more robust event-based C++ backend and a more flexible frontend. These are the main improvements:

  • Enhanced programmability The timeout activity is more than just a delay. It admits a user-defined function, which can be as complex as needed in order to interact with the simulation model. The old v2.0 was no more than a queueing network simulator. This feature makes simmer a flexible and generic DES framework. Moreover, we have finally got rid of the infamous add_skip_event function to implement a more flexible and user-friendly branching method.
  • Robustness The event-based core design is rigorous and simple, which makes simmer faster and less error-prone, at the same level of other state-of-the-art DES frameworks.
    Much better performance. Instead of creating n arrivals beforehand, this release leverages the concept of generator of arrivals, which is faster and more flexible. At the same time, the concept of trajectory as a chain of activities is implemented entirely in C++ internally. Our tests show that simmer is even faster than SimPy when it comes to simulate queueing networks.
  • Replication In the pre-release, replication was implemented inside simmer. This no longer makes sense since, with the current design, it is more than straightforward to replicate and even parallelize the execution of replicas using standard R tools.

A nice getting started manual is provided in the vignette: https://cran.r-project.org/web/packages/simmer/vignettes/introduction.html.

For feedback, questions and bug reports please create an issue at the GitHub repository: https://github.com/Bart6114/simmer. Here you can also find the latest development version.

Let’s close with a simple example:


  coffees<-list(espresso=runif(1, min=5, max=10),
                macchiato=runif(1, min=6, max=12),
                americano=runif(1, min=3, max=8))
  sample(coffees, 1)[[1]]

  create_trajectory("I want coffee!") %>%
  seize("barista", 1) %>%
  timeout(coffee_prep_duration) %>%
  release("barista", 1)

    simmer("coffee shop") %>%
      add_resource("barista", 2) %>%
      add_generator("caffeine addict",
	      function() abs(rnorm(1, 5, 2))) %>%
plot_evolution_arrival_times(env, type = "flow_time")

flowtime plot

Have fun with it! (and let us know what we can improve further)