What is a discrete event simulator?

Introduction
Discrete event simulator (DES) is a simulation technique that discretizes the real-world into a computer so that we can "fast-forward" the reality. Applications include what-if analysis and bottlenecks, optimization (used as an evaluation), and semi-supervised learning (can be used as the feedback loop). It models the entities in the real-world (cars, trains, people, equipment, etc.) in the framework of finite state machines where the states are updated by a set of rules by a certain trigger (e.g., time).

Rules and time
Rules are basically conditions under which an entity departs from one state to another. States are connected to one another using the rules, that are evaluated at preset times. Therefore, at any given time, an entity is in a state, and each state is connected to another by a rule. The state is updated when its time is triggered.

Example
For example, assume you have some material you want to move from one place to another, you own a road and three trucks. The trucks cannot cross-path one another as the road is too tight. There is a side-road that the trucks can wait until the other truck passes and then they can continue.


The entities in this problem are trucks, there is only one entity, but three copies of that. The states of the truck are: 1) on the road, 2) stopped at the side road, 3) at the loading site, 4) loading, 5) at the dumping site, 6) dumping. The states  Now, we need to generate our rules. Rules connect the states of an entity. For example, a truck (entity) goes form the "at the loading site" to the "loading" state "if the loader is vacant, ready, and the stock is available". In the case of multiple entities in the system, there might be some cross-entity rules.


Application
Let's assume that you are the owner of a mine you want to know what would happen if you buy some new trucks. This is a what-if analysis question. One way is to really buy the truck and observe the outcome, but that might end-up to losing money. Another way is to design a discrete event simulator to model the business and test variation of scenarios, adding a new train, truck, removing them, changing the planned and unplanned maintenance timings, and anything else that you may want to see its impact on your system. This is the same as finding the "bottlenecks" in your system.

A higher level of use for DES is to optimize the business. For example, you may define the parameters you wanna change (buying trucks, tuning up equipment, number of crushers, etc.) and their costs. An optimizer is then able to find the best investment (maximize the benefit and minimize the total cost of changes) using the DES as an evaluation, i.e., estimated reality. This is extremely valuable for large organizations. See some real examples here (this was actually my work), and here.

Tools
There are many tools for designing DES. You may design yours in Java, but I personally prefer Python for this purpose (simpy is quite good). Anylogic  and Extendsim are also very easy to use but they are visualized tools (not useful for any production, just pre-proof of concept maybe) and they are expensive. Simevents, of course, is also another tool (under Simulink/Matlab) but you need to buy Matlab license. A good thing about Simevent is that you may generate the Matlab code and add an optimizer on top of the simulator (see this example).

The middle ground
DES heavily relies on subject matter experts. The reason is that the models of entities (equipment) and their states, as well as the connection between states (rules), are formulated based on the reality of the equipment and how it works. This is one the most fundamental differences between DES model of a process and a machine learning model of a process, the former is built based on subject matter expert knowledge while the latter is built based on historical data. Of course, both of them involve their own specific limitations (subject matter experts, historical data), a combination can be very interesting, i.e., some equipment is modeled based on data and some others are modeled based on rules. A simple example would be to model an pump using a neural network and its data while other connected components using a set of rules. In fact, the functionality of each equipment, as an essential knowledge for DES, can be simply estimated using machine learning models. This indeed can end up to a comprehensive "digital twin" for any process.

Simulation vs optimization
Simulation provides the ability to model the reality and fast-forward it given a configuration. It makes it easy to then test different configurations and compare them (what-if analysis). Optimization is a tool to maximize or minimize an objective or a set of objectives, given a set of constraints. This means optimization can automate "what-if" analysis when it is paired with a simulation tool. Watch a good example in Simulink here.


Like always, this is only my opinion based on my experience and only a point of discussion. I would love to discuss this topic further in the comments.


By R. Bonyadi










Comments

Popular Posts