## 3 Theoretical Background and Methodology
### Simulation Algorithm of the Hybrid Dynamic Queueing System  
The production process of an industrial product is subjected to interdependent physical and aleatory phenomena that cannot be caught by Hypotheses Hp1-Hp6. Indeed, these provide a rigid framework of operations which are not applicable to real cases that are characterized by complex working and environmental conditions that can modify the performance of a system and affect its wear. More generally, a system can be subjected to continuous changes during its mission, and the stochastic modelling requires coupling the aleatory behaviour of the system (linked to the uncertainties of the features of workloads and resistance of the materials) with the physical equations that describe its mechanics and its process. This type of modelling [33], based on the knowledge of the mathematical relationships that make the dynamic failure rate, changes over time [39]; it aims to relax the framework defined by the Hypotheses Hp1-Hp6. The conception and resolution of such models is complex and can be undertaken using simulation techniques. Under this modelling framework, numerical integration is used to integrate the dynamics equations of the system, and Monte Carlo simulation is applied to take into account the contribution of the random variables; the resulting model is defined as hybrid. The simulation paradigm is required to model and evaluate complex systems for which a closed analytical solution is difficult to model and compute. From a simulation perspective, systems can be categorized as discrete or continuous. The difference between a discrete and continuous system is the change in their variables that may happen in discrete points in time or continuously. Simulation models are analysed by numerical methods which employ computational procedures to solve mathematical models. Within the scope of the simulation, the model is solved by means of a \"run\" or \"iteration\" [41] which constitutes one of the possible realizations of the system's evolution. The simulation model must keep track of the results generated during each run and, at the end of the simulation, it computes the average. Therefore, in order to achieve an accurate result, simulation can be time consuming. Figure 3 shows the flowchart of the Monte Carlo simulation (MCS) used as a general algorithm for combining a queueing system with a dynamic reliability problem. As said, it is important to highlight that this algorithm is able to combine together a Discrete Event  
Simulation and Time-Driven (Continuous) Simulation engines by adding the complexity of a repairable queueing system constituted by a simple machine tool that can get broken and repaired, overcoming the limitations of [39] and [24]. In fact, the Block.4, as explained in the section of the case study, is the simulation component that manages the scheduling of the production performed by the service station. The discrete simulation engine has to consider when the manufacturing station is unavailable and, thus, shifts or extends the processing of a work item accordingly. Let us illustrate the algorithm proposed. The first block (Block.1) concerns the setting of the parameters which characterize the use case scenario. Basically, it should be possible to configure the variables and the related distributions of the queueing system (e.g., the machine tool) and of the dynamic reliability problem. In the Block.2, the simulation engine samples the interarrival (t\({}_{\rm{mi}}\)) and service (t\({}_{\rm{sm}}\)) time of each job which will enter in the queueing system, so as to build the table of the Discrete Events.