**4. Modified AABKR**

In this section, the modified AABKR is presented. The framework of the proposed method is depicted in **Figure 3**. It comprises the steps of calculating the feature distance that captures the spatial variation in the data; calculating the feature kernel weights based on the calculated feature distance; identifying the time position index using DTW technique; computing the temporal weighted-distance that captures the temporal variation and dependencies in the data, based on the time position index; calculating the temporal kernel weights, based on the calculated weighted-distance; and evaluating the adaptive bilateral kernel that computes the combined kernels and dynamically compensates for faulty sensor inputs to the bilateral kernel evaluation, and then, makes the prediction using a weighted average for the purpose of fault detection. Only the modifications to the original AABKR are discussed in this section. The basics of the DTW technique is first presented in Section 4.1. Then, the developed methods based on the DTW are discussed in Section 4.2. Finally, a demonstration of the developed identification methods is showcased in Section 4.3.

#### **4.1 Dynamic time warping**

Dynamic time warping (DTW) is a technique for finding an optimal alignment between two time-dependent sequences. This technique uses a dynamic programming approach to align the time-series data [56]. Suppose we have two time-series sequences of values taken from the feature space, **x** ¼ ½ � *x*<sup>1</sup> *x*<sup>2</sup> ⋯ *xL* and **y** ¼ *y*<sup>1</sup> *y*<sup>2</sup> ⋯ *yM* , of length *L* and *M*, respectively. To align these sequences using DTW, an *L* � *M* matrix, **D**, is first established, where the element *dl*,*<sup>m</sup>* of **D** is a local distance measured between the points *xl* and *xm*, usually called *cost function* since the DTW technique is based on the dynamic programming algorithm. Thus, the task of optimal alignment of these sequences is the arrangement of all sequence

**Figure 3.** *Framework of the modified AABKR for fault detection system.*

points for minimizing the *cost function*. Once the local cost matrix has been built, the algorithm finds the alignment path which runs through the low-cost area—valley on the matrix. The alignment path, usually called the warping path, is a sequence of points, **w** ¼ ½ � *w*<sup>1</sup> *w*<sup>2</sup> ⋯ *w*<sup>P</sup> and defines the correspondence of an element *xl* to *ym* with *wp* ¼ *lp*, *mp* � �∈½ �� <sup>1</sup> : *<sup>L</sup>* ½ � <sup>1</sup> : *<sup>M</sup>* for *<sup>p</sup>*∈½ � <sup>1</sup> : <sup>P</sup> satisfying the following three criteria [57, 58]:


The total cost of a warping path **w** between **x** and **y** with respect to the local cost matrix (which represents all pairwise distances) is:

$$d\_{\mathbf{w}}(\mathbf{x}, \mathbf{y}) = \sum\_{p=1}^{\mathcal{P}} d(w\_p) = \sum\_{p=1}^{\mathcal{P}} d\left(\mathbf{x}\_{l\_p}, \mathbf{y}\_{m\_p}\right) \tag{25}$$

Moreover, an optimal warping path between **x** and **y** is a warping path, **w**<sup>∗</sup> , that has minimal total cost among all possible warping paths. The DTW distance, DTW (**x**, **y**) between **x** and **y** is, then, defined as the total cost of **w**<sup>∗</sup> :

$$\text{DTW}(\mathfrak{x}, \mathfrak{y}) = d\_{\mathfrak{w}^\mathsf{T}}(\mathfrak{x}, \mathfrak{y}) = \min \left\{ d\_{\mathfrak{w}}(\mathfrak{x}, \mathfrak{y}), \mathfrak{w} \in \mathbf{W}^{L \times M} \right\} \tag{26}$$

where **W***<sup>L</sup>*�*<sup>M</sup>* is the set of all possible warping paths.

To determine the optimal warping path, one could test every possible warping path between **x** and **y**, which would however very be computationally intensive. Therefore, the optimal warping path can be found using dynamic programming by building an accumulated cost matrix called global cost matrix, **G**, which is defined by the following recursion [57]:

First row:

