In this brief example I implement a simmer backlog simulation, using discrete-event simulation. I have stated that free tools such as simmer can be a strong support and can replace many of the commercial discrete-event simulation licenses currently in use. This is because many licenses are in use for simple objectives and focus on simple shop floor, layout or process problems. For this free tools such as simmer in R are well suited and can be valid replacement candidates for commercial simulation software.
The FIFO backlog development simulation implemented with simmer in this article is a very simple example. A commercial simulation study with realistic settings will most likely be more complex. Complexity can e.g. be added by increasing the number of part families, product groups, and production controls. In addition, there could be alternative routings in the production flow, requiring at least some sort of heuristic decision making.
Conceptual model of push-based production
In this simple example I model a receival process that receives raw material. This material goes into a central storage area that acts as a buffer. From there, parts go to one of four processing stations. From there processed parts go into another buffer ahead of shipping. Shipping facilitates the final process in this simple example.
The job prioritization logic applied is a simple “first in first out” (FIFO) logic. Furthermore, there is only one product and only one raw material type. The processing stations are all identical. Shift calenders etc. are not considered, and any efficiency losses at processing stations due to breakdowns or rework are merely considered by applying exponential distributions for processing times. More complex logic can be implemented with simmer as well, using the basic building blocks provided by the package. For more, see my simmer documentation. A link to that documentation is provided at the end of this article.
Parts received via the receival process follow a random distribution with regards to the time interval between deliveries. The processing time of the processing stations follows a random distribution as well. The shipping process has a fixed time interval.
Random distributions for backlog simulation
For the time intervals between part receivals I used a random uniform distribution. For the processing time at the processing station I used exponential distributions. The idea behind this being that the exponential distribution has a long tail, capturing e.g. unexpected breakdowns, retoolings or rework etc. This is a simplification. Normally, one would have to implement e.g. scrap, breakdown, setups and e.g. machine warm-up in detail.
Note: The processing time has a minimum duration, defined by a constant lower limit.
Model implementation with simmer in R
I implement the model below, using the simmer package in R for discrete-event simulation.
library(magrittr) library(simmer) library(simmer.plot) library(dplyr) # set seed for random number generation set.seed(42) # declarate / create simulation environment env = simmer("Backlog simulation") # setup a trajectory workflow production = trajectory("production process") %>% seize("processing",1) %>% timeout(function() 1+rexp(1,0.05)) %>% release("processing",1) %>% seize("shipping",1) %>% timeout(5) %>% release("shipping",1) # adding a ressource to the simulation environment env %>% add_resource("processing", capacity = 4, queue_size=100000) %>% add_resource("shipping", capacity=1, queue_size=100000) trajectory to generator env %>% add_generator(name_prefix = "parts", trajectory = production, distribution = function() runif(1,3,7)) # run simulation for 3000 time units env %>% run(3000)
Analyzing results obtained from the simmer simulation model
I procede with an analysis of the simulation results below. To learn more about monitored simmer data see my references at the end of the article.
First, I obtain (“get”) relevant monitored data in the form of R dataframes. I can plot the backlog curves with this data, e.g. using ggplot2 in R:
library(ggplot2) ggplot(get_mon_resources(env)) + geom_line(mapping=aes(x = time, y = queue, color = resource),size=2) + ggtitle("Simulated backlog curve") + xlab("Time") + ylab("Backlog") + scale_colour_manual(values = c("#FF0000", "#428EF4"))
With the current system configurations and processing times, the backlog ahead of processing is non-stationary. This indicates a bottleneck.
What happens if we add an additional processing station? I investigate this in the code below.
simmer("Backlog simulation (additional processing station") %>% add_resource("processing", capacity = 5, queue_size=100000) %>% add_resource("shipping", capacity=1, queue_size=100000) %>% add_generator(name_prefix = "parts", trajectory = production, distribution = function() runif(1,3,7)) %>% run(3000) %>% get_mon_resources() %>% ggplot() + geom_line(mapping=aes(x = time, y = queue, color = resource),size=2) + ggtitle("Simulated backlog curve") + xlab("Time") + ylab("Backlog") + scale_colour_manual(values = c("#FF0000", "#428EF4"))
Adding additional resources to processing seems to stabilize the system. This indicates a resource bottleneck.
Benefits of simple backlog simmer simulation
Even a simple backlog simulation model such as the one in this article offers a strong advantage over conventional Excel sheets: It captures the dynamics of processing times and resource limitations / capacities.
Limitations of simple backlog simmer simulation
This simple backlog simulation model has many limitations. Raw material supply does not depend on current backlog (missing feedback loop will result in ever increasing inventory levels). In addition, the model merely implements a FIFO logic, which is e.g. not sufficient to model a more complex production system with many alternative production controls and job prioritizations.
Alternative methods for simulating backlog
One alternative approach that I can recommend for a simple backlog simulation of this kind is to build a simulation model in VenSim. VenSim facilitates are very simple tool for system dynamics, i.e. systems described by stocks and flows. A system of this kind could very well have been analyzed using a system dynamics approach. I will cover VenSim and system dynamics in upcoming articles.
Concluding remarks and references
In this article I demonstrated a more appropriate technique for simulating production backlog when compared to simple Excel calculations. The method applied was discrete-event simulation. I made use of the R-package simmer, a simulation package in R for discrete-event simulation.
For your reference, here are some articles that could be of interest to you in this context:
- Link: Simulation techniques
- Link: Discrete-event simulation in R with simmer
- Link: Simulating a simple receival process using the simmer R-package
Data scientist focusing on simulation, optimization and modeling in R, SQL, VBA and Python