In this brief example I implement a simmer backlog simulation, using discrete-event simulation. As a matter of fact free simulation tools can provide a strong support. In my opinion free tools can replace many of the commercial discrete-event simulation licenses currently in use. I explicitly believe that most commercial simulation licenses are applied to simple rather than complex problems. Most licenses focus on simple shop floor, layout or process problems. All in all free tools such as simmer, a package in R, are well suited for this. They can be valid replacement candidates for commercial simulation software.
The FIFO backlog simulation implemented with simmer in this article is a simple example. Overall, a commercial simulation study with realistic settings is often more complex. This complexity grows by whenever the number of part families, product groups, and production controls increases. In addition, there could be alternative routings in the production flow that may require 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. Secondly, this material goes into a central storage area that acts as a buffer. Afterwards parts go to one of four processing stations from there. From there processed parts go into another another buffer. The buffer is basically placed shortly ahead of shipping. Lastly, 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 are not considered. However, breakdowns and rework and therefrom resulting efficiency losses at processing stations are considered. These efficiency losses are considered only by applying exponential distributions to processing times. simmer furthermore also allows more complex logic to be implemented as well. For this the basic building blocks provided by the package can be applied. 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.
Backlog simulation 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 simmer results of backlog simulation
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.
Firstly, I obtain relevant 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 dynamics approach could have analyzed a system of this kind very effectively. 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