Wind and solar power prediction method based on collaborative learning strategy and encoding and decoding architecture
Through a method based on collaborative learning strategy and codec architecture, the accuracy problem of wind and light power prediction is solved, and higher prediction accuracy and stability are achieved, supporting the stable operation of the power grid and the efficient utilization of new energy.
Patent Information
- Application Number
- CN202411837144.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-04-08
AI Technical Summary
The existing technology cannot accurately predict wind and light power data, which has affected the stability of the power grid and the efficiency of new energy utilization.
A wind power prediction method based on collaborative learning strategies and codec architecture is adopted to build a wind power prediction model through variational modal decomposition, collaborative learning strategies, optimization of loss functions and encoder-decoder architecture.
It significantly improves the accuracy, stability and real-time performance of wind and light power prediction, optimizes the prediction capabilities of short-term fluctuations and long-term trends, and improves the utilization efficiency of new energy and the stable operation of the power grid.
Smart Images

Figure CN119787316A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of new energy technology, and in particular to a wind and solar power prediction method based on a collaborative learning strategy and a coding and decoding architecture. Background Art
[0002] With the gradual decrease in global fossil energy reserves and the proposal of carbon neutrality goals, countries are accelerating the construction of power systems based on new energy. In my country, the development and utilization of new energy such as wind energy and photovoltaics have made significant progress. At the same time, the successful dispatching, real-time control and operation planning of the power system are inseparable from accurate power forecasting, which is the key to maintaining supply and demand balance. With the significant increase in the total power load and the continuous evolution of the power grid structure, accurate wind and solar power forecasting is crucial.
[0003] However, due to the large volatility and randomness of wind and solar power data, it poses a challenge to the stability of the power system and makes it difficult to fully absorb new energy. Therefore, accurate wind and solar power forecasting has become a key technical means to ensure the stable operation of the power grid and improve the efficiency of new energy utilization. By improving the accuracy of wind and solar power forecasting, the stable operation of the power grid can be effectively guaranteed, the impact of renewable energy grid connection on the power system can be reduced, the utilization efficiency of new energy can be improved, and the energy goals of sustainable development can be achieved. Summary of the invention
[0004] In view of this, the purpose of the present invention is to provide a wind and solar power prediction method based on a collaborative learning strategy and a codec architecture to solve the problem that the prior art cannot accurately predict wind and solar power data.
[0005] To achieve the above invention, the present invention provides a wind-solar power prediction method based on a collaborative learning strategy and a codec architecture, the method comprising the following steps:
[0006] S101, collecting historical data of wind farms and photovoltaic farms: obtaining the geographical location, power, and wind speed data of each wind turbine in the wind farm, and the geographical location, power, and temperature data of each photovoltaic panel in the photovoltaic farm, and establishing a wind and photovoltaic power original data set;
[0007] S102, data preprocessing: performing outlier detection and outlier processing on the original data set of wind and solar power, and normalizing the processed data;
[0008] S103, KNN data enhancement: perform data enhancement on the original wind and solar power data set after data preprocessing, use geographic location information to find neighboring devices, and enrich prediction features by merging wind speed and temperature data of neighboring devices to construct a wind and solar power time series data set. The neighboring devices include wind turbines and photovoltaic panels.
[0009] S104, dynamic division of data set: dynamically divide the wind and solar power time series data set;
[0010] S105, VMD decomposition: Perform VMD decomposition on the dynamically divided wind and solar power time series data set to decompose it into multiple modes;
[0011] S106. Construction of loss function based on collaborative learning strategy: Construct a collaborative loss function, use the collaborative loss function to guide the neural network to learn to extract the relationship between various modes during the VMD decomposition process, and optimize the collaborative learning between different modes and the wind and solar power time series data set;
[0012] S107, constructing a wind-solar power prediction model: based on step S106, constructing a wind-solar power prediction model of an Encoder-Decoder architecture;
[0013] S108. Use the PyTorch framework to implement a wind-solar power prediction model based on the Encoder-Decoder architecture: input data to train and verify the wind-solar power prediction model, and optimize the hyperparameters of the model;
[0014] S109. Based on step S108, output the predicted value of wind and solar power data.
[0015] Furthermore, the outlier detection specifically includes the following steps:
[0016] S21, respectively calculating the average values of wind power and photovoltaic power, that is, dividing the sum of all data points by the number of data points;
[0017] S22, respectively calculating the standard deviation of wind power and photovoltaic power, where the standard deviation reflects the degree of dispersion between data points;
[0018] S23. Based on steps S21-S22, the Z-Score of each data point is calculated, which is expressed as follows:
[0019]
[0020] Among them, Z is Z-Score, X i is the i-th data point, μ is the average value of wind power and photovoltaic power, and σ is the standard deviation of wind power and photovoltaic power;
[0021] S24. Determine the criteria for determining outliers, select a threshold of 2, and when the absolute value of the Z-Score of a data point is greater than 2, the data point is considered to be an outlier.
[0022] Furthermore, the outlier processing includes setting a window size, calculating an average value within the window, and replacing outliers.
[0023] Furthermore, the step S103 specifically includes the following steps:
[0024] S31. Calculate the geographical distance between the wind turbine and the photovoltaic panel by using the geographical coordinates, as shown below:
[0025]
[0026] Where d is the geographical distance between the wind turbine and the photovoltaic panel, r is the radius of the earth, Δ is the latitude difference between the two locations, and φ 1 ,φ 2 are the latitudes of the two locations, and Δλ is the longitude difference between the two locations;
[0027] S32, based on the wind turbine or photovoltaic panel to be predicted, find K neighboring wind turbines and photovoltaic panels by calculating the geographical distance;
[0028] S33, merging the pre-processed wind speed and temperature data of the adjacent wind turbines and photovoltaic panels into a three-dimensional feature vector, and adding time features and power features to form a feature vector containing five-dimensional information;
[0029] S34. Based on step S33, the time features of wind turbines and photovoltaic panels are expanded into a time series, ensuring that the input features contain information about neighboring devices, and constructing a wind and solar power time series data set.
[0030] Furthermore, the dynamic division of the wind and solar power time series data set specifically includes:
[0031] Define sliding window parameters: divide the wind and solar power time series data set into training set, validation set, and test set, select the window size as 1000 time steps, set the validation set size to 200 time steps, and the step size to 100 time steps.
[0032] Furthermore, in step S105, the modal decomposition number is 3.
[0033] Furthermore, the step S106 specifically includes the following steps:
[0034] S61. Based on the modal decomposition number being selected as 3, the wind and solar power time series data set is decomposed into multiple modes, and the Pearson correlation coefficient between each decomposed mode and the wind and solar power time series data set is calculated, which is expressed as follows:
[0035]
[0036] Among them, ω i is the Pearson correlation coefficient between the ith decomposition mode and the wind and solar power time series data set, x is the wind and solar power time series data set, y iis the sequence after decomposition, n is the number of decompositions;
[0037] S62. Perform a convolution operation on the decomposed mode, and then activate the data through the Sigmoid function to obtain the collaborative parameters, which are expressed as follows:
[0038] Y fi =f i1 ω 1 +f i2 ω 2 +f i3 ω 3
[0039] Among them, Y fi is the coordination parameter, f i1 、f i2 、f i3 are the VMD decomposition values after convolution of sequence i, ω 1 ,ω 2 ,ω 3 They are the Pearson correlation coefficients between the decomposed mode and the wind and solar power time series data set;
[0040] S63. Based on the collaborative parameters, a collaborative loss function is constructed to optimize the collaborative learning between different modes and wind and solar power time series data sets, which is expressed as follows:
[0041]
[0042] Among them, loss co is the collaborative loss function, i is the i-th sample, n is the number of predictions, Y i is the true value of the i-th sample, is the predicted value of the i-th sample, Y fi is a coordination parameter.
[0043] Furthermore, the construction of the Encoder module specifically includes the following steps:
[0044] S71, the Encoder module performs feature encoding on the input sequence and receives the input data after preprocessing and feature merging. The input data includes wind speed features, time features, and power data of the target wind turbine, which are expressed as follows:
[0045]
[0046] Among them, x t is the input feature vector at time t, To predict the wind speed of the wind turbine at time t, and are the wind speed of the neighboring wind turbine at time t, u t is the time characteristic at time t, Predict the wind turbine power at time t;
[0047] S72, based on step S71, the input data is processed step by step through multiple layers of GRU, each layer of GRU will generate a hidden state of a time step, the hidden state contains the information of all time steps in the input sequence, expressed as follows:
[0048] z t =σ(W z *x t +U z *h t-1 )
[0049] r t =σ(W r *x t +U r *h t-1 )
[0050] h′ t =tanh(W h *x t +U h *(r t ⊙h t-1 ))
[0051] h t =(1-z t )⊙h t-1 +z t ⊙h′ t
[0052] Among them, z t is the output of the update gate, σ is the activation function, W z , W r , W h are respectively t The associated weight matrix, U z , U r , U h They are respectively the hidden state h of the previous moment t-1 The associated weight matrix, r t is the output of the reset gate, h′ t is the candidate hidden state, h t is the hidden state at the current moment;
[0053] S73. The hidden state generated by the multi-layer GRU is passed to the Self-Attention layer. The Self-Attention mechanism determines the importance of each time step in the input sequence to the current decoding moment by calculating the attention weight of each time step, which is expressed as follows:
[0054] Q t=W Q *h t ,K t =W K *h t ,V t =W V *h t
[0055]
[0056]
[0057] Among them, Q t , K t 、V t They are query vector, key vector, and value vector respectively, and the input hidden state h at time t t After the weight matrix W Q , W K , W V After transformation, we get; α ij The value vector V at time j when calculating the output at time i is j The weight assigned; Q i is the query vector at time i; is the transpose of the key vector at time j; the superscript T is the transpose operation of the matrix; V is the key vector; d k is the dimension of the key vector; O i is the final output vector at time i.
[0058] Furthermore, the Decoder module gradually generates future wind and solar power predictions based on the weighted context vector generated by the Encoder module and the historical state of the Decoder module itself.
[0059] Furthermore, the input data is used to train and verify the wind and solar power prediction model, including customizing the loss function, setting the training and verification process, and using evaluation indicators to test the performance of the wind and solar power prediction model.
[0060] Compared with the prior art, the present invention has the following beneficial effects:
[0061] The present invention proposes a wind and solar power prediction method based on a collaborative learning strategy and a codec architecture. By combining variational mode decomposition, collaborative learning strategy, optimized loss function and encoder-decoder architecture, the accuracy, stability and real-time performance of wind and solar power prediction are significantly improved. By adopting a model based on the encoder-decoder architecture, combined with the spatial layout data of wind turbines and photovoltaic panels and historical meteorological information (such as wind speed, temperature, etc.), the model can capture the temporal and spatial dependencies, effectively consider the mutual influence between different devices, and further optimize the prediction ability of short-term fluctuations and long-term trends. The present invention improves the accuracy and stability of wind and solar power prediction through refined feature extraction and modeling, and provides strong technical support for power system scheduling, efficient utilization of renewable energy and stable operation of power grids. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only preferred embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0063] Figure 1 A schematic diagram of a flow chart of a wind-solar power prediction method based on a collaborative learning strategy and a coding-decoding architecture provided in an embodiment of the present invention;
[0064] Figure 2 A schematic diagram of a model prediction process based on a collaborative learning strategy and a codec architecture provided by an embodiment of the present invention;
[0065] Figure 3 A schematic diagram of a collaborative learning strategy provided by an embodiment of the present invention;
[0066] Figure 4 A schematic diagram of the structure of a wind-solar power prediction model based on an Encoder-Decoder architecture provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0067] The principles and features of the present invention are described below in conjunction with the accompanying drawings. The enumerated embodiments are only used to explain the present invention and are not used to limit the scope of the present invention.
[0068] like Figure 1 As shown, the present invention provides a flow chart of a wind-solar power prediction method based on a collaborative learning strategy and a coding and decoding architecture;
[0069] like Figure 2 As shown, the present invention provides a schematic diagram of a model prediction process based on a collaborative learning strategy and an encoder-decoder architecture.
[0070] Reference Figure 1-Figure 2 This embodiment provides a wind and solar power prediction method based on a collaborative learning strategy and a codec architecture, the method comprising the following steps:
[0071] S101. Collect historical data of wind farms and photovoltaic farms: obtain the geographical location, power, and wind speed data of each wind turbine in the wind farm, and the geographical location, power, and temperature data of each photovoltaic panel in the photovoltaic farm, and establish an original data set of wind and photovoltaic power.
[0072] S102, data preprocessing: perform outlier detection and outlier processing on the original data set of wind and solar power, and normalize the processed data, specifically including:
[0073] The outlier detection specifically includes the following steps:
[0074] S21, respectively calculating the average values of wind power and photovoltaic power, that is, dividing the sum of all data points by the number of data points;
[0075] S22, respectively calculating the standard deviation of wind power and photovoltaic power, where the standard deviation reflects the degree of dispersion between data points;
[0076] S23. Based on steps S21-S22, the Z-Score of each data point is calculated, which is expressed as follows:
[0077]
[0078] Among them, Z is Z-Score, X i is the i-th data point, μ is the average value of wind power and photovoltaic power, and σ is the standard deviation of wind power and photovoltaic power;
[0079] S24. Determine the criteria for determining outliers, select a threshold of 2, and when the absolute value of the Z-Score of a data point is greater than 2, the data point is considered to be an outlier.
[0080] Outlier processing: For the above-mentioned outlier detection, the outlier is replaced by the average value of the data points near the outlier, thereby reducing its impact on the training or prediction of the wind and solar power prediction model, including:
[0081] Setting the window size: The choice of window size is crucial, as it determines the range of smoothing replacement. The larger the window size, the more significant the smoothing effect of the replacement, but it may also affect more data points. The window size can be adjusted according to the characteristics of the data and the distribution of outliers. Usually, the best window size can be selected according to the actual situation or through cross-validation. The present invention selects a window size of 5;
[0082] Calculate the average value within the window: For each outlier, select the 2 data points before and after it (i.e., the data points within the window), and then calculate the average of these data points. Usually, the average of the adjacent data points before and after the window is used as the replacement value;
[0083] Replace outliers: The calculated mean value in the window is used to replace outliers. The replaced data points form a smooth transition with other data points in the original wind and solar power data set, reducing the impact of outliers on the overall data trend.
[0084] Normalization processing: In order to convert the feature values in the original wind and solar power data set after outlier processing to a unified scale, eliminate the influence of different feature dimensions and numerical ranges, and ensure that each feature has the same contribution to the training of the wind and solar power prediction model, normalization can improve the convergence speed of the wind and solar power prediction model and prevent some features from having an unbalanced impact on the training process of the wind and solar power prediction model due to large or small values. Therefore, the minimum-maximum normalization method is used to compress the data to between 0 and 1, as shown below:
[0085]
[0086] Among them, X′ is the normalized data, that is, after linear transformation, the value range of the data is usually limited to [0,1]; X is the original data set of wind and solar power, which is the data sample that needs to be normalized; X min is the minimum value in the original data, indicating the smallest observed value in the original data set of wind and solar power; X max It is the maximum value in the original data, indicating the largest observed value in the original data set of wind and solar power.
[0087] S103, KNN data enhancement: Data enhancement is performed on the original wind and solar power data set after data preprocessing, and the neighboring devices are found by using geographic location information. The wind speed and temperature data of these neighboring devices are merged to enrich the prediction features and construct a wind and solar power time series data set. The neighboring devices include wind turbines and photovoltaic panels. Specifically, the following steps are included:
[0088] S31. Calculate the geographical distance between the wind turbine and the photovoltaic panel by using the geographical coordinates (longitude, latitude), as shown below:
[0089]
[0090] Where d is the geographical distance between the wind turbine and the photovoltaic panel, r is the radius of the earth, Δφ is the latitude difference between the two locations, and φ 1 ,φ 2 are the latitudes of the two locations, and Δλ is the longitude difference between the two locations;
[0091] S32, based on the wind turbine or photovoltaic panel to be predicted, find K neighboring wind turbines and photovoltaic panels by calculating the geographical distance, and select K=3;
[0092] S33. For the wind turbine and photovoltaic panel to be predicted, after finding the three neighboring devices, the pre-processed wind speed and temperature data of the neighboring wind turbine and photovoltaic panel are merged into a three-dimensional feature vector, and the time feature and power feature are added to form a feature vector containing five-dimensional information;
[0093] S34. Based on step S33, the time features of wind turbines and photovoltaic panels are expanded into a time series, ensuring that the input features contain information about neighboring devices, and constructing a wind and solar power time series data set. For example, a time window T (i.e., data at each time step) is selected, and the feature vector of each device will become a time series with a length of T*K, containing relevant data of neighboring devices at the same time step.
[0094] S104, dynamic division of data set: Dynamic division of wind and solar power time series data set, specifically including:
[0095] Time series data has obvious time dependence and sequentiality. Therefore, the use of traditional random partitioning methods may lead to the problem of "future data leakage", thereby affecting the prediction performance and generalization ability of the model. In order to better adapt to the temporal characteristics of time series data, avoid data leakage and improve the performance of the model, the sliding window method is used to realize the dynamic partitioning of the data set, including:
[0096] Define sliding window parameters: Divide the wind and solar power time series data set into training set, validation set, and test set. First, determine the window size, validation set size, and step size. The window size determines the amount of data used by the wind and solar power prediction model during each training. Select the window size as 1000 time steps, which means that the training set contains the data of the latest 1000 time steps during each training. The validation set is used to evaluate the performance of the wind and solar power prediction model during the training process and to help adjust the hyperparameters. The validation set size is set to 200 time steps. During each validation, the length of the validation set is relatively short, which can evaluate the performance of the model in the current period. The step size determines the speed of the window sliding, that is, how many time steps each time it slides. The step size is 100 time steps, which means that the training set will slide 100 time steps each time, and the test set and validation set will also slide forward accordingly.
[0097] Basic process: During each training, the training set includes data within a window size of 1000 time steps, the validation set contains a 200 time step data after the window, and the test set is the data of the next 1000 time steps. The training set, validation set and test set continue to slide 100 time steps until the window reaches the end of the data set. Each training of the wind and solar power prediction model uses different training data and validation data, and the time periods of the validation set and test set will also change accordingly. Ultimately, data from all time steps can participate in the training and testing process of the wind and solar power prediction model.
[0098] S105, VMD decomposition: Perform VMD decomposition on the dynamically divided wind and solar power time series data set into multiple modes, including:
[0099] Variational mode decomposition (VMD) is used to decompose complex signals into a set of modal components with specific frequency characteristics. Its basic goal is to minimize the frequency bandwidth of the signal by variational methods while maintaining the main characteristics of the signal. It can reduce the non-stationarity of time series with high complexity and strong nonlinearity, and decompose to obtain relatively stable subsequences containing multiple different frequency scales, which is suitable for non-stationary sequences.
[0100] (1) The mathematical model of VMD is usually a variational problem with constraints. Specifically, the form of the constraints is to ensure that the sum of all components is consistent with the wind and solar power time series data set. The constraints are expressed as follows:
[0101]
[0102] Among them, u k (t) is the kth modal component obtained after decomposition, and f(t) is the wind and solar power time series data set;
[0103] In order to facilitate the solution, VMD transforms the above constrained variational problem into an unconstrained optimization problem, namely the "minimization problem", introduces quadratic penalty terms and Lagrange multipliers, and reconstructs the original constrained problem into an augmented Lagrangian function, which is expressed as follows:
[0104]
[0105] Among them, u k is the kth component after decomposition, λ is the Lagrange multiplier, α is the penalty factor (used to balance decomposition accuracy and smoothness), is the derivative of the variable t, u k (t) is the modal component to be determined, t is the time variable, For a frequency ω k is the complex number representation of the sine wave of the parameter, the superscript j is the imaginary unit (representing the imaginary part of the complex number), ωk is the modal component u k (t) The relevant center frequency, ||·|| 2 is the L2 norm (measure of signal energy);
[0106] The above minimization problem is solved by the iterative-counting optimization method, which is expressed as follows:
[0107]
[0108] in, is the frequency domain representation of the kth mode, the estimate calculated in the n+1th iteration; is the estimated value of the center frequency of the kth mode, calculated in the n+1th iteration; the subscript i is an index used to refer to other modes except the kth mode; ω is the frequency; is the frequency domain representation of the ith mode, usually an estimate calculated in an iterative process; is the representation of the kth mode in the frequency domain, dω is the differential operation, n is the number of original wind and solar power data, are the Fourier transforms of f(t), μ(t), and λ(t) respectively.
[0109] (2) Selection of VMD mode number: VMD is a technology widely used in time series data processing. It can decompose the original time series into multiple subsequences (modes). Each mode represents the change of data at different frequencies or time scales. When the number of VMD decomposition modes increases, the training process and complexity of the wind and solar power prediction model also change. By comparing the performance of the model under different numbers of mode decompositions and combining the actual training set size, we can determine the most suitable number of mode decompositions. The specific steps are as follows:
[0110] S51. Select different VMD decomposition mode numbers for experiments, set to 2, 3, 4, 5, and 6 modes respectively, to observe the training performance and effect of the wind and solar power prediction model under each decomposition. These decomposition mode numbers represent different frequency components in the wind and solar power time series data set. The wind and solar power prediction model needs to extract valuable information from these different frequency modes.
[0111] S52. In order to ensure that the wind and solar power prediction model can effectively learn each frequency component under more modes, when the number of decomposed modes is 5 and 6, the time step number of the training set is increased to 2000 steps. This adjustment is intended to provide more data support for the wind and solar power prediction model and avoid the model being unable to fully learn the characteristics of each mode due to too little training set data in fine-grained modal decomposition;
[0112] S53. By comparing the performance of wind and solar power prediction models under different decomposition modal numbers of 2, 3, 4, 5, and 6, the accuracy, training time, and overfitting under each modal number are analyzed. Finally, considering the training effect and computing efficiency comprehensively, the modal decomposition number of 3 is selected as the optimal number.
[0113] S106. Construction of loss function based on collaborative learning strategy: Construct a collaborative loss function, use the collaborative loss function to guide the neural network to learn to extract the relationship between each mode in the VMD decomposition process, and optimize the collaborative learning between different modes and wind and solar power time series data sets, including:
[0114] like Figure 3 As shown in the figure, the core of the collaborative learning strategy is to use the collaborative loss function to guide the neural network to learn the relationship between the various modes extracted in the VMD process. Although the input of the wind and solar power prediction model is still the original time series, by adjusting the loss function, the wind and solar power prediction model can learn and capture the characteristics of periodicity, trend and seasonality during the training process. Specifically, the basic idea of the collaborative learning strategy is to strengthen the collaborative relationship between different modes during the training process, so that the wind and solar power prediction model not only pays attention to the prediction error, but also can measure the relationship between the decomposed mode and the wind and solar power time series data set through the Pearson Correlation Coefficient, thereby improving the learning ability of the model. The specific steps include:
[0115] S61. Based on the modal decomposition number of 3, the wind and solar power time series data set is decomposed into multiple modes, and it is determined which modes can better represent the different components of the wind and solar power time series data set (such as periodicity, trend and seasonality, etc.). The Pearson correlation coefficient between each decomposed mode and the wind and solar power time series data set is calculated, which is expressed as follows:
[0116]
[0117] Among them, ω i is the Pearson correlation coefficient between the i-th decomposition mode and the wind-solar power time series data set, indicating the correlation between the wind-solar power time series data set sequence x and the i-th decomposition mode y i The linear correlation between them, x is the wind and solar power time series data set, y is i is the sequence after decomposition, n is the number of decompositions;
[0118] S62, the decomposed mode is convolved, and then the data is activated through the Sigmoid function to obtain the synergy parameter. The role of the synergy parameter is to determine the weight of different modes in the final prediction, so that the wind and solar power prediction model can adjust the learning strategy according to the importance of each mode, which is expressed as follows:
[0119] Y fi =f i1 ω 1 +f i2 ω 2 +f i3 ω 3
[0120] Among them, Y fi is the coordination parameter, f i1 、f i2 、f i3 are the VMD decomposition values after convolution of sequence i, ω 1 ,ω 2 ,ω 3 They are the Pearson correlation coefficients between the decomposed mode and the wind and solar power time series data set;
[0121] S63. Based on the collaborative parameters, a collaborative loss function is constructed to optimize the collaborative learning between different modes and wind and solar power time series data sets, which is expressed as follows:
[0122]
[0123] Among them, loss co is the collaborative loss function, i is the i-th sample, n is the number of predictions, Y i is the true value of the i-th sample, is the predicted value of the i-th sample, Y fi is a coordination parameter.
[0124] S107, constructing a wind-solar power prediction model: Based on step S106, constructing a wind-solar power prediction model of an encoder-decoder architecture, specifically including:
[0125] like Figure 4 As shown, the wind-solar power prediction model based on the Encoder-Decoder architecture is divided into an Encoder module and a Decoder module;
[0126] Encoder module: It not only encodes the features of the input sequence, but also generates a dynamically weighted context vector through the Self-Attention mechanism to help the model better capture important information in the time series. These weighted context vectors will then be used as input to the Decoder. The specific steps are as follows:
[0127] S71, the Encoder module performs feature encoding on the input sequence and receives the input data after preprocessing and feature merging. The input data includes wind speed features, time features, and power data of the target wind turbine, which are expressed as follows:
[0128]
[0129] Among them, x t is the input feature vector at time t, To predict the wind speed of the wind turbine at time t, and are the wind speed of the neighboring wind turbine at time t, u t is the time characteristic at time t, Predict the wind turbine power at time t;
[0130] S72, based on step S71, the input data is processed step by step through multiple layers of GRU, each layer of GRU will generate a hidden state of a time step, the hidden state contains the information of all time steps in the input sequence, expressed as follows:
[0131] z t =σ(W z *x t +U z *h t-1 )
[0132] r t =σ(W r *x t +U r *h t-1 )
[0133] h′ t =tanh(W h *x t +U h *(r t ⊙h t-1 ))
[0134] h t =(1-z t )⊙h t-1 +z t ⊙h′ t
[0135] Among them, z t To update the output of the gate, control each input x t and the previous hidden state h t-1 The degree of influence in the current hidden state; σ is the activation function, a nonlinear activation function used to control the flow of information; W z , W r , W h are respectively t The associated weight matrix; U z , U r , U h They are respectively the hidden state h of the previous momentt-1 The associated weight matrix; r t is the output of the reset gate, which controls which parts of the hidden state at the previous moment need to be forgotten; h′ t is the candidate hidden state, which is the potential hidden state at the current time t, and contains the information of the input data and the hidden state at the previous time (after being controlled by the reset gate); h t is the hidden state at the current moment;
[0136] S73, the hidden state H generated by the multi-layer GRU t =[h 1 、h 2 ...h T ] is passed to the Self-Attention layer. The Self-Attention mechanism determines the importance of each time step in the input sequence to the current decoding moment by calculating the attention weight of each time step, which is expressed as follows:
[0137] Q t =W Q *h t ,K t =W K *h t ,V t =W V *h t
[0138]
[0139] Among them, Q t , k t 、V t They are query vector, key vector, and value vector respectively, and the input hidden state h at time t t After the weight matrix W Q , W K , W V After transformation, we get; α ij The value vector V at time j when calculating the output at time i is j The weight assigned; Q i is the query vector at time i; is the transpose of the key vector at time j; the superscript T is the transpose operation of the matrix; V is the key vector; d k is the dimension of the key vector; O i is the final output vector at time i.
[0140] Decoder module: According to the weighted context vector O generated by the Encoder module iAs well as the historical status of the Decoder module itself, it gradually generates future wind and solar power forecasts. The Decoder module uses the context information provided by the Encoder module to guide the prediction, and combines its own historical status to make dynamic adjustments, and finally outputs the wind power prediction results through the fully connected layer.
[0141] S108. Use the PyTorch framework to implement a wind-solar power prediction model based on the Encoder-Decoder architecture: input data to train and verify the wind-solar power prediction model, and optimize the model's hyperparameters, including:
[0142] We will customize the loss function, set up the training and validation process, and use evaluation indicators (such as MSE and MAE) to test the model performance, including:
[0143] Customized loss function: Based on step S106, a customized loss function is defined. The loss function is optimized based on the signal characteristics after data decomposition and combined with the collaborative learning strategy to ensure that the wind and solar power prediction model not only focuses on the prediction error, but also strengthens the collaborative relationship between different modes.
[0144] Set the training and validation process: Epoch is set to 50, the wind and solar prediction model will iterate the training data 50 times, and the parameters of the wind and solar prediction model will be updated after each iteration; Batch size is set to 32, and the wind and solar prediction model will use 32 samples for parameter update each time during training; Shuffle is set to True, for the training set and validation set, set shuffle = True to ensure that the data order of each Epoch is random; Drop_last is set to False. During the training process, if the wind and solar power time series data set cannot be divided into the batch size, you can choose whether to discard the last sample that is not full of the batch. Here it is set to False, that is, the last small amount of data is retained;
[0145] Evaluation indicators: During the training process and after verification, we need to use the following evaluation indicators to evaluate the prediction effect of the wind and solar power prediction model to ensure that the wind and solar power prediction model can effectively predict wind and solar power, as shown below:
[0146]
[0147]
[0148] Among them, MAE is the mean absolute error, which is the average of the absolute differences between the predicted value and the true value; MSE is the mean square error, which is the average of the squares of the differences between the predicted value and the true value; R 2is the determination coefficient, which measures the fitting effect of the wind and solar power prediction model; n is the number of samples; y i and are the true value and predicted value of the i-th sample respectively; is the mean of all true values; the smaller the MSE and MAE values are, the better the prediction effect is. 2 The larger the value, the better the prediction effect.
[0149] By comparing different optimizers (Adam, SGD, momentum method and RMSProp), learning rates, the number of hidden layers and the number of neurons, different prediction results are obtained. In the experiment, the present invention finds that the best MSE and MAE values can be obtained by using the Adam optimizer, a learning rate of 0.001, a 2-layer GRU, and a configuration of 128 neurons in each layer, so the above parameters are selected as hyperparameters.
[0150] S109: Based on step S108, output the predicted value of wind and solar power data, and conduct comparative experiments to analyze the prediction effect of each model, specifically including:
[0151] Evaluation index display of wind and solar power prediction results
[0152]
[0153] As shown in the table above, it can be clearly seen that the mean square error of the wind-solar power prediction model of the present invention is significantly lower than that of other comparison models (such as RNN, LSTM, VMD-LSTM), which shows that the wind-solar power prediction model has obvious advantages in prediction accuracy. At the same time, the determination coefficient (R 2 ) is also significantly higher than other comparative models, further verifying the superiority of its prediction performance. Taking into account factors such as mean square error and determination coefficient, the model based on collaborative learning strategy and encoder-decoder architecture performs significantly better than other comparative models in predicting wind and solar power data.
[0154] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A wind and solar power prediction method based on collaborative learning strategy and codec architecture, characterized in that: The method comprises the following steps: S101, collecting historical data of wind farms and photovoltaic farms: obtaining the geographical location, power, and wind speed data of each wind turbine in the wind farm, and the geographical location, power, and temperature data of each photovoltaic panel in the photovoltaic farm, and establishing a wind and photovoltaic power original data set; S102, data preprocessing: performing outlier detection and outlier processing on the original data set of wind and solar power, and normalizing the processed data; S103, KNN data enhancement: perform data enhancement on the original wind and solar power data set after data preprocessing, use geographic location information to find neighboring devices, and enrich prediction features by merging wind speed and temperature data of neighboring devices to construct a wind and solar power time series data set. The neighboring devices include wind turbines and photovoltaic panels. S104, dynamic division of data set: dynamically divide the wind and solar power time series data set; S105, VMD decomposition: Perform VMD decomposition on the dynamically divided wind and solar power time series data set to decompose it into multiple modes; S106. Construction of loss function based on collaborative learning strategy: Construct a collaborative loss function, use the collaborative loss function to guide the neural network to learn to extract the relationship between various modes during the VMD decomposition process, and optimize the collaborative learning between different modes and the wind and solar power time series data set; S107, constructing a wind-solar power prediction model: based on step S106, constructing a wind-solar power prediction model of an Encoder-Decoder architecture; S108. Use the PyTorch framework to implement a wind-solar power prediction model based on the Encoder-Decoder architecture: input data to train and verify the wind-solar power prediction model, and optimize the hyperparameters of the model; S109. Based on step S108, output the predicted value of wind and solar power data.
2. According to claim 1, a wind and solar power prediction method based on collaborative learning strategy and codec architecture is characterized in that: The outlier detection specifically includes the following steps: S21, respectively calculating the average values of wind power and photovoltaic power, that is, dividing the sum of all data points by the number of data points; S22, respectively calculating the standard deviation of wind power and photovoltaic power, the standard deviation reflects the degree of dispersion between data points; S23. Based on steps S21-S22, the Z-Score of each data point is calculated, which is expressed as follows: Among them, Z is Z-Score, X i is the i-th data point, μ is the average value of wind power and photovoltaic power, and σ is the standard deviation of wind power and photovoltaic power; S24. Determine the criteria for judging outliers, select a threshold of 2, and when the absolute value of the Z-Score of a data point is greater than 2, the data point is considered to be an outlier.
3. According to claim 1, a wind and solar power prediction method based on collaborative learning strategy and codec architecture is characterized in that: The outlier processing includes setting the window size, calculating the average value within the window, and replacing the outlier.
4. According to claim 1, a wind and solar power prediction method based on collaborative learning strategy and codec architecture is characterized in that: The step S103 specifically includes the following steps: S31. Calculate the geographical distance between the wind turbine and the photovoltaic panel by using the geographical coordinates, as shown below: Where d is the geographical distance between the wind turbine and the photovoltaic panel, r is the radius of the earth, Δφ is the latitude difference between the two locations, φ1 and φ2 are the latitudes of the two locations, and Δλ is the longitude difference between the two locations; S32, based on the wind turbine or photovoltaic panel to be predicted, find K neighboring wind turbines and photovoltaic panels by calculating the geographical distance; S33, merging the pre-processed wind speed and temperature data of the adjacent wind turbines and photovoltaic panels into a three-dimensional feature vector, and adding time features and power features to form a feature vector containing five-dimensional information; S34. Based on step S33, the time features of wind turbines and photovoltaic panels are expanded into a time series, ensuring that the input features contain information about neighboring devices, and constructing a wind and solar power time series data set.
5. The method for predicting wind and solar power based on collaborative learning strategy and codec architecture according to claim 1 is characterized in that: In step S104, the dynamic division of the wind and solar power time series data set specifically includes: Define sliding window parameters: divide the wind and solar power time series data set into training set, validation set, and test set, select the window size as 1000 time steps, set the validation set size to 200 time steps, and the step size to 100 time steps.
6. The method for predicting wind and solar power based on collaborative learning strategy and codec architecture according to claim 1, characterized in that: In step S105, the modal decomposition number is 3.
7. The method for predicting wind and solar power based on collaborative learning strategy and codec architecture according to claim 6, characterized in that: The step S106 specifically includes the following steps: S61. Based on the modal decomposition number being selected as 3, the wind and solar power time series data set is decomposed into multiple modes, and the Pearson correlation coefficient between each decomposed mode and the wind and solar power time series data set is calculated, which is expressed as follows: Among them, ω i is the Pearson correlation coefficient between the ith decomposition mode and the wind and solar power time series data set, x is the wind and solar power time series data set, y i is the sequence after decomposition, n is the number of decompositions; S62. Perform a convolution operation on the decomposed mode, and then activate the data through the Sigmoid function to obtain the collaborative parameters, which are expressed as follows: Y fi =f i1 ω1+f i2 ω2+f i3 ω3 Among them, Y fi is the coordination parameter, f i1 、f i2 、f i3 are the VMD decomposition values after convolution of sequence i, ω1, ω2, and ω3 are the Pearson correlation coefficients between the decomposition mode and the wind and solar power time series data set; S63. Based on the collaborative parameters, a collaborative loss function is constructed to optimize the collaborative learning between different modes and wind and solar power time series data sets, which is expressed as follows: Among them, loss co is the collaborative loss function, i is the i-th sample, n is the number of predictions, Y i is the true value of the i-th sample, is the predicted value of the i-th sample, Y fi is a coordination parameter.
8. The method for predicting wind and solar power based on collaborative learning strategy and codec architecture according to claim 1, characterized in that: The wind-solar power prediction model of the encoder-decoder architecture is divided into an encoder module and a decoder module. The encoder module is constructed in the following steps: S71, the Encoder module performs feature encoding on the input sequence and receives the input data after preprocessing and feature merging. The input data includes wind speed features, time features, and power data of the target wind turbine, which are expressed as follows: Among them, x t is the input feature vector at time t, To predict the wind speed of the wind turbine at time t, and are the wind speed of the neighboring wind turbine at time t, u t is the time characteristic at time t, Predict the wind turbine power at time t; S72, based on step S71, the input data is processed step by step through multiple layers of GRU, each layer of GRU will generate a hidden state of a time step, the hidden state contains the information of all time steps in the input sequence, expressed as follows: z t =σ(W z *x t +U z *h t-1 ) r t =σ(W r *x t +U r *h t-1 ) h' t =tanh(W h *x t +U h *(r t ⊙h t-1 )) h t =(1-z t )⊙h t-1 +z t ⊙h ′ t Among them, z t is the output of the update gate, σ is the activation function, W z , W r , W h are respectively t The associated weight matrix, U z , U r , U h They are respectively the hidden state h of the previous moment t-1 The associated weight matrix, r t is the output of the reset gate, h ′ t is the candidate hidden state, h t is the hidden state at the current moment; S73. The hidden state generated by the multi-layer GRU is passed to the Self-Attention layer. The Self-Attention mechanism determines the importance of each time step in the input sequence to the current decoding moment by calculating the attention weight of each time step, which is expressed as follows: Q t =W Q *h t ,K t =W K *h t ,V t =W V *h t Among them, Q t , K t 、V t They are query vector, key vector, and value vector respectively, and the input hidden state h at time t t After the weight matrix W Q , W K , W V After transformation, we get; α ij The value vector V at time j when calculating the output at time i is j The weight assigned; Q i is the query vector at time i; is the transpose of the key vector at time j; the superscript T is the transpose operation of the matrix; V is the key vector; d k is the dimension of the key vector; O i is the final output vector at time i.
9. The method for predicting wind and solar power based on collaborative learning strategy and codec architecture according to claim 8, characterized in that: The Decoder module gradually generates future wind and solar power predictions based on the weighted context vector generated by the Encoder module and the historical state of the Decoder module itself.
10. The method for predicting wind and solar power based on collaborative learning strategy and codec architecture according to claim 1, characterized in that: The input data is used to train and verify the wind and solar power prediction model, including customizing the loss function, setting the training and verification process, and using the evaluation index to test the performance of the wind and solar power prediction model.