Method and system for driving CNN-LSTM neural network to predict photovoltaic power generation based on eagle optimization algorithm
By using a CNN-LSTM neural network driven by the Osprey optimization algorithm, combined with the RCBAM attention mechanism and Transformer encoder, the problem of insufficient accuracy in photovoltaic power generation prediction was solved, achieving high-precision and stable photovoltaic power generation prediction, and improving the robustness and adaptability of the model.
Patent Information
- Application Number
- CN202511531840.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-24
- Publication Date
- 2026-02-06
AI Technical Summary
Existing photovoltaic power generation prediction methods suffer from insufficient accuracy, traditional physical models are unable to respond to minute-level meteorological changes, statistical methods are insufficient in capturing nonlinear change features, and machine learning methods rely on human experience to set parameters, resulting in underfitting of features and excessively high learning rates, making it difficult to meet the demand for high-precision prediction.
The Osprey optimization algorithm is used to drive the CNN-LSTM neural network. By screening meteorological factors that significantly affect photovoltaic power generation, the hyperparameters of the CNN-RCBAM-LSTM model are dynamically optimized. The RCBAM attention mechanism and Transformer encoder are combined for feature recalibration. A bidirectional long short-term memory network is used to capture time series features to achieve photovoltaic power generation prediction.
It improves the accuracy and stability of photovoltaic power generation forecasts, enhances the model's ability to analyze meteorological heterogeneity, improves the ability to identify and strengthen key features, reduces the deviation between predicted and actual values, and enhances the model's robustness and generalization performance under extreme weather conditions.
Smart Images

Figure CN121480804A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of renewable energy prediction technology, and in particular to a method and system for predicting photovoltaic power generation based on the Osprey optimization algorithm-driven CNN-LSTM neural network. Background Technology
[0002] Photovoltaic power generation is affected by various meteorological factors, exhibiting significant intermittency, volatility, and randomness. Traditional photovoltaic forecasting methods have significant limitations: physical model-based methods rely on precise modeling of component parameters, making them difficult to respond to minute-level meteorological changes; statistical methods (such as time series analysis) are insufficient in capturing nonlinear mutation features; while machine learning methods have improved, such as the CNN-LSTM combined architecture which extracts spatial features through convolutional neural networks and combines them with LSTM for time series modeling, core parameters such as the number of hidden layer nodes, learning rate, and training epochs rely on manual experience for setting, leading to underfitting of features, excessively high learning rates causing training oscillations, and inappropriate training epochs weakening generalization ability. Furthermore, features extracted solely through traditional CNNs cannot efficiently collaborate with subsequent processing modules, still failing to meet the practical needs of high-precision photovoltaic power generation forecasting. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to provide a method and system for predicting photovoltaic power generation based on the Osprey optimization algorithm-driven CNN-LSTM neural network, in order to address the above-mentioned deficiencies of the prior art, and to solve the problem of insufficient accuracy in estimating the power generation of photovoltaic systems in the prior art.
[0004] To address the aforementioned technical problems, in a first aspect, the present invention provides a method for predicting photovoltaic power generation based on a CNN-LSTM neural network driven by an Osprey optimization algorithm, comprising the following steps:
[0005] Historical meteorological data and photovoltaic power generation data of the target area are collected. The meteorological factors include at least irradiance, temperature and cloud cover, and meteorological factors that have a significant impact on photovoltaic power generation are selected from them.
[0006] Build the CNN-RCBAM-LSTM model;
[0007] The osprey population parameters are initialized using the osprey optimization algorithm, and global exploration and local mining are performed to dynamically optimize the hyperparameters of the CNN-RCBAM-LSTM model. The hyperparameters include at least the number of network units, the learning rate, and the number of training rounds.
[0008] Meteorological factors that significantly affect photovoltaic power generation are input into the CNN-RCBAM-LSTM model;
[0009] The system sequentially performs one-dimensional convolution to initially extract features, followed by feature recalibration based on the RCBAM attention mechanism. After multiple stacking operations, a preprocessed feature matrix is obtained. During the feature recalibration process, the coefficients involved are optimized using the Osprey optimization algorithm. Based on the preprocessed feature matrix, preliminary photovoltaic power generation prediction results are output.
[0010] Iteratively update the position of the osprey until the maximum number of iterations is reached, obtain the final optimization result, and complete the training of the CNN-RCBAM-LSTM model;
[0011] Real-time meteorological data that significantly affects photovoltaic power generation is obtained, and this real-time meteorological data is input into the trained CNN-RCBAM-LSTM model to obtain the final photovoltaic power generation prediction result.
[0012] In one embodiment, the method for screening meteorological factor data that have a significant impact on photovoltaic power generation is to calculate the Pearson correlation coefficient between each meteorological factor data and photovoltaic power generation data. When the absolute value of the Pearson correlation coefficient is greater than a preset threshold, the meteorological factor is considered to have a significant impact on photovoltaic power generation.
[0013] In one implementation, when initializing the osprey population parameters using the osprey optimization algorithm and performing global exploration and local mining, the following optimization formula is adopted:
[0014] Osprey population initialization:
[0015]
[0016] X i,j =l j +r i,j ·(k j -l j ),i=1,2,…,N,j=1,2,…,m,
[0017] In the formula: X represents the osprey population, X i,j Let be the element in the i-th row and j-th column of the matrix, representing the specific value of the i-th osprey on the j-th solution variable, where N is the osprey population size, m is the number of solution variables, and l j k is the lower bound for the j-th solution variable. j r is the upper bound of the j-th solution variable. i,j The value is a random number between 0 and 1, where i is the index of the individual osprey and j is the index of the variable being solved.
[0018] Phase One Global Exploration:
[0019] The position of each osprey is indicated as follows:
[0020] FP i={X k |k∈{1,2,...,N}∧F k <F i}∪{X best},
[0021] In the formula: FP i Let X be the set of locations of the i-th osprey. k Let F be the position of the k-th osprey. k Let F be the objective function value for the k-th osprey. i Let X be the objective function value for the i-th osprey. best The optimal position for the osprey, k is the index of the individual osprey;
[0022] Based on the motion simulation of ospreys fishing, the formula for calculating the new position of all ospreys is as follows: when the fitness of the objective function for the new position is higher, the osprey position is updated as follows:
[0023]
[0024] In the formula: Let X be the new position of the i-th osprey in the j-th dimension during the first stage. i,j Let i be the current position of the i-th osprey in the j-th dimension of the solution variable. for The corresponding fitness, r i,j S is a random number between 0 and 1. i,j I is a random number between 0 and 1. i,j F is a random number in the set. i Let X be the fitness of the current position of the i-th osprey. i The position vector of the i-th osprey;
[0025] Second phase of localized mining:
[0026] This study simulates the behavior of ospreys moving captured prey to a safe location for feeding. The osprey's position in the search space undergoes minor changes; when the objective function fitness of the new location is higher, the osprey's position is updated.
[0027]
[0028] In the formula: Let i be the new position of the i-th osprey in the j-th dimension during the second stage; for Corresponding fitness; X i,j Let l be the current position of the i-th osprey in the j-th solution variable dimension. j k is the lower bound for the j-th solution variable. j r is the upper bound of the j-th solution variable.i,j Let F be a random number between 0 and 1, t be the current iteration number, T be the maximum iteration number, and F be the maximum iteration number. i Let X be the fitness of the current position of the i-th osprey. i The position vector of the i-th osprey.
[0029] In one implementation, the feature recalibration based on the RCBAM attention mechanism includes:
[0030] For the feature tensor extracted by one-dimensional convolution, global average pooling and global max pooling are performed on the channel dimension respectively to obtain average pooling features and max pooling features. Then, the fused channel features are obtained by calculating a×average pooling features + b×max pooling features, where the coefficients a and b are obtained by optimization through the Osprey optimization algorithm. The fused channel features are input into a shared multilayer perceptron to obtain channel attention weights.
[0031] The channel attention weights are multiplied channel-wise with the feature tensor extracted by one-dimensional convolution to obtain the channel-weighted feature tensor. Average pooling and max pooling are then performed on the channel-weighted feature tensor in the spatial dimension to obtain the channel average pooling feature and channel max pooling feature. The fused spatial feature is then obtained by calculating c × channel average pooling feature + d × channel max pooling feature, where the coefficients c and d are optimized using the Osprey optimization algorithm. The fused spatial feature is then input into a one-dimensional convolutional layer to obtain the spatial attention weights.
[0032] The spatial attention weights are multiplied element-wise with the channel-weighted feature tensor to obtain the final feature tensor recalibrated by the RCBAM attention mechanism.
[0033] In one embodiment, the step of outputting preliminary photovoltaic power generation prediction results based on the preprocessed feature matrix further includes: inputting the preprocessed feature matrix into a Transformer encoder; constructing global dependencies across time steps in the preprocessed feature matrix based on the multi-head self-attention mechanism integrated in the Transformer encoder; weighting the importance of each element in the preprocessed feature matrix; and obtaining a deep feature matrix after passing through a residual connection structure and layer normalization in sequence; and outputting preliminary photovoltaic power generation prediction results based on the deep feature matrix.
[0034] In one implementation, the LSTM in the CNN-RCBAM-LSTM model is a bidirectional long short-term memory network.
[0035] In one implementation, a bidirectional long short-term memory network is used to stack forward and backward LSTM layers in parallel, which are then integrated via a fully connected layer and subjected to inverse normalization to obtain preliminary photovoltaic power generation prediction results. The calculation process of the hidden layers stacked in parallel with the forward and backward LSTM layers is as follows:
[0036] Forward LSTM layer: Processes the input sequence from front to back and computes the hidden state.
[0037] Backward LSTM layer: Processes the input sequence from back to front and computes the hidden state.
[0038] Final hidden state
[0039] In the formula, h t-1 The hidden state from the previous moment; x t For the current input; c t-1 This represents the LSTM network state at the previous moment; The element-wise sum of the forward and backward output components.
[0040] In one implementation, a prediction error index is calculated based on the final photovoltaic power generation prediction result. The prediction error index includes at least the mean absolute error (MAE), root mean square error (RMSE), and R0. 2 Fraction.
[0041] Secondly, this invention provides a system for predicting photovoltaic power generation based on an osprey optimization algorithm-driven CNN-LSTM neural network, the system comprising:
[0042] The data acquisition module is used to collect historical meteorological factor data and photovoltaic power generation data of the target area. The meteorological factors include at least irradiance, temperature and cloud cover, and the meteorological factors that have a significant impact on photovoltaic power generation are selected from them.
[0043] The model training module is used to build the CNN-RCBAM-LSTM model;
[0044] The osprey population parameters are initialized using the osprey optimization algorithm, and global exploration and local mining are performed to dynamically optimize the hyperparameters of the CNN-RCBAM-LSTM model. The hyperparameters include at least the number of network units, the learning rate, and the number of training rounds.
[0045] Meteorological factors that significantly affect photovoltaic power generation are input into the CNN-RCBAM-LSTM model;
[0046] The system sequentially performs one-dimensional convolutional feature extraction and RCBAM unit to perform feature recalibration based on RCBAM attention mechanism. After multiple stacking steps, a preprocessed feature matrix is obtained. During the feature recalibration process, the coefficients involved are optimized using the Osprey optimization algorithm. Based on the preprocessed feature matrix, the system outputs preliminary photovoltaic power generation prediction results through LSTM unit.
[0047] Iteratively update the position of the osprey until the maximum number of iterations is reached, obtain the final optimization result, and complete the training of the CNN-RCBAM-LSTM model;
[0048] The power generation prediction module is used to acquire real-time meteorological factor data that has a significant impact on photovoltaic power generation. This real-time meteorological factor data is then input into the trained CNN-RCBAM-LSTM model to obtain the final photovoltaic power generation prediction result.
[0049] In one implementation, the model training module further includes a Transformer unit, which is used to input the preprocessed feature matrix into the Transformer encoder. Based on the multi-head self-attention mechanism integrated in the Transformer encoder, the global dependencies across time steps in the preprocessed feature matrix are constructed, the importance of each element in the preprocessed feature matrix is weighted, and after passing through the residual connection structure and layer normalization processing in sequence, a deep feature matrix is obtained.
[0050] The beneficial effects of this invention are:
[0051] 1. By using Pearson correlation coefficients to screen out meteorological factors that significantly affect photovoltaic power generation, the redundancy of subsequent feature extraction and model calculation is reduced. Based on this, feature extraction is performed by combining RCBAM attention mechanism and transformer encoder. Channel attention weighting of key meteorological dimensions and spatial attention positioning of abrupt change regions enhance the model's ability to analyze meteorological spatial heterogeneity, achieving synergy between local feature capture, key feature enhancement and global temporal correlation mining, providing high-quality data support for accurate prediction of photovoltaic power generation.
[0052] 2. The Osprey optimization algorithm is introduced. On the one hand, it optimizes and adjusts the core hyperparameters of the model, effectively avoiding problems such as overfitting, slow convergence, and parameter fixation based on human experience caused by unreasonable hyperparameter settings. On the other hand, the algorithm optimizes the feature recalibration coefficients in the RCBAM attention mechanism, further improving the attention mechanism's ability to identify and strengthen key features. Furthermore, the Osprey optimization algorithm's simultaneous and coordinated optimization of both ensures that the final optimization result achieves a mutually compatible balance between the hyperparameters and the feature recalibration coefficients, thereby further improving the accuracy and stability of photovoltaic power generation prediction.
[0053] 3. Employing a bidirectional long short-term memory network can simultaneously capture both forward and reverse temporal dependencies in photovoltaic power generation time series data, enabling a more comprehensive extraction of temporal features from the data. The deep feature matrix extracted in the preceding steps through a collaborative mechanism of CNN and RCBAM-transformer works synergistically with the temporal feature processing capabilities of the BiLSTM network, further reducing the deviation between predicted and actual values.
[0054] 4. Construct a full life-cycle performance monitoring system for the predictive model, which can not only verify the model's ability to characterize the meteorological-power generation patterns, but also provide a comprehensive basis for model optimization and energy storage planning.
[0055] 5. By introducing a robust convolutional attention module, the model's resistance to outliers and noise in complex meteorological data is significantly enhanced. Under the dual weighting of channel and spatial attention, RCBAM can automatically identify and suppress the interference of noise signals, enabling the model to maintain high prediction stability and generalization performance under extreme weather conditions, thereby improving the robustness of photovoltaic power prediction under abrupt changes.
[0056] 6. The joint optimization of the Osprey optimization algorithm and deep attention networks forms an efficient global-local adaptive search mechanism. This mechanism takes into account both the global nature of parameter optimization and the local sensitivity of attention weighting, and can dynamically adjust the optimal parameter region within the search space to achieve adaptive and coordinated optimization of model structure parameters and feature weights, significantly improving the convergence speed and the probability of obtaining the global optimum during the training phase.
[0057] 7. The model proposed in this invention has good transferability and versatility. In addition to photovoltaic power generation prediction, this method can be applied to various renewable energy scenarios such as wind power output prediction and load demand prediction, and has broad application and promotion potential, providing a new technical path for the intelligent and automated development of the field of new energy power generation prediction. Attached Figure Description
[0058] The invention will now be further described with reference to the accompanying drawings.
[0059] Figure 1 This is a flowchart illustrating the photovoltaic power generation prediction process according to an embodiment of the present invention.
[0060] Figure 2 This is a power generation prediction diagram of the CNN-LSTM neural network method for predicting photovoltaic power generation based on the Osprey optimization algorithm in an embodiment of the present invention.
[0061] Figure 3 This is a power generation prediction graph of CNN-LSTM based on the traditional attention mechanism in an embodiment of the present invention. Detailed Implementation
[0062] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the present invention or its application or use. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0063] like Figure 1-3 As shown, this embodiment of the invention provides a method for predicting photovoltaic power generation based on the Osprey optimization algorithm-driven CNN-LSTM neural network, including the following steps:
[0064] S1. Collect historical meteorological data and photovoltaic power generation data of the target area. The meteorological factors include at least irradiance, temperature and cloud cover, and screen out the meteorological factors that have a significant impact on photovoltaic power generation.
[0065] In this embodiment, solar and meteorological data from the Desert Knowledge Australia Solar Centre (DKASC) and the European Centre for Medium-Range Weather Forecasts Reanalysis 5th Generation (ERA5) dataset were used, spanning from January 2021 to December 2021. Data was collected daily from 5:30 to 19:30 (local time), covering the effective output period of the photovoltaic system. The data collection interval was 5 minutes, covering photovoltaic output and multiple environmental parameters: air temperature, cloud opacity, relative humidity, direct solar radiation, diffuse solar radiation, fixed-tilt radiation, tracking-tilt radiation, atmospheric precipitation, surface air pressure, and wind speed at 10 meters above sea level.
[0066] When the historical photovoltaic power generation data cannot be directly obtained, it can be simulated using the following photovoltaic power generation system power formula, which includes the rated power of the photovoltaic array, the number of installations, the temperature coefficient, and the real-time solar radiation intensity.
[0067]
[0068] Q(t) = P pv (t)×1(2)
[0069] Where p pv The rated output power of the unit photovoltaic array is taken as 2kW; N pvThe number of photovoltaic arrays to be installed is set to 500. For a certain region (latitude: The hourly average surface solar radiation intensity at time t, in W / m² 2 G0 is the standard radiation intensity, taken as 1 kW / m². 2 ;θ T The power temperature coefficient of the photovoltaic array is taken as -0.35% / ℃ at normal ambient temperature and -0.70% / ℃ at low temperature; T is the current ambient temperature; T r The reference temperature for the photovoltaic array is 25℃; Q(t) is the power generation per hour.
[0070] In one embodiment, the method for screening meteorological factor data that significantly affects photovoltaic power generation is to calculate the Pearson correlation coefficient between each meteorological factor data and the photovoltaic power generation data. When the absolute value of the Pearson correlation coefficient is greater than a preset threshold, the meteorological factor is considered to have a significant impact on photovoltaic power generation. Alternatively, Spearman's rank correlation coefficient, Kendall's τ correlation coefficient, etc., can also be used to screen meteorological factors that significantly affect photovoltaic power generation.
[0071] This embodiment uses Python to calculate the correlation coefficients of air temperature, cloud opacity, relative humidity, direct solar radiation, diffuse solar radiation, fixed-tilt radiation, tracking-tilt radiation, atmospheric precipitation, surface air pressure, and wind speed at a height of 10 meters. The results are shown in Table 1. This embodiment uses a preset threshold of 0.3. The calculation results show that atmospheric precipitation, surface air pressure, and wind speed at a height of 10 meters have low correlations with photovoltaic power generation. Therefore, the remaining features are selected as input parameters for the prediction model in this embodiment for training and testing.
[0072] Table 1 Correlation coefficients between meteorological factors and photovoltaic power generation
[0073]
[0074] S2, build the CNN-RCBAM-LSTM model;
[0075] First, local temporal features of the input features are extracted using a one-dimensional convolutional layer (Conv1D). The convolutional output is then fed into a robust attention module (RCBAM), where channel attention and spatial attention operations are performed: Global average pooling and global max pooling are performed along the channel dimension, using the Osprey optimization algorithm to determine weighting coefficients a and b, calculating the fused channel features, and passing them through a shared multilayer perceptron to obtain channel attention weights; Average pooling and max pooling are performed along the spatial dimension, using the Osprey optimization algorithm to determine weighting coefficients c and d, calculating the fused spatial features, and passing them through a one-dimensional convolutional layer to obtain spatial attention weights. The channel and spatial weights are then applied sequentially to the original feature tensor, achieving channel-wise and spatial-wise recalibration of the features, thereby enhancing the expressive power of key meteorological factors. The output of this module undergoes feature smoothing and dimensionality reduction through multiple convolutional layers and the robust attention module to obtain a fused and weighted deep feature tensor, which is then passed to the Transformer module. In the Transformer module, positional encoding is first added to the input sequence to preserve the positional information of the time series. The weighted features are then input into a multi-head self-attention mechanism structure. By computing the correlation matrix of multiple attention heads in parallel, global dependencies across time steps are captured. Attention scores are normalized using Softmax, and the value matrix is then weighted and summed to form a context-aware temporal feature representation. This output is then processed through residual connections and layer normalization, followed by nonlinear feature mapping via a feedforward neural network to form a deep feature matrix with global dependencies, providing input for subsequent temporal refinement. The deep feature matrix output from the Transformer is input into a Bidirectional Long Short-Term Memory (BiLSTM) network. Parallel forward and backward LSTM layers simultaneously capture the positive and negative dependencies of the time series. The forward LSTM models historical trends, while the backward LSTM analyzes future associations; their outputs are concatenated to form a complete temporal representation vector. The BiLSTM output is followed by a feature fusion output layer to integrate global and local temporal features, improving prediction accuracy and stability. The feature vector output from the BiLSTM is then input into the feature fusion output layer, where a fully connected layer performs feature mapping and power prediction output, yielding a preliminary prediction of photovoltaic power generation.
[0076] S3. Using the Osprey optimization algorithm, initialize the Osprey population parameters and perform global exploration and local mining to dynamically optimize the hyperparameters of the CNN-RCBAM-LSTM model. The hyperparameters include at least the number of network units, the learning rate, and the number of training rounds.
[0077] Specifically, the parameters of the osprey population are first initialized. These parameters correspond to the hyperparameters (number of network units, learning rate, number of training epochs, etc.) of the CNN-RCBAM-LSTM model to be optimized. The position of each osprey represents a set of hyperparameter combinations. The iteration count t is initialized to 1, and then a loop iteration process is entered. In each iteration, t = t + 1 is executed to update the iteration count.
[0078] First, a global exploration is conducted. By simulating the global search behavior of an osprey in nature, the hyperparameter space is extensively explored to avoid getting trapped in local optima. After identifying a potential region through global exploration, the osprey will conduct refined local mining in the vicinity of that region. This involves meticulously adjusting and optimizing the potential optimal hyperparameter set to uncover the optimal solution within that region.
[0079] In one implementation, when performing global exploration and local mining using the Osprey optimization algorithm, the following optimization formula is employed:
[0080] 1) Osprey population initialization
[0081]
[0082] X i,j =l j +r i,j ·(k j -l j ), i = 1, 2, ..., N, j = 1, 2, ..., m
[0083] In the formula: X represents the osprey population, X i,j Let be the element in the i-th row and j-th column of the matrix, representing the specific value of the i-th osprey on the j-th solution variable, where N is the osprey population size, m is the number of solution variables, and l j k is the lower bound for the j-th solution variable. j r is the upper bound of the j-th solution variable. i,j is a random number between 0 and 1, i is the index of the individual osprey, and j is the index of the variable to be solved.
[0084] 2) Global Exploration (Phase 1)
[0085] The first stage of population renewal in OOA is modeled based on a simulation of the natural behavior of ospreys diving underwater to hunt fish after determining their location. In the OOA design, for each osprey, the locations of other ospreys in the search space with better objective function values are considered as underwater fish. The location of each osprey can be represented as:
[0086] FP i ={X k |k∈{1,2,...,N}∧F k <Fi}∪{X best}
[0087] In the formula: FP i Let X be the set of locations of the i-th osprey. k Let F be the position of the k-th osprey. k Let F be the objective function value for the k-th osprey. i Let X be the objective function value for the i-th osprey. best The optimal position for the osprey is given by k, where k is the index of the individual osprey.
[0088] During the hunt, the osprey randomly detects the position of a fish and attacks. Based on the motion simulation of the osprey catching fish, the formula for calculating the new position of all ospreys is as follows: when the objective function fitness of the new position is higher, the osprey will replace the previous position; when the objective function fitness of the new position is higher, the osprey position is updated as follows:
[0089]
[0090] In the formula: Let X be the new position of the i-th osprey in the j-th dimension during the first stage. i,j Let i be the current position of the i-th osprey in the j-th dimension of the solution variable. for The corresponding fitness, r i,j S is a random number between 0 and 1. i,j I is a random number between 0 and 1. i,j F is a random number in the set. i Let X be the fitness of the current position of the i-th osprey. i The position vector of the i-th osprey.
[0091] 3) Localized mining (Phase II)
[0092] This phase simulates the behavior of ospreys moving captured prey to a safe location for feeding. This behavior causes a slight change in the osprey's position in the search space, thereby enhancing the algorithm's local search capability. When the objective function of the new position has a higher fitness, the osprey's position is updated to...
[0093]
[0094] In the formula: Let i be the new position of the i-th osprey in the j-th dimension during the second stage; for Corresponding fitness; X i,j Let l be the current position of the i-th osprey in the j-th solution variable dimension. j k is the lower bound for the j-th solution variable.j r is the upper bound of the j-th solution variable. i,j Let F be a random number between 0 and 1, t be the current iteration number, T be the maximum iteration number, and F be the maximum iteration number. i Let X be the fitness of the current position of the i-th osprey. i The position vector of the i-th osprey.
[0095] S4. Input meteorological data that have a significant impact on photovoltaic power generation into the CNN-RCBAM-LSTM model;
[0096] The system sequentially performs one-dimensional convolution to initially extract features, followed by feature recalibration based on the RCBAM attention mechanism. After multiple stacking operations, a preprocessed feature matrix is obtained. During the feature recalibration process, the coefficients involved are optimized using the Osprey optimization algorithm. Based on the preprocessed feature matrix, preliminary photovoltaic power generation prediction results are output.
[0097] In one implementation, the feature recalibration based on the RCBAM attention mechanism includes:
[0098] For the feature tensor extracted by one-dimensional convolution, global average pooling and global max pooling are performed on the channel dimension respectively to obtain average pooling features and max pooling features. Then, the fused channel features are obtained by calculating a×average pooling features + b×max pooling features, where the coefficients a and b are obtained by optimization through the Osprey optimization algorithm. The fused channel features are input into a shared multilayer perceptron to obtain channel attention weights.
[0099] The channel attention weights are multiplied channel-wise with the feature tensor extracted by one-dimensional convolution to obtain the channel-weighted feature tensor. Average pooling and max pooling are then performed on the channel-weighted feature tensor in the spatial dimension to obtain the channel average pooling feature and channel max pooling feature. The fused spatial feature is then obtained by calculating c × channel average pooling feature + d × channel max pooling feature, where the coefficients c and d are optimized using the Osprey optimization algorithm. The fused spatial feature is then input into a one-dimensional convolutional layer to obtain the spatial attention weights.
[0100] The spatial attention weights are multiplied element-wise with the channel-weighted feature tensor to obtain the final feature tensor recalibrated by the RCBAM attention mechanism.
[0101] Since the coefficients a, b, c, and d are all obtained through the Osprey optimization algorithm, the position of each Osprey not only represents a set of hyperparameter combinations, but also includes the coefficients a, b, c, and d.
[0102] In one implementation, the step of outputting preliminary photovoltaic power generation prediction results based on the preprocessed feature matrix further includes: inputting the preprocessed feature matrix into a Transformer encoder to extract key features from the feature matrix and generate corresponding context-aware representations; constructing global dependencies across time steps in the preprocessed feature matrix based on the multi-head self-attention mechanism integrated in the Transformer encoder; weighting the importance of each element in the preprocessed feature matrix; and obtaining a deep feature matrix after passing through a residual connection structure and layer normalization; and inputting the deep feature matrix into a bidirectional long short-term memory network for further modeling of temporal dependencies to output preliminary photovoltaic power generation prediction results. The attention score calculation formula for the multi-head self-attention mechanism is as follows:
[0103]
[0104] In the formula, Q is the query matrix; K is the keyword matrix; V is the value matrix; d k For vector dimensions.
[0105] The attention score is used to measure the correlation and dependence strength between time steps in the input sequence. By concatenating the outputs of multiple attention heads, the model can fuse the feature information extracted by different attention heads, thereby comprehensively capturing the correlation features in the input sequence. The calculation process can be expressed as follows:
[0106] MultiHead(Q,K,V)=Concat(Attention1(Q1,K1,V1),…,Attention1(Q h ,K h V h ))W o
[0107] In the formula: Q is the query matrix; K is the keyword matrix; V is the value matrix; h is the number of attention heads; W o It is a learnable matrix.
[0108] S5, iteratively update the position of the osprey until the maximum number of iterations is reached, obtain the final optimization result, and complete the training of the CNN-RCBAM-LSTM model;
[0109] Specifically, this embodiment uses mean squared error (MSE) as the fitness function, and determines the final optimization result in the current iteration by comparing the fitness of all Ospreys.
[0110] The mean squared error (MSE) is calculated as follows:
[0111] Root mean square error
[0112] In the formula, Y i This represents the actual power generation value. To predict the power generation value, n is the number of samples, and MSE is the average of the sum of squares of all prediction errors;
[0113] Because photovoltaic power generation is affected by its own fluctuations, the selection of prediction models, and the quality of historical data, there will be errors between the prediction results and the actual photovoltaic power generation. Therefore, it is necessary to evaluate the prediction accuracy and performance of each model through error evaluation indicators. Selecting a good error evaluation indicator plays an important role in prediction error analysis. Mean Squared Error (RMSE) is used to construct a prediction model evaluation system, providing a comprehensive basis for model optimization.
[0114] The smaller the mean squared error (MSE), the better the model performance. The optimal optimization result is the parameter of the model that performs best under the MSE index.
[0115] Specifically, the prediction performance of the OOA-CNN-LSTM model proposed in this embodiment and the traditional CNN-LSTM model are shown in Table 2:
[0116] Table 2 Fitness functions and evaluation metrics based on different prediction algorithms
[0117]
[0118] As can be seen from Table 2, the OOA-CNN-LSTM model designed in this invention has better prediction performance compared with the CNN-LSTM model.
[0119] S6. Obtain real-time meteorological data that significantly affects photovoltaic power generation, and input this real-time meteorological data into the trained CNN-RCBAM-LSTM model to obtain the final photovoltaic power generation prediction result, such as... Figure 2 As shown, this is the final photovoltaic power generation prediction result obtained in this embodiment. Figure 3 The figure shown is a power generation prediction graph of CNN-LSTM based on the traditional attention mechanism.
[0120] In one implementation, a prediction error index is calculated based on the final photovoltaic power generation prediction result. The prediction error index includes at least the mean absolute error (MAE), root mean square error (RMSE), and R0. 2 Fraction.
[0121] The specific calculation method is as follows:
[0122] Mean Absolute Error
[0123] In the formula, Y i This represents the actual power generation value. To predict the power generation value, n is the number of samples, and MAE represents the average prediction error of all samples;
[0124] Root mean square error
[0125] In the formula, Y i This represents the actual power generation value. To predict the power generation value, n is the number of samples, and RMSE is the square root of the average of the sum of squares of all prediction errors;
[0126]
[0127] In the formula, Y i This represents the actual power generation value. To predict power generation values, R is the mean of the actual power generation, where n is the number of samples. 2 The score typically ranges between 0 and 1, with a higher value indicating a more accurate prediction. 2 A value less than 0 indicates a very poor prediction result.
[0128] This invention also provides a system for predicting photovoltaic power generation based on an Osprey optimization algorithm-driven CNN-LSTM neural network, the system comprising:
[0129] The data acquisition module is used to collect historical meteorological factor data and photovoltaic power generation data of the target area. The meteorological factors include at least irradiance, temperature and cloud cover, and the meteorological factors that have a significant impact on photovoltaic power generation are selected from them.
[0130] The model training module is used to build the CNN-RCBAM-LSTM model;
[0131] The osprey population parameters are initialized using the osprey optimization algorithm, and global exploration and local mining are performed to dynamically optimize the hyperparameters of the CNN-RCBAM-LSTM model. The hyperparameters include at least the number of network units, the learning rate, and the number of training rounds.
[0132] Meteorological factors that significantly affect photovoltaic power generation are input into the CNN-RCBAM-LSTM model;
[0133] The system sequentially performs one-dimensional convolutional feature extraction and RCBAM unit to perform feature recalibration based on RCBAM attention mechanism. After multiple stacking steps, a preprocessed feature matrix is obtained. During the feature recalibration process, the coefficients involved are optimized using the Osprey optimization algorithm. Based on the preprocessed feature matrix, the system outputs preliminary photovoltaic power generation prediction results through LSTM unit.
[0134] Iteratively update the position of the osprey until the maximum number of iterations is reached, obtain the final optimization result, and complete the training of the CNN-RCBAM-LSTM model;
[0135] The power generation prediction module is used to acquire real-time meteorological factor data that has a significant impact on photovoltaic power generation. This real-time meteorological factor data is then input into the trained CNN-RCBAM-LSTM model to obtain the final photovoltaic power generation prediction result.
[0136] In one implementation, the model training module further includes a Transformer unit, which is used to input the preprocessed feature matrix into the Transformer encoder. Based on the multi-head self-attention mechanism integrated in the Transformer encoder, the global dependencies across time steps in the preprocessed feature matrix are constructed, the importance of each element in the preprocessed feature matrix is weighted, and after passing through the residual connection structure and layer normalization processing in sequence, a deep feature matrix is obtained.
Claims
1. A method for predicting photovoltaic power generation based on the Osprey optimization algorithm-driven CNN-LSTM neural network, characterized in that, Includes the following steps: Historical meteorological data and photovoltaic power generation data of the target area are collected. The meteorological factors include at least irradiance, temperature and cloud cover, and meteorological factors that have a significant impact on photovoltaic power generation are selected from them. Build the CNN-RCBAM-LSTM model; The osprey population parameters are initialized using the osprey optimization algorithm, and global exploration and local mining are performed to dynamically optimize the hyperparameters of the CNN-RCBAM-LSTM model. The hyperparameters include at least the number of network units, the learning rate, and the number of training rounds. Meteorological factors that significantly affect photovoltaic power generation are input into the CNN-RCBAM-LSTM model; One-dimensional convolution is performed sequentially to extract features, followed by feature recalibration based on the RCBAM attention mechanism. After multiple stacking steps, a preprocessed feature matrix is obtained. During the feature recalibration process, the coefficients involved are obtained by optimization using the Osprey optimization algorithm; Based on the preprocessed feature matrix, preliminary photovoltaic power generation prediction results are output. Iteratively update the position of the osprey until the maximum number of iterations is reached, obtain the final optimization result, and complete the training of the CNN-RCBAM-LSTM model; Real-time meteorological data that significantly affects photovoltaic power generation is obtained, and this real-time meteorological data is input into the trained CNN-RCBAM-LSTM model to obtain the final photovoltaic power generation prediction result.
2. The method for predicting photovoltaic power generation based on the Osprey optimization algorithm-driven CNN-LSTM neural network as described in claim 1, characterized in that: The method for screening meteorological factor data that have a significant impact on photovoltaic power generation is to calculate the Pearson correlation coefficient between each meteorological factor data and photovoltaic power generation data. When the absolute value of the Pearson correlation coefficient is greater than a preset threshold, the meteorological factor is considered to have a significant impact on photovoltaic power generation.
3. The method for predicting photovoltaic power generation based on the Osprey optimization algorithm-driven CNN-LSTM neural network as described in claim 1, characterized in that: When initializing the Osprey population parameters using the Osprey optimization algorithm and performing global exploration and local mining, the following optimization formula is adopted: Osprey population initialization: X i,j =l j +r i,j ·(k j -l j ),i=1,2,…,N,j=1,2,…,m, In the formula: X represents the osprey population, X i,j Let be the element in the i-th row and j-th column of the matrix, representing the specific value of the i-th osprey on the j-th solution variable, where N is the osprey population size, m is the number of solution variables, and l j k is the lower bound for the j-th solution variable. j r is the upper bound of the j-th solution variable. i,j The value is a random number between 0 and 1, where i is the index of the individual osprey and j is the index of the variable being solved. Phase One Global Exploration: The position of each osprey is indicated as follows: FP i ={X k |k∈{1,2,...,N}∧F k <F i }∪{X best }, In the formula: FP i Let X be the set of locations of the i-th osprey. k Let F be the position of the k-th osprey. k Let F be the objective function value for the k-th osprey. i Let X be the objective function value for the i-th osprey. best The optimal position for the osprey, k is the index of the individual osprey; Based on the motion simulation of ospreys fishing, the formula for calculating the new position of all ospreys is as follows: when the fitness of the objective function for the new position is higher, the osprey position is updated as follows: In the formula: Let X be the new position of the i-th osprey in the j-th dimension during the first stage. i,j Let i be the current position of the i-th osprey in the j-th dimension of the solution variable. for The corresponding fitness, r i,j S is a random number between 0 and 1. i,j I is a random number between 0 and 1. i,j F is a random number in the set. i Let X be the fitness of the current position of the i-th osprey. i The position vector of the i-th osprey; Second phase of localized mining: This study simulates the behavior of ospreys moving captured prey to a safe location for feeding. The osprey's position in the search space undergoes minor changes; when the objective function fitness of the new location is higher, the osprey's position is updated. In the formula: Let i be the new position of the i-th osprey in the j-th dimension during the second stage; for Corresponding fitness; X i,j Let l be the current position of the i-th osprey in the j-th solution variable dimension. j k is the lower bound for the j-th solution variable. j r is the upper bound of the j-th solution variable. i,j Let F be a random number between 0 and 1, t be the current iteration number, T be the maximum iteration number, and F be the maximum iteration number. i Let X be the fitness of the current position of the i-th osprey. i The position vector of the i-th osprey.
4. The method for predicting photovoltaic power generation based on the Osprey optimization algorithm-driven CNN-LSTM neural network as described in claim 1, characterized in that: The feature recalibration based on the RCBAM attention mechanism includes: For the feature tensor extracted by one-dimensional convolution, global average pooling and global max pooling are performed on the channel dimension respectively to obtain average pooling features and max pooling features. Then, the fused channel features are obtained by calculating a×average pooling features + b×max pooling features, where the coefficients a and b are obtained by optimization through the Osprey optimization algorithm. The fused channel features are input into a shared multilayer perceptron to obtain channel attention weights. The channel attention weights are multiplied channel-wise with the feature tensor extracted by one-dimensional convolution to obtain the channel-weighted feature tensor. Average pooling and max pooling are then performed on the channel-weighted feature tensor in the spatial dimension to obtain the channel average pooling feature and channel max pooling feature. The fused spatial feature is then obtained by calculating c × channel average pooling feature + d × channel max pooling feature, where the coefficients c and d are optimized using the Osprey optimization algorithm. The fused spatial feature is then input into a one-dimensional convolutional layer to obtain the spatial attention weights. The spatial attention weights are multiplied element-wise with the channel-weighted feature tensor to obtain the final feature tensor recalibrated by the RCBAM attention mechanism.
5. The method for predicting photovoltaic power generation based on the Osprey optimization algorithm-driven CNN-LSTM neural network as described in claim 1, characterized in that: The step of outputting preliminary photovoltaic power generation prediction results based on the preprocessed feature matrix further includes: inputting the preprocessed feature matrix into the Transformer encoder; constructing the global dependency relationship across time steps in the preprocessed feature matrix based on the multi-head self-attention mechanism integrated in the Transformer encoder; weighting the importance of each element in the preprocessed feature matrix; and obtaining the deep feature matrix after passing through the residual connection structure and layer normalization in sequence. Based on this deep feature matrix, preliminary photovoltaic power generation prediction results are output.
6. The method for predicting photovoltaic power generation based on the Osprey optimization algorithm-driven CNN-LSTM neural network as described in claim 1, characterized in that: The LSTM in the CNN-RCBAM-LSTM model is a bidirectional long short-term memory network.
7. The method for predicting photovoltaic power generation based on the Osprey optimization algorithm-driven CNN-LSTM neural network as described in claim 6, characterized in that: A bidirectional long short-term memory network is used to stack forward and backward LSTM layers in parallel, which are then integrated via a fully connected layer and processed by inverse normalization to obtain preliminary photovoltaic power generation prediction results. The calculation process of the hidden layers stacked in parallel with the forward and backward LSTM layers is as follows: Forward LSTM layer: Processes the input sequence from front to back and computes the hidden state. Backward LSTM layer: Processes the input sequence from back to front and computes the hidden state. Final hidden state In the formula, h t-1 The hidden state from the previous moment; x t For the current input; c t-1 This represents the LSTM network state at the previous moment; The element-wise sum of the forward and backward output components.
8. The method for predicting photovoltaic power generation based on the Osprey optimization algorithm-driven CNN-LSTM neural network as described in claim 1, characterized in that: The prediction error index is calculated based on the final photovoltaic power generation prediction results. The prediction error index includes at least the mean absolute error (MAE), root mean square error (RMSE), and R0. 2 Fraction.
9. A system for predicting photovoltaic power generation based on the Osprey optimization algorithm-driven CNN-LSTM neural network, characterized in that, The system includes: The data acquisition module is used to collect historical meteorological factor data and photovoltaic power generation data of the target area. The meteorological factors include at least irradiance, temperature and cloud cover, and the meteorological factors that have a significant impact on photovoltaic power generation are selected from them. The model training module is used to build the CNN-RCBAM-LSTM model; The osprey population parameters are initialized using the osprey optimization algorithm, and global exploration and local mining are performed to dynamically optimize the hyperparameters of the CNN-RCBAM-LSTM model. The hyperparameters include at least the number of network units, the learning rate, and the number of training rounds. Meteorological factors that significantly affect photovoltaic power generation are input into the CNN-RCBAM-LSTM model; The system sequentially performs one-dimensional convolutional feature extraction and RCBAM unit to perform feature recalibration based on RCBAM attention mechanism. After multiple stacking steps, a preprocessed feature matrix is obtained. During the feature recalibration process, the coefficients involved are optimized using the Osprey optimization algorithm. Based on the preprocessed feature matrix, the system outputs preliminary photovoltaic power generation prediction results through LSTM unit. Iteratively update the position of the osprey until the maximum number of iterations is reached, obtain the final optimization result, and complete the training of the CNN-RCBAM-LSTM model; The power generation prediction module is used to acquire real-time meteorological factor data that has a significant impact on photovoltaic power generation. This real-time meteorological factor data is then input into the trained CNN-RCBAM-LSTM model to obtain the final photovoltaic power generation prediction result.
10. The system for predicting photovoltaic power generation based on the Osprey optimization algorithm-driven CNN-LSTM neural network as described in claim 9, characterized in that: The model training module also includes a Transformer unit, which is used to input the preprocessed feature matrix into the Transformer encoder. Based on the multi-head self-attention mechanism integrated in the Transformer encoder, the global dependencies across time steps in the preprocessed feature matrix are constructed, the importance of each element in the preprocessed feature matrix is weighted, and after passing through the residual connection structure and layer normalization processing in sequence, a deep feature matrix is obtained.
Citation Information
Cited By
Data processing method for farmland-to-forest performance-excellent mode screening and effect prediction
CN121707153A
Laser printer control task management method and system based on deep learning
CN122387398A