$$\mathbf{G}(\mathbf{1}, m) = \sum\_{k=1}^{m} d(\mathbf{x}\_1, \mathbf{y}\_k), \quad m \in [\mathbf{1}, M] \tag{27}$$

First column:

$$\mathbf{G}(l,\mathbf{1}) = \sum\_{k=1}^{m} d(\mathbf{x}\_k, \mathbf{y}\_1), \quad l \in [\mathbf{1}, L] \tag{28}$$

All other elements:

$$\mathbf{G}(l,m) = d(\mathbf{x}\_l, \mathbf{y}\_m) + \min\left\{ \begin{aligned} &\mathbf{G}(l-1, m-1),\\ &\mathbf{G}(l-1, m),\\ &\mathbf{G}(l, m-1) \end{aligned} \right\}, l \in [1, L] \& m \in [1, M] \qquad \text{(29)}$$

This means that, the accumulated global distance is the sum of the distance between the current elements and the minimum of the accumulated global

*Fault Detection by Signal Reconstruction in Nuclear Power Plants DOI: http://dx.doi.org/10.5772/intechopen.101276*

distances of the neighboring elements. The required time for building matrix **G** is *Ο*ð Þ *LM* .

Having determined the accumulated cost matrix **G**, obviously, the DTW distance between **x** and **y** is simply given by Eq. (30):

$$\text{DTW}(\mathbf{x}, \mathbf{y}) = \mathbf{G}(L, M). \tag{30}$$

Once the accumulated cost matrix has been built, the optimal warping path could be found by backtracking from the point *w*<sup>P</sup> ¼ ð Þ *L*, *M* to the *w*<sup>1</sup> ¼ ð Þ 1, 1 , using a greedy strategy.

### **4.2 DTW-based time position index identification approaches**

One of the significant steps that requires modification in AABR is the identification of the time position index. The goal here is that the identification of the time position index should be solely based on the feature data and must be freed from the use of the derivatives, in order to improve the monitoring performance of the AABKR during steady-state operations. To achieve this goal, we developed two approaches based on the DTW algorithm described in Section 4.1 for the identification of the time position index. The two approaches are described in the following subsections.

#### *4.2.1 First approach: based on the generated subsequences of the memory data*

For simplicity of description, we assume *p* ¼ 1 (single signal) and present the description of the algorithm by referring to **Figure 4**, where **X** ∈ *<sup>M</sup>*�*<sup>p</sup>* and **X**<sup>∗</sup> *<sup>q</sup>* ∈ *<sup>r</sup>*�*<sup>p</sup>* are memory data and query data, respectively. We also assume that the memory data, **X** has already been reorganized into an array containing *N* matrices each of length *r* with ð Þ *r* � 1 overlapping between them, as described in Section 3.1 where ð Þ *N* ¼ *M* � *r* þ 1 . By using DTW, the goal is to find a subsequence A*k <sup>r</sup> <sup>a</sup>*<sup>∗</sup> ½ � : *<sup>ε</sup>* <sup>∈</sup> *<sup>r</sup>*�*<sup>p</sup>* <sup>¼</sup> *xa*<sup>∗</sup> , *xa*<sup>∗</sup> <sup>þ</sup>1, <sup>⋯</sup>*x<sup>ε</sup>* ½ �, with 1≤*a*<sup>∗</sup> <sup>≤</sup>*<sup>ε</sup>* <sup>≤</sup> *<sup>M</sup>*, that minimizes the DTW distance to **X**<sup>∗</sup> *<sup>q</sup>* over all *<sup>N</sup>* matrices generated from **<sup>X</sup>**. Note that, <sup>A</sup>*<sup>k</sup> <sup>r</sup>* is a *k*th subsequence in the generated array, where *k* ¼ 1, 2, … , *N*. Thus, the DTW distance between **X**<sup>∗</sup> *<sup>q</sup>* and each of the *<sup>k</sup>*th matrix, <sup>A</sup>*<sup>k</sup> <sup>r</sup>* in **A** can be determined by:

$$\text{DTW}\left(\mathbf{X}\_q^\*, \mathcal{A}\_r^k\right) = \mathbf{G}(r, r) \tag{31}$$

which can be calculated from the local cost function matrix, **D**, using Eqs. (27)–(29) of the DTW algorithm described in Section 4.1. Each element of **D**

**Figure 4.**

*Alignment between two time-dependent data: Sequences X<sup>q</sup> and X.*

is a local distance measured between the points in **X**<sup>∗</sup> *<sup>q</sup>* and A*<sup>k</sup> <sup>r</sup>*, which can be calculated by:

$$d[l,m] = d\left(\mathbf{x}\_l^\*, \mathbf{x}\_m\right) = \left||\mathbf{x}\_l^\* - \mathbf{x}\_m\right||\_1 \tag{32}$$

where *<sup>l</sup>* <sup>¼</sup> 1, 2, … ,*r*, is the row index of the query data, **<sup>X</sup>**<sup>∗</sup> *<sup>q</sup>* , and *m* ¼ 1, 2, … ,*r*, is the row index of the *k*th subsequence, A*<sup>k</sup> <sup>r</sup>*, of the memory data.

Then, the time position index can be determined as:

$$\varepsilon = \left( \underset{k \in [1:N]}{\text{arg min}} \left\{ \text{DTW} \left( \mathbf{X}\_q^\*, \mathcal{A}\_r^k \right) \right\} \right) + r - 1. \tag{33}$$

This index can, then, be used in the weighted-distance algorithm for the calculation of the temporal weighted-distance. This approach is summarized in Algorithm A.2.1 of Appendix A.2.

#### *4.2.2 Second approach: based on the entire memory data*

In this approach, instead of calculating the DTW distances between the query input data and each of the subsequence data generated from the memory data, the mapping between the query input data and the memory data can be determined directly, from which the time position index can be obtained. Thus, the generation of the array from the memory data is not required in this case. This approach is described as follows.

First, calculate the local cost function matrix, **D** between the query data, **X**<sup>∗</sup> *q* , and the memory data, **X**. Having calculated **D**, the calculation of **G** from **D** using dynamic programming [57] is a bit modified through the following recursion:

First row:

$$\mathbf{G}(\mathbf{1}, i) = d\left(\mathbf{x}\_1^\*, \mathbf{x}\_i\right), \quad i \in [\mathbf{1}, M] \tag{34}$$

First column:

$$\mathbf{G}(l, \mathbf{1}) = \sum\_{s=1}^{l} d\left(\mathbf{x}\_s^\*, \mathbf{x}\_1\right), \quad l \in [1, r] \tag{35}$$

All other elements:

$$\mathbf{G}(l,i) = d\left(\mathbf{x}\_l^\*, \mathbf{x}\_i\right) + \min\left\{ \begin{aligned} &\mathbf{G}(l-1, i-1),\\ &\mathbf{G}(l-1, i),\\ &\mathbf{G}(l, i-1) \end{aligned} \right\}, l \in [1, r] \& i \in [1, M] \end{aligned} \tag{36}$$

leading to an accumulated matrix, **G** ∈ *<sup>r</sup>*�*<sup>M</sup>*. Finally, the time position index is obtained as follows, using the last row of **G**:

$$\boldsymbol{\varepsilon} = \underset{\boldsymbol{i}\boldsymbol{e}[:\boldsymbol{r}\boldsymbol{M}]}{\text{arg min}} \left(\mathbf{G}[\boldsymbol{r},\boldsymbol{i}]\right) \tag{37}$$

Note that the calculation of **G** is the same as earlier discussed, except that, its first row is taken equal to the first row of **D** without accumulating [57], as shown in Eq. (34). This is because, our goal is to determine the time position index using the

last row of **G** and to minimize the impact of the fault (if it occurs) during the determination of the index. The obtained time position index in Eq. (37) can, then, be used in the weighted-distance algorithm for the calculation of the temporal weighted distance. This approach is summarized in Algorithm A.2.2 of Appendix A.2.
