A method and system for predicting distributed photovoltaic output under variable weather

By processing photovoltaic data through multi-scale wavelet transform and clustering, and training the model with a loss function based on physical constraints, the adaptability and interpretability issues of deep learning models under variable weather conditions were solved, achieving high-precision and efficient photovoltaic power output prediction.

CN120892843BActive Publication Date: 2026-02-06STATE GRID JIANGSU ELECTRIC POWER CO LTD MARKETING SERVICE CENT +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511385309.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-26
Publication Date
2026-02-06
Estimated Expiration
2045-09-26

AI Technical Summary

Technical Problem

Existing deep learning models are poorly adapted to variable weather patterns in distributed photovoltaic power output prediction, their feature representation and dependency modeling are not flexible enough, and their prediction results lack physical interpretability.

Method used

Feature engineering is performed by extracting timestamp features and multi-scale wavelet transform. Weather type datasets are divided by combining clustering and anomaly detection algorithms. Independent photovoltaic power output prediction models are trained for each weather type and trained using a combined loss function that includes photovoltaic physical constraints. Prediction results are generated using multi-head attention layers and fully connected layers.

Benefits of technology

It improves the accuracy and robustness of distributed photovoltaic power output prediction, enhances the model's ability to identify periodic patterns, simplifies computational complexity, and improves the interpretability and credibility of prediction results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120892843B_ABST
    Figure CN120892843B_ABST
Patent Text Reader

Abstract

The application discloses a kind of distributed photovoltaic output under variable weather prediction method and system, the method is first obtained historical photovoltaic station operating data, and by photovoltaic data preprocessing model is handled: it is through timestamp feature extraction and multi-scale wavelet transform is carried out feature engineering, and combining clustering and anomaly detection algorithm, data is divided and purified into multiple weather type data sets;Subsequently, for each weather type data set, an independent photovoltaic output prediction model is trained respectively, and the model is composed of LSTM layer, multi-head attention layer and fully connected layer;When predicting, first determine the weather type attribution of real-time data, and then call the corresponding pre-training model to complete the prediction. The frequency domain features extracted by wavelet transform dynamically guide the weight calculation of multi-head attention layer, realizing adaptive modeling of global features and local details, and improving the accuracy and robustness of distributed photovoltaic output prediction.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of photovoltaic power generation prediction, in particular to a distributed photovoltaic output prediction method and system under variable weather. BACKGROUND

[0002] In the scenarios of power system load prediction, photovoltaic output prediction, etc., long time series prediction is of great significance to improve the foresight of the decision system. Photovoltaic output has strong nonlinearity, randomness and volatility, and is significantly affected by various meteorological factors such as solar irradiance, temperature, cloud cover and humidity. Especially under variable weather or extreme weather conditions, the output power fluctuates dramatically, bringing great challenges to power grid dispatching and stable operation of the power system.

[0003] In order to improve the predictability and controllability of photovoltaic power generation, researchers have proposed various output prediction methods, mainly including physical models, statistical models and data-driven models based on machine learning or deep learning. Physical models rely on physical quantities such as solar radiation transmission, geographic information and component parameters to construct an output model. Although they have certain physical interpretability, they require high precision of input parameters and computing resources, making it difficult to adapt to complex and dynamic actual environments. Statistical models such as ARIMA and regression models can reflect data trends to some extent, but have limitations in dealing with highly nonlinear and non-stationary sequences. Deep learning methods have developed rapidly in recent years, such as LSTM (Long Short-Term Memory), CNN, Transformer, etc. By learning the potential time series features in massive historical data, they have achieved better prediction results than traditional methods, becoming a hot research topic.

[0004] However, traditional LSTM models still have problems such as weak ability to capture local features, insufficient robustness to input under variable weather, and decline in long-time dependency learning ability when facing high-frequency fluctuations in photovoltaic output and sudden weather changes, which can easily lead to prediction bias. At the same time, most models only focus on data fitting accuracy, ignoring the constraints of physical laws, which may produce physically unreasonable prediction results.

[0005] Therefore, it is urgent to propose a new method that can intelligently adopt the optimal prediction strategy to accurately capture power fluctuation details according to different weather conditions, while integrating physical mechanism constraints to ensure that the prediction results are not only accurate in data but also physically reasonable and reliable. SUMMARY

[0006] To solve the technical problems of poor adaptability of the model to variable weather patterns, insufficient flexibility of feature representation and dependence modeling, and lack of physical interpretability of the prediction results in the prior art, especially when a deep learning model is used for distributed photovoltaic power output prediction, the present application provides a method and system for predicting distributed photovoltaic power output under variable weather conditions. The method first acquires historical photovoltaic station operation data and processes it using a photovoltaic data preprocessing model. The model extracts features through timestamp feature extraction and multi-scale wavelet transform, and combines clustering and anomaly detection algorithms to divide and purify the data into multiple weather type data sets. Then, for each weather type data set, an independent photovoltaic power output prediction model is trained. The model is composed of LSTM layers, multi-head attention layers, and fully connected layers. During prediction, the weather type of real-time data is first determined, and then the corresponding pre-trained model is called to complete the prediction. The frequency domain features extracted by wavelet transform dynamically guide the weight calculation of the multi-head attention layer, achieving adaptive modeling of global features and local details and improving the accuracy and robustness of distributed photovoltaic power output prediction.

[0007] The present application adopts the following technical solutions.

[0008] The first aspect of the present application provides a method for predicting distributed photovoltaic power output under variable weather conditions, comprising:

[0009] Step 1: Collect historical photovoltaic station operation data in the target area and perform time feature extraction and normalization according to the timestamp to generate an initial photovoltaic feature sequence.

[0010] Step 2: Process the initial photovoltaic feature sequence using a photovoltaic data preprocessing model, including: extracting multi-scale frequency domain features through wavelet transform; clustering based on the multi-scale frequency domain features to divide different weather type data sets; detecting intra-cluster abnormal data for each weather type data set to obtain purified weather type data sets.

[0011] Step 3: For each purified weather type data set, build a photovoltaic power output prediction model to generate photovoltaic gating weights using the multi-scale frequency domain features, and dynamically weight and fuse the outputs of parallel attention branch units inside the model using the photovoltaic gating weights to generate a frequency domain prediction result.

[0012] Step 4: Train the photovoltaic power output prediction model using a combined loss function containing photovoltaic physical constraints based on the frequency domain prediction result to obtain a trained photovoltaic power output prediction model.

[0013] Step 5: Use the trained photovoltaic power output prediction model based on real-time photovoltaic station operation data and obtain photovoltaic power output prediction values through inverse wavelet transform.

[0014] Preferably, the historical photovoltaic power station operation data comprises:

[0015] historical photovoltaic output data of the target region, and historical cell temperature data and historical meteorological data corresponding to the historical photovoltaic output data;

[0016] The historical meteorological data comprises irradiance, ambient temperature, humidity, high cloud cover, medium cloud cover and low cloud cover.

[0017] Preferably, the specific process of processing the initial photovoltaic feature sequence by using the photovoltaic data preprocessing model comprises:

[0018] performing multi-layer wavelet decomposition on the initial photovoltaic feature sequence to extract the multi-scale frequency domain features; wherein the multi-scale frequency domain features comprise a low-frequency approximation coefficient sequence and a high-frequency detail coefficient sequence;

[0019] splicing the multi-scale frequency domain features and the initial photovoltaic feature sequence to form a photovoltaic enhanced feature sequence;

[0020] performing clustering on the photovoltaic enhanced feature sequence by using a K-Means algorithm to divide different weather type data sets; wherein the number of weather types of the clustering is determined by calculating and selecting the optimal silhouette coefficient value in a preset range;

[0021] performing in-cluster anomaly data detection on each weather type data set by using an Isolation Forest algorithm to obtain an anomaly score of each data point; and dividing the anomaly score by using a preset high threshold and a low threshold, and screening each weather type data set into normal data and fuzzy data used for photovoltaic output prediction model training, and discarded abnormal data;

[0022] setting the normal data and the fuzzy data as the purified weather type data set.

[0023] Preferably, the structure of the photovoltaic output prediction model comprises:

[0024] an LSTM layer for performing time series feature encoding on the purified weather type data set to generate a hidden state sequence;

[0025] a multi-head attention layer for receiving and processing the hidden state sequence, and splicing the output of each head to generate a fusion feature representation;

[0026] a fully connected layer for receiving the fusion feature representation to map to a final prediction value to generate the frequency domain prediction result;

[0027] wherein each head of the multi-head attention layer comprises:

[0028] The parallel attention branch unit comprises a plurality of parallel attention branches, at least one sparse attention branch and one improved local attention branch;

[0029] The gating network unit is configured to generate photovoltaic gating weights according to the multi-scale frequency domain features;

[0030] The fusion unit is configured to dynamically weight and fuse the outputs of the parallel attention branch unit using the photovoltaic gating weights.

[0031] Preferably, the hidden state sequence is processed using the improved local attention branch, comprising:

[0032] For a scale layer s in the preset photovoltaic scale layer, a causal attention window containing historical positions is determined for each time step t in the hidden state sequence, and the causal attention window is defined by the window size and the expansion step size of the scale layer s;

[0033] The expansion step size is exponentially increased with the increase of the preset photovoltaic scale layer until a preset expansion upper limit is reached.

[0034] The photovoltaic attention score is calculated by performing a scaled dot product operation between the query vector of the time step t and the key vector of each historical position in the causal attention window;

[0035] The photovoltaic attention score is normalized to obtain the attention weight of each historical position in the causal attention window;

[0036] The output vector of the time step t at the scale layer s is obtained by performing weighted summation on all value vectors in the causal attention window according to the attention weight.

[0037] The output vectors of all scale layers are spliced in the feature dimension to generate a photovoltaic output vector sequence.

[0038] Preferably, the calculation process of the combined loss function comprises:

[0039] The frequency domain real value obtained by wavelet transform on the real photovoltaic output value is obtained; the mean square error between the frequency domain prediction result and the frequency domain real value is calculated to obtain a prediction error loss term.

[0040] obtaining a frequency domain physical value obtained by performing wavelet transform on a physical theory value of photovoltaic power generation, calculating an absolute difference value between the frequency domain prediction result and the frequency domain physical value, subtracting a preset tolerance range value from the absolute difference value, wherein the tolerance range value is proportional to a standard deviation of the frequency domain physical value, and taking a larger value between 0 as a single-point physical loss, calculating an average value of all single-point physical losses to obtain a physical constraint loss term;

[0041] multiplying the physical constraint loss term by a preset weight coefficient, adding the prediction error loss term to obtain a combined loss function value.

[0042] Preferably, the specific process of obtaining a photovoltaic output prediction value based on real-time photovoltaic station operation data includes:

[0043] performing the same processing as in step 2 on the real-time photovoltaic station operation data to obtain a real-time feature sequence;

[0044] calculating the Euclidean distance between the real-time feature sequence and the data center of each weather type determined in the training process;

[0045] classifying the real-time feature sequence into the weather type corresponding to the data center with the smallest Euclidean distance;

[0046] selecting the trained photovoltaic output prediction model corresponding to the weather type, inputting the classified real-time feature sequence into the selected photovoltaic output prediction model to generate a frequency domain prediction result at the current time;

[0047] performing inverse wavelet transform on the frequency domain prediction result at the current time to obtain the final photovoltaic output prediction value.

[0048] The second aspect of the application provides a distributed photovoltaic output prediction system under variable weather conditions, comprising:

[0049] a historical photovoltaic data acquisition module for acquiring historical photovoltaic station operation data of a target area and performing time feature extraction and normalization according to a time stamp to generate an initial photovoltaic feature sequence;

[0050] a historical photovoltaic data preprocessing module for processing the initial photovoltaic feature sequence using a photovoltaic data preprocessing model, including: extracting multi-scale frequency domain features by wavelet transform; clustering based on the multi-scale frequency domain features to divide different weather type data sets; performing intra-cluster anomaly data detection on each weather type data set to obtain a purified weather type data set;

[0051] A photovoltaic prediction model construction module is configured to construct a photovoltaic output prediction model according to the purified weather type dataset, generate photovoltaic gate weights by using the multi-scale frequency domain features, and dynamically weight and fuse the outputs of parallel attention branches in the model by using the photovoltaic gate weights to generate a frequency domain prediction result.

[0052] A photovoltaic prediction model training module is configured to train the photovoltaic output prediction model by using a combined loss function containing photovoltaic physical constraints according to the frequency domain prediction result, and obtain a trained photovoltaic output prediction model.

[0053] A photovoltaic output prediction module is configured to generate the frequency domain prediction result by using the trained photovoltaic output prediction model based on real-time photovoltaic station operation data, and obtain a photovoltaic output prediction value through inverse wavelet transform.

[0054] The third aspect of the present application provides a terminal comprising a processor and a storage medium.

[0055] The storage medium is configured to store instructions.

[0056] The processor is configured to operate according to the instructions to perform the steps of the method for predicting distributed photovoltaic output under variable weather.

[0057] The fourth aspect of the present application provides a computer-readable storage medium having a computer program stored thereon, which is executed by a processor to implement the steps of the method for predicting distributed photovoltaic output under variable weather.

[0058] The present application has the following advantages compared with the prior art:

[0059] 1. Wavelet transform can effectively identify and extract periodic changes and frequency components in the sequence, making up for the shortcomings of the LSTM model in explicitly modeling periodicity and frequency domain features, and enhancing the model's ability to identify and predict periodic patterns. In addition, performing partial operations in the frequency domain can also simplify complex time-domain calculations, especially when dealing with long time series data, which helps to reduce computational overhead and improve model efficiency.

[0060] 2. Photovoltaic output rules vary under different weather types, such as strong fluctuations in sunny weather and stable but low output in light rain. By classifying data according to weather types, a special model can be established for each type of weather to improve the model's fitting ability for nonlinear changes. Fine-tuning in a certain type of weather can improve prediction accuracy in specific scenarios and help address data scarcity problems under new or extreme weather conditions.

[0061] 3、The local attention mechanism proposed in the application fuses the advantages of causal local attention and pyramid local attention, can well capture recent detailed information, and can reduce the modeling difficulty brought by long-term dependence. According to the characteristics of time series prediction, a structure with a multi-scale increasing attention window and an expansion limit is designed to ensure that the mechanism strictly follows the causality of time series. Through the layer-by-layer increasing attention window and the expansion step, the dependence relationship on different time scales is effectively captured, and the collaborative modeling of short-term and long-term features is realized. At the same time, the upper limit of expansion is introduced to limit the maximum range of the attention window, avoiding the disorderly growth of the computational complexity, thereby improving the efficiency of the model.

[0062] 4、The application introduces a physical soft constraint to guide the model to improve the prediction accuracy while following the basic physical law, thereby improving the interpretability and reliability of the prediction result. Unlike hard constraints, soft constraints allow the model to deviate from the physical theory within a certain tolerance range, retaining the flexibility of data-driven models and enhancing their generalization ability, effectively integrating physical priors and data learning. BRIEF DESCRIPTION OF DRAWINGS

[0063] Figure 1 is a prediction method flowchart of the application. DETAILED DESCRIPTION

[0064] In order to make the purpose, technical scheme and advantages of the application clearer, the technical scheme of the application will be described clearly and completely below in combination with the drawings in the embodiments of the application. The embodiments described in the application are only a part of the embodiments of the application, not all embodiments. Based on the spirit of the application, all other embodiments obtained by those skilled in the art without creative labor fall within the protection scope of the application.

[0065] Embodiment one:

[0066] As shown in Figure 1 , the application discloses a distributed photovoltaic output prediction method under variable weather, comprising the following steps:

[0067] Step 1: Collect the historical photovoltaic station operation data of the target area, and perform time feature extraction and normalization according to the time stamp to generate an initial photovoltaic feature sequence.

[0068] The historical photovoltaic station operation data includes:

[0069] The historical photovoltaic output data of the target area, and the historical cell temperature data and historical meteorological data corresponding to the historical photovoltaic output data;

[0070] The historical meteorological data includes irradiance, ambient temperature, humidity, high cloud cover, medium cloud cover and low cloud cover.

[0071] Specifically, the embodiment selects historical photovoltaic output data of a distributed photovoltaic power station in a certain region, the data time range is from January 1, 2024 to June 30, 2024, the sampling time interval is 1 minute, 70% is divided into a training set, 10% is divided into a validation set, and 20% is divided into a test set.

[0072] The timestamp is extracted as five time features of minute, hour, day of the week, month and year, and is spliced with the collected data, and normalized, for example, the minimum-maximum normalization method is used to scale all feature values to the interval [0, 1] to eliminate the influence of dimension.

[0073] Finally, a time sliding window with a length of L (for example, L = 60, representing a time window of 60 minutes) is used to form an initial photovoltaic feature sequence of the model from t-L+1 time to t time , wherein represents a feature vector at a single time, and the normalized photovoltaic actual output at t+1 time is taken as the prediction label corresponding to the input sequence .

[0074] Step 2: processing the initial photovoltaic feature sequence by using a photovoltaic data preprocessing model , including: extracting multi-scale frequency domain features by wavelet transform; clustering based on the multi-scale frequency domain features to divide different weather type data sets; performing intra-cluster anomaly data detection on each weather type data set to obtain a purified weather type data set.

[0075] The specific process of processing the initial photovoltaic feature sequence by using the photovoltaic data preprocessing model includes:

[0076] First, in order to effectively separate the fluctuation information of different time scales contained in the photovoltaic output sequence, such as daily periodicity (long period), hourly weather change (medium period) and minute-level random noise (short period), the initial photovoltaic feature sequence is subjected to multi-layer wavelet decomposition, and the multi-scale frequency domain features are extracted; wherein the multi-scale frequency domain features include low-frequency approximation coefficient sequence and high-frequency detail coefficient sequence;

[0077] The multi-scale frequency domain features and the initial photovoltaic feature sequence are spliced to form a photovoltaic enhanced feature sequence.

[0078] Specifically, the sampling interval is known , so The signal sampling frequency is:

[0079] ,

[0080] The frequency of the daily cycle of photovoltaic output is:

[0081] .

[0082] In order to be able to use wavelet decomposition to separate the 24-hour daily cycle, weather changes (hourly level) and random noise (minute level), according to the approximate period of each layer:

[0083]

[0084] wherein, is the number of wavelet decomposition layers, and is calculated Therefore, the wavelet layer number m can be selected as 9 or 10 in theory, and the decomposition layer number m = 9 is finally determined by numerical experiments in the embodiment.

[0085] db4 (Daubechies 4) wavelet is selected as the mother wavelet, and the signal boundary is processed by periodic extension. The Mallat algorithm is used to perform wavelet decomposition on the first component of the sequence layer, and the sequence is obtained:

[0086] ,

[0087] wherein, is the low-frequency approximate coefficient sequence of the first layer, is the high-frequency detail coefficient sequence of the first layer, . ,

[0088] ,

[0089] wherein, is the original signal, i.e. the first sequence;

[0090] , are the values of the first layer approximate component and the detail component of the first feature at position , , are the low-pass filter and the high-pass filter, respectively. All components are spliced: , All features are spliced again:

[0091] ,

[0092]

[0093] .​​​​​​​

[0094] Finally, the feature set F is spliced with the initial photovoltaic feature sequence to obtain a photovoltaic enhanced feature sequence . The photovoltaic enhanced feature sequence will be used for subsequent weather type clustering analysis.

[0095] Next, the photovoltaic enhanced feature sequence is clustered by using the K-Means algorithm to divide different weather type data sets; wherein the number of weather types of the clustering is determined by calculating and selecting the optimal silhouette coefficient value in a preset range.

[0096] Specifically, the silhouette coefficient method is used for evaluation in the preset range . For each candidate cluster number , the K-Means algorithm is executed and the average silhouette coefficient of all data samples is calculated. For a single data sample , the calculation formula of the silhouette coefficient is as follows:

[0097] ,

[0098] wherein is the average distance of the sample to all other samples in the cluster to which it belongs, and the smaller the value, the higher the cluster cohesion. is the average distance of the sample to all samples in the nearest neighbor cluster, and the larger the value, the better the cluster separation. The value range of the silhouette coefficient is [-1, 1], and the closer the value to 1, the better the clustering effect. Finally, the that makes the average silhouette coefficient reach the maximum value is selected as the optimal weather type number.

[0099] The clustering number is set to the optimal value evaluated , and a final K-Means clustering is performed, aiming to find a set of optimal cluster divisions and a set of optimal centroids to minimize the within-cluster sum of squares, and the objective function is as follows:

[0100] ,

[0101] The iteration process is as follows:

[0102] The K-Means++ algorithm is used for selection of initial centroids, denoted as .

[0103] The following assignment and update steps are repeated, assuming that the current is the jth iteration:

[0104] The centroid obtained according to the last round of iteration Each data sample is assigned to the nearest cluster. The mathematical expression of its assignment rule is:

[0105] ,

[0106] According to the newly divided cluster , the average value (centroid) of the features contained in each data set under different weather types is recalculated , wherein represents the jth updated data set, represents the number of samples contained in the jth updated data set.

[0107] The above steps are repeated, and after each iteration, it is determined whether the algorithm converges. When the moving distance (for example, the square of the Euclidean distance) of the centroid of all clusters in the last two iterations is less than a predetermined threshold , the algorithm terminates, as shown below:

[0108] ,

[0109] , wherein represents the average value of the features contained in the data set of different weather types after the th update, is a predetermined threshold.

[0110] Finally, the optimal cluster division and the optimal centroid are output.

[0111] Next, in order to eliminate the interference of abnormal data points in each weather type on subsequent model training, an isolation forest algorithm is used to detect intra-cluster abnormal data in each weather type data set to obtain an abnormal score of each data point; and a high threshold and a low threshold are used to divide the abnormal score, and each weather type data set is filtered into normal data and fuzzy data for photovoltaic power output prediction model training, and discarded abnormal data;

[0112] The normal data and fuzzy data are set as the purified weather type data set.

[0113] Specifically, in this embodiment, an isolation forest model is constructed and trained. The hyperparameters of the model are preferably set as follows: the number of isolated trees is 100, and the maximum number of samples for each tree is 256. The trained model is used to calculate the anomaly score of each data sample in each weather type data set Compute its anomaly score .

[0114] According to experience, set a preset low threshold and a high threshold Divide the anomaly score, and divide each sample into three categories. The division rule is as follows:

[0115]

[0116] According to the above classification result, the data set is screened into three subsets: normal data , ambiguous data and abnormal data . Discard the abnormal data set , and merge the normal data and the ambiguous data to form the final purified weather type data set, which is used for subsequent photovoltaic power output prediction model training.

[0117] Step 3: Construct a photovoltaic power output prediction model according to the purified weather type data set, which is used to generate photovoltaic gate weight using the multi-scale frequency domain feature, and dynamically weight and fuse the output of the parallel attention branch inside the model using the photovoltaic gate weight, to generate a frequency domain prediction result.

[0118] The embodiment adopts the strategy of training photovoltaic power output prediction models for different weather types, which are applied to a weather type data set, thereby training independent photovoltaic power output prediction models. In the prediction phase, first determine the weather type to which the data to be processed belongs, and then select the corresponding pre-trained model for prediction.

[0119] The structure of the photovoltaic power output prediction model includes:

[0120] An LSTM layer for encoding the time series features of the purified weather type data set to generate a hidden state sequence; in this embodiment, the LSTM layer is a 2-layer stacked structure, and the hidden state sequence dimension is set to 128.

[0121] A multi-head attention layer for receiving and processing the hidden state sequence, and concatenating the output of each head to generate a fused feature representation;

[0122] A fully connected layer for receiving the fused feature representation and mapping it to the final prediction value to generate the frequency domain prediction result. In this embodiment, this layer consists of a hidden layer containing 64 neurons and a ReLU activation function, and a linear output layer with a single neuron for outputting the prediction value.

[0123] Specifically, a weather type to which the to-be-processed data belongs is determined, and a pre-trained photovoltaic output prediction model is selected The input LSTM layer obtains a hidden state sequence The calculation formula is as follows:

[0124] ,

[0125] Among them, , , denotes the hidden state of the current time step, denotes the input of the current time step, denotes the hidden state of the previous time step.

[0126] Then, the hidden state sequence H of the LSTM layer is input to the multi-head attention layer, and through the internal gating mechanism, the multi-scale frequency domain features are used to guide the weight calculation of the multi-head attention, and then the attention results are weighted fused and spliced The input of the full connection layer outputs the prediction result .

[0127] Among them, each head of the multi-head attention layer includes:

[0128] a parallel attention branch unit including a plurality of parallel attention branches, the parallel attention branches including at least one sparse attention branch and one improved local attention branch;

[0129] a gating network unit for generating photovoltaic gating weights according to the multi-scale frequency domain features;

[0130] a fusion unit for dynamically weighting and fusing the outputs of the attention branch unit by using the photovoltaic gating weights.

[0131] Specifically, the hidden state sequence H (dimension 128) output by the LSTM layer is evenly divided into h parts in the feature dimension, which can be divided into 4 parts, each part being 32-dimensional, and is used as the independent input of each attention head, and is denoted as:

[0132] ,

[0133] Among them, denotes the input sequence of the i-th attention head.

[0134] In this embodiment, for the i-th attention head, it internally includes two parallel calculation paths: a gating weight generation path and an attention branch calculation path.

[0135] The gating weight generation path is used to generate a photovoltaic gating weight for fusing the two paths according to the frequency domain characteristics of the signal The corresponding multi-scale frequency domain feature vector is input into the gated multi-layer perception as input. The structure of the gated multi-layer perception is set as:

[0136] Input layer: The dimension is the same as that of the frequency domain feature vector (e.g., 64 dimensions).

[0137] Hidden layer: Contains 128 neurons and uses a ReLU activation function.

[0138] Output layer: Contains 1 neuron and uses a linear activation function.

[0139] The linear output value of the single neuron of the gated multi-layer perception is input into a Sigmoid activation function to obtain the photovoltaic gating weight of the head, and the calculation formula is as follows:

[0140] .

[0141] As for the attention branch calculation path, it is used to capture the dependency relationship of the sequence from different angles. The input of the head is simultaneously input into the following two parallel attention branches:

[0142] Branch A: Sparse attention branch.

[0143] For sparse attention, a sparse selection is used. It aims to capture the most key few associated information from the global. For each query in the sequence, only the attention weight of the query with the top k keys is calculated. The value of k is set to 8. The calculation formula is as follows:

[0144] .

[0145] wherein, is the output vector of the first parallel branch of the i-th attention head, and SparseAttention() refers to a sparse attention function based on top-k selection.

[0146] Branch B: Improved local attention branch.

[0147] The improved local attention branch is used to process the hidden state sequence, including:

[0148] For a scale layer s in the preset photovoltaic scale layers, a causal attention window containing historical positions is determined for each time step t in the hidden state sequence, the causal attention window being jointly defined by a window size and an expansion step of the scale layer s;

[0149] wherein the expansion step exponentially increases with an increase in the preset photovoltaic scale layers until reaching a preset expansion upper limit;

[0150] A photovoltaic attention score is calculated by performing a scaled dot product operation between a query vector of the time step t and a key vector of each historical position in the causal attention window;

[0151] The photovoltaic attention score is normalized to obtain an attention weight of each historical position in the causal attention window;

[0152] All value vectors in the causal attention window are weighted and summed according to the attention weight to obtain an output vector of the time step t at the scale layer s;

[0153] The output vectors of all scale layers are spliced in the feature dimension to generate the photovoltaic output vector sequence. The photovoltaic output vector sequence is one of the inputs of the full connection layer.

[0154] Specifically, unlike the general local attention which requires each time step to only focus on a fixed window size, the modified local attention combines the advantages of causal local attention and pyramid local attention, requires only to focus on historical positions, the scale of each layer increases, and an expansion upper limit is set.

[0155] For the input sequence of this attention head , it is transformed by three independent trainable linear projection matrices , , respectively to obtain a query matrix Q, a key matrix K and a value matrix V.

[0156] For the first scale, the causal attention window of the time step is:

[0157] ,

[0158] wherein is the expansion step of the first layer ( ) and , specifically 1, 2, 4 and 8.

[0159] In each scale layer, a window size of The local attention calculation is performed for the window. That is, at each time step, it focuses on itself and the two historical positions before and after (according to the dilation step sampling). Within the window, the standard scaled dot-product attention operation is performed.

[0160] Next, for sequence position , the photovoltaic attention score of it with each position in the window is calculated:

[0161] ,

[0162] where is the query vector of time step t, is the key vector of position j, is the dimension of the key vector.

[0163] and the attention weight :

[0164] ,

[0165] The output vector is obtained by weighted summation:

[0166] .

[0167] Finally, the output vectors of the s scale layers are spliced in the feature dimension to form the photovoltaic output vector sequence of this branch.

[0168] The two parallel branches are dynamically weighted and fused by using the gating weight to obtain the final output of the i-th head:

[0169] .

[0170] Finally, the fusion outputs of all h attention heads are spliced in the feature dimension to obtain the final fusion feature representation , denoted as:

[0171] .

[0172] is passed to the fully connected layer of the next layer.

[0173] Step 4: In order to ensure that the prediction result of the model is not only accurate on the data, but also reasonable in the physical law, a combined loss function containing photovoltaic physical constraints is used to train the photovoltaic power output prediction model, and a trained photovoltaic power output prediction model is obtained.

[0174] The calculation process of the combined loss function comprises:​

[0175] obtaining a frequency domain real value obtained after wavelet transform of the real photovoltaic output value; calculating a mean square error between the frequency domain prediction result and the frequency domain real value to obtain a prediction error loss term;

[0176] obtaining a frequency domain physical value obtained after the same wavelet transform of the photovoltaic power generation physical theory value; calculating an absolute difference value between the frequency domain prediction result and the frequency domain physical value; subtracting a preset tolerance range value from the absolute difference value, and taking a larger value between 0 as a single-point physical loss; obtaining a physical constraint loss term by averaging all single-point physical losses;

[0177] multiplying the physical constraint loss term by a preset weight coefficient, adding the prediction error loss term to obtain a combined loss function value.

[0178] Specifically, a physical constraint is added in the loss function for back propagation. The photovoltaic power generation physical theory value can be calculated by a formula:

[0179]

[0180] wherein, represents a standard reference photoelectric conversion efficiency, which is set to 21.5%, represents a photovoltaic module area, which is set to 1.65 square meters, represents total solar radiation received per unit area, represents a temperature loss coefficient, which is set to 0.4% / ℃, represents a cell temperature, represents a reference temperature of 25℃.

[0181] Suppose that the photovoltaic power generation physical theory value is obtained after wavelet transform to obtain a frequency domain physical value , and the frequency domain prediction result is , then the physical constraint loss term calculation formula is as follows:

[0182] ,

[0183] wherein, is a tolerance range, which is set to is related to a standard deviation :

[0184] ,

[0185] The model is debugged at about 0.7 , which allows the prediction result of the model to deviate from the physical theory within a certain error range. The prediction error loss term and the physical constraint loss term are combined to obtain a final loss function :

[0186] ,

[0187] wherein, is the mean square loss error, used to measure the prediction error of the model, is the frequency domain true value, is the frequency domain prediction result, controls the weight size of the physical soft constraint, used to adjust the guidance strength of the physical soft constraint, and the constraint is in , which is fine-tuned by experiment.

[0188] Step 5: Based on the real-time photovoltaic station operation data, the trained photovoltaic output prediction model is used to generate the frequency domain prediction result, and the photovoltaic output prediction value is obtained through inverse wavelet transform.

[0189] The specific process of obtaining the photovoltaic output prediction value based on real-time photovoltaic station operation data includes:

[0190] The same processing as step 2 is performed on the real-time photovoltaic station operation data to obtain a real-time feature sequence;

[0191] Calculate the Euclidean distance between the real-time feature sequence and the data center of each weather type determined in the training process , as follows:

[0192] ,

[0193] Classify the real-time feature sequence into the weather type corresponding to the data center with the smallest Euclidean distance;

[0194] Input the classified real-time feature sequence into the corresponding trained photovoltaic output prediction model to generate the frequency domain prediction result;

[0195] Perform inverse wavelet transform on the frequency domain prediction result to obtain the final photovoltaic output prediction value:

[0196]

[0197] wherein, represents the prediction data after wavelet transform, i.e. the prediction data of wavelet coefficients, represents the restored photovoltaic output prediction value.

[0198] Embodiment 2:

[0199] Embodiment 2 of the present application proposes a distributed photovoltaic output prediction system under variable weather conditions using the method described in embodiment 1 of the present application, comprising:

[0200] a historical photovoltaic data collection module, configured to collect historical photovoltaic station operation data of a target region, and perform time feature extraction and normalization according to timestamps to generate an initial photovoltaic feature sequence;

[0201] a historical photovoltaic data preprocessing module, configured to process the initial photovoltaic feature sequence by using a photovoltaic data preprocessing model, including: extracting multi-scale frequency domain features by wavelet transform; clustering based on the multi-scale frequency domain features to divide different weather type data sets; performing intra-cluster anomaly data detection on each weather type data set to obtain a purified weather type data set;

[0202] a photovoltaic prediction model construction module, configured to construct a photovoltaic output prediction model according to the purified weather type data set, configured to generate photovoltaic gating weights by using the multi-scale frequency domain features, and configured to dynamically weight and fuse the outputs of parallel attention branches in the model by using the photovoltaic gating weights to generate a frequency domain prediction result;

[0203] a photovoltaic prediction model training module, configured to train the photovoltaic output prediction model by using a combined loss function containing photovoltaic physical constraints to obtain a trained photovoltaic output prediction model;

[0204] a photovoltaic output prediction module, configured to use the trained photovoltaic output prediction model to generate the frequency domain prediction result based on real-time photovoltaic station operation data, and to obtain a photovoltaic output prediction value through inverse wavelet transform.

[0205] The present application has the following advantages:

[0206] 1. Wavelet transform can effectively identify and extract periodic changes and frequency components in the sequence, making up for the shortcomings of the LSTM model in explicitly modeling periodicity and frequency domain features, and enhancing the model's ability to identify and predict periodic patterns. In addition, performing partial operations in the frequency domain can also simplify complex time-domain calculations, especially when dealing with long time series data, which helps to reduce computational overhead and improve model running efficiency.

[0207] 2. Photovoltaic output laws are different under different weather types, such as strong fluctuations in sunny days and stable but low output in light rain. After classifying the data according to weather types, a special model can be established for each type of weather to improve the model's fitting ability for nonlinear changes. Fine-tuning in a certain type of weather can improve prediction accuracy in specific scenarios and help address data scarcity problems under new or extreme weather conditions.

[0208] 3. The local attention mechanism proposed in the application fuses the advantages of causal local attention and pyramid local attention, can well capture recent detailed information, and can reduce the modeling difficulty brought by long-term dependence. According to the characteristics of time series prediction, a structure with a multi-scale increasing attention window and an expansion limit is designed to ensure that the mechanism strictly follows the causality of time series. Through the layer-by-layer increasing attention window and the expansion step, the dependence relationship on different time scales is effectively captured, and the collaborative modeling of short-term and long-term features is realized. At the same time, the upper limit of expansion is introduced to limit the maximum range of the attention window, avoiding the disorderly growth of the computational complexity, thereby improving the efficiency of the model.

[0209] 4. The application introduces a physical soft constraint to guide the model to improve the prediction accuracy while following the basic physical law, thereby improving the explainability and reliability of the prediction result. Unlike hard constraints, soft constraints allow the model to deviate from the physical theory within a certain tolerance range, retaining the flexibility of data-driven models and enhancing their generalization ability, effectively integrating physical priors and data learning.

[0210] The present disclosure can be a system, a method, and / or a computer program product. The computer program product can include a computer readable storage medium (or media) having computer readable program instructions thereon for causing a processor to carry out aspects of the present disclosure.

[0211] The computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium can be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable storage medium include the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch cards or punched tape, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.

[0212] Computer readable program instructions described herein can be downloaded to respective computing / processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and / or a wireless network. The network can comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and / or edge servers. A network adapter card or network interface in each computing / processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing / processing device.

[0213] Computer readable program instructions for carrying out operations of the present disclosure can be assembly instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C++ or the like, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The computer readable program instructions can execute entirely on the user's computing device, partly on the user's computing device, as a stand-alone software package, partly on the user's computing device and partly on a remote computing device or entirely on the remote computing device or server. In the latter scenario, the remote computing device can be connected to the user's computing device through any kind of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computing device, for example, through the Internet using an Internet Service Provider. In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) can execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present disclosure.

[0214] Finally, it should be noted that the above-mentioned embodiments are merely intended for describing the technical solutions of the present application, but not for limiting it. Although the present application has been described in detail with reference to the above-mentioned embodiments, those skilled in the art should understand that the specific embodiments of the present application can be modified or equivalent replacements without departing from the spirit and scope of the present application, and any modifications or equivalent replacements without departing from the spirit and scope of the present application should be covered in the protection scope of the claims of the present application.

Claims

1. A method for predicting distributed photovoltaic power output under variable weather conditions, characterized in that, include: Step 1: Collect historical photovoltaic power station operation data of the target area, and extract and normalize time features according to timestamps to generate an initial photovoltaic feature sequence; Step 2: Process the initial photovoltaic feature sequence using a photovoltaic data preprocessing model, including: extracting multi-scale frequency domain features through wavelet transform; clustering based on the multi-scale frequency domain features to divide different weather type datasets; and performing intra-cluster anomaly detection on each weather type dataset to obtain a cleaned weather type dataset. Step 3: For each type of weather data set that is cleaned up, a photovoltaic power output prediction model is constructed. The photovoltaic gating weights are generated using the multi-scale frequency domain features. The photovoltaic gating weights are then used to dynamically weight and fuse the outputs of the parallel attention branch units within the model to generate frequency domain prediction results. Step 4: Based on the frequency domain prediction results, the photovoltaic power output prediction model is trained using a combined loss function that includes photovoltaic physical constraints to obtain a trained photovoltaic power output prediction model; the combined loss function is used to perform a weighted summation of the mean square error between the frequency domain prediction results and the true frequency domain values ​​and the absolute difference between the frequency domain prediction results and the frequency domain physical values ​​with a tolerance range. Step 5: Based on real-time photovoltaic power plant operation data, use the trained photovoltaic power output prediction model and obtain the photovoltaic power output prediction value through inverse wavelet transform.

2. The method for predicting distributed photovoltaic power output under variable weather conditions according to claim 1, characterized in that, The historical photovoltaic power station operation data includes: The historical photovoltaic power output data of the target area, as well as the historical cell temperature data and historical meteorological data corresponding to the historical photovoltaic power output data; The historical meteorological data includes irradiance, ambient temperature, humidity, cloud cover in the upper, middle, and lower cloud layers.

3. The method for predicting distributed photovoltaic power output under variable weather conditions according to claim 2, characterized in that, The specific process of processing the initial photovoltaic feature sequence using a photovoltaic data preprocessing model includes: The initial photovoltaic feature sequence is subjected to multi-level wavelet decomposition to extract the multi-scale frequency domain features; wherein, the multi-scale frequency domain features include a low-frequency approximation coefficient sequence and a high-frequency detail coefficient sequence; The multi-scale frequency domain features are concatenated with the initial photovoltaic feature sequence to form a photovoltaic enhancement feature sequence; The K-Means algorithm is used to cluster the photovoltaic enhancement feature sequences to divide them into different weather type datasets; wherein, the number of the weather type datasets is determined by calculating and selecting the optimal profile coefficient value within a preset range; The isolated forest algorithm is used to detect in-cluster anomalies in each weather type dataset to obtain anomaly scores for each data point. The anomaly scores are then divided using preset high and low thresholds to filter each weather type dataset into normal data and fuzzy data for training the photovoltaic power output prediction model, as well as discarded anomaly data. Set the normal data and fuzzy data as the purified weather type dataset.

4. The method for predicting distributed photovoltaic power output under variable weather conditions according to claim 3, characterized in that, The structure of the photovoltaic power output prediction model includes: The LSTM layer is used to encode the temporal features of the purified weather type dataset and generate a hidden state sequence. A multi-head attention layer is used to receive and process the hidden state sequence and concatenate the outputs of each head to generate a fused feature representation; A fully connected layer is used to receive the fused feature representation mapped to the final predicted value and generate the frequency domain prediction result; Each head in the multi-head attention layer includes: A parallel attention branch unit includes multiple parallel attention branches, wherein each parallel attention branch includes at least one sparse attention branch and one improved local attention branch; Gated network units are used to generate photovoltaic gating weights based on the multi-scale frequency domain features; The fusion unit is used to dynamically weight and fuse the output of the parallel attention branch unit using the photovoltaic gating weight.

5. The method for predicting distributed photovoltaic power output under variable weather conditions according to claim 4, characterized in that, The hidden state sequence is processed using an improved local attention branch, including: For a scale layer s in a preset photovoltaic scale layer, a causal attention window containing historical positions is determined for each time step t in the hidden state sequence. The causal attention window is defined by the window size and expansion step size of the scale layer s. The expansion step size increases exponentially with the increase of the preset photovoltaic scale layer until it reaches the preset expansion limit. The photovoltaic attention score is calculated by performing a scaled dot product operation between the query vector at time step t and the key vector at each historical position within the causal attention window. The photovoltaic attention score is normalized to obtain the attention weight of each historical position within the causal attention window; For all value vectors within the causal attention window, a weighted sum is performed based on the attention weights to obtain the output vector at time step t at scale layer s; The output vectors of all scale layers are concatenated along the feature dimension to generate a photovoltaic output vector sequence.

6. The method for predicting distributed photovoltaic power output under variable weather conditions according to claim 5, characterized in that, The calculation process of the combined loss function includes: Obtain the true frequency domain value of the actual photovoltaic power output after wavelet transform; calculate the mean square error between the frequency domain prediction result and the true frequency domain value to obtain the prediction error loss term; The frequency domain physical values ​​are obtained by applying the same wavelet transform to the theoretical physical values ​​of photovoltaic power generation; the absolute difference between the frequency domain prediction result and the frequency domain physical values ​​is calculated; a preset tolerance range value is subtracted from the absolute difference, and the average value of all single-point physical losses is calculated to obtain the physical constraint loss term; wherein, the tolerance range value is proportional to the standard deviation of the frequency domain physical values; and the larger value between 0 and 0 is taken as the single-point physical loss. The physical constraint loss term is multiplied by a preset weighting coefficient and added to the prediction error loss term to obtain the combined loss function value.

7. The method for predicting distributed photovoltaic power output under variable weather conditions according to claim 6, characterized in that, The specific process of obtaining photovoltaic power output predictions based on real-time photovoltaic power plant operation data includes: Perform the same processing as step 2 on the real-time photovoltaic power station operation data to obtain a real-time feature sequence; Calculate the Euclidean distance between the real-time feature sequence and the data center for each weather type determined during training; The real-time feature sequences are classified into the weather type corresponding to the data center with the smallest Euclidean distance; Select the trained photovoltaic power output prediction model corresponding to the weather type, input the classified real-time feature sequence into the selected photovoltaic power output prediction model, and generate the frequency domain prediction result for the current time. Perform an inverse wavelet transform on the frequency domain prediction result at the current moment to obtain the final photovoltaic power output prediction value.

8. A system for predicting distributed photovoltaic power output under variable weather conditions, characterized in that, The system is used to perform the steps of the method according to any one of claims 1-7, including: The historical photovoltaic data acquisition module is used to collect historical photovoltaic power station operation data in the target area, and extract and normalize time features according to timestamps to generate an initial photovoltaic feature sequence. The historical photovoltaic data preprocessing module is used to process the initial photovoltaic feature sequence using a photovoltaic data preprocessing model, including: extracting multi-scale frequency domain features through wavelet transform; clustering based on the multi-scale frequency domain features to divide different weather type datasets; and performing intra-cluster anomaly detection on each weather type dataset to obtain a cleaned weather type dataset. The photovoltaic prediction model construction module is used to construct a photovoltaic output prediction model based on the purified weather type dataset. It is used to generate photovoltaic gating weights using the multi-scale frequency domain features and to dynamically weight and fuse the outputs of the parallel attention branches inside the model using the photovoltaic gating weights to generate frequency domain prediction results. The photovoltaic prediction model training module is used to train the photovoltaic power output prediction model based on the frequency domain prediction results using a combined loss function that includes photovoltaic physical constraints, so as to obtain a trained photovoltaic power output prediction model. The photovoltaic output prediction module is used to generate the frequency domain prediction result based on real-time photovoltaic power plant operation data and a trained photovoltaic output prediction model, and obtain the photovoltaic output prediction value through inverse wavelet transform.

9. A terminal, comprising a processor and a storage medium; characterized in that: The storage medium is used to store instructions; The processor is configured to operate according to the instructions to perform the steps of the method according to any one of claims 1-7.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements the steps of the method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Photovoltaic power prediction method and device, computer equipment and storage medium

    CN117810982A

  • Power distribution network net load prediction method and system considering multiple time-space correlation

    CN118411062A