1. Introduction
In the electricity market, electricity price forecasting is one of the basic conditions for optimal decision-making. The prediction accuracy of the electricity price directly affects the income and risk of transactions and it is the information that market participants pay close attention to [
1,
2,
3,
4]. Power generation companies need to determine the bidding curve according to the predicted electricity price in order to maximize profits while reducing risk [
5,
6]. However, due to the advance of power system development, the fluctuation of the electricity price is not increasing, but affected by many uncertain factors, such as the change of supply and demand, network congestion, market and the psychology of bidders [
7]. These random factors, which are difficult to quantify and screen, make it more difficult to forecast electricity price.
At present, the mainstream short-term electricity price forecasting methods can be divided into traditional methods and intelligent methods. The main idea of traditional methods is to take time series as the basis of modeling, such as in the auto-regressive method, auto-regressive moving average method, multiple linear regression method and so on [
8,
9,
10,
11,
12]. The advantages of these models are simple models and high speed of operation, but the prediction accuracy of the data with nonlinear relationship is not high. Intelligent methods mainly include the neural network, support vector machine, random forest, etc. [
13,
14,
15]. Deep learning is also one of the popular intelligent prediction methods, such as long short-term memory (LSTM) and gated recurrent unit (GRU) [
16,
17,
18,
19,
20]. Among intelligent methods, the neural network has a strong nonlinear function fitting ability. The main reason is that the method collects abstract features between massive data in the form of multi-layer nonlinear mapping, which is of positive significance to obtain accurate electricity price forecasting results.
The research of artificial neural network technology began in the 1940s. After decades of research, its theory has become quite mature. It has been widely used in various engineering fields, such as prediction, pattern recognition and image processing, control and optimization, prediction and intelligent information management, communication, space science and so on [
21,
22,
23,
24,
25]. The BP neutral network is one of the most widely used models in electricity price forecasting. Various types of neural networks, such as convolutional neural networks, wavelet neural networks and adaptive neural networks, have been used to forecast electricity prices with good results [
26,
27]. Long and short-term memory neural networks are often used to solve the very random and sequential electricity price prediction problem due to their unique memory function [
18].
The BP neural network has been improved in both network theory and performance. Its outstanding advantage is that it has a strong nonlinear mapping ability and flexible network structure. The number of middle layers and the number of neurons in each layer of the network can be set arbitrarily according to the specific situation and its performance varies with the difference in the structure. However, the BP neural network also has some defects: the learning speed is slow, so even a simple problem generally needs hundreds or even thousands of learning to converge; it is easy to fall into local minimum; there is no corresponding theoretical guidance for the selection of the number of network layers and neurons; there is limited network promotion capacity [
28,
29,
30]. For the above problems, there have been many improvement measures and the most researched issue is how to accelerate the convergence speed of the network and avoid falling into local extremum as much as possible. Many studies have overcome the above shortcomings by combining some optimization methods, such as genetic algorithm, improved LM algorithm, principal component analysis (PCA), Markov chain, etc., in order to improve the convergence performance of the network and improve the stability and predictive ability of the model [
31,
32,
33,
34].
Particle swarm optimization (PSO) is a bionic stochastic global optimization method based on swarm intelligence. It has many advantages, such as simple process, few parameters and easy implementation. It is widely used in various optimization problems [
35]. However, the original PSO algorithm has obvious disadvantages. One is that the convergence speed is slow in the later stage. If the inertia coefficient is large at this time, the particles do not accurately converge to the optimal solution. The other is the “premature” phenomenon, that is, in the early stage, the particles quickly approach the local optimal value and finally converge to the local optimal value [
36,
37]. Therefore, this paper uses the linearly decreasing inertia coefficient and the simulated annealing algorithm (SA) to improve the PSO algorithm, obtaining the SAPSO algorithm, so as to overcome the above shortcomings of the PSO algorithm.
The structure of the BP network model is mainly composed of three parts, namely, the input layer, the hidden layer and the output layer, which are associated to weights, thresholds and mapping functions. The current research shows that, in the design of the BP network, the choice of network structure depends on human factors; further, not every time the results are satisfactory and there are many parameters to be estimated, which makes it prone to over-fitting problems, so that the generalization ability of the model is poor [
38]. In addition, the neural network for electricity price forecasting also needs to be based on a large number of test data and the analysis of the influencing factors is difficult, so it is difficult to determine the input characteristics. Based on this, this paper uses the maximum information number and Pearson coefficient to analyze the main factors affecting the electricity price and uses the improved particle swarm optimization algorithm to optimize the weights and thresholds of the three-layer BP network, as well as establishing the electricity price forecasting model of the SAPSO-BP network, which is calculated by case data and compared with the traditional BP network and PSO-BP network, in order to find a more accurate electricity price forecasting method.
2. Feature Selection
There are many factors affecting the price of electricity, including some random factors that are difficult to determine and quantify. The holistic approach is obviously impractical. According to the analysis of actual data, it is necessary to conduct a correlation analysis for the factors that may affect the price of electricity and select the main influencing factors as the input factors of neural network prediction. The following factors were taken into consideration:
Market supply and demand index (SDI). System load demand generally has a direct impact on the price of electricity; usually, the greater the electricity consumption, the higher the price of electricity. At the same time, the electricity supplied by the system also affects the price of electricity. Generally, the more the maximum available capacity of the system is, the lower the price of electricity is. Therefore, it’s not reasonable to think about demand and supply alone, but to put them together and use SDI as the impact factor. The specific calculation formula is as follows:
In the formula,
D(
t) is the maximum load in the forecast period
t and
Smax(
t) is the maximum available capacity of the period
t;
Previous system marginal electricity price (SMP). Because the bidding mode in the system does not change greatly in a short time, the previous SMP can be used as a strong influence factor in the short-term electricity price forecast;
The installed capacity ratio, that is, the proportion of the installed capacity of the power plant in the total system capacity; generally speaking, the larger the proportion, the greater the influence of the power generation company on the quotation;
System reserve demand and reactive power demand are also one of the factors that affect the system electricity price.
In this paper, the maximum information coefficient (MIC) and Pearson correlation coefficient are used to comprehensively evaluate the influence of various factors on electricity price fluctuation.
The Pearson coefficient is used to measure the linear correlation between two variables and its value is between −1 and 1. Greater than 0 means positive correlation and less than 0 means negative correlation. The calculation method is the quotient of covariance and standard deviation of two variables and the formula is as follows:
The MIC is a kind of excellent data correlation calculation used to measure the degree of linear or nonlinear correlation between two variables and is of high accuracy. The idea of the MIC is to draw two random variables into a scatter graph and then divide them with small squares continuously to calculate the probability of falling on each square, so as to estimate the joint probability density distribution. The calculation formula is as follows:
In the formulas, and represent the number of cells divided on the x and y axes and is the joint probability between the two variables.
The dataset contains 50 samples and each sample contains values of supply and demand index, previous SMP, system reserve rate, installed capacity and actual electricity value [
39]. The previous SMP and the actual electricity price are between 0.1 and 0.6. The supply and demand index, system reserve rate and installed capacity are all in the form of ratios and their values are between 0 and 1.
First, we calculated the MIC value and Pearson coefficient between the above four factors and the actual electricity price for all samples, with
= [
x1,
x2, …,
xi],
i = 50, being the influencing factor of 50 samples and
= [
y1,
y2, …,
yi],
i = 50, being the electricity price of 50 samples. The calculation results are shown in
Table 1. According to the calculation results in
Table 1, it can be seen that the MIC and Pearson coefficient values of SDI and previous SMP, are high, indicating that they are the main factors affecting the electricity price. The Pearson coefficient values of system reserve rate and installed capacity ratio are low but the MIC values are not, indicating that the linear correlation between them and electricity price is weak, but the nonlinear correlation is strong.
Combined with the above analysis of the related influencing factors of electricity price, four factors, such as supply and demand index, previous SMP, system reserve rate and installed capacity ratio, were selected as the input factors for the prediction of electricity price by the neural network.
4. Results
Considering the neural network activation function is sensitive to the data between −1 and 1, all sample data were normalized before network training to reduce training time and improve training effect. The electricity price, supply and demand index, previous SMP, system reserve rate and installed capacity were normalized according to Equation (15).
In the formula, X′ is the normalized input variable and max(X) and min(X) are the maximum and minimum values of the variable to be normalized, respectively.
4.1. Algorithm Parameter Setting
The parameter selection of the intelligent algorithm has a great impact on the accuracy and stability of the prediction results. Through many simulation experiments, the parameters of the SAPSO-optimized BP network algorithm were set as follows: learning factor c1 = 1.5, c2 = 1.5; particle position limit xmax = 10 and xmin = −10; speed limit vmax = 5 and vmin = −5; cooling rate q = 0.998. The number of particles was 250 and the maximum number of iterations was 200. The PSO-optimized BP network adopts the same parameters as above to ensure the comparability of the experiment.
The structure setting of the BP network also has a certain impact on the prediction effect. The neural network structure includes input layers, hidden layers and output layers. The network was established by the function newff. Due to the small number of input variables and samples, the network structure did not need to be too complicated; then, the number of hidden layers of the BP network was selected as 1. Here, we used Matlab R2017a and the version number of Neural Network Toolbox used was Version 10.0. The transfer functions of hidden and output layer were Tansig and purelin, respectively, and the training function of back propagation was trainlm, all of which were set by default, with faster speed and higher accuracy. Tansig is a tangent siomoid transfer function and the input value can take any value and the output value is between −1 and +1; purelin is a linear transfer function and the input and output values can be arbitrary. By changing the number of hidden layer neurons to 3, 9 and 15 respectively, we established nine models—BP-3N, BP-9N, BP-15N, PSO-BP-3N, PSO-BP-9N, PSO-BP-15N, SAPSO-BP-3N, SAPSO-BP-9N and SAPSO-BP-15N—to predict the sample data, compare the results, explore the prediction effect of the improved algorithm and observe the impact of the number of hidden layer neurons on the prediction results.
When forecasting electricity prices, we used the first 25 samples of the dataset as the training set and the last 25 samples as the test set. The predictive network input variable is xij, where i = 1, 2, …, 25, j = 1, 2, …, 4, representing the four electricity price influencing factors in the 25 samples, while the output variables are yi, i = 1, 2, …, 25, representing the predicted electricity value of the 25 samples.
4.2. Evaluating Indicator
In order to verify the accuracy and feasibility of the electricity price prediction model proposed in this paper, the mean absolute percentage error (MAPE) and root mean square error (RMSE) were used as the quantitative criteria for the prediction accuracy evaluation and their expressions are as follows:
In the formula, n is the number of predicted data, Y(t) is the actual value of the electricity price at the predicted time and Y × (t) represents the predicted electricity value at the predicted time.
4.3. Results Analysis
Sample data were collected according to the four impact factors identified above and the data in Table 3-1,2 in Reference [
39] were used for training and test. The nine models, BP-3N, BP-9N, BP-15N, PSO-BP-3N, PSO-BP-9N, PSO-BP-15N, SAPSO-BP-3N, SAPSO-BP-9N and SAPSO-BP-15N, were trained with the training set data and then they were tested with the testing set data.
Table 3,
Table 4 and
Table 5 show the predicted value and error calculation results of electricity price for testing set. It can be seen that, no matter how many neurons in the hidden layer of the neural network, the prediction effect of SAPSO-BP is better than that of PSO-BP and the electricity price prediction effect of the BP network is the worst. Although individual samples have large error values, generally speaking, the predicted electricity price of SAPSO-BP is the closest to the real electricity price and the prediction error is the smallest.
Figure 5 shows the comparison between the predicted electricity price and the real electricity price of the nine models for the testing set. The trend of the electricity price curve is consistent with the data in the table, which can show that the SAPSO-BP model has higher accuracy. The longitudinal comparison in
Figure 5 shows that the prediction effect order, from good to bad, is SAPSO-BP, PSO-BP and BP. The horizontal comparison in
Figure 5 shows that the number of neurons in the hidden layer has little effect on the prediction results. The overall prediction accuracy of the SAPSO-BP method is relatively high and most of the sample prediction errors were less than 5%, but the prediction accuracy of the first, 11th and 17th samples was very poor, exceeding 20%, or even as high as 60%. This should not be a problem with the network model, because the sample training accuracy can meet the preset requirements. The problem may come from the data themselves and there are two possibilities. First, the training sample data contain noise and abnormal samples, which causes the network to fall into a wrong mode in order to correct the above defects during training, causing the illusion that the training accuracy meets the requirements but the network mode is wrong, which leads to large errors in the prediction results. Second, there are noise and abnormal samples in the test sample data, which leads to large errors in the prediction results. In view of the above problems, methods such as wavelet analysis and rough set theory can be used in advance to correct the sample data to eliminate inherent noise and anomalies and improve the accuracy of prediction.
Table 6 shows the calculated values of the evaluation indexes of each model for the testing set. The mean absolute percentage errors of the BP model with hidden layer neurons of 3, 6 and 9 were 32.89%, 27.90% and 38.00%, respectively, and the root mean square errors were 0.0858, 0.0885 and 0.0902, respectively. The mean absolute percentage errors of the PSO-BP model with hidden layer neurons of 3, 6 and 9 were 28.29%, 21.83% and 17.06%, respectively, and the root mean square errors were 0.0688, 0.0780 and 0.0733, respectively. The average absolute percentage errors of the SAPSO-BP model with hidden layer neurons of 3, 6 and 9 were 9.03%, 7.63% and 9.71%, respectively, and the root mean square errors were 0.0639, 0.0548 and 0.0577, respectively. According to the evaluation index, the results of the SAPSO-BP model are obviously better than those of the PSO-BP and BP model. The number of hidden neurons has little effect on the results. For the SAPSO-BP model, when the number of hidden neurons is 9, the prediction result is slightly better than the other two cases.
Figure 6 shows the regression curve of predicted electricity price and actual electricity price of the nine models for the testing set. The R value represents the correlation between the predicted value and the actual value, which can explain the fitting degree between the network output value and the actual value. The closer the R value is to 1, the better the model fitting, but it may also be over fitting. It can be seen, from the figure, that the fitting degree of SAPSO-BP model is the best and the R value is very close to 1. The R value of BP-15N is also close to 1. However, according to the predicted electricity price data, the prediction result is not good, which may be due to too many hidden layer neurons and over fitting. Therefore, the selection of the neural network model should be suitable, not based on the assumption that the more complex the model, the better.
Figure 7 shows the comparison of convergence curves of different algorithms. By comparing the convergence process between SAPSO-BP and PSO-BP, it can be seen that PSO-BP, apparently, incurred convergence stagnation several times, while SAPSO-BP improved the phenomenon by which the PSO algorithm is prone to local convergence stagnation by optimizing the PSO algorithm. In addition, the SAPSO-BP algorithm converged around 80 generations, while PSO-BP converged to the optimal value around 100 times. Therefore, the SAPSO algorithm-optimized BP neutral network has better convergence effect and faster convergence speed.