## 4 Algorithm Design
### Leak Detection Algorithm
#### 4.1.2 Leak Initial Recognition Based on SVM Multiple Classifiers  
At sensor nodes, the leak recognition model is built based on SVM multiple classifiers because the SVM method is able to detect small leaks and slow leaks which could not be detected by the traditional methods. Also, the SVM method avoids the large sample requirements of traditional classification methods [36,37]. To build a model of SVM multiple classifiers includes designing the following aspects: input vector, classification principle, inner product function, penalty coefficient. Sensor nodes in the networks adopt the same structure of SVM multiple classifiers, shown in Figure 3. Where \(X_{i}\) (\(i\) = 1,2,...,\(N\)) denote the input characteristic parameters, and \(Y_{j}\) (\(j\) = 1,2,...,\(M\)) denote the output results from SVM multiple classifiers. Related studies have demonstrated that (i) peak value, (ii) average amplitude, (iii) variance and (iv) mean square root are parameters which can reflect the fluctuation of stress waves caused by pipeline leaks; (v) peak factor, (vi) pulse factor and (vii) margin factor are parameters which can reflect the impact of dramatic changes of stress waves; (viii) skewness factor and (ix) kurtosis factor  
Figure 3: Structure of SVM multiple classifiers. are parameters which can reflect the changes of amplitude distribution of stress waves [38]. Consequently, the nine parameters mentioned above are selected as characteristic input vectors of the SVM multiple classifiers. Owing to the fact that a single SVM only resolves the two-classifier problem, we set up a SVM model composed by several classifiers to distinguish different states of the pipeline. According to the application requirements analysis for leak detection, the pipeline has three types of recognition states: normal, small leak and big leak. As a result, we need to construct three SVMs to correspond with the three kinds of states. For the \(i\)th SVM, the recognition output of \(i\)th pipeline state is \(+1\) while the outputs of other two states are both \(-1\). Namely, the number of output variables is 3. When the pipeline states are normal, small leak and big leak, output variables of multiple classifiers are (\(+1\), \(-1\), \(-1\)), (\(-1\), \(+1\), \(-1\)) and (\(-1\), \(-1\), \(+1\)), respectively. (2) Classification Principle and Parameters Optimization  
The classification principle of SVM multiple classifiers is based on structural risk minimization principle and kernel function method [39]. The expression of discriminant function is:  
\[f(x)=\text{sgn}(\sum_{i=1}^{n}\alpha_{i}y_{i}k(x_{i},x)+b) \tag{2}\]  
where \(x_{i}\) and \(x\) represent training and measured samples, respectively; \(y=\{-1,\,+1\}\) is the classification label. \(\alpha\) denotes Lagrange coefficient vector, which satisfies that \(0\leq\alpha_{i}\leq C\) and \(\sum_{i=1}^{n}a_{i}y_{i}=0\), \(i=1\),2,...,\(n\), where \(C\) is the penalty factor. In Equation (2), \(b\) denotes the classification threshold value and \(k(x_{i}x)\) is the kernel function. In this paper RBF kernel function is adopted and its expression is:  
\[k(x_{i},x)=\exp[-\gamma\big{\|}x_{i}-x\big{\|}^{2}\,] \tag{3}\]  
where \(\gamma\) is the parameter of the kernel function. Simulation experiments show that RBF kernel function has better classification results than others. In the aspect of parameter selection, both \(C\) and \(\gamma\) are important parameters, which are able to directly affect classification precision. Here, a bilinear search method is used to work out the optimal parameters. Its principle is that different values of parameters combinations (\(C\), \(\gamma\)) have different properties to correspond with, so we use \(\log C\) and \(\log\gamma\) as the coordinates of parameter space and parameter combination (\(C\), \(\gamma\)) for maximum learning precision will occur in the vicinity of the straight line \(\log\gamma=\log C-\log\tilde{C}\).