## 4 Case Study and Hybrid Modelling
### Simulation Algorithm of the Hybrid Dynamic Queueing System  
In a simulation model, variables can be deterministic (and non-random) or stochastic (and random). A Monte Carlo simulation (MCS) is basically a stochastic simulation method and a sampling technique in which random sampling is used. In this paper, the Monte Carlo simulation (MCS) core algorithm has been codified so as to combine together Discrete-Event and a Time-Driven simulation. In this way, MCS can change dynamically the parameters characterizing each run of the system evolution during the mission time. In order to understand the hybridization of the simulation, let us recall first the generic algorithms for the queue and reliability independently before merging the two of them. For a queueing system, one run of the simulation will result in a sample path that models the number of items in the queue during the time. The interarrival \(\text{Z}_{\text{i}}\)(t) and service time \(\text{S}_{\text{i}}\)(t), characterizing a generic ith item entering the queue, are simulated by sampling the inverse of the distribution probability functions, \(\text{Z}^{-1}\) and \(\text{S}^{-1}\), characterizing the two processes. This allows one to construct a sample path of the system evolution that, as shown in Figure 5[42], depicts for each discrete event time-point the number of items enqueued in the system. As it can be understood, the advantage of the Monte Carlo simulation is to overcome the limitation of the analytical \"Little's Law\" which is valid only for the Poisson distribution and to generalize the modelling with the possibility to simulate the behaviour of a general queueing system. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Distribution** & **Variable** & **Symbol** & **Value** & **Measuring Unit** \\ \hline Failure Event & Expected Mean Life & \(\alpha\) & 100 & h \\ (Weibull) & Shape Factor & \(\beta\) & 3 & - \\ \hline Repair Event & Min Time to Repair & \(\text{TTR}_{\text{min}}\) & 1 & h \\ (Uniform) & Max Time to Repair & \(\text{TTR}_{\text{max}}\) & 8 & h \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Main parameters for the failure and repair distributions of the machine tool. For the reliability of a system, the MCS corresponds to performing an experiment for a certain mission time (\(\rm T_{M}\)) in which a large number of identical stochastic systems, each one behaving differently, runs virtually instead of performing real physical tests. The simulation algorithm monitors whether a system fails before the completion of the mission and, in that case, records the time of the failure. This procedure corresponds to the observation of several realizations of the system process. Based on the amount of observations fallen into each range, simulation results are examined [41]. In a reliability problem, on the one hand, a set of possible states can be considered for a component (e.g., functioning, degraded and failed, as shown in Figure 5(a)), and based on its failure distribution, random numbers are generated for the duration that the component remains in each state; on the other hand, an infinite set of other states can be modelled considering how the failure rate h(t) changes over time, depending on the age of the component and on the boundary conditions in which it operates (Figure 5(b)). Both these approaches overcome the hypothesis HP4 of dyadic states. With regard to the first, the sojourn time into a state (duration) is computed by the inverse distribution function \(\rm F^{-1}\) that characterizes the jump towards another state. To obtain the unreliability for a given time (t), the number of runs that have jumped into a failure state before the mission time can be divided by the total number of runs [43]. Figure 5(a) shows an example of the sample path generated by 6 runs of a simulation where the transitions among the three different states of the components occur at different times.