## 4 Maintainability Evaluation Approaches Using the Maintenance Process Model
### Maintenance Time Simulation  
When all the firing rates of transitions are constant, the SCPN will be isomorphic to a continuous-time Markov chain. However, time durations of maintenance tasks may follow various distributions, the continuous-time Markov chain cannot be applied to obtain the maintenance time in this situation. We will use a discrete-event simulation to obtain the maintenance time.  
The input of our discrete-event simulation procedure includes: (1) the input incidence matrix \(\mathbf{W}^{-}=[W(s_{i},t_{j})]\); (2) the output incidence matrix \(\mathbf{W}^{+}=[W(t_{j},s_{i})]\); (3) the initial marking \(\mathbf{M}_{0}\); (4) the capacity function \(K(s_{i})\), \(K(s_{c})\) and \(K(s_{r})\); (5) the firing time distribution of each timed transition; (6) the probability that the immediate transition \(t_{i}\) can be fired, namely \(p_{i}\) given in Equation (11).  
The flowchart of the discrete-event simulation procedure is given in Figure 5.  
Figure 5: The discrete-event simulation for maintenance time.  
We can get one sample of the maintenance time from one simulation, and we can get the mean maintenance time of the maintenance process from several simulations.  
The detailed step of one discrete-event simulation is as follows:  
Step 1: initialize variables  
Let \(\mathbf{M}=\mathbf{M}_{0}\),\(\pi_{current}=0\), and \(\pi_{j}=0\) for all \(j\); \(\pi_{current}\) is the current time, \(\pi_{j}\) is the firing time of the transition \(t_{j}\), and \(\mathbf{M}\) is the current system marking.  
Step 2: decide whether the simulation can terminate  
The simulation will terminate when \(M(\mathrm{s}_{s}^{(u)})=c_{s}\), \(\mathrm{s}_{s}^{(u)}\) is the state place that denotes the ultimate maintenance state. In this situation, \(\pi_{current}\) will be a sample of the maintenance time. If \(M(\mathrm{s}_{s}^{(u)})\
eq c_{s}\), the simulation will go to Step 3.  
Step 3: determine the enabled transitions  
A Boolean variable \(E_{j}\) is used to denote whether the transition \(t_{j}\) is enabled or not. When \(E_{j}\) equals 1, \(t_{j}\) is enabled; otherwise, \(t_{j}\) is not enabled. We let \(E_{j}=0\) for all \(j\). We can determine which transitions are enabled by Equation (3). If \(t_{j}\) is enabled, let \(E_{j}=1\).  
Step 4: update the firing time for all transitions  
For each non-enabled transition (\(E_{j}=0\)), let its firing time equal 0 (\(\pi_{j}=0\)). For each enabled transition (\(E_{j}=1\)), if its original firing time is 0 (\(\pi_{j}=0\)), a random variable will be generated as its new firing time according to its firing time distribution; otherwise, its firing time will not be changed.  
Step 5: determine the fired transition  
Among all the enabled transitions, the transition that has the minimum firing time (\(\pi_{\min}\)) will be fired. If \(\pi_{\min}=0\), it means an immediate transition will be fired. In this situation, there might be several enabled immediate transitions, and the fired transition will be selected in terms of Equation (11).  
A Boolean variable \(F_{j}\) is used to denote whether the transition \(t_{j}\) is enabled or not. If \(F_{j}\) equals 1, \(t_{j}\) is enabled; otherwise, \(t_{j}\) is not enabled.  
Step 6: update the current time  
The current time \(\pi_{current}\) will be updated by \(\pi_{current}+\pi_{\min}\), i.e., let \(\pi_{current}=\pi_{current}+\pi_{\min}\).  
Step 7: update the firing time for all enabled transitions  
The firing time of the enabled transition \(t_{j}\) (\(\pi_{j}\)) will be updated by \(\pi_{j}-\pi_{\min}\), i.e., let \(\pi_{j}=\pi_{j}-\pi_{\min}\).  
Step 8: update the markings  
The markings will be updated via the state function of the Petri net, i.e., \(\mathbf{M}\) will be updated by \(\mathbf{M}+\mathbf{C}\times\mathbf{F}\) (\(\mathbf{M}=\mathbf{M}+\mathbf{C}\times\mathbf{F}\)). The \(j\)th element of \(\mathbf{F}\) is the Boolean variable \(F_{j}\). Finally, go back to Step 2.