Wind-solar short-term power prediction method based on firefly optimization and random forest (FA-RF)

By combining non-parametric kernel density estimation and Frank-Copula function and combining firefly optimization algorithm to adjust the random forest model, the accuracy and generalization ability of short-term power prediction of scenery are solved, more efficient scenery output prediction is achieved, and energy management is promoted and the development of renewable energy.

CN119005003AInactive Publication Date: 2024-11-22ZHEJIANG UNIV OF TECH
View PDF 11 Cites 0 Cited by

Patent Information

Application Number
CN202411218470.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-02
Publication Date
2024-11-22
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing short-term power prediction methods for scenery have limitations in dealing with complex and variable meteorological conditions and nonlinear relationships. There are problems with data quality, model generalization ability and computing efficiency, making it difficult to achieve accurate and efficient predictions.

Method used

The non-parametric kernel density estimation method is used to fit the scenery data, and the combined scenery distribution model of the Frank-Copula function is constructed, and the parameters of the random forest model are adjusted through the firefly optimization algorithm to improve the accuracy and generalization ability of the scenery output prediction.

Benefits of technology

It improves the accuracy and generalization ability of short-term power prediction of scenery and light, generates more realistic and reliable scenery output scenarios, and promotes energy utilization efficiency and sustainable development of renewable energy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119005003A_ABST
    Figure CN119005003A_ABST
Patent Text Reader

Abstract

A wind and light short-term power prediction method based on firefly optimization and a random forest algorithm comprises the steps that firstly, a non-parametric kernel density estimation method is used for conducting probability distribution modeling on measured data of wind and light, a kernel density expression of wind and light output is obtained, a wind and light electric field output joint distribution model based on a Frank-Copula function is established on the basis, and a wind and light electric field output joint distribution model is established; and generating wind and light output scenes with correlation for subsequent wind and light output prediction. And then respectively constructing a firefly algorithm (FA) parameter optimization model and a random forest (RF) prediction model, and optimizing parameters of the random forest prediction model through a firefly algorithm. And finally, carrying out comparative analysis on prediction results and errors under the RF algorithm and the LSTM neural network algorithm and prediction results and errors under the FA-RF algorithm, and verifying that the prediction precision of the FA-RF prediction model in the aspect of short-term wind and light output prediction is higher.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention proposes a wind-solar short-term power prediction method based on firefly optimization and random forest (FA-RF). Background Art

[0002] In the process of pursuing sustainable development around the world, energy transformation has become a top priority. Faced with severe challenges such as environmental pollution, resource depletion and climate change brought about by traditional fossil energy, wind and solar energy, as clean and renewable energy forms, are rapidly emerging and occupying an increasingly important position in the energy field.

[0003] With the large-scale construction and grid connection of wind farms and photovoltaic power stations, the volatility and uncertainty of their output power have brought great challenges to the stable operation and planning of the power system. Accurate short-term wind and solar power forecasting is crucial for the optimal dispatching, economic operation and power supply reliability of the power system.

[0004] In recent years, the impact of global climate change has become increasingly significant, and extreme weather events have occurred frequently, which has further exacerbated the instability of wind and solar resources. At the same time, the increasingly fierce competition in the power market has put forward higher requirements for the quality and cost of power supply. In this case, improving the accuracy and reliability of short-term wind and solar power forecasting can not only effectively reduce the backup capacity of the power system and reduce operating costs, but also promote the large-scale consumption of renewable energy and promote the optimization and upgrading of the energy structure.

[0005] Traditional prediction methods, such as physical models, empirical models, and statistical models, are mainly based on historical data and meteorological parameters, and use mathematical formulas or statistical laws to predict wind and solar power. However, these methods have limitations when dealing with complex and changeable meteorological conditions and nonlinear relationships. With the rapid development of emerging technologies such as big data, artificial intelligence, and cloud computing, more powerful tools and means are provided for short-term wind and solar power prediction. Such as decision trees, support vector machines, neural networks, random forests, etc., they can learn and capture complex nonlinear patterns from a large amount of historical data, and mine valuable information and laws, thereby improving the accuracy of predictions. However, these technologies still face problems in data quality, model generalization ability, and computational efficiency in practical applications, and require further research and optimization.

[0006] In addition, with the continuous development of smart grid and energy Internet technology, real-time monitoring and accurate prediction of wind and solar power have become key links in achieving efficient energy management and intelligent control. Through accurate short-term power prediction, we can better coordinate the complementary use of various energy sources, improve energy utilization efficiency, and realize intelligent distribution and supply of energy.

[0007] In summary, the research on short-term wind and solar power forecasting methods has important theoretical significance and practical application value, and plays an indispensable role in ensuring energy security, promoting sustainable economic and social development, and promoting technological innovation in the energy field. Summary of the invention

[0008] The present invention aims to overcome the above-mentioned shortcomings of the prior art and proposes a short-term wind and solar power output prediction method based on the firefly optimized random forest (FA-RF) algorithm.

[0009] The present invention first applies the non-parametric kernel density estimation method to fit a large amount of sample data to obtain the kernel density estimation expression of wind and light. On this basis, a joint distribution model of wind and light power output based on the Frank-Copula function is established to generate wind and light output scenes with correlation for subsequent wind and light output prediction. Then, the FA-RF prediction model is constructed, and the parameters of the random forest model are optimized using the firefly algorithm to improve the accuracy of the prediction. Finally, the prediction results and errors under the RF algorithm and the LSTM neural network algorithm are compared and analyzed with the prediction results and errors under the FA-RF algorithm to verify that the FA-RF prediction model has higher prediction accuracy in short-term wind and light output prediction.

[0010] In order to achieve the above object, the technical solution of the present invention is:

[0011] A method for short-term wind and solar power prediction based on firefly optimization and random forest (FA-RF) includes the following steps:

[0012] S1: Use non-parametric kernel density estimation method to model the probability distribution of wind and solar power measured data, and obtain the kernel density expression of wind and solar power output;

[0013] S2: Study the Copula theory, and based on the probability distribution functions of wind and solar output obtained in step S1, use the Frank-Copula function to construct the wind-solar joint output distribution function;

[0014] S3: Sampling the joint probability distribution function of wind and solar power output obtained in step S2, and inversely transforming the sampled wind turbine and photovoltaic output according to the sampling result and the joint probability distribution function of wind and solar power, thereby generating an output scenario that takes into account the correlation and randomness of wind and solar power, and using it for subsequent wind and solar power output prediction;

[0015] S4: Build a firefly algorithm (FA) parameter optimization model and a random forest (RF) prediction model respectively, optimize the parameters of the random forest prediction model through the firefly algorithm, and improve the prediction accuracy of wind and solar output.

[0016] S5: The short-term change trend of wind and solar output is predicted by the output scenario considering the correlation and randomness of wind and solar power generated in step S3 and the prediction model established in step S4, and the results are compared and analyzed, which proves that the FA-RF prediction model has higher prediction accuracy and better generalization ability.

[0017] Furthermore, in step S1, a non-parametric kernel density estimation method is used to perform probability distribution modeling on the measured data of wind and light, and obtaining the kernel density expressions of wind and light outputs includes the following steps:

[0018] S1-1: Kernel Density Estimation (KDE) is a common nonparametric method in statistics, which is used to estimate the probability density function of a random variable. This method uses kernel smoothing to estimate the probability density function. The kernel function is placed on each data point and summed to estimate the probability density function, that is, the population is inferred based on a limited data sample. Commonly used kernel functions include Gaussian kernel function and rectangular kernel function. The kernel function usually selects the Gaussian kernel function, and the formula of the Gaussian kernel function is as shown in formula (1):

[0019]

[0020] Where x is the input value and K(x) represents the value of the Gaussian kernel function.

[0021] When using the kernel density estimation method, the distance between each point in the neighborhood of x and x can be calculated to analyze the distance between each point and x, and then the estimated values ​​of these point pairs can be determined. The contribution of . Let the independent and identically distributed samples drawn from X be X 1 ,X 2 ,…,X n ,f(x) is the density function that X meets, x∈R, and the probability density function estimate at point x needs to be calculated Right now:

[0022]

[0023] Where n is the number of samples, h is the bandwidth, and K(·) is the kernel function.

[0024] The kernel density estimation method is used to directly carry out non-parametric estimation on the data of wind power and photovoltaic power, and then their respective probability density functions are obtained.

[0025] According to equations (1) and (2), the kernel density expressions of wind and solar output can be obtained.

[0026] Furthermore, in step S2, based on step S1, the wind-solar joint output distribution function is constructed using the Frank-Copula function. The specific steps are as follows:

[0027] S2-1: The joint distribution of N random variables can be decomposed into the marginal distribution of each of the N variables and a Copula function, thereby separating the randomness and coupling of the variables. The randomness of each random variable is described by the marginal distribution, and the coupling characteristics between random variables are described by the Copula function.

[0028] Assume X 1 ,X 2 ,…,X N are N random variables, and their respective marginal distributions are F 1 (x 1 ),F 2 (x 2 ),…,F N (x N ), their joint distribution is H(x 1 ,x 2 ,…,x N ), then there exists a function C(·) that “connects” the marginal distribution and the joint distribution, such that:

[0029] H(x 1 ,x 2 ,…,x N )=C(F 1 (x 1 ),F 2 (x 2 ),…,F N (x N )) (3)

[0030] Where: N is the number of variables; F i (x i )(i=1,2,…,N) is the marginal distribution function of a single variable; C(·) is the Copula function; H(x 1 ,x 2 ,…,x N ) is the joint distribution function of N variables.

[0031] S2-2: There are many types of Copula functions, which can usually be divided into elliptic Copula functions and Archimedean Copula functions. Archimedean Copula functions are widely used, and the three most common ones are Gumbel Copula functions, Clayton Copula functions, and Frank Copula functions. Clayton Copula functions and Gumbel Copula functions can usually only describe the non-negative correlation between variables. The two-dimensional Frank Copula function has the lowest requirements and has no restrictions on the positive and negative correlation and the degree. Its distribution function is as shown in formula (4):

[0032]

[0033] From formula (4), we can get the wind-solar power output joint density function as the probability density function as follows:

[0034]

[0035] Where u and v are the marginal distribution functions of wind and solar power output; θ is the Copula function parameter.

[0036] In step S3, the wind-solar joint output distribution function obtained in step S2 is used to generate an output scenario that takes into account wind-solar correlation and randomness, including the following steps:

[0037] S3-1: The core idea of ​​generating scenarios based on the Frank Copula function is: first, construct the marginal distribution function of random variables, and then build the multivariate Copula function; then discretize the Frank Copula function, and use the inverse operation of the marginal distribution function to obtain the original joint distribution function scenario. The specific process is as follows:

[0038] (1) Randomly generate a number a in the interval [0,1] 1 ,a 2 ,…,a n .

[0039] (2) Let the marginal distribution function value of the first random variable be u 1 =a 1 , according to the Frank Copula function, the marginal distribution function value u of the second random variable is obtained 2 , that is, find the solution of formula (6).

[0040]

[0041] (3) For the marginal distribution function value u of the nth random variable n , that is, find the solution of formula (7).

[0042]

[0043] (4) Repeat the above steps (1), (2), and (3) k times to obtain the marginal distribution function values ​​of k groups of n random variables.

[0044] (5) Using inverse function calculation The sampled data (u 1j ,u 2j ,…,u nj ) is converted to a joint distribution function scenario, where j = 1, 2, …, T, where T is the total number of days.

[0045] Through the above calculations, a scenario was generated that fully considered the correlation between wind and solar power output.

[0046] In step S4, the parameters of the random forest prediction model are optimized by the firefly algorithm, and the specific steps are as follows:

[0047] S4-1: Random forest (RF) is an ensemble learning method that constructs multiple decision trees and votes or averages their results to get the final prediction. The main advantage of this method is that by integrating multiple models, it can effectively deal with the overfitting problem and improve the generalization ability of the model.

[0048] Random forest (RF) achieves the final decision by creating hundreds of decision trees (RT). The random forest model uses the "bagging" method to combine the results of RT and obtain the peak result by voting or averaging, which improves the prediction performance and reduces the prediction variance. Formula (8) gives the training sample R n , including output variables and input variables with m features (X = {x 1 ,x 2 ,…,x m}).

[0049] In the process of training each decision RT, n samples are randomly selected from the training set without replacement. The sampling process is called "bootstrap", and the bootstrap sample set is represented as After that, the algorithm performs an operation on the input dataset After the RT training is completed, the prediction ability is obtained. The random forest algorithm consists of k uncorrelated RTs, thus forming k prediction functions k ranges from 1 to k, is an independent random vector used to distinguish decision trees.

[0050] Thus, RF generates k outputs Corresponding to each RT respectively, the average of these outputs is taken according to formula (9) to obtain the predicted value Y.

[0051] R n ={(X 1 ,Y 1 ),(X 2 ,Y 2 ),…,(X n ,Y n )} (8)

[0052]

[0053] The modeling process of random forest mainly includes the following steps:

[0054] Step 1: Use bootstrap sampling to extract samples from the original data set to form multiple sub-data sets.

[0055] Step 2: For each sub-dataset, build a decision tree. At each node, randomly select a portion of features for splitting.

[0056] Step 3: Repeat the above steps until the specified number of decision trees are generated.

[0057] The number of decision trees and the number of randomly selected features are key parameters. The more decision trees there are, the better the model performance is usually, but the computational cost will also increase accordingly. The choice of the number of features will affect the bias and variance of the model.

[0058] S4-2: Firefly algorithm (FA) is a bionic random optimization algorithm based on group search, and its idea is derived from the biological characteristics of fireflies moving towards brighter fireflies. In the search space, the position of the firefly represents the solution to the optimization problem, and the brightness corresponds to the adaptation value of the optimization problem. The firefly continues to move towards the brighter firefly until it reaches the preset termination condition of the algorithm and completes the optimization task. FA is efficient in solving complex optimization problems and is superior to other metaheuristic algorithms. Therefore, FA is used to adjust RF hyperparameters in the present invention.

[0059] In the firefly algorithm, when evaluating the attractiveness of fireflies, no distinction is made between male and female, and each firefly in the population can attract each other. There is a correlation between the attractiveness of individual fireflies and the brightness. The higher the brightness, the stronger the attraction. Fireflies with weaker attraction will move towards fireflies with higher attraction. Firefly colonies rely on light emission to communicate information. The brightest fireflies in the colony will move around the optimal solution within the search range. When the algorithm converges, the population will eventually concentrate on the location of the optimal solution that can characterize the objective function. In the firefly algorithm, brightness and attractiveness are two key parameters. Brightness determines the position of the firefly and the direction of movement, while attractiveness plays a controlling role. The brightness function of a firefly can be expressed as:

[0060]

[0061] Where: I 0 is the initial brightness of the firefly, that is, the maximum brightness of the firefly; r is the distance between two fireflies; y is the light intensity absorption coefficient, which is used to characterize the loss of light propagating in the medium.

[0062] In the firefly algorithm, the attraction of fireflies decreases monotonically with increasing distance, and the attraction function β(r) can be defined as:

[0063]

[0064] Where: β 0 is the attraction at r = 0, that is, the attraction of fireflies at the light source. In the firefly population, if two firefly individuals i and j are located at and The distance between them can be expressed as the Euclidean distance r ij It is expressed as:

[0065]

[0066] Where: D is the spatial dimension of the target problem, X ik is the coordinate of the i-th firefly in the k-dimensional space. The firefly with weaker light brightness will move towards the firefly j with stronger light brightness, and its position will be gradually updated. The update formula is:

[0067]

[0068] Where: α is the step size factor, and rand is a random real number uniformly distributed on [0,1]. In the firefly population, the position update equation of the firefly with the highest brightness is:

[0069]

[0070] S4-3: Considering that the number of decision trees and the number of randomly selected features directly affect the prediction accuracy, the present invention uses the FA algorithm to optimize the key parameters of RF to improve the accuracy and stability of the model. The main steps of FA optimization of RF can be summarized as follows:

[0071] (1) Initialize the individuals and parameters of FA.

[0072] (2) Calculate the objective function (fitness) value of the firefly as its maximum brightness.

[0073] (3) Update the spatial position of the firefly through equation (13) and update the optimal value at the same time.

[0074] (4) Iterative calculation. When the search accuracy is met or the maximum number of searches is reached, go to step 5. Otherwise, go to step 2 for the next search.

[0075] (5) Generate the FA-RF model, where FA optimizes the number of decision trees and the number of randomly selected features.

[0076] S4-4: The prediction accuracy is often tested by residual size. This paper uses mean square error MSE, root mean square error RMSE, mean absolute error MAE, and determination coefficient R 2 These four indicators are used for evaluation. When MSE, RMSE and MAE are smaller, R 2 The larger the value is, the better the prediction result is. Each index can be expressed by formula (15):

[0077]

[0078] In the formula, y i is the measured value, is the predicted value, and n is the number of data.

[0079] In step S5, the short-term change trend of the power load is predicted by the output scenario considering the correlation and randomness of wind and solar power generated in step S3 and the prediction model established in step S4, including the following steps:

[0080] S4-1: The experimental data is the annual grid-connected wind power and photovoltaic output data of a certain park area as a sample, which is collected every 15 minutes, with a total of 96 data per day. The wind-solar joint output distribution model is constructed using kernel density estimation and Frank-Copula function to generate output scenarios that consider wind-solar correlation and randomness.

[0081] S4-2: Use the FA-RF model to make short-term predictions of wind and solar output. To further illustrate the superiority of the FA-RF model, the prediction results of this algorithm are compared with those of a single LSTM neural network and the RF algorithm.

[0082] The beneficial effects of the present invention are:

[0083] 1) Combining kernel density estimation and Copula function, it can better describe the randomness and correlation of historical wind and solar output data, and generate more realistic and reliable wind and solar output scenarios;

[0084] 2) The parameters of the random forest model were optimized by the firefly optimization algorithm, which improved the accuracy and generalization ability of the model in predicting wind and solar power output;

[0085] 3) The wind-solar short-term power prediction method of the present invention can be widely used in power prediction of wind farms and photovoltaic power stations, which helps to improve energy utilization efficiency and management level and promote the sustainable development of renewable energy.

[0086] 4) The prediction algorithm proposed in this invention can be applied to prediction research in other fields and has a certain universality. BRIEF DESCRIPTION OF THE DRAWINGS

[0087] Figure 1 It is the RF principle diagram of the present invention.

[0088] Figure 2 It is a flow chart of constructing the FA-RF model of the present invention.

[0089] Figure 3 It is a binary Frank-Copula wind-solar joint output distribution function diagram of the present invention.

[0090] Figure 4a to Figure 4b is the wind and solar output scene generation diagram of the present invention, wherein Figure 4a It is the wind power output scenario generation diagram. Figure 4b It is a photovoltaic output scenario generation diagram.

[0091] Figure 5a to Figure 5b is the wind power output prediction result and error of the present invention, where Figure 5a This is the wind power output prediction result diagram. Figure 5b It is the prediction error diagram of wind power output.

[0092] Figure 6a to Figure 6b is the regression diagram and error histogram of the wind power output prediction results under the FA-RF algorithm of the present invention, where Figure 6a is the regression diagram of wind power output prediction results. Figure 6b It is the error histogram of wind power output prediction results.

[0093] Figure 7a to Figure 7b is the prediction result and error of the photovoltaic output of the present invention, where Figure 6a This is the prediction result diagram of photovoltaic output. Figure 6b It is the prediction error diagram of PV output.

[0094] Figure 8a to Figure 8b is the regression diagram and error histogram of the photovoltaic output prediction results under the FA-RF algorithm of the present invention, where Figure 8a is the regression diagram of the photovoltaic output prediction results, Figure 8b It is the error histogram of the PV output prediction results.

[0095] Fig. 9 is a flow chart of the method of the present invention. Specific implementation methods

[0096] The present invention will be further described below in conjunction with the accompanying drawings.

[0097] Reference Figures 1 to 9 , a wind-solar short-term power prediction method based on FA-RF algorithm, comprising the following steps:

[0098] S1: Use non-parametric kernel density estimation method to model the probability distribution of wind and solar power measured data, and obtain the kernel density expression of wind and solar power output;

[0099] S2: Study the Copula theory, and based on the probability distribution functions of wind and solar output obtained in step S1, use the Frank-Copula function to construct the wind-solar joint output distribution function;

[0100] S3: Sampling the joint probability distribution function of wind and solar power output obtained in step S2, and inversely transforming the sampled wind turbine and photovoltaic output according to the sampling result and the joint probability distribution function of wind and solar power, thereby generating an output scenario that takes into account the correlation and randomness of wind and solar power, and using it for subsequent wind and solar power output prediction;

[0101] S4: Build a firefly algorithm (FA) parameter optimization model and a random forest (RF) prediction model respectively, optimize the parameters of the random forest prediction model through the firefly algorithm, and improve the prediction accuracy of wind and solar output.

[0102] S5: The short-term change trend of wind and solar output is predicted by the output scenario considering the correlation and randomness of wind and solar power generated in step S3 and the prediction model established in step S4, and the results are compared and analyzed, which proves that the FA-RF prediction model has higher prediction accuracy and better generalization ability.

[0103] Furthermore, in step S1, a non-parametric kernel density estimation method is used to perform probability distribution modeling on the measured data of wind and light, and obtaining the kernel density expressions of wind and light outputs includes the following steps:

[0104] S1-1: Kernel Density Estimation (KDE) is a common nonparametric method in statistics, which is used to estimate the probability density function of a random variable. This method uses kernel smoothing to estimate the probability density function. The kernel function is placed on each data point and summed to estimate the probability density function, that is, the population is inferred based on a limited data sample. Commonly used kernel functions include Gaussian kernel function and rectangular kernel function. The kernel function usually selects the Gaussian kernel function, and the formula of the Gaussian kernel function is as shown in formula (1):

[0105]

[0106] Where x is the input value and K(x) represents the value of the Gaussian kernel function.

[0107] When using the kernel density estimation method, the distance between each point in the neighborhood of x and x can be calculated to analyze the distance between each point and x, and then the estimated values ​​of these point pairs can be determined. The contribution of . Let the independent and identically distributed samples drawn from X be X 1 ,X 2 ,…,X n ,f(x) is the density function that X meets, x∈R, and the probability density function estimate at point x needs to be calculated Right now:

[0108]

[0109] Where n is the number of samples, h is the bandwidth, and K(·) is the kernel function.

[0110] The kernel density estimation method is used to directly carry out non-parametric estimation on the data of wind power and photovoltaic power, and then their respective probability density functions are obtained.

[0111] According to equations (1) and (2), the kernel density expressions of wind and solar output can be obtained.

[0112] Furthermore, in step S2, based on step S1, the wind-solar joint output distribution function is constructed using the Frank-Copula function. The specific steps are as follows:

[0113] S2-1: The joint distribution of N random variables can be decomposed into the marginal distribution of each of the N variables and a Copula function, thereby separating the randomness and coupling of the variables. The randomness of each random variable is described by the marginal distribution, and the coupling characteristics between random variables are described by the Copula function.

[0114] Assume X 1 ,X 2 ,…,X Nare N random variables, and their respective marginal distributions are F 1 (x 1 ),F 2 (x 2 ),…,F N (x N ), their joint distribution is H(x 1 ,x 2 ,…,x N ), then there exists a function C(·) that “connects” the marginal distribution and the joint distribution, such that:

[0115] H(x 1 ,x 2 ,…,x N )=C(F 1 (x 1 ),F 2 (x 2 ),…,F N (x N )) (3)

[0116] Where: N is the number of variables; F i (x i )(i=1,2,…,N) is the marginal distribution function of a single variable; C(·) is the Copula function; H(x 1 ,x 2 ,…,x N ) is the joint distribution function of N variables.

[0117] S2-2: There are many types of Copula functions, which can usually be divided into elliptic Copula functions and Archimedean Copula functions. Archimedean Copula functions are widely used, and the three most common ones are Gumbel Copula functions, Clayton Copula functions, and Frank Copula functions. Clayton Copula functions and Gumbel Copula functions can usually only describe the non-negative correlation between variables. The two-dimensional Frank Copula function has the lowest requirements and has no restrictions on the positive and negative correlation and the degree. Its distribution function is as shown in formula (4):

[0118]

[0119] From formula (4), we can get the wind-solar power output joint density function as the probability density function as follows:

[0120]

[0121] Where u and v are the marginal distribution functions of wind and solar power output; θ is the Copula function parameter.

[0122] In step S3, the wind-solar joint output distribution function obtained in step S2 is used to generate an output scenario that takes into account wind-solar correlation and randomness, including the following steps:

[0123] S3-1: The core idea of ​​generating scenarios based on the Frank Copula function is: first, construct the marginal distribution function of random variables, and then build the multivariate Copula function; then discretize the Frank Copula function, and use the inverse operation of the marginal distribution function to obtain the original joint distribution function scenario. The specific process is as follows:

[0124] (1) Randomly generate a number a in the interval [0,1] 1 ,a 2 ,…,a n .

[0125] (2) Let the marginal distribution function value of the first random variable be u 1 =a 1 , according to the Frank Copula function, the marginal distribution function value u of the second random variable is obtained 2 , that is, find the solution of formula (6).

[0126]

[0127] (3) For the marginal distribution function value u of the nth random variable n , that is, find the solution of formula (7).

[0128]

[0129] (4) Repeat the above steps (1), (2), and (3) k times to obtain the marginal distribution function values ​​of k groups of n random variables.

[0130] (5) Using inverse function calculation The sampled data (u 1j ,u 2j ,…,u nj ) is converted to a joint distribution function scenario, where j = 1, 2, …, T, where T is the total number of days.

[0131] Through the above calculations, a scenario was generated that fully considered the correlation between wind and solar power output.

[0132] In step S4, the parameters of the random forest prediction model are optimized by the firefly algorithm, and the specific steps are as follows:

[0133] S4-1: Random forest (RF) is an ensemble learning method that constructs multiple decision trees and votes or averages their results to get the final prediction. The main advantage of this method is that by integrating multiple models, it can effectively deal with the overfitting problem and improve the generalization ability of the model.

[0134] Random Forest (RF) achieves the final decision by creating hundreds of decision trees (RT). The principle is as follows Figure 1 The random forest model uses the “bagging” method to combine the results of RT and obtain the peak results by voting or averaging, which improves the prediction performance and reduces the prediction variance. Formula (8) gives the training sample R n , including output variables and input variables with m features (X = {x 1 ,x 2 ,…,x m}).

[0135] In the process of training each decision RT, n samples are randomly selected from the training set without replacement. The sampling process is called "bootstrap", and the bootstrap sample set is represented as After that, the algorithm performs an operation on the input dataset After the RT training is completed, the prediction ability is obtained. The random forest algorithm consists of k uncorrelated RTs, thus forming k prediction functions k ranges from 1 to k, is an independent random vector used to distinguish decision trees.

[0136] Thus, RF generates k outputs Corresponding to each RT respectively, the average of these outputs is taken according to formula (9) to obtain the predicted value Y.

[0137] R n ={(X 1 ,Y 1 ),(X 2 ,Y 2 ),…,(X n ,Y n )} (8)

[0138]

[0139] The modeling process of random forest mainly includes the following steps:

[0140] Step 1: Use bootstrap sampling to extract samples from the original data set to form multiple sub-data sets.

[0141] Step 2: For each sub-dataset, build a decision tree. At each node, randomly select a portion of features for splitting.

[0142] Step 3: Repeat the above steps until the specified number of decision trees are generated.

[0143] The number of decision trees and the number of randomly selected features are key parameters. The more decision trees there are, the better the model performance is usually, but the computational cost will also increase accordingly. The choice of the number of features will affect the bias and variance of the model.

[0144] S4-2: Firefly algorithm (FA) is a bionic random optimization algorithm based on group search, and its idea is derived from the biological characteristics of fireflies moving towards brighter fireflies. In the search space, the position of the firefly represents the solution to the optimization problem, and the brightness corresponds to the adaptation value of the optimization problem. The firefly continues to move towards the brighter firefly until it reaches the preset termination condition of the algorithm and completes the optimization task. FA is efficient in solving complex optimization problems and is superior to other metaheuristic algorithms. Therefore, FA is used to adjust RF hyperparameters in the present invention.

[0145] In the firefly algorithm, when evaluating the attractiveness of fireflies, no distinction is made between male and female, and each firefly in the population can attract each other. There is a correlation between the attractiveness of individual fireflies and the brightness. The higher the brightness, the stronger the attraction. Fireflies with weaker attraction will move towards fireflies with higher attraction. Firefly colonies rely on light emission to communicate information. The brightest fireflies in the colony will move around the optimal solution within the search range. When the algorithm converges, the population will eventually concentrate on the location of the optimal solution that can characterize the objective function. In the firefly algorithm, brightness and attractiveness are two key parameters. Brightness determines the position of the firefly and the direction of movement, while attractiveness plays a controlling role. The brightness function of a firefly can be expressed as:

[0146]

[0147] Where: I 0 is the initial brightness of the firefly, that is, the maximum brightness of the firefly; r is the distance between two fireflies; y is the light intensity absorption coefficient, which is used to characterize the loss of light propagating in the medium.

[0148] In the firefly algorithm, the attraction of fireflies decreases monotonically with increasing distance, and the attraction function β(r) can be defined as:

[0149]

[0150] Where: β 0is the attraction at r = 0, that is, the attraction of fireflies at the light source. In the firefly population, if two firefly individuals i and j are located at and The distance between them can be expressed as the Euclidean distance r ij It is expressed as:

[0151]

[0152] Where: D is the spatial dimension of the target problem, X ik is the coordinate of the i-th firefly in the k-dimensional space. The firefly with weaker light brightness will move towards the firefly j with stronger light brightness, and its position will be gradually updated. The update formula is:

[0153]

[0154] Where: α is the step size factor, and rand is a random real number uniformly distributed on [0,1]. In the firefly population, the position update equation of the firefly with the highest brightness is:

[0155]

[0156] S4-3: Considering that the number of decision trees and the number of randomly selected features directly affect the prediction accuracy, the present invention uses the FA algorithm to optimize the key parameters of RF to improve the accuracy and stability of the model. The FA-RF model construction flow chart is as follows: Figure 2 As shown. The main steps of FA optimization RF can be summarized as follows:

[0157] (1) Initialize the individuals and parameters of FA.

[0158] (2) Calculate the objective function (fitness) value of the firefly as its maximum brightness.

[0159] (3) Update the spatial position of the firefly through equation (13) and update the optimal value at the same time.

[0160] (4) Iterative calculation. When the search accuracy is met or the maximum number of searches is reached, go to step 5. Otherwise, go to step 2 for the next search.

[0161] (5) Generate the FA-RF model, where FA optimizes the number of decision trees and the number of randomly selected features.

[0162] S4-4: The prediction accuracy is often tested by residual size. This paper uses mean square error MSE, root mean square error RMSE, mean absolute error MAE, and determination coefficient R 2 These four indicators are used for evaluation. When MSE, RMSE and MAE are smaller, R 2 The larger the value is, the better the prediction result is. Each index can be expressed by formula (15):

[0163]

[0164] In the formula, y i is the measured value, is the predicted value, and n is the number of data.

[0165] In step S5, the short-term change trend of the power load is predicted by the output scenario considering the correlation and randomness of wind and solar power generated in step S3 and the prediction model established in step S4, including the following steps:

[0166] S4-1: The experimental data is selected from the annual grid-connected wind power and photovoltaic output data of a certain park area as samples, which are collected every 15 minutes, with a total of 96 data per day. The wind-solar joint output distribution model is constructed using kernel density estimation and Frank-Copula function. Figure 3 It is the binary Frank-Copula wind-solar joint output distribution function. It can be seen that the surface is symmetrical, showing the joint distribution of wind and solar output and its correlation.

[0167] By sampling the wind-solar joint output distribution function, an output scenario that takes into account wind-solar correlation and randomness is generated, as shown in Figure 4. From the perspective of wind-solar correlation, the wind-solar output in each scenario has the same or opposite change trends in some sections, and has a certain correlation. The data generated by the scenario is used for subsequent wind-solar output prediction.

[0168] S4-2: Use the FA-RF model to make short-term predictions of wind and solar output. To further illustrate the superiority of the FA-RF model, the prediction results of the algorithm are compared with those of a single LSTM neural network and the RF algorithm. Figure 5 shows the prediction results and errors of wind power output under the three algorithms, Figure 6 shows the regression plot and error histogram of wind power output prediction results under the FA-RF algorithm, Figure 7 shows the prediction results and errors of photovoltaic output under the three algorithms, and Figure 8 shows the regression plot and error histogram of photovoltaic output prediction results under the FA-RF algorithm. Table 1 shows the model prediction performance evaluation indicators under the three algorithms.

[0169] In order to enable those skilled in the art to better understand the present invention, the example analysis includes the following components:

[0170] 1. Case description and analysis of short-term power load forecasting results

[0171] The short-term wind and solar output prediction results under different algorithms are compared and analyzed. Figure 5 shows the prediction results and errors of wind power output under the three algorithms, Figure 6 shows the regression diagram and error histogram of wind power output prediction results under the FA-RF algorithm, Figure 7 shows the prediction results and errors of photovoltaic output under the three algorithms, and Figure 8 shows the regression diagram and error histogram of photovoltaic output prediction results under the FA-RF algorithm. Table 1 shows the model prediction performance evaluation indicators under the three algorithms.

[0172] Table 1 Evaluation index values ​​under three methods

[0173]

[0174] As can be seen from Figure 5, under the prediction of wind power output, the fitting degree between the prediction curve of the FA-RF algorithm and the actual curve is the highest, with an error range of (-0.8, 1.1), the fitting degree between the prediction curve of the LSTM algorithm and the actual curve is the lowest, with an error range of (-1.5, 1.6), and the fitting degree between the prediction curve of the RF algorithm and the actual curve is lower than that of the FA-RF algorithm, with an error range of (-1.5, 1). As can be seen from Figure 7, under the prediction of photovoltaic output, the fitting degree between the prediction curve of the FA-RF algorithm and the actual curve is also the highest, with an error range of (-0.5, 0.8), and the fitting degrees between the prediction curve of the LSTM algorithm and the RF algorithm and the actual curve are similar, both lower than the fitting degree under the FA-RF algorithm, and their error ranges are between (-1.5, 0.7) and (-1, 1.5), respectively. It can be observed from FIG6 and FIG8 that the predicted values ​​of wind and solar outputs under the FA-RF algorithm proposed in the present invention are highly consistent with the true values, and the probability of zero error is high, which verifies the effectiveness of the prediction algorithm designed in the present invention and improves the prediction accuracy to a certain extent.

[0175] At the same time, it can be seen from Table 1 that the evaluation indicators MSE, RMSE, and MAE of the random forest (FA-RF) prediction method optimized by the firefly algorithm are all smaller than the corresponding values ​​of the RF and LSTM prediction methods, which proves the accuracy of the FA-RF prediction model. 2 However, it is relatively large, indicating that the difference between the actual results and the predicted results is very small, further reflecting the accuracy of the predicted results.

[0176] In summary, compared with the predictions under the LSTM algorithm and RF algorithm, the FA-RF model has higher prediction accuracy in short-term wind and solar forecasting.

[0177] In this specification, the schematic description of the present invention does not necessarily refer to the same embodiment or example, and those skilled in the art may combine and combine different embodiments or examples described in this specification. In addition, the contents described in the embodiments of this specification are merely an enumeration of the implementation forms of the inventive concept, and the protection scope of the present invention should not be considered as limited to the specific forms described in the implementation cases. The protection scope of the present invention also includes equivalent technical means that those skilled in the art can think of based on the inventive concept.

Claims

1. A wind-solar short-term power prediction method based on firefly optimization and random forest, characterized in that: The following steps are involved: S1: Use non-parametric kernel density estimation method to model the probability distribution of wind and solar power measured data, and obtain the kernel density expression of wind and solar power output; S2: Study the Copula theory, and based on the kernel density expressions of wind and solar output obtained in step S1, use the Frank-Copula function to construct the wind-solar joint output distribution function; S3: Sampling the joint probability distribution function of wind and solar power output obtained in step S2, and inversely transforming the sampled wind turbine and photovoltaic output according to the sampling result and the joint probability distribution function of wind and solar power, thereby generating an output scenario that takes into account the correlation and randomness of wind and solar power, and using it for subsequent wind and solar power output prediction; S4: Build the firefly algorithm FA parameter optimization model and the random forest RF prediction model respectively, optimize the parameters of the random forest prediction model by the firefly algorithm, and improve the prediction accuracy of wind and solar output; S5: The short-term change trend of wind and solar output is predicted by the output scenario considering the correlation and randomness of wind and solar power generated in step S3 and the prediction model established in step S4, and the results are compared and analyzed, which proves that the FA-RF prediction model has higher prediction accuracy and better generalization ability.

2. The method for wind-solar short-term power prediction based on firefly optimization and random forest as claimed in claim 1, characterized in that: In step S1, a non-parametric kernel density estimation method is used to perform probability distribution modeling on the measured data of wind and light to obtain the kernel density expressions of wind and light outputs, which includes the following steps: S1-1: Kernel density estimation method; the kernel function is Gaussian kernel function, and the formula of Gaussian kernel function is as follows: In the formula, x is the input value, K(x) represents the value of the Gaussian kernel function; When using the kernel density estimation method, the distance between each point in the neighborhood of x and x is calculated, and the distance between each point and x is analyzed to determine the estimated values ​​of these point pairs. The contribution of X; suppose the independent and identically distributed samples drawn from X are X1, X2, …, X n ,f(x) is the density function that X meets, x∈R, and the probability density function estimate at point x needs to be calculated Right now: Where: n is the number of samples, h is the bandwidth, and K(·) is the kernel function; The kernel density estimation method is used to directly carry out non-parametric estimation on the data of wind power and photovoltaic power, and then their respective probability density functions are obtained; According to equations (1) and (2), the kernel density expressions of wind and solar output are obtained.

3. The method for wind and solar short-term power prediction based on firefly optimization and random forest as claimed in claim 2, characterized in that: Based on step S1, step S2 uses the Frank-Copula function to construct a wind-solar joint output distribution function. The specific steps are as follows: S2-1: For the joint distribution of N random variables, decompose it into the marginal distribution of each of the N variables and a Copula function, so as to separate the randomness and coupling of the variables; the randomness of each random variable is described by the marginal distribution, and the coupling characteristics between random variables are described by the Copula function; Assume that X1, X2, …, X N are N random variables, whose marginal distributions are F1(x1), F2(x2), …, F N (x N ), their joint distribution is H(x1,x2,…,x N ), then there exists a function C(·) that "connects" the marginal distribution and the joint distribution, such that: H(x1,x2,…,x N )=C(F1(x1),F2(x2),…,F N (x N )) (3) Where: N is the number of variables; F i (x i )(i=1,2,…,N) is the marginal distribution function of a single variable; C(·) is the Copula function; H(x1,x2,…,x N ) is the joint distribution function of N variables; S2-2: Two-dimensional Frank Copula function, whose distribution function is as shown in formula (4): From formula (4), we can get the wind-solar power output joint density function as the probability density function as follows: Where u and v are the marginal distribution functions of wind and solar power output; θ is the Copula function parameter.

4. The method for wind-solar short-term power prediction based on firefly optimization and random forest as claimed in claim 3 is characterized in that: The wind-solar joint output distribution function obtained in step S2 described in step S3 generates an output scenario that takes into account wind-solar correlation and randomness, including the following steps: S3-1: The scenario generation based on the Frank Copula function includes: firstly, constructing the marginal distribution function of the random variable, thereby constructing the multivariate Copula function; then discretizing the Frank Copula function, and obtaining the original joint distribution function scenario by inverse operation of the marginal distribution function; the specific process is as follows: (1) Randomly generate numbers a1, a2, ..., a in the interval [0, 1] n ; (2) Let the marginal distribution function value of the first random variable u1 = a1, and obtain the marginal distribution function value of the second random variable u2 according to the Frank Copula function, that is, to find the solution of formula (6); (3) For the marginal distribution function value u of the nth random variable n , that is, find the solution of formula (7); (4) Repeat the above steps (1), (2), and (3) k times, and you can get the marginal distribution function values ​​of k groups of n random variables; (5) Using the inverse function to calculate x i =F i -1 (u i ), through the empirical cumulative distribution function and spline interpolation methods, the sampled data (u 1j ,u 2j ,…,u nj ) is converted to a joint distribution function scenario, where j = 1, 2, …, T, T is the total number of days; Through the above calculations, a scenario was generated that fully considered the correlation between wind and solar power output.

5. The method for wind-solar short-term power prediction based on firefly optimization and random forest as claimed in claim 4, characterized in that: The specific steps of optimizing the parameters of the random forest prediction model by the firefly algorithm in step S4 are as follows: S4-1: Formula (8) gives the training sample R of random forest RF n , including output variables and input variables with m features (X={x1,x2,…,x m }); In the process of training each decision RT, n samples are randomly selected from the training set without replacement; the sampling process is called "bootstrap", and the bootstrap sample set is represented as After that, the algorithm performs an operation on the input dataset After the RT training is completed, the prediction ability is obtained. The random forest algorithm consists of k unrelated RTs, thus forming k prediction functions k ranges from 1 to k, is an independent random vector used to distinguish decision trees; Thus, RF generates k outputs Corresponding to each RT respectively, and then taking the average of these outputs according to formula (9) to obtain the predicted value Y; R n ={(X1,Y1),(X2,Y2),…,(X n ,Y n )} (8) The modeling process of random forest includes the following steps: Step 1: Extract samples from the original data set using bootstrap sampling to form multiple sub-data sets; Step 2: For each sub-dataset, build a decision tree; at each node, randomly select a part of the features for splitting; Step 3: Repeat the above steps until a specified number of decision trees are generated; The number of decision trees and the number of randomly selected features are key parameters. The more decision trees there are, the better the model performance is usually, but the computational cost will also increase accordingly. The choice of the number of features will affect the bias and variance of the model. S4-2: Use Firefly Algorithm FA; adjust RF hyperparameters; The brightness function of a firefly can be expressed as: Where: I0 is the initial brightness of the firefly, that is, the maximum brightness of the firefly; r is the distance between two fireflies; y is the light intensity absorption coefficient, which is used to characterize the loss of light propagation in the medium; In the firefly algorithm, the attraction of fireflies decreases monotonically with increasing distance, and the attraction function β(r) can be defined as: Where: β0 is the attraction at r = 0, that is, the attraction of fireflies at the light source; in the firefly population, if two firefly individuals i and j are located at and The distance between them can be expressed as the Euclidean distance r ij It is expressed as: Where: D is the spatial dimension of the target problem, X ik is the coordinate of the i-th firefly in the k-dimensional space; the firefly with weaker brightness will move towards the firefly j with stronger brightness, and its position will be gradually updated. The update formula is: Where: α is the step size factor, rand is a random real number uniformly distributed on [0,1]; the position update equation of the firefly with the highest brightness in the firefly population is: S4-3: Consider using the FA algorithm to optimize the key parameters of RF to improve the accuracy and stability of the model; the steps of FA optimization of RF include: (1) Initialize the individuals and parameters of FA; (2) Calculate the objective function (fitness) value of the firefly as its maximum brightness; (3) Update the spatial position of the firefly through equation (13) and update the optimal value at the same time; (4) Iterative calculation; when the search accuracy is met or the maximum number of searches is reached, go to step 5; otherwise, go to step 2 for the next search; (5) Generate FA-RF model, FA optimizes the number of decision trees and the number of randomly selected features; S4-4: The prediction accuracy is often tested by residual size; mean square error (MSE), root mean square error (RMSE), mean absolute error (MAE), and determination coefficient (R) are used. 2 These four indicators are used for evaluation. When MSE, RMSE and MAE are smaller, R 2 The larger the value is, the better the prediction result is. Each index is expressed by formula (15): In the formula, y i is the measured value, is the predicted value, and n is the number of data.

6. The method for wind-solar short-term power prediction based on firefly optimization and random forest as claimed in claim 5, characterized in that: In step S5, the short-term change trend of the power load is predicted by the output scenario considering the correlation and randomness of wind and solar power generated in step S3 and the prediction model established in step S4, including the following steps: S4-1: The experimental data is the annual grid-connected wind power and photovoltaic output data of a certain park area as samples, which are collected every 15 minutes, with a total of 96 data per day. The wind-solar joint output distribution model is constructed using kernel density estimation and Frank-Copula function to generate output scenarios that consider wind-solar correlation and randomness. S4-2: The FA-RF model is used to make short-term predictions of wind and solar output. To further illustrate the superiority of the FA-RF model, the prediction results of the algorithm are compared with those of the single RF algorithm and the LSTM neural network.

Citation Information

Patent Citations

  • PCA and quantile regression forest-based short-term load probability density prediction method

    CN108022001A

  • Short-item load prediction method for optimization of neural network through Firefly algorithm

    CN108446808A

  • Improved random forest method-based wind-solar power generation output short-term prediction method

    CN110516840A

  • Generation power prediction method and device, electronic equipment and storage medium

    CN116702992A

  • Deep reinforcement learning short-term random optimization scheduling method for wind-light-cascade reservoir

    CN116720674A