A short-term photovoltaic power generation amount prediction method, device, medium and product
By using the Transformer model to extract the temporal features of photovoltaic power generation and performing clustering, combined with a lightweight GRU model for prediction, the problems of large sample space and long computation time in short-term photovoltaic prediction are solved, and efficient and low-cost photovoltaic power generation prediction is achieved.
Patent Information
- Application Number
- CN202411208910.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-30
- Publication Date
- 2025-11-21
- Estimated Expiration
- 2044-08-30
AI Technical Summary
Existing short-term photovoltaic forecasting technologies suffer from problems such as large sample size and long computation time for high-precision forecasting models, making them difficult to effectively implement and deploy.
The Transformer model is used for temporal feature extraction and cluster analysis, and a lightweight GRU model is used for classification training, which reduces the data storage space requirements and computation time.
It achieves high-precision short-term photovoltaic forecasting, reduces equipment storage and computing requirements, simplifies the deployment process, and lowers deployment costs.
Smart Images

Figure CN119130187B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of short-term photovoltaic prediction, in particular to a short-term photovoltaic power generation prediction method, device, medium and product. BACKGROUND
[0002] The randomness and uncertainty of photovoltaic power generation have brought challenges to the smooth operation of the power system. Among them, short-term photovoltaic prediction is the research field most affected by meteorological changes and real-time disturbances and most affected by randomness and uncertainty.
[0003] Past short-term photovoltaic prediction has started from three aspects of reducing uncertainty, enhancing data quality, and improving prediction accuracy, and has adopted clustering, dimensionality reduction, risk assessment, autoregressive integrated moving average (ARIMA), long short-term memory (LSTM) and other algorithms to achieve high-precision and fast prediction. However, due to the need for a large number of samples to reduce uncertainty and enhance data quality, and the need to use complex models to improve prediction accuracy, the operation time is longer, so that the short-term prediction algorithm needs a large amount of storage space and computing resources to be applied, hindering the landing deployment of the algorithm. SUMMARY
[0004] The purpose of the present application is to provide a short-term photovoltaic power generation prediction method, device, medium and product, which can solve the problems of large sample space occupation and long operation time of high-precision prediction model, and facilitate landing deployment.
[0005] To achieve the above-mentioned purpose, the present application provides the following solutions:
[0006] In a first aspect, the present application provides a short-term photovoltaic power generation prediction method, comprising:
[0007] obtaining a photovoltaic power generation dataset; the photovoltaic power generation dataset includes 24h (hour) photovoltaic power generation power data of a plurality of historical times;
[0008] training a Transformer model according to the photovoltaic power generation dataset to obtain a trained Transformer model as a preprocessing model, and extracting time sequence features of the photovoltaic power generation dataset;
[0009] clustering the time sequence features of the photovoltaic power generation dataset to obtain photovoltaic power generation data of different categories; the photovoltaic power generation data of different categories includes 24h photovoltaic power generation power data of different categories and corresponding subsequent 1h photovoltaic power generation power; the subsequent 1h photovoltaic power generation power is obtained by predicting the preprocessing model;
[0010] training a Gated Recurrent Unit (GRU) model according to the different categories of photovoltaic power generation data, respectively, to obtain a plurality of trained GRU models as prediction models, and extracting photovoltaic power generation data of a corresponding category as screening samples;
[0011] performing short-term photovoltaic prediction based on the preprocessing model, the prediction model, and the screening samples.
[0012] Optionally, a Transformer model is trained according to the photovoltaic power generation data set to obtain a trained Transformer model as a preprocessing model, and time sequence features of the photovoltaic power generation data set are extracted, specifically including:
[0013] a plurality of groups of 24-hour photovoltaic power generation data before and after are extracted from the photovoltaic power generation data set; the last value of the 24-hour photovoltaic power generation data before and the first value of the 24-hour photovoltaic power generation data after are adjacent in time sequence;
[0014] the 24-hour photovoltaic power generation data before and the 24-hour photovoltaic power generation data after are jointly input into an input data part of the Transformer model for preprocessing to obtain a corresponding position encoding matrix;
[0015] the position encoding matrix corresponding to the 24-hour photovoltaic power generation data before is input into an encoding model part of the Transformer model for encoding processing to obtain an encoding feature matrix;
[0016] the position encoding matrix corresponding to the 24-hour photovoltaic power generation data after and the encoding feature matrix are input into a decoding model part of the Transformer model for decoding processing to obtain a decoding feature matrix;
[0017] the decoding feature matrix is input into an output result part of the Transformer model for calculation to obtain a result matrix;
[0018] a loss value is calculated according to the result matrix and the 24-hour photovoltaic power generation data after, and a gradient descent method is used to update parameters of the Transformer model until the loss value converges, to obtain a trained Transformer model as a preprocessing model;
[0019] the preprocessing model is used to extract time sequence features of the photovoltaic power generation data set.
[0020] Optionally, the input data part comprises, in sequence, a convolution layer and position encoding; the encoding model part comprises, in sequence, a vector calculation layer, a multi-head attention layer, addition and layer normalization, a feedforward network layer, and addition and layer normalization; the decoding model part comprises, in sequence, a vector calculation layer, a mask and multi-head attention layer, addition and layer normalization, a multi-head attention layer, addition and layer normalization, a feedforward network layer, and addition and layer normalization; and the output result part comprises a full connection layer.
[0021] Optionally, the time sequence features of the photovoltaic power generation data set are clustered to obtain photovoltaic power generation data of different categories, specifically including:
[0022] The time sequence features of the photovoltaic power generation data set are clustered by using a spectral clustering method to obtain a clustering result.
[0023] The photovoltaic power generation data set is classified according to the clustering result to obtain photovoltaic power generation data of different categories.
[0024] Optionally, the time sequence features of the photovoltaic power generation data set are clustered by using a spectral clustering method to obtain a clustering result, specifically including:
[0025] The Euclidean distance between each pair of time sequence features of the photovoltaic power generation data set is calculated by using a Euclidean distance formula to construct a distance matrix.
[0026] A standard Laplacian matrix is calculated based on the distance matrix.
[0027] The standard Laplacian matrix is subjected to eigenvalue decomposition to obtain an eigenvector.
[0028] The eigenvector is subjected to Kmeas clustering to obtain a clustering result.
[0029] Optionally, a GRU model is trained according to the photovoltaic power generation data of different categories to obtain a plurality of trained GRU models as prediction models, and photovoltaic power generation data of a corresponding category is extracted as a screening sample, specifically including:
[0030] A GRU model is trained according to the photovoltaic power generation data of different categories to obtain a plurality of trained GRU models as prediction models; wherein, for any one category of photovoltaic power generation data, the previous 24h photovoltaic power generation data is taken as the input of the GRU model, the subsequent 1h photovoltaic power generation is taken as the output of the GRU model, the mean square error of the predicted value and the true value of the subsequent 1h photovoltaic power generation is calculated, the parameters of the GRU model are updated by using the gradient descent method until the mean square error converges, and a trained GRU model is obtained.
[0031] Extract a set proportion of photovoltaic power generation data as a screening sample from the photovoltaic power generation data set according to categories.
[0032] Optionally, performing short-term photovoltaic prediction based on the preprocessing model, the prediction model and the screening sample, specifically comprising:
[0033] Inputting photovoltaic power generation data of the previous 24 hours of the current time as a prediction sample into the preprocessing model to obtain corresponding time sequence features;
[0034] Calculating the similarity between the time sequence features corresponding to the prediction sample and the time sequence features corresponding to the screening sample by using the Euclidean distance formula to determine the classification result of the prediction sample;
[0035] Selecting a corresponding trained GRU model from the prediction model according to the classification result of the prediction sample;
[0036] Inputting the prediction sample into the trained GRU model for prediction to obtain corresponding subsequent 1h photovoltaic power generation.
[0037] In a second aspect, the present application provides a computer device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the short-term prediction method of photovoltaic power generation.
[0038] In a third aspect, the present application provides a computer readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the short-term prediction method of photovoltaic power generation.
[0039] In a fourth aspect, the present application provides a computer program product comprising a computer program, wherein the computer program is executed by a processor to implement the short-term prediction method of photovoltaic power generation.
[0040] According to the specific embodiments provided by the present application, the following technical effects are disclosed:
[0041] The present application provides a short-term prediction method, device, medium and product of photovoltaic power generation, which trains a high-precision Transformer model as a preprocessing model for time sequence feature extraction, reduces the data storage space requirement and guarantees the accuracy of subsequent lightweight prediction models; clusters the time sequence features to facilitate the classification and processing of data and accelerate the operation speed; trains a more lightweight GRU model as a prediction model through classification to reduce the amount of data used, reduce the operation time and reduce the device requirements while avoiding the decline of prediction accuracy; and the present application only needs to deploy the above preprocessing model and prediction model at the station to achieve high-precision short-term photovoltaic prediction, which is lower in deployment cost. BRIEF DESCRIPTION OF DRAWINGS
[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiments will be briefly introduced as follows. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort on the basis of these drawings.
[0043] Figure 1 The flow chart of the short-term prediction method of photovoltaic power generation provided by the present application is shown in the following table:
[0044] Figure 2 The structure diagram of the Transformer model provided by the present application is shown in the following table:
[0045] Figure 3 The schematic diagram of the convolution kernel calculation method provided by the present application is shown in the following table:
[0046] Figure 4 The structure diagram of the GRU model provided by the present application is shown in the following table. DETAILED DESCRIPTION
[0047] The technical solutions in the embodiments of the present application will be described clearly and completely in the following with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present application.
[0048] The present application provides a short-term prediction method, device, medium and product of photovoltaic power generation, which is used to solve the problems of large sample space occupation and long operation time of high-precision prediction model, and is convenient for landing deployment. The technical solution mainly includes four steps: feature extraction, clustering analysis, classification training model and prediction result. Among them, the feature extraction is used to extract the time sequence features of photovoltaic power generation data, which is convenient for subsequent clustering and reduces the data storage space requirement; the clustering analysis is used to divide the data categories, which is convenient for processing data by category and speeds up the operation speed; the classification training model is used to train the prediction model with small storage space and small precision reduction; and the prediction result is used to realize the final prediction result output.
[0049] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the present application will be further described in detail with reference to the drawings and specific embodiments.
[0050] In one exemplary embodiment, the present application provides a short-term prediction method for photovoltaic power generation, which is executed by a computer device, specifically, by a terminal or a server or the like computer device alone or by a terminal and a server together. In the embodiment of the present application, as shown in Figure 1 FIG. 1, the method comprises the following steps 1 to 5. Wherein:
[0051] Step 1: Obtain a photovoltaic power generation dataset. The photovoltaic power generation dataset comprises 24h photovoltaic power generation data of a plurality of historical times.
[0052] Step 2: Train a Transformer model according to the photovoltaic power generation dataset to obtain a trained Transformer model as a preprocessing model, and extract time sequence features of the photovoltaic power generation dataset.
[0053] This step specifically comprises: extracting a plurality of groups of 24h photovoltaic power generation data before and after from the photovoltaic power generation dataset; inputting the 24h photovoltaic power generation data before and after into an input data part of the Transformer model for preprocessing to obtain a corresponding position encoding matrix; inputting the position encoding matrix corresponding to the 24h photovoltaic power generation data before into an encoding model part of the Transformer model for encoding processing to obtain an encoding feature matrix; inputting the position encoding matrix corresponding to the 24h photovoltaic power generation data after and the encoding feature matrix into a decoding model part of the Transformer model for decoding processing to obtain a decoding feature matrix; inputting the decoding feature matrix into an output result part of the Transformer model for calculation to obtain a result matrix; calculating a loss value according to the result matrix and the 24h photovoltaic power generation data after, and updating parameters of the Transformer model by using a gradient descent method until the loss value converges to obtain a trained Transformer model as a preprocessing model; and extracting time sequence features of the photovoltaic power generation dataset by using the preprocessing model.
[0054] Wherein, the input data part comprises a convolution layer and a position encoding in sequence; the encoding model part comprises a vector calculation layer, a multi-head attention layer, an addition and layer normalization, a feedforward network layer and an addition and layer normalization in sequence; the decoding model part comprises a vector calculation layer, a mask and a multi-head attention layer, an addition and layer normalization, a multi-head attention layer, an addition and layer normalization, a feedforward network layer and an addition and layer normalization in sequence; and the output result part comprises a full connection layer.
[0055] The Transformer model is used to learn the time-series characteristics of photovoltaic power generation data. The input to the Transformer model contains two types of data: the photovoltaic power generation data of the previous 24 hours (i.e., ... Figure 2 The photovoltaic data for the first 24 hours and the photovoltaic power generation data for the next 24 hours (i.e., the first 24 hours of photovoltaic power generation data) Figure 2 (The last 24 hours of photovoltaic power generation data). The last value of the photovoltaic power generation data in the previous 24 hours and the first value of the photovoltaic power generation data in the next 24 hours are temporally adjacent. During training, the Transformer model needs to learn the photovoltaic power generation data of the previous day to predict the photovoltaic power generation data of the next day. The structure of the Transformer model is as follows: Figure 2 As shown, the model can be divided into four parts. The following describes the calculation process of each part of the model in the order of input data, encoding model, decoding model, and output results.
[0056] 1) Input data
[0057] The input data section is responsible for preprocessing photovoltaic power generation data. The calculation process for processing the photovoltaic power generation data of the first 24 hours and the last 24 hours is exactly the same, both consisting of two parts: convolutional layers and position encoding.
[0058] First, a convolutional layer consists of N convolutional kernels, each a 1×4 matrix. The calculation process for a single convolutional kernel is as follows: Figure 3 As shown. For a 1×6 matrix, using a 1×4 convolution kernel results in a 1×6 matrix. Using N convolution kernels results in N 1×6 matrices. Based on this method, N convolution kernels are used to convolve a B×L matrix, where B is the number of samples in the 24-hour photovoltaic power generation data, and L is the length of the 24-hour photovoltaic power generation data. Concatenating the results yields a B×N×L matrix. Transposing the matrix gives a B×L×N matrix x.
[0059] Next, positional codes are added to the elements in matrix x. The formula for calculating the positional code of the (b, k, i)th element in matrix x0 is as follows.
[0060]
[0061] In the formula, n is taken as 10000 and d is taken as N. The position codes of all elements in matrix x are calculated using this formula and then added one by one. For the photovoltaic power generation data of the first 24 hours, a matrix X0 of size B×L×N containing position code information is obtained, which is used for calculating the encoding model; for the photovoltaic power generation data of the last 24 hours, a matrix Y0 of size B×L×N containing position code information is obtained, which is used for calculating the decoding model.
[0062] 2) Coding Model
[0063] The encoding model includes five parts: vector calculation layer, multi-head attention layer, addition and layer normalization, feedforward network layer, addition and layer normalization. The calculation process of the addition and layer normalization of the third step and the fifth step is exactly the same, and is not introduced repeatedly.
[0064] Firstly, the vector calculation layer is used to calculate three values of query vector Q, key vector K and value vector V. The calculation process is as follows.
[0065] Q = X0·W Q
[0066] K = X0·W K
[0067] V = X0·W V
[0068] In the formula, W Q ,W K ,W V is a neural network parameter, which is an N×N matrix. After the calculation, Q, K and V obtained are B×L×N matrices.
[0069] Then, the multi-head attention layer is calculated. The multi-head attention layer refers to analyzing the input data using multiple attention layers, and the number of attention layers is H. Q, K and V are split into H sub-matrices, named Q 1 ,Q 2 ,...,Q H ,K 1 ,K 2 ,...,K H ,V 1 ,V 2 ,...,V H . The size of the sub-matrix is B×L×h, wherein the relationship between N, H and h is as follows.
[0070] N = H·h
[0071] The calculation process of each attention layer is the same, and the calculation process of the attention layer is illustrated by taking Q 1 ,K 1 ,V 1 as an example as follows.
[0072]
[0073]
[0074] In the above calculation process, (K 1 ) T only the last two dimensions are transposed to become a B×h×L matrix. Q 1 ·(K1 ) T The matrix z is calculated row-wise and then concatenated to obtain a B×L×L matrix. 1 . Yes Perform row-wise normalization. Let z be the element at position (b, i, j) in the matrix before normalization. bij The element at position (b, i, j) in the normalized matrix is z'. bij The normalization formula is as follows.
[0075]
[0076] Similarly, the matrix is calculated row by row and then concatenated to obtain a B×L×h matrix.
[0077] The calculation results of H attention layers By concatenating the matrices, we obtain a B×L×N matrix X1.
[0078] Then, the data is processed using addition and layer normalization. The processing method is as follows.
[0079] X2 = LN(X1 + X0)
[0080] In the formula, X1 + X0 means adding X1 and X0 one-to-one. LN refers to column-wise normalization. The following formula is used to calculate the values for each column of data.
[0081]
[0082]
[0083]
[0084] In the formula, v bij It is the element at position (b, i, j) in the matrix. μ bi σ is the mean of the column of data. bi It represents the variance of the data. bij These are the normalized column data. After normalizing each column, we get the output result X2.
[0085] The calculation formula for the feedforward network layer is as follows.
[0086] X3 = relu(X2·W) 1 ·W 2 )
[0087] relu(v) = max(0,v)
[0088] In the formula, W 1 It is an L×C matrix, W 2is a matrix of C x L. X3 is a matrix of B x L x N, i.e. the time series features.
[0089] Finally, the output results of the feedforward network layer are added and normalized, and a matrix X4, i.e. the encoding feature matrix, is obtained, and the calculation formula is as follows.
[0090] X4 = LN(X3 + X2)
[0091] 3) Decoding model
[0092] The decoding model includes seven parts: vector calculation layer, mask and multi-head attention layer, addition and layer normalization, multi-head attention layer, addition and layer normalization, feedforward network layer, and addition and layer normalization. Among them, the calculation method of the vector calculation layer, the multi-head attention layer, the addition and layer normalization, and the feedforward network layer, and the size of the rectangle and the encoding model are the same, and are not introduced. Only the mask and multi-head attention layer is introduced below.
[0093] The calculation process of the mask and multi-head attention layer is as follows.
[0094]
[0095]
[0096] Among them, the mask function is a function of using a mask matrix to control data input. The mask function will set the element of the corresponding position of the input data to an infinite negative number (-10 9 ) according to the position of the element of 0 in the mask matrix. Since softmax uses an exponential function for normalization, when the value is an infinite negative number, the calculation result in softmax is close to 0, and has no effect on the normalization result of other values.
[0097] The mask matrix is a lower triangular matrix of L x L.
[0098]
[0099] Finally, using the decoding model, a matrix X5 of B x L x N, i.e. the decoding feature matrix, is obtained.
[0100] 4) Output result
[0101] The output result uses a fully connected layer, and the calculation process is as follows.
[0102] Y = X5 · W
[0103] In the formula, W is a matrix with a size of N x 1. X5·W is a matrix of B x L x 1 obtained by splicing after calculation by row. The B x L x 1 matrix is compressed into a B x L matrix Y, that is, a result matrix. A loss value Loss is calculated according to the result matrix Y and the 24h photovoltaic power data. The calculation formula is as follows.
[0104]
[0105] Based on the calculation result of Loss, the parameters of the Transformer model are updated using the gradient descent method, and the iteration is continuously trained on the server until Loss converges.
[0106] After the server completes the training, the photovoltaic power data is input into the Transformer model to obtain the X3 data output by the encoding model, the 24h photovoltaic power data, and the subsequent 1h photovoltaic power predicted using the trained model, which are stored in the database as "basic samples". The input data of the Transformer and the parameters of the encoding model are saved and stored in the field computer as a "preprocessing model".
[0107] Step 3: clustering the time sequence features of the photovoltaic power data set to obtain photovoltaic power data of different categories. The photovoltaic power data of different categories includes 24h photovoltaic power data of different categories and corresponding subsequent 1h photovoltaic power; the subsequent 1h photovoltaic power is predicted using the preprocessing model.
[0108] This step specifically includes: using a spectral clustering method to cluster the time sequence features of the photovoltaic power data set (i.e., the X3 data stored in the "basic sample") to obtain a clustering result; and classifying the photovoltaic power data set according to the clustering result to obtain photovoltaic power data of different categories.
[0109] The spectral clustering method is used to cluster the X3 data stored in the "basic sample". The spectral clustering calculation process is as follows.
[0110] First, the Euclidean distance formula is used to calculate the distance matrix.
[0111]
[0112] In the formula, d ij is the Euclidean distance between the ith X3 data and the jth X3 data. is the tth value of the ith X3 data. L is the length of the 24h photovoltaic power data. It is assumed that the "basic sample" has r X3 data. According to the Euclidean distance formula, the Euclidean distance between each two X3 data is calculated and filled into the r x r distance matrix R.
[0113] Then, the Laplacian matrix is calculated.
[0114] The calculation of the Laplacian matrix requires the calculation of the adjacency matrix and the degree matrix.
[0115] The calculation of the adjacency matrix is based on the distance matrix R. The numerical calculation of the adjacency matrix A is as follows.
[0116]
[0117] The degree matrix is a diagonal matrix D, and the calculation formula is as follows.
[0118]
[0119] The calculation formula of the Laplacian matrix O is as follows.
[0120] O = D - R
[0121] Then, the eigenvalues of the standard Laplacian matrix are calculated.
[0122] The calculation formula of the standard Laplacian matrix O is as follows.
[0123]
[0124] The eigenvalues of the standard Laplacian matrix are decomposed to obtain the eigenvector T.
[0125] Finally, the Kmeas clustering is performed on the eigenvector T. The Kmeas clustering result is output as the class division result of the X3 data. After the spectral clustering is completed, the class division result of the photovoltaic power generation data is obtained.
[0126] Step 4: Training GRU models according to the different categories of photovoltaic power generation data to obtain a plurality of trained GRU models as prediction models, and extracting photovoltaic power generation data corresponding to the categories as screening samples.
[0127] This step specifically includes: training GRU models according to the different categories of photovoltaic power generation data to obtain a plurality of trained GRU models as prediction models; wherein for any category of photovoltaic power generation data, the previous 24h photovoltaic power data is taken as the input of the GRU model, the subsequent 1h photovoltaic power is taken as the output of the GRU model, the mean square error of the predicted value and the true value of the subsequent 1h photovoltaic power is calculated, and the gradient descent method is used to update the parameters of the GRU model until the mean square error converges, and the trained GRU model is obtained; a certain proportion of photovoltaic power data is extracted from the photovoltaic power generation data set according to the category as screening samples.
[0128] Using a single category of data for training can reduce data usage while avoiding a decrease in prediction accuracy. In addition, to reduce deployment costs, a GRU model with lower complexity but better prediction accuracy is used to complete the prediction task.
[0129] The structure of the GRU model is shown in Figure 4 The calculation process of the variables is as follows.
[0130] r t =σ(x t U r +h t-1 W r )
[0131] z t =σ(x t U z +h t-1 W z )
[0132]
[0133]
[0134]
[0135] In the formula, ° is the Hadamard integral, which means that the elements in the matrix are multiplied one by one. x t is the photovoltaic power generation data in the previous 24 hours, which is a matrix with a size of B x L. U r is a parameter matrix with a size of L x E (E is the dimension of the hidden layer); W r is a parameter matrix with a size of E x E; h t-1 is a matrix with a size of B x E, representing the time series characteristics at the previous moment. r t is a forgetting matrix with a size of B x E at time t, which is used to determine the retention proportion of the time series characteristics h t-1 at the previous moment. z t is an update matrix at time t, which is used to determine the retention proportion of the new data at time t. U z is a parameter matrix with a size of L x E; W z is a parameter matrix with a size of E x E. is the update data at time t, which is calculated based on the past photovoltaic power generation data and the current input photovoltaic power generation data. U h is a parameter matrix with a size of L x E; W h is a parameter matrix with a size of E x E. h t is the time series characteristics at time t extracted from the current input photovoltaic power generation data, which is a matrix with a size of B x E. Based on h t , the photovoltaic power generation data Y t at time t is predicted.
[0136] Y t = h t W Y
[0137] In the formula, W Y is a parameter matrix of E x 1. Y t is a B x 1 output result, i.e. the predicted subsequent 1h photovoltaic power data based on the previous 24h photovoltaic power data x t . Y t is compared with the real data y t of the subsequent 1h, and the Mean Square Error (MSE) is calculated.
[0138]
[0139] In the formula, is the i th data of y t , is the i th data of Y t . Based on the calculation result of the MSE, the parameters of the GRU model are updated using the gradient descent method, and are iterated constantly until the MSE converges and the training is stopped.
[0140] The multiple GRU models trained are saved and regarded as "prediction models", and are stored in the station computer. And according to the classification result, samples are extracted by category, and 30% of the sample amount is extracted for each category to jointly constitute "screening samples" and be stored in the station computer.
[0141] Step 5: performing short-term photovoltaic prediction based on the preprocessing model, the prediction model and the screening samples.
[0142] For ease of illustration, it is assumed that the subsequent 1h photovoltaic power needs to be predicted at this time. The previous 24h photovoltaic power data of the current time is input as a "prediction sample" into the "preprocessing model" stored in the station computer to obtain the corresponding X3. The similarity of the X3 of the "prediction sample" and all X3 in the "screening samples" is calculated, and the Euclidean distance formula is used as the similarity calculation formula.
[0143] The similarity calculation results of the same category are averaged to serve as the "category similarity". The "category similarity" of different categories is compared. The category with the highest "category similarity" is the classification result of the "prediction sample".
[0144] According to the classification result, the GRU model of the corresponding category is taken out from the saved "prediction model". The "prediction sample" is input into the GRU model for prediction to obtain the prediction result.
[0145] In summary, compared with the past short-term photovoltaic prediction technology, the application uses the high-precision Transform algorithm as the time sequence feature extraction to ensure the accuracy of the subsequent lightweight prediction model; only part of the model is deployed at the station to reduce the storage space requirement and the local deployment cost; a lighter GRU model is used for prediction to reduce the operation time and the equipment requirement. Moreover, on the basis of reducing the deployment cost and the operation time, the prediction accuracy loss of the application is small, and the application has certain value for the deployment of high-precision photovoltaic power generation prediction algorithm.
[0146] In an exemplary embodiment, the application further provides a computer device including a memory and a processor, the memory storing a computer program, and the processor implementing the steps in the above method embodiments when executing the computer program.
[0147] In an exemplary embodiment, the application further provides a computer readable storage medium storing a computer program, and the processor implementing the steps in the above method embodiments when executing the computer program.
[0148] In an exemplary embodiment, the application further provides a computer program product including a computer program, and the processor implementing the steps in the above method embodiments when executing the computer program.
[0149] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of the related data need to comply with relevant legal regulations.
[0150] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer readable storage medium, and when executed, can include the processes of the above-mentioned embodiment methods. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc.
[0151] The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a blockchain, etc., without being limited thereto. The processor involved in the embodiments provided in the present application can be a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., without being limited thereto.
[0152] The technical features of the above embodiments can be combined arbitrarily. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combinations of the technical features do not exist, they should be considered as the scope of the present application.
[0153] The principles and implementation manners of the present application are described herein by using specific examples, and the above examples are only used to help understand the method of the present application and its core idea; meanwhile, for those skilled in the art, according to the idea of the present application, the specific implementation manners and application ranges will have changes. In conclusion, the content of the specification should not be understood as a limitation of the present application.
Claims
1. A method for short-term prediction of photovoltaic power generation, characterized in that, The method comprises the following steps: obtaining a photovoltaic power generation dataset; the photovoltaic power generation dataset comprises 24-hour photovoltaic power generation data of a plurality of historical times; training a Transformer model according to the photovoltaic power generation dataset to obtain a trained Transformer model as a preprocessing model, and extracting time sequence features of the photovoltaic power generation dataset; clustering the time sequence features of the photovoltaic power generation dataset to obtain photovoltaic power generation data of different categories; the photovoltaic power generation data of different categories comprises 24-hour photovoltaic power generation data of a previous day and corresponding 1-hour photovoltaic power generation data of a subsequent day; the 1-hour photovoltaic power generation data of the subsequent day is predicted by using the preprocessing model; performing clustering on the time sequence features of the photovoltaic power generation dataset by using a spectral clustering method to obtain a clustering result; performing clustering on the time sequence features of the photovoltaic power generation dataset by using a spectral clustering method to obtain a clustering result, specifically comprising: calculating the Euclidean distance between each pair of time sequence features of the photovoltaic power generation dataset by using a Euclidean distance formula to construct a distance matrix; calculating a standard Laplacian matrix based on the distance matrix; performing eigenvalue decomposition on the standard Laplacian matrix to obtain an eigenvector; performing Kmeans clustering on the eigenvector to obtain a clustering result; dividing the photovoltaic power generation dataset into different categories according to the clustering result to obtain photovoltaic power generation data of different categories; training a GRU model according to the photovoltaic power generation data of different categories respectively to obtain a plurality of trained GRU models as prediction models, and extracting photovoltaic power generation data of corresponding categories as screening samples; performing short-term photovoltaic prediction based on the preprocessing model, the prediction model and the screening sample.
2. The method for short-term prediction of photovoltaic power generation amount according to claim 1, characterized by, training a Transformer model according to the photovoltaic power generation dataset to obtain a trained Transformer model as a preprocessing model, and extracting time sequence features of the photovoltaic power generation dataset, specifically comprising: extracting a plurality of groups of 24-hour photovoltaic power generation data and 24-hour photovoltaic power generation data from the photovoltaic power generation dataset; the last value of the 24-hour photovoltaic power generation data and the first value of the 24-hour photovoltaic power generation data are adjacent in time sequence; inputting the 24-hour photovoltaic power generation data and the 24-hour photovoltaic power generation data into an input data part of the Transformer model for preprocessing to obtain a corresponding position encoding matrix; inputting the position encoding matrix corresponding to the 24-hour photovoltaic power generation data into an encoding model part of the Transformer model for encoding processing to obtain an encoding feature matrix; inputting the position encoding matrix corresponding to the 24-hour photovoltaic power generation data and the encoding feature matrix into a decoding model part of the Transformer model for decoding processing to obtain a decoding feature matrix; inputting the decoding feature matrix into an output result part of the Transformer model for calculation to obtain a result matrix; According to the result matrix and the 24h photovoltaic power data after the 24h, a loss value is calculated, and a gradient descent method is used to update parameters of the Transformer model until the loss value converges, so as to obtain a trained Transformer model as a preprocessing model; The preprocessing model is used to extract time sequence features of the photovoltaic power dataset.
3. The method for short-term prediction of photovoltaic power generation according to claim 2, characterized in that, The input data part sequentially includes a convolution layer and position encoding; the encoding model part sequentially includes a vector calculation layer, a multi-head attention layer, addition and layer normalization, a feedforward network layer, and addition and layer normalization; the decoding model part sequentially includes a vector calculation layer, a mask and multi-head attention layer, addition and layer normalization, a multi-head attention layer, addition and layer normalization, a feedforward network layer, and addition and layer normalization; and the output result part includes a full connection layer.
4. The photovoltaic power generation short-term prediction method according to claim 1, characterized by, According to the different categories of photovoltaic power data, GRU models are trained respectively to obtain a plurality of trained GRU models as prediction models, and the photovoltaic power data of the corresponding categories are extracted as screening samples, specifically including: According to the different categories of photovoltaic power data, GRU models are trained respectively to obtain a plurality of trained GRU models as prediction models; wherein for any one category of photovoltaic power data, the 24h photovoltaic power data before the 24h are taken as the input of the GRU model, the subsequent 1h photovoltaic power is taken as the output of the GRU model, the mean square error of the predicted value and the true value of the subsequent 1h photovoltaic power is calculated, and the gradient descent method is used to update the parameters of the GRU model until the mean square error converges, so as to obtain a trained GRU model; A set proportion of photovoltaic power data is extracted from the photovoltaic power dataset according to categories as screening samples.
5. The photovoltaic power generation short-term prediction method according to claim 1, characterized by, Based on the preprocessing model, the prediction model and the screening sample, short-term photovoltaic prediction is performed, specifically including: The 24h photovoltaic power data before the current time are taken as a prediction sample and input into the preprocessing model to obtain corresponding time sequence features; The similarity between the time sequence features corresponding to the prediction sample and the time sequence features corresponding to the screening sample is calculated by using the Euclidean distance formula to determine the classification result of the prediction sample; According to the classification result of the prediction sample, a corresponding trained GRU model is selected from the prediction model; The prediction sample is input into the trained GRU model for prediction to obtain corresponding subsequent 1h photovoltaic power.
6. A computer device comprising: A memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that the processor executes the computer program to implement the short-term prediction method of photovoltaic power of any one of claims 1-5.
7. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the short-term prediction method of photovoltaic power of any one of claims 1-5.
8. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the short-term prediction method of photovoltaic power of any one of claims 1-5.
Citation Information
Patent Citations
Photovoltaic power prediction method, device and equipment and readable storage medium
CN111695601A