This post has been transferred from another blog platform and could have dead links / incorrect lay-out.
Please note: the syntax described here is no longer up-to-date, please refer to the readme at simmer’s GitHub page.
The simmer package grew out of a personal need for a simple rapid development discrete event simulation (DES) framework. I work in the hospital sector and at times use a DES approach to simulate hospital processes / patient trajectories. DES can give you a quick look at process bottlenecks and test out the impact of alternative process set-ups.
Tools such as SimPy and SimJulia.jl served as inspiration for this package. What I wanted to achieve most was to develop a simple rapid development DES environment which had all (or most) important analysis/plotting functions easily at hand. Aiming for this rapid development DES package and working from a specific business process background has most likely tainted the development of the package to an extent that it won’t be as dynamic to be applicable to everyone’s specific needs.
Speed & performance
While R is arguably not known as a fast language the current performance bottleneck of the simmer package is in simmer‘s own design. Future development will focus more on the performance of the package, where there is definitely room for improvement. If the package will gain popularity, I might be persuaded to move some of the fundamental parts of the simulation engine to C++ to achieve further performance gains.
Let’s say we want to simulate a very simple patient trajectory; a patient enters the hospital and has to register at the desk, next, is seen by a nurse for an intake and finally is met by the doctor for a consult.
Below this trajectory is written as a ‘trajectory dataframe’.
This gives the following data frame:
As you can see, the durations given here are in the form of an R command. Any function call or value which generates a (single) number can be used for the duration and sucessor values. These values are re-evaluated for every entity that get assigned to this trajectory.
Next we build up a simple simulation with 10 patients, each starting about 10 minutes apart, to be precise
rnorm(1,10) apart. We decide let this run for 15 replications to get a view on the variability.
All resources required have to be added using the
add_resource command. Note that we add 2 doctors to the simulation here. Once the simulation object
sim has been built up, we can start up the simulation and let it
simmer for a while.
Once the simmering stops we can plot some of the results. We can for example have a look at the resource utilization of the doctor resource.
Or have a look at the utilization of the different resources in the simulation.
Maybe we want a view on the evolution of the entities’ flow, waiting or activity times.
Try it out!
Installation instructions, further documentation and extra examples can be found at https://github.com/Bart6114/simmer. For issues / bugs / improvement suggestions create an issue on GitHub or send me a mail at email@example.com.
Have fun with it: feedback & tips are always welcome!