## 4 BP and GA-BP Neural Network Realization
### BP Neural Network Model Design  
(1) The input and output nodes are decided upon: this model selects the wind power data of a wind power plant in Seville, Spain, within a total of 96 h in 4 days. Firstly, it is necessary to make the data normalized. The normalization of sample data mainly serves to eliminate the difference in the order of magnitude between the influencing factors, unify the data processing, and improve the prediction accuracy. This topic adopts the normalization method as shown in the following formula:  
\[x_{gij}=\frac{x_{ij}-x_{imin}}{x_{imax}-x_{imin}} \tag{9}\]  
where \(x_{gij}\) is the normalized value of the \(j\) sample data of the \(i\) influencing factor; \(x_{ij}\) represents the \(j\) sample data of the \(i\) influencing factor; \(x_{imin}\) is the minimum value of the \(i\) influencing factor; and \(x_{imax}\) is the maximum value of the \(i\) influencing factor.  
For the normalization of the wind degree, the wind direction indicates the direction of the wind, the circle is divided into 360 degrees, and north is 0 degrees. To distinguish wind directions in every degree, the value sine and cosine of wind direction are taken as input. This is to mitigate the large gap between the data affecting the training effect. Selecting the sine and cosine values of the wind direction for normalization is a good choice.  
In this model, the average relative temperature, pressure, humidity, wind speed, and sine and cosine wind direction angles are selected as input variables, namely \(i=6\). The real -time electricity price of the wind power plant or wind power load is taken as the prediction target, so the output node number is \(k=1\).  
(2) Determine the hidden layer numbers.  
The determination of the number of nodes in hidden layers generally requires testing by setting a different number of nodes, comparing the global error of their prediction results, and constantly adjusting the number of hidden layer nodes to test the algorithm. In the actual training, the following formula is generally adopted for a candidate number of hidden layer nodes, and then the number of nodes with the minimum global error is selected as the number of hidden layer nodes.  
\[l=\sqrt{m+n}+a \tag{10}\]  
where \(a\) is the empirical constant, usually \(1<a<10\), and \(m\) and \(n\) represent the input number and output number. Through the continuous adjustment of network training, the prediction error is minimized when the number nodes in the hidden layer is 6.  
(3) Determine the value of the learning rate.  
As an important parameter, the learning rate determines the changes in weights and thresholds in the backpropagation process of the BP neural network. If the learning rate is excessively large, the stable operation of the system may be affected. However, when the model has a small learning rate, the time for training may be directly affected. Hence, the program will take a long time to converge. Therefore, a learning rate of 0.001 is selected in this model.  
(4) Network performance is evaluated by error parameters.  
Coefficient of determination (R\({}^{2}\)):  
\[\text{R}^{2}=1-\frac{\sum(\overline{y_{i}}-y_{i})^{2}}{\sum(\overline{y_{i}}- \overline{y})^{2}} \tag{11}\]  
Mean square error (MSE):  
\[\text{MSE}=\frac{\sum_{i=1}^{n}{(y_{i}-\overline{y_{i}})^{2}}}{n} \tag{12}\]  
Root mean square error (RMSE):  
\[\text{RMSE}=\sqrt{\frac{\sum_{i=1}^{n}{(y_{i}-\overline{y_{i}})}^{2}}{n}} \tag{13}\]  
Mean absolute percentage error (MAPE):  
\[\text{MAPE}=\frac{1}{n}\sum_{i=1}^{n}\left|\frac{y_{i}-\overline{y_{i}}}{ \overline{y_{i}}}\right|100\% \tag{14}\]  
Residual prediction deviation (RPD):  
\[\text{RPD}=\frac{standard\ deviation}{RMSE} \tag{15}\]  
where \(y_{i}\) is the actual load value; \(\overline{y_{i}}\) is the predicted load value; and \(n\) is the number of historical load data.