## 2 Materials and Methods  
### Simulation of Manufacturing System and Digital Twin  
Simulations can be understood as imitations of the behavior of a dynamic system. The basic purpose of a simulation is to determine the result based on known input parameters. Their sequence and value determine the final behavior of the system [63]. The simulation model is based on the conceptual design of a real problem, for example, a newly projected manufacturing system. The creation, verification, and validation of the model are time consuming, therefore, the model is often simplified. In the case of simple models of production systems, results can be obtained relatively quickly, but they do not fully reflect the functioning of the production system, e.g., due to failures or disturbances caused by human and robotic factors which are difficult to model. The development of more sophisticated models is laborious and requires the use of advanced methods of statistical analysis of the results. Typically, many simulating experiments are needed, usually according to an experimental scenario. The results obtained after the implementation of the simulation can be interpreted as a form of consequence for the real system. Based on those results, a decision can be made as to whether the system should be modified or whether changes to another system parameter should be investigated [31]. An illustration of the main phases of a simulation project is presented in Figure 2.  
The theoretical assumptions and the principles of DES modeling and simulation have been presented in many publications, including [23; 24; 25; 63]. The simulation model M of a manufacturing system can be defined as a set of components:  
\[\text{M}=\{\text{X},\,\Omega,\,\text{R},\,\text{C},\,\text{T},\,\text{Y}\} \tag{1}\]  
Including:  
* X--inputs, e.g., raw materials, energy;
* \(\Omega\)--objects, e.g., machines, employees, transport, stores;
* R--relations, connections between objects defining material or information transfers;
* C--constraints, parameters defining limitations of resources, e.g., buffers capacity;
* T (time)--the life cycle and timespan of modeled processes, and disturbances;
* Y--outputs, finished products with good or bad quality, waste. The graphical representation of the model is presented in Figure 3.  
Figure 2: The main phases of the simulation methodology. The state of the process at time \(t\) can be described by the transition function f(g, t), which transforms input elements X to output elements Y, based on the state of the system elements at time \(t-1\):  
\[\text{Y}=\text{f(g, t), and g}=\left(\text{X, }\Omega,\text{ R, C, }t-1\right),\text{ for t }\in\text{T} \tag{2}\]  
The scheme of the modeling and simulation methodology is presented in Figure 4. The DES model should take into account all resources in the production system, i.e., machines, buffers, warehouses, means of transport, and the necessary workers or industrial robots. It is also necessary to define the relations between objects and constraints, i.e., the operating parameters of all objects (e.g., the time of execution of a given operation) and the relationships (relations) between the objects (e.g., transport routes) [44; 61]. DES simulation reflects changes in the state of objects in the model that occur at certain points in time at the time of certain events (e.g., the start or end of an operation) and the flow of intermediates between the system input and output. The simulation can be used to analyze the existing production systems in the case of reorganization of production processes, as well as in the case of designing new production systems in order to analyze various concepts of the building of a production system [63; 64]. Modeling requires a diverse knowledge of the system being considered. That knowledge includes understanding the historical, current, and/or anticipated characteristics of the system. The simulation then becomes a repository of that knowledge and the resulting dynamics, and it makes these available to others, for example, for management purposes [64].