Short-Term Power Generation Forecasting of a Photovoltaic Plant Based on PSO-BP and GA-BP Neural Networks

With the improvement in the integration of solar power generation, photovoltaic (PV) power forecasting plays a significant role in ensuring the operation security and stability of power grids. At present, the widely used backpropagation (BP) and improved BP neural network algorithm in short-term output prediction of PV power stations own the drawbacks of neglection of meteorological factors and weather conditions in inputs. Meanwhile, the existing traditional BP prediction model lacks a variety of numerical optimization algorithms, such that the prediction error is large. Therefore, based on the PV power plant in Lijiang, considering the related factors that influence PV output such as solar irradiance, environmental temperature, atmospheric pressure, wind velocity, wind direction, and historical generation data of the PV power station, three neural network algorithms (i.e., BP, GA-BP, and PSO-BP) are utilized respectively in this work to construct a short-term forecasting model of PV output. Simulation results show that GA-BP and PSO-BP network forecasting models both obtain high prediction accuracy, which indicates GA and PSO methods can effectively reduce the prediction errors in contrast to the original BP model. In particular, PSO owns better applicability than GA, which can further reduce the errors of the PV power prediction model.


INTRODUCTION
Over the recent decades, global photovoltaic (PV)-installed capacity has been steadily and gradually expanded Yang et al., 2020a;Muniappan, 2021). It is worth noting that the PV unit output is greatly affected by the operation environment, which is characterized by volatility, intermittence, and periodicity Zhang et al., 2015). As an uncontrolled energy source, its fluctuation also brings new challenges to the stable and economic operation of power grids (Wang Q et al., 2020;Padhy and Panda, 2021). For a PV power generation system, its geographical position, configuration, and the performance of the equipment are critical inherent factors influencing the PV power output. Moreover, PV power generation will also be influenced by external conditions, such as illumination intensity, cloud cover, temperature, and wind velocity. Due to the characteristics of uncertainty, randomness, and periodicity change with such meteorological factors, the output power of the PV system is consequently random and varies intermittently, which severely reduces the stability of the PV generator-set power output. It is verified from relevant studies that when the PV power penetration exceeds 10% of the total power, the maximum peakvalley difference of the power grid will be significantly increased, resulting in difficulties in peak load regulation, and affecting the power quality and the stability of power grid operation.
Therefore, to predict the output power of the PV system in 24 h utilizing weather information, we formulated reasonable dispatching and management scheme of the PV power plant and duly adjusted the proportion of PV connected to the grid, which can effectively reduce the impact to the power grid caused by the disproportionality of PV connected to the grid, and then achieving the security of grid-connected operation, smooth running, and economic dispatch for better economic benefit and social benefit.
Nowadays, the power forecasting approaches can be classified into statistical prediction techniques, physical prediction methods, and artificial intelligence prediction ways in view of the principle of forecasting methods. In the literature (Kazem and Yousif, 2017), the multi-layer perceptron (MLP), self-organizing feature mapping (SOFM) network, feedforward network (FFN), and support vector machine (SVM) model are compared in terms of prediction performance and prediction accuracy, and SOFM gets the lowest mean square error (MSE) value while the FFN attains the highest prediction accuracy. The literature (Tang et al., 2016) combines the entropy method and extreme learning machine (ELM) to predict the PV output power. First, the entropy method pre-process initial data which are the training set of the network, and finally, the PV output power is predicted by ELM, and experiments show that the combination of the entropy method and ELM can efficiently accelerate the prediction accuracy and the calculation speed. The solar zenith angle and solar azimuth angle are added to the input data set of the neural network to forecast PV power outputs. The results show that the proposed artificial neural network (ANN) model attains high accuracy in forecasting the PV power output under any weather conditions (Huang et al., 2016;Li et al., 2021).
Until now, the technique of the backpropagation (BP) neural network algorithm applied to solar power generation forecasting has attained certain achievements (Kaushika et al., 2014;Shen et al., 2019;Erdiwansyah et al., 2021). However, existing research studies mostly adopt one single algorithm, the genetic algorithm (GA) or particle swarm optimization (PSO), to improve the BP prediction model, lacking the comparative study of these two algorithms on the optimization effect for the BP prediction model (Liu et al., 2015;Liu et al., 2016;Liu et al., 2021).
To overcome the above problems, this work comprehensively considers the wind velocity, solar irradiance, wind direction, atmospheric pressure, humidity, ambient temperature, and other meteorological factors and the historical power generation data of PV plants, and adopts three neural network algorithms, i.e., BP, GA-BP, and PSO-BP, to construct a shortterm prediction model of PV power generation which can forecast the power outputs of the PV system every 15 min during the working time. The simulation test results verify that the modified GA-BP and PSO-BP prediction models have less error in contrast to the original BP forecasting model. Especially, the PSO has better adaptability than GA in optimizing the BP neural network.
The structure of this study is organized as follows: The principle of the BP neural network and the power forecasting model of traditional BP are introduced in Section 2. The main optimization principle of how GA and PSO optimize the weights and threshold values is elaborated in Section 3. In the meantime, the PV output power short-term prediction models by GA-BP and PSO-BP algorithms are constructed in Section 3. Simulation tests of three algorithms and detailed statistical analysis on the effectiveness of network optimization and forecasting model are elaborated and analyzed in Section 4. Ultimately, three conclusions are given in Section 5.

Principle of the BP Algorithm
The BP neural network is a kind of multilayer feedforward neural network with error backpropagation training, which displays good performance in self-organizing learning and achieves an arbitrary nonlinear map from inputs to outputs Zhao et al., 2021). Through the onward spread of input data and the backward spread of the error value, the BP network prediction model realizes the training process and then processes large-scale data in parallel (Yan et al., 2020;Zhu et al., 2021). In addition, it has certain robustness and fault tolerance, and the typical construction of a common three-layer BP neural network is represented in Figure 1. As shown in Figure 1, the number of neuron nodes in the input layer, hidden layer, and output layer are m, p and n, respectively. W ij is the weight connected with the input layer and the hidden layer; W jk is the weight connected with the hidden layer and the output layer; θ j is the threshold of the hidden layer; α k is the threshold of the output layer; (x 1 , x 2 , . . . , x m ) and (y 1 , y 2 , . . . , y m ) are input and output vectors of the BP neural network; Y h is the desired output; e is the difference value between the desired output and the actual output.
The two stages of BP network learning are as follows: the onward spread of input signals and the backward spread of error (Wagner and Mccomb, 2019). In the first stage, the training sample information is inputted in the input layer and then processed by the hidden layer before being transferred to the output layer. If there is an error between the actual output and the predicted output, the second stage will be executed. The second process is to transfer the error of the output signal from the hidden layer to the input layer through the original path. Then, based on the assigned error signal, each neuron of all layers adjusts the connection weights and threshold values of each network and finally makes the error signal gradually decrease. These two processes are performed alternately and repeatedly until the algorithm converges and the satisfactory error accuracy is obtained.
The fundamental execution procedure of the BP algorithm is elaborated as below: a) Initialize all the weights and threshold values of the BP network, i.e., set as a random figure within the range of [−1,+1]; b) Specify a network training sample set, which contains the input vector x and expected output result Y h ; c) Calculated the output values of the hidden layer and output layer; d) Adjust the connection weights and thresholds of the network.
The standard BP neural network algorithm adopts the gradient descent learning approach to modify the weight and threshold vector: where the W(k + 1) and W(k) denote the network connection weight/threshold value in the (k + 1) th and k th iteration; α represents the training rate; D(k) is the negative gradient of network error to weights and thresholds which indicates the fastest descending direction of the gradient; e) Repeat the steps b) to d) until attaining satisfactory error accuracy.

Power Prediction Model of the BP Network
In this work, the BP neural network algorithm is employed to forecast the output power of a 10 MW PV station in Lijiang, China. The three-layered construction is employed, and the input layer is the atmospheric environment parameters consisting of environment temperature, humidity, illumination intensity, wind velocity, wind direction, atmospheric pressure, real irradiance, and practical power outputs. The initial node number of the hidden layer neuron p is determined by empirical Eq. 2. And then, the trial-and-error method is used to gradually adjust the number of the hidden layer node to minimize the error of the neural network. Finally, the number of the hidden layer node is set to be 10.
where the value of v ranges from 1 to 10.
The output layer has one neuron node. Therefore, the threelayer neural network structure used for short-term power prediction is 8-10-1.
The BP neural network algorithm can fit various complex nonlinear relations between any inputs and outputs through continuous training and learning and consequently has certain robustness and generalization ability. However, the BP neural network algorithm has inherent defects (Karakose et al., 2014). The BP neural network algorithm is likely to trap in local extremum during data training, resulting in data training failure since it adopts the standard gradient descent algorithm. Meanwhile, the BP algorithm has the drawback of data overfitting phenomenon (Wang G et al., 2020). Generally speaking, the prediction ability of the neural network is directly proportional to the sample training ability. In fact, with the improvement of the sample training ability, the prediction ability of the BP neural network will reach an extreme limit and then decline, which is the so-called overfitting phenomenon. To settle the aforementioned shortcomings of the BP neural network algorithm, GA and PSO are employed to optimize the network structure of BP.

GA-BP AND PSO-BP FORECASTING MODELS
The main inspiration and the optimization process of GA-BP and PSO-BP are elaborated in this section, respectively.

GA-BP Neural Network
GA is a multiple-agent searching global optimization algorithm based on biological evolution and therefore can avoid falling into local optimal solutions (Deshkar et al., 2015). GA adopts the heuristic principle and manages the search agents according to their fitness function values. Specifically, GA selects individuals with high fitness for genetic operation (selection, chromosomal chiasma, and mutation) and simulates the natural evolution process of survival of the fittest, to search for the optimal solution (Yang et al., 2021a).
The traditional divination model of the BP network has some defects, such as easily falling into local optimum, low convergence speed, and the data overfitting phenomenon. Because GA has a strong macro exploration ability and good global optimization performance (Rajan et al., 2017), it is used to optimize the connection weight and threshold value between various layers in the BP neural network model. Theoretically, GA can make up for the defects of the BP neural network algorithm and improve the prediction approximation ability of the BP neural network model. The optimization procedure of the BP neural network by GA mainly includes population initialization, fitness function establishment, selection, crossover, and mutation operation.

Population Initialization of GA
Common chromosome encoding methods of GA include binary encoding, real encoding, character encoding, and string encoding (Zhou et al., 2020;Yang et al., 2021b). There are eight environment input variables, one output neuron nodes, and 10 neuron nodes in the hidden layer. Hence, the number of weight W ij and W jk are 8 × 10 and 10 × 1, respectively. And, there are 10 threshold values in the hidden layer and one in the output layer. The real number encoding is adopted for population individuals. The information contained in a chromosome includes the weights connecting the input layer and hidden layer and those connecting the hidden layer and output layer, and the threshold values of the hidden layer and output layer. As a result, the length of the individual code is 8 × 10 + 10 + 10 × 1 + 1 101.

Fitness Function
Based on the connection weights and thresholds attained by the individual code, the absolute value sum of the forecasting bias of training data is regarded as single fitness, which can be calculated as below: where n means the output neurons' number, y i denotes the desired output of the i th neural node, z i represents the predicted output of the i th neural node, and k is a coefficient.

Selection, Crossover, and Mutation
The GA selection operation is executed based on roulette, i.e., selection on fitness proportion. The selected probability C x of the individual x is calculated as follows: where F x is the fitness of the individual x, N represents the population size, and k is the coefficient. In order to ensure the balance between population diversity and convergence of GA, an adaptive crossover mutation operator is adopted. When one individual fitness is less than the average fitness, the proposed GA increases the probability of crossover and mutation to promote individual updating and population diversity; otherwise, GA decreases that to guarantee the high fitness one's proportion in population and improve the convergence speed of GA.
The adaptive crossover operator can be expressed by the following equation: The adaptive mutation operator can be expressed by where F a is the fitness of the individual before the crossover; F b is the fitness of the individual before mutation; F max and F avg denote maximum fitness and average fitness values of the current population; and K 1 , K 2 , K 3 , and K 4 are all random numbers between 0 and 1.

Process of GA-BP
Above all, the summation of connection weights between various layers and of thresholds of each layer is determined based on the BP network construction. Second, the individuals in the population are encoded. And then, the optimal individual is obtained by selection, crossover, and mutation which are regarded as the best original weights and thresholds. Lastly, the BP network is applied to training data and prediction simulation until the prediction error is acceptable or the iterations terminate. The flow chart of the GA-BP algorithm is represented in Figure 2

PSO-BP Neural Network
PSO is a swarm intelligence optimization algorithm derived from the predation behavior of birds in nature (Kennedy and Eberhart, 1995;Yang et al., 2020b). During the birds foraging, each bird usually follows the one closest to the food and searches its surroundings to get food Zhang X et al., 2021;Yang et al., 2021c). Similar to GA, PSO also utilizes the fitness of individuals in the population to evaluate the cost of individuals but without the operation of crossover and mutation. Each particle in the population that contains information of every weight and threshold in the BP neural network is characterized by three indicators, i.e., particle position, speed, and fitness. Moreover, the best initialization weights and thresholds of the BP neural network can be obtained by tracking the optimal positions of individuals and populations. Thus, both the convergence speed and prediction performance of the BP neural network can be improved.

Population Initialization of PSO
Based on the construction of the BP neural network, the initialization population of the PSO algorithm is a 101 dimensional vector. Moreover, the fitness function still adopts the training error summation in GA-BP calculated by Eq. 3. And then, the optimal population particle obtained by iteration searching represents the optimal initialization weights and thresholds of the BP neural network. Afterward, the BP neural network is applied to the training data and prediction simulation.

Particle Updating of PSO
For each iteration of the PSO algorithm, every particle updates its own velocity and position through individual historical extremum and global extremum (Xi et al., 2016;Babu et al., 2018;Zhang K et al., 2021). The update formulas are as follows. velocity updating: position updating: where t is the current iteration; ω is the weight of inertia; a 1 and a 2 are the acceleration factors of the particles, which are nonnegative constants; V i (t) represents the speed of the i th agent in the t th iteration; and r 1 and r 2 are the mean random values ranging from 0 to 1. And, the inertia weight is alterable calculating as below: where t max means maximum iterations; t is the current number of iteration; ω max represents the maximum weight of inertia, the typical value of which is 0.9; and ω min represents the minimum weight of inertia, the typical value of which is 0.4. In general, ω is close to 1 to strengthen the exploitation ability of PSO when the maximum velocity of the particle is very small; otherwise, ω is designed as 0.8 to emphasize the exploration phase.

Process of PSO-BP
Compared with GA, PSO does not encode the chromosome during the initialization but initializes the speed and position of the particle swarm on the basis of the total number of connection weights between various layers and of thresholds of each layer based on the construction of the BP network. Moreover, PSO-BP adopts the same fitness function with GA-BP. After the iterative search for the individual and population best solution, the global best agent which includes all weights and threshold values is regarded as the initial parameters of the BP neural network for improving its prediction effect. The flow chart of the PSO-BP algorithm is demonstrated in Figure 3.

SIMULATION TEST
The experimental data in this work are derived from the historical record data of the PV power plant in Lijiang, Yunnan, China. In this work, meteorological environment data and historical power generation data from January 1, 2017, to April 30, 2018, are extracted from the database, including six meteorological indicators, i.e., solar irradiance, wind speed, wind direction, temperature, atmospheric pressure, and humidity. At an interval of 15 min, a total of 43,737 pieces of data are reserved for the simulation test after screening and sorting, among which 43,688 pieces of data are used to train the neural network, and the latter 49 pieces of data are regarded as a test set.

Simulation Data Pre-processing
On account of the particularity of the selected data and the large fluctuation of PV power generation within a day, the output power varies greatly at all times. In addition, the units of the historical PV output power data and meteorological data and their values are different. Therefore, it will affect the accuracy and effect of prediction to directly input them into the power prediction model. To guarantee the validity of experimental results, the premnmx function is adopted to uniformize the experimental data which will be evenly distributed between 0 and 1 after uniformization processing. Besides, the premnmx function is formulated as the following equation.
where P u denotes the data after uniformization processing; P is the initial data before uniformization processing; andP max and P min mean the maximum and minimum value in the input information, respectively.

Prediction Error Indicator
For the sake of accurately reflecting the actual deviation of the prediction error of the proposed model, two error indicators are introduced. Concretely speaking, the root mean square error (RMSE) (Chen et al., 2019) and mean absolute percentage error (MAPE)  are the error indexes of local PV power station output forecasting. Particularly, the specific reference formulas are: where N is the summation of test data in the test set, P pi means the predicted PV output power at the i th time-tag, and P ri denotes the measured PV output power at the i th time-tag.

Simulation Test on the Prediction Model
The power output data of the forecasting model are trained by BP, GA-BP, and PSO-BP neural network algorithms, respectively. And, the prediction results and measured results are compared and analyzed. Moreover, after repeated imitation tests, the training parameters of each algorithm are determined as shown in Table 1. In particular, all simulation tests are performed by Matlab 2019b through a personal computer with IntelR CoreTMi5 CPU at 3.0 GHz and 16 GB of RAM.
In the simulation test, the neuron number for each layer of the designed network (i.e., input, hidden, and output layer) is 8, 10, and 1, respectively. The comparison curves between the predicted power and measured power of the three neural network algorithms are shown in Figure 4, and the error curves of the three algorithms are depicted in Figures 5, 6. Besides, the corresponding prediction error average of the three algorithms is shown in Table 2.
Based on the above comparison power curves of the PV power station between short-term prediction and the actual measured value and the prediction error data, it can be inferred that PSO-BP and GA-BP both can realize the short-term power forecasting of the PV plant, but the original BP neural network algorithm has a relatively large error with larger forecasting power than the actual value. Particularly, the PSO-BP network has more accurate prediction performance than GA-BP due to smaller values in two error indicators of the RMSE and MAPE. In other words, both of GA and PSO can optimize the BP prediction model and effectively reduce the prediction error of the BP prediction model. In addition, the optimization effect of PSO is better than that of GA, which indicates that PSO has better applicability.

CONCLUSION
In this work, given the lack of multiple numerical optimization algorithms in the existing traditional BP prediction model, the negligence of meteorological factors and weather conditions in inputs and the large prediction error, GA and PSO are introduced to improve the network construction of the BP algorithm and further establish the PV power generation short-term prediction model, thus improving the weights and thresholds of BP neural networks. Thus, three PV output short-term forecasting models of BP, GA-BP, and PSO-BP are established. Meanwhile, the comparison between the predicted and measured power curves and error analysis are studied. The following conclusions can be stated: • Both GA and PSO algorithms can efficiently enhance the forecasting accuracy of the BP divination model and optimize the prediction effect; • Compared with GA, PSO has stronger applicability in neural network structure optimization; • The PSO-BP prediction model has a higher prediction accuracy and can be used as an effective short-term power prediction model for this aforementioned PV power station in Lijiang.
The results show that this work is crucial for the power management department to formulate the reasonable energy management and dispatch scheme to undertake the stability and safety of large grid-connected PV.

DATA AVAILABILITY STATEMENT
The original contributions presented in the study are included in the article/Supplementary Material, further inquiries can be directed to the corresponding author.

AUTHOR CONTRIBUTIONS
YL contributed to conceptualization, formal analysis, and writing of the original draft; LZ helped with the supervision and review and editing of the manuscript; PG performed visualization and validation; BY contributed to data curation and visualization; YH was responsible for formal analysis and software; CL was responsible for investigation, validation, and supervision.