## 5 Methodology for Reliability and Availability Evaluation
### Sharpe Source Code Generation  
After computing the minimal cut sets it becomes possible to generate a _minimal_ fault tree that represents the network failure process. As discussed previously, we choose to proceed in this way to enable faster computations, but also due to the fact that the sharpe tool does not accept models expressed as cut sets, but accept models described as fault trees. In this _minimal_ fault tree the top event results from two events. The first one is related to the failure of the gateway, whereas the second one is related to the network failure condition that is application dependent. The top events are described in Figure 11. Note that event \(nfc\) is based on the Figures 6 and 7 (Sections 5.4 and 5.6). For the sake of understanding of the top event definition, consider the example represented in Figure 10. We assume that the failure condition is defined as the following: \(Fd_{0}\) + \(Fd_{1}\cdot Fd_{2}\). In other words, the network fails if the device \(Fd_{0}\) fails or if devices \(Fd_{1}\) and \(Fd_{2}\) fail. We also assume that all devices are configured without redundancy. The first step is to find the device failure condition (\(fc\_Fd_{i}\)) for each device present in the network failure condition. In this case, \(fc\_Fd_{0}=Fd_{0,a}\), \(fc\_Fd_{1}=Fd_{1,a}\) and \(fc\_Fd_{2}=Fd_{2,a}+Fd_{0,a}\cdot Fd_{1,a}\). The top event for this example is presented in Figure 12.  
The following step is to transform the generated fault tree into an input file for the sharpe tool. The source code exported to the sharpe is simple and intuitively understandable. The procedure includes: (a) define constants, functions and events; (b) decide if an event is basic or repeated; (c) eliminate inconsistencies; (d) build the fault tree and define the measures to be computed. Figure 11: Events that conduct to a network failure. The functions used in the source code are related to failure and repair CDFs associated with each field device. If we intend to evaluate the network reliability \(R(t)\) then it is only necessary to replace each event related with the failure of device \(i\) by the respective CDF (as described in Section 4.3), since sharpe computes the device reliability \(R_{i}(t)\) from that. However, if we are interested in evaluating the network availability \(A(t)\) then the process is slightly different. If failure and repair rates are constant (_i.e._, defined by an exponential distribution) then we can use these parameters to compute the availability function of the device \(A_{i}(t)\) as described in Section 4.3. Then, it is only necessary to replace each event related with the device \(i\) by its availability function \(A_{i}(t)\) (note: sharpe has already a function that computes this function from the rates). When other CDFs are used to characterize the failure and repair processes (or at least one of them) it is necessary to use the concept of _model hierarchy_ provided by sharpe. The reasoning behind this concept is to use the output of one model as the input of another model. Applied to this case, we can model the behavior of device as a semi-Markov chain with two states: _operational_ and _failed_. In the former case the device is operational, and in the latter it is failed. Transitions between these two states are described by failure and repair CDFs. As discussed in Section 5.2, these functions must be expressed using exponential polynomial terms. This model can be solved by sharpe and the respective availability (_i.e._, _operational_ state probability) can be used as the input event of the device in the fault tree. Note that it is not necessary to solve this model in advance. The model's code can be placed in the same code that describes the fault tree, since sharpe analyzes the dependencies between models before computing the results. Details about the use of hierarchical models can be found in [49]. If a device is redundant, sub-events are created according to Figure 7(a); otherwise sub-events are created according to Figure 7(b).