CNN-BiLSTM-Attention-based short-term photovoltaic power generation power prediction method and device, and storage medium
Through the CNN-BiLSTM-Attention model, combined with real-time meteorological data, the problem of low prediction accuracy of short-term photovoltaic power generation power is solved, and higher prediction accuracy and model self-learning ability are achieved, and different climatic conditions and time are adapted to different climatic conditions and time. prediction of segment.
Patent Information
- Application Number
- CN202411275647.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2025-01-03
AI Technical Summary
The existing photovoltaic power prediction methods have low accuracy in short-term (minute and hourly) periods, which affects grid scheduling safety and power transaction returns.
A model based on CNN-BiLSTM-Attention was adopted, combined with real-time meteorological data (irradiation intensity and temperature), and a short-term photovoltaic power prediction model was constructed, and prediction results were generated through convolutional operations, bidirectional long and short-term memory networks and attention mechanisms. And continuously fit the model parameters through mean square error to achieve self-learning of the model.
It significantly improves the prediction accuracy of short-term photovoltaic power generation power, improves the self-learning ability and generalization ability of the model, and adapts to the prediction of different climatic conditions and time periods.
Smart Images

Figure CN119253586A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of short-term photovoltaic power prediction, and in particular to a method, device and storage medium for predicting short-term photovoltaic power based on CNN-BiLSTM-Attention. Background Art
[0002] The power generation of photovoltaic power generation systems is affected by many factors, such as solar radiation intensity, ambient temperature, seasonal changes, and cloud coverage. With the rapid increase in the proportion of photovoltaic power generation capacity in the power grid, the volatility and unadjustability of photovoltaic power have greatly increased the difficulty of safe and stable operation of the power grid, making the prediction of photovoltaic power generation more important. Photovoltaic power prediction at different time scales can provide important reference for the formulation and scheduling of power grid generation strategies.
[0003] In the existing technology, researchers have developed a variety of photovoltaic power generation prediction methods. Hu Shenghong et al. proposed a photovoltaic power station active power optimization allocation method for ultra-short-term photovoltaic power prediction using PSO-LSTM in Chinese patent CN202311223922.4; Zhang Jie et al. proposed a BP neural network with momentum to predict power generation based on historical meteorological data in Chinese patent CN201210495015.0; Mei Fei et al. first clustered the daily feature data in the meteorological feature library through the KFCM algorithm in Chinese patent CN201711103682.9, and then established an SVR sub-model to predict the power generation of the photovoltaic power station through the corresponding sub-model; Li Fei et al. proposed a method considering long-term data in Chinese patent CN202211407351.5 According to the influence of the data, an LSTM power generation prediction model is established; Fan Jinxing et al. proposed an optimization algorithm of adaptive clustering analysis to predict power generation in the document "Ultra-short-term photovoltaic power generation prediction based on adaptive particle swarm algorithm [J]. Energy Conservation, 2024, 43(05): 43-46)" to solve the intermittent and unstable problems of photovoltaic power generation; Chen Jun et al. used variational mode decomposition to decompose the power generation in the document "Short-term photovoltaic power generation prediction based on MPBiLSTM [J / OL]. Computer Technology and Development, 1-8[2024-07-15])", and then established a prediction model through residual inversion one-dimensional convolution and bidirectional long short-term memory network to predict photovoltaic power generation.
[0004] However, when the above prediction method is used for short-term prediction of photovoltaic power generation, that is, when predicting the power output at the minute and hour level in the future, the accuracy rate drops significantly. However, the accuracy of short-term prediction of photovoltaic power is directly related to the safety of grid-level dispatching and the benefits of participating in power trading, and is of great value. Summary of the invention
[0005] The purpose of the present invention is to provide a method, device and storage medium for predicting short-term photovoltaic power generation based on CNN-BiLSTM-Attention. On the basis of real-time photovoltaic power generation, it is combined with real-time meteorological data, and the meteorological data includes radiation intensity and temperature, so as to effectively improve the accuracy of short-term photovoltaic power generation.
[0006] The purpose of the present invention can be achieved by the following technical solutions:
[0007] A short-term photovoltaic power generation prediction method based on CNN-BiLSTM-Attention includes:
[0008] Step S1: Acquire real-time meteorological data and photovoltaic power generation;
[0009] Step S2: input the extracted real-time meteorological data and photovoltaic power generation into the trained short-term photovoltaic power generation prediction model to obtain the photovoltaic power generation at the next moment;
[0010] Among them, the meteorological data includes radiation intensity and temperature, and the short-term photovoltaic power generation power prediction model is a model built based on CNN-BiLSTM-Attention.
[0011] The process of constructing the training set data of the short-term photovoltaic power generation prediction model includes:
[0012] Step A1: Obtain historical meteorological data and photovoltaic power generation within a set time interval of a day;
[0013] Step A2: Segment the acquired historical meteorological data and photovoltaic power generation according to a pre-configured time step to obtain meteorological data sequences and photovoltaic power generation sequences of multiple time slots;
[0014] Step A3: construct independent variables of training samples based on the meteorological data sequence and photovoltaic power generation sequence of the current time slot, and construct dependent variables based on the photovoltaic power generation sequence of the next moment, and construct multiple training samples.
[0015] The set time interval includes the interval [T 日出 , T 日落 ],
[0016] Where: T 日出 For sunrise time, T 日落 It's sunset time.
[0017] The preconfigured time step is 5 minutes.
[0018] The step S2 specifically includes:
[0019] Step S2-1: Based on the real-time meteorological data and photovoltaic power generation, construct time series data of meteorological data and photovoltaic power generation according to a preconfigured time step;
[0020] Step S2-2: Input the constructed meteorological data and the time series data of photovoltaic power generation into the trained short-term photovoltaic power generation prediction model to obtain the photovoltaic power generation at the next moment.
[0021] The short-term photovoltaic power generation prediction model includes a CNN model, a bidirectional long short-term memory network, an attention mechanism and a fully connected layer.
[0022] There are two layers in the CNN model. The first layer of the CNN model inputs meteorological data of specified length and time series data of photovoltaic power generation for convolution operation. After the first activation function and normalization processing, the output is used as the input of the second layer of the CNN model. After the second activation function and normalization processing, the second layer of the CNN model outputs as the input of the bidirectional long short-term memory network. The hidden value of BiLSTM and the time series feature after convolution are input into the defined attention mechanism for weighting to generate a context vector that can capture the most relevant current information and historical information. The feature vector is further weighted by the attention mechanism. The feature vector is used as the input of the fully connected layer, and the output of the fully connected layer is used as the prediction result.
[0023] After the short-term photovoltaic power generation prediction model is trained, it is tested and verified through a test set.
[0024] The test set covers the four seasons of spring, summer, autumn and winter, as well as data of rainy, snowy, sunny and cloudy days.
[0025] A short-term photovoltaic power prediction device based on CNN-BiLSTM-Attention includes a memory, a processor, and a program stored in the memory. When the processor executes the program, the method as described above is implemented.
[0026] A storage medium stores a program, which implements the above method when executed.
[0027] Compared with the prior art, the present invention has the following beneficial effects:
[0028] 1. Based on the real-time photovoltaic power generation, combined with real-time meteorological data, and the meteorological data includes radiation intensity and temperature, it can effectively improve the accuracy of short-term photovoltaic power generation.
[0029] 2. Construct a CNN-BiLSTM-Attention model to predict the power generation in the future minute-level period, calculate the mean square error between the predicted value and the true value, and use the error value to continuously fit the predicted value to update the model parameters, realize model self-learning, and improve the accuracy of the short-term photovoltaic power prediction model. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 It is a schematic diagram of the technical route of the present invention;
[0031] Figure 2 It is a schematic diagram of the main steps of the reasoning stage of the present invention;
[0032] Figure 3 This is the data preprocessing process in the method of the present invention;
[0033] Figure 4 is the generated power collected;
[0034] Figure 5 The original value of power generation on a certain day;
[0035] Figure 6 Prediction results of short-term photovoltaic power generation. DETAILED DESCRIPTION
[0036] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0037] A short-term photovoltaic power generation prediction method based on CNN-BiLSTM-Attention, such as Figure 1 and Figure 2 As shown, including:
[0038] Step S1: Acquire real-time meteorological data and photovoltaic power generation;
[0039] Step S2: input the extracted real-time meteorological data and photovoltaic power generation into the trained short-term photovoltaic power generation prediction model to obtain the photovoltaic power generation at the next moment;
[0040] Among them, meteorological data include radiation intensity and temperature, and the short-term photovoltaic power generation prediction model is a model built based on CNN-BiLSTM-Attention.
[0041] The process of constructing the training set data of the short-term photovoltaic power generation prediction model includes:
[0042] Step A1: Obtain historical meteorological data and photovoltaic power generation within a set time interval of a day;
[0043] In some embodiments, the set time interval includes an interval [T 日出 , T 日落 ],
[0044] Where: T 日出 For sunrise time, T 日落 The time of sunset is the time of sunset, thus including the complete sunrise and sunset interval.
[0045] Of course, in some other embodiments, the time interval can also be directly set to 7 am to 7 pm. In this way, the data before 7 am can be ignored. The data at this time fluctuates greatly and will affect the training accuracy of the model.
[0046] Relevant historical meteorological data and photovoltaic power generation can be extracted through some data platforms, such as Figure 5 is the original value of power generation on a certain day, from Figure 4 The data shown is extracted from the sequence.
[0047] Step A2: Segment the acquired historical meteorological data and photovoltaic power generation according to a pre-configured time step to obtain meteorological data sequences and photovoltaic power generation sequences of multiple time slots;
[0048] In this embodiment, the preconfigured time step is 5 minutes, with every 5 minutes as an interval.
[0049] Step A3: construct independent variables of training samples based on the meteorological data sequence and photovoltaic power generation sequence of the current time slot, and construct dependent variables based on the photovoltaic power generation sequence of the next moment, and construct multiple training samples.
[0050] The short-term photovoltaic power prediction model includes a CNN model, a bidirectional long short-term memory network, an attention mechanism and a fully connected layer. There are two layers in the CNN model. The first layer of the CNN model inputs meteorological data of a specified length and time series data of photovoltaic power generation for convolution operation. After the first activation function and normalization processing, the output is used as the input of the second layer of the CNN model. After the second activation function and normalization processing, the second layer of the CNN model outputs as the input of the bidirectional long short-term memory network. The hidden value of BiLSTM and the time series features after convolution are input into the defined attention mechanism for weighting to generate a context vector that can capture the most relevant current and historical information. The feature vector is further weighted by the attention mechanism. The feature vector is used as the input of the fully connected layer, and the output of the fully connected layer is used as the prediction result.
[0051] (1) Network parameter setting: two-layer CNN model, convolution kernel sizes are 3*3 and 1*1 respectively, and the number of convolution kernels is 200; the number of BiLSTM layers is 3, the number of neurons in each layer is 47, 89, and 54 respectively, and the input value of each layer is 7, 94, and 178 respectively; the number of network training times is 40 times, and the learning rate is 0.00597.
[0052] (2) Training and testing: The processed and normalized data is input into the CNN-BiLSTM-Attention model for training and testing. The normalization formula is: x n is the original data.
[0053] (3) Save the best model, define the lowest mean square error value, compare the mean square error obtained after each round of test set verification with the lowest mean square error, and if the mean square error on the current test set is less than the defined mean square error value, update the minimum mean square error and save the current model as the best model.
[0054] The root mean square error formula is: Where n is the number of samples, xi is the true value of the i-th sample, and yi is the model's predicted value for the i-th sample. The smaller the MSE value, the smaller the difference between the model's predicted value and the true value, and the better the model's performance.
[0055] (4) Verify the generalization ability of the model and denormalize it. Adjust the model to the evaluation mode and use other time series data of the same type to verify the actual prediction performance of the model. Denormalize the prediction results and compare them with the original power to draw the relevant curve.
[0056] The formula for attention score is: scores = v(tanh(W h [h dec ,h enc ])), where h dec is the hidden state of the decoder, h enc is the output of the encoder, W h is the weight of the linear layer, v is the linear layer, and finally the attention score is normalized by softmax to obtain α normal , output context vector c, the calculation formula is Where T is the length of the encoder output sequence, α norm,i is the normalized attention weight of the i-th time step, h rnc,i is the output of the encoder at the i-th time step.
[0057] Step S2 specifically includes:
[0058] Step S2-1: Based on the real-time meteorological data and photovoltaic power generation, construct time series data of meteorological data and photovoltaic power generation according to a preconfigured time step;
[0059] Step S2-2: Input the constructed meteorological data and the time series data of photovoltaic power generation into the trained short-term photovoltaic power generation prediction model to obtain the photovoltaic power generation at the next moment.
[0060] After the short-term photovoltaic power generation prediction model is trained, it is tested and verified through a test set, which covers the four seasons of spring, summer, autumn and winter, as well as data on rainy, snowy, sunny and cloudy days.
[0061] In some embodiments, a set of model parameters is obtained by training each day's historical data. For each set of model parameters, the optimal model parameters are saved through verification by a test set for real-time prediction. The best model parameters in training are saved in .pt format, that is, the weight parameters of the model are saved, the model is adjusted to evaluation mode, the model parameters in .pt format are loaded, and the prediction performance of the model is verified using a test set different from the model training. During the model evaluation stage, the parameters of the model are not updated.
[0062] Figure 3 This is a flowchart of data processing. The data read by the sensor is saved in JSON format. Since the Pn node of the photovoltaic solar panel is sensitive to temperature, the read data is classified into four seasons: spring, summer, autumn and winter. The geographical location is East China. The data after the four seasons are clustered again to separate the data of rainy, snowy, sunny and cloudy days. Check whether the data is abnormal, including zero value, null data, extreme data, etc., process the abnormal data, and output the processed data.
[0063] like Figure 6 The figure shows the prediction result of short-term photovoltaic power generation. It can be seen that the prediction accuracy of the present application is relatively high.
[0064] If the above functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program code.
Claims
1. A method for predicting short-term photovoltaic power generation based on CNN-BiLSTM-Attention, characterized in that: include: Step S1: Acquire real-time meteorological data and photovoltaic power generation; Step S2: input the extracted real-time meteorological data and photovoltaic power generation into the trained short-term photovoltaic power generation prediction model to obtain the photovoltaic power generation at the next moment; Among them, the meteorological data includes radiation intensity and temperature, and the short-term photovoltaic power generation power prediction model is a model built based on CNN-BiLSTM-Attention.
2. According to claim 1, a method for predicting short-term photovoltaic power generation based on CNN-BiLSTM-Attention is characterized in that: The process of constructing the training set data of the short-term photovoltaic power generation prediction model includes: Step A1: Obtain historical meteorological data and photovoltaic power generation within a set time interval of a day; Step A2: Segment the acquired historical meteorological data and photovoltaic power generation according to a pre-configured time step to obtain meteorological data sequences and photovoltaic power generation sequences of multiple time slots; Step A3: construct independent variables of training samples based on the meteorological data sequence and photovoltaic power generation sequence of the current time slot, and construct dependent variables based on the photovoltaic power generation sequence of the next moment, and construct multiple training samples.
3. According to claim 2, a method for predicting short-term photovoltaic power generation based on CNN-BiLSTM-Attention is characterized in that: The set time interval includes the interval [T 日出 , T 日落 ], Where: T 日出 For sunrise time, T 日落 It's sunset time.
4. According to claim 2, a method for predicting short-term photovoltaic power generation based on CNN-BiLSTM-Attention is characterized in that: The preconfigured time step is 5 minutes.
5. According to claim 2, a method for predicting short-term photovoltaic power generation based on CNN-BiLSTM-Attention is characterized in that: The step S2 specifically includes: Step S2-1: Based on the real-time meteorological data and photovoltaic power generation, construct time series data of meteorological data and photovoltaic power generation according to a preconfigured time step; Step S2-2: Input the constructed meteorological data and the time series data of photovoltaic power generation into the trained short-term photovoltaic power generation prediction model to obtain the photovoltaic power generation at the next moment.
6. A method for predicting short-term photovoltaic power generation based on CNN-BiLSTM-Attention according to claim 5, characterized in that: The short-term photovoltaic power generation prediction model includes a CNN model, a bidirectional long short-term memory network, an attention mechanism and a fully connected layer. There are two layers in the CNN model. The first layer of the CNN model inputs meteorological data of specified length and time series data of photovoltaic power generation for convolution operation. After the first activation function and normalization processing, the output is used as the input of the second layer of the CNN model. After the second activation function and normalization processing, the second layer of the CNN model outputs as the input of the bidirectional long short-term memory network. The hidden value of BiLSTM and the time series feature after convolution are input into the defined attention mechanism for weighting to generate a context vector that can capture the most relevant current information and historical information. The feature vector is further weighted by the attention mechanism. The feature vector is used as the input of the fully connected layer, and the output of the fully connected layer is used as the prediction result.
7. The method for predicting short-term photovoltaic power generation based on CNN-BiLSTM-Attention according to claim 5 is characterized in that: After the short-term photovoltaic power generation prediction model is trained, it is tested and verified through a test set.
8. The method for predicting short-term photovoltaic power generation based on CNN-BiLSTM-Attention according to claim 7 is characterized in that: The test set covers the four seasons of spring, summer, autumn and winter, as well as data of rainy, snowy, sunny and cloudy days.
9. A short-term photovoltaic power prediction device based on CNN-BiLSTM-Attention, comprising a memory, a processor, and a program stored in the memory, characterized in that: When the processor executes the program, the method according to any one of claims 1 to 8 is implemented.
10. A storage medium having a program stored thereon, characterized in that: When the program is executed, the method according to any one of claims 1 to 8 is implemented.
