Manufacturing Line Optimization using Discrete Event Simulation

Barecasco
ZebraX
Published in
7 min readNov 23, 2021

The objective of this article is to describe our approach in optimizing a manufacturing line with complex process interactions using a simulation model. The approach consists of two main steps: building a simulation model, and performing optimization on the target metrics over a list of controllable variables. A simple target metrics for the optimization is the production throughput, while the controllable variables are the machine speeds or conveyor-belt sizes.

Discrete Event Simulation

A simulation model is an imitation or replication of a real system or processes over time. The model is used to generate artificial data to help us understand the operating characteristics of the real system. When developing a simulation, it is best to start with a simple model and iterate towards a model with a balanced accuracy and complexity. After the model is ready and validated, we can then perform a what-if analysis, or run an optimization task using the model.

A Discrete Event Simulation (DES) is a modeling approach in which the state of the system changes only at discrete points in time. For this article, we are using SimPy, which is a process-based discrete-event simulation framework based on standard Python.

Figure 1. System modeling approach

Manufacturing Line Abstraction

Let’s consider a manufacturing or production line consisting of multiple machines that are connected using conveyor belts in a sequence. Each machine has a different speed (products/minute), and each conveyor belt has a different maximum capacity (number of products).

The dynamic of the manufacturing line system can be summarized as follows:

  • The state of the machine is either running or stopped due to failure, starvation, or blockage
  • The machine is starved if the preceding conveyor belt is empty
  • The machine is blocked if the following conveyor belt is full
  • Machine uptime follows an exponential distribution with λ = 1/(Mean Time To Failure)
  • Machine downtime follows an exponential distribution with λ = 1/(Mean Time To Repair)
  • If historical Manufacturing Execution System (MES) data is available, the machine up and downtime can be collected and randomly sampled
  • At each production batch, a warm-up or a startup period will occur until the production stabilizes
Figure 2. Model abstraction in SimPy

SimPy Model Setup

A Glimpse on SimPy

Please note that this is a simplification of how SimPy works. Please find the documentation here. There are three important terms to understand SimPy:

  1. Environment
  2. Process
  3. Event

A simulation in SimPy runs within an Environment. In an environment, some processes need to or may not be executed. The simulation starts by prompting SimPy to execute at least one initial process:

In a process, there can be event triggers and at least one event listener (the line that uses keyword yield). An event listener in the process will halt any code execution below it until the corresponding event is triggered. Upon the trigger, the code is executed up to another event listener or the end of the process. Event trigger can exist among the executed code so it may start code execution in another process with the corresponding event listener.

SimPy simulation runs by going from event to event. The discrete simulation time flow and simultaneity are defined by the events themselves. For example: env.timeout(3) set and listen if 3-time steps simulation can pass (not violating any other event) and it will trigger itself if the condition is met. An event trigger can be listened to by more than one event listener, meaning they will be executed simultaneously in the simulation time.

And of course, we can define our event in SimPy.

Conveyor

The first approach to model manufacturing lines is to model the Conveyor and the Machine.

A Conveyor object is designed to have a SimPy Container that can be loaded or unloaded. The container can represent the buffering function of the conveyor belt. In the real world, it represents how items can crowd up on the belt.

SimPy has a built-in class called Container that can be used to put and take several items from it. It has the capacity where capacity-related constraint definition can be applied. Below is the instantiation of the Container class within the constructor function of the Conveyor class.

Loading the container will take some time, while unloading happens instantly. The time taken to load the container represents the time it takes for an item to travel from the start to the end of the conveyor belt. Instant unloading represents how the next machine takes in items at the end of the conveyor belt. Controlling how the time flow for loading and unloading in the simulation is done via timeout event. The speed of the conveyor belt is represented by the number of time steps used in timeout.

There are two conditions regarding the container capacity. When the preceding machine attempts to put items to the container while the result will exceed its capacity (container.level + num_item >= container.capacity), a blockage event is triggered so the preceding machine will stop its process. When the next machine attempts to take in items from the container while it has no sufficient number of items (Container.level - num_item < 0), a starved event is triggered so the next machine will stop its process.

Below is an example of a load method of Conveyor class that implements conveyor belt traveling time and over-capacity condition:

Once the container is ready to be loaded or unloaded, the event load_ready or unload_ready is triggered so the corresponding machine can resume its process.

Machine

A Machine object is designed to be connected with input and output conveyor instances. The connection will allow the machine to do a request to the conveyors’ container to put and get items from it.

Once the machine takes in an item it will be processed for some time steps. The amount of time steps for thetimeout event is determined by desired products/minute speed parameter and time step equivalent in the real world. After the processing is done the item will be put to the output conveyor.

The connected conveyor can trigger blockage or starved event if its capacity rule is violated on loading or unloading attempt. A stopped machine will wait until the conveyor is available to be loaded/unloaded, represented by load_ready or unload_ready event from the corresponding conveyor.

Below is the example of how a Machine class with blockage event logic can be defined:

Machine Failure

A machine failure (or breakdown) is simulated as a periodic event where the time between two failures is generated from a random number following an exponential distribution. A mean time between failure is required. In SimPy we can create a process that will interrupt the machine when the breakdown time has come.

The same logic applies to simulate the repairing process of the machine. The mean time to repair is required to generate the exponentially distributed random number for repair time.

Simulation Arrangement

Once the Machine and Conveyor object is defined, we can arrange the simulation objects and parameters. Below is an example of a manufacturing line consisting of 2 machines connected to 3 conveyors.

The above arrangement will run up to 200 simulation time steps. For real use cases, more machines and much more time steps are required. The result of the simulation can be obtained by logging the system state for every event and computing the throughput for the whole given simulation time.

For the optimization purpose, for every machine and every conveyor, we can set its speed and items capacity within a predetermined boundary.

Optimization Process

One thing to note is that the solution found is not guaranteed to be global optimum due to the non-linearity of the problem. However, we can still validate the throughputs between the current line configuration, and the optimized configuration to assess the performance improvement.

Figure 3. Optimization process using the black-box simulation model

Results from the optimization task can be visualized in terms of the v-shape graph to understand the current bottleneck and be used as an input to improve the line performance by adjusting the machine speed or the conveyor-belt capacity.

Figure 4. Manufacturing line v-shape graph

Summary

In this article, we’ve covered the general idea of manufacturing line optimization or what is commonly known as line balancing analysis. The key benefit of this solution is to provide line managers a tool to simulate production lines, perform what-if analysis, and optimize throughput.

Author

  • Agra Barecasco (Sr. Data Scientist)
  • Edward Christian (Data Architect)

--

--