# Off-Grid Power Plant Load Management System Applied in a Rural Area of Africa
## 5 Pattern Matching-Based Load Anomaly Detector
### Pattern Matching Scheme
#### 5.2.1 Result Pattern Matching  
General regression model-based anomaly detectors detect anomalies by comparing the differences between the prediction result and real data. This approach cannot avoid the influence of prediction error on the detection results and lacks a reasonable interpretation process. In this study, pattern matching for the results is designed to first determine whether the prediction result and the real data can be classified into the same benign pattern. The classification model used is an SVM; such models have been widely used in many classification studies and flexibly strengthened by the kernel method. Notably, because the SVM operates locally and does not need to have the same functional form for all the data, the computational cost can be reduced [17]. However, in addition to the kernel function, the penalty factor \(C\) of the SVM also seriously affects its classification performance, and it is difficult to select due to the lack of a corresponding theoretical basis [21; 23]. Therefore, to address this issue, the FOA is introduced to select the best \(C\) for the SVM according to the training data. Fruit Fly Optimization Algorithm  
The FOA is a swarm intelligence method that was first proposed by [PERSON] [23]. The FOA provides a new method for global optimization by imitating the food-finding behavior of fruit flies. Fruit flies have superior vision compared to that of other species. The food-finding process of fruit flies can  
Figure 3: The results of benign data training. be summarized as follows. First, one fly smells the food source using its ophresis organ, and it flies to the food location. Second, after the fly gets close to the food, sensitive vision is used to find food and the locations of flocks of fruit flies. The fruit fly then travels in the optimal direction. To the food-finding process, the FOA can be divided into several steps, as follows [24]:  
1. Randomly initialize the following parameters: initial location of fly {\(X_{init}\), \(X_{init}\)}, maximum iteration number _maxgen_, population size _sizepop_, and random flight distance range _FR_. 2. Give the random flight direction and the distance for food searching for each individual fruit fly in a swarm. \[\left\{ \begin{array}{rcl}\mathrm{X_{i}}&=&\mathrm{X_{axis}}+\mathrm{ RandomValue}\\ \mathrm{Y_{i}}&=&\mathrm{Y_{axis}}+\mathrm{RandomValue}\end{array} \right.\] (4)
3. Initially, the food cannot be seen; therefore, the distance to the origin is estimated (_Dist_), and the smell concentration judgment value (\(S\)) is calculated, which is the reciprocal of the distance: \[\left\{ \begin{array}{rcl}\mathrm{Dist_{i}}&=&\sqrt{\mathrm{X_{i}}^{2}+ \mathrm{Y_{i}}^{2}}\\ \mathrm{S_{i}}&=&\frac{1}{\mathrm{Dist_{i}}}\end{array} \right.\] (5)
4. Substitute the smell concentration judgment value (\(S\)) into the smell concentration judgment function to determine the smell concentration (\(\mathrm{Smell_{i}}\)) for a given location of the fruit fly: \[\mathrm{Smell_{i}}\ =\ \mathrm{Function(S_{i})}\] (6)
5. The fruit fly with the maximum smell concentration among those in a fruit fly group is screened: \[[\mathrm{bestSmell,\ bestIndex}]\ =\ \mathrm{Max(Small)}\] (7)
6. The best smell concentration value and coordinate (X, Y) are retained. The fruit fly group will use vision to fly toward this location: \[\left\{ \begin{array}{rcl}\mathrm{Smellbest}&=&\mathrm{bestSmall}\\ \mathrm{X_{axis}}&=&\mathrm{X(bestIndex)}\\ \mathrm{Y_{axis}}&=&\mathrm{Y(bestIndex)}\end{array} \right.\] (8)
7. Repeat the implementation of Steps 2-5 and then determine if the smell concentration is superior to the previous iterative smell concentration; if so, implement Step 6. Fruit Fly Optimization Algorithm for Optimal Penalty Factor Selection of SVM  
The FOA is used to select the best penalty factor for the SVM and to effectively improve the classification accuracy. The process of optimizing the SVM penalty factor with the FOA can be described as follows [21; 23]. 1.