A photovoltaic power generation power prediction method based on a deep time sequence block model
By combining the DFT decomposition of the deep temporal block model with whale optimization and the Transformer self-attention mechanism, the problems of high time complexity and low prediction accuracy in photovoltaic power generation prediction are solved, and more efficient photovoltaic power generation prediction is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHANGJIAKOU POWER SUPPLY COMPANY OF STATE GRID JINBEI ELECTRIC POWER COMPANY
- Filing Date
- 2024-11-29
- Publication Date
- 2026-06-02
AI Technical Summary
Existing photovoltaic power generation prediction methods based on Transformer suffer from high time complexity and low prediction accuracy under long-sequence input conditions, making it difficult to improve the prediction accuracy of photovoltaic power generation in the short and medium to long term.
We employ a deep time-series block model, decompose the photovoltaic power sequence through DFT signal processing, use whale optimization to find the optimal time-series block size, and combine the self-attention mechanism of the Transformer model to capture long-term dependencies in the time series, thereby improving the model's ability to capture local patterns.
It significantly improves the accuracy of photovoltaic power generation prediction and solves the problems of high time complexity and low prediction accuracy in existing methods.
Smart Images

Figure CN122132705A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of photovoltaic power generation prediction, and in particular to a photovoltaic power generation prediction method based on a deep time-series block model. Background Technology
[0002] Accurate forecasting of photovoltaic (PV) power output is crucial for the efficient management of daily power generation and the maintenance of energy storage equipment. However, due to the intermittency and uncertainty of solar energy resources, PV power generation is affected by factors such as weather conditions, seasonal variations, and geographical location, exhibiting significant volatility and unpredictability. Therefore, accurate forecasting of PV power generation is extremely challenging.
[0003] In recent years, deep learning model research has made rapid progress, with numerous outstanding achievements in the field of photovoltaic forecasting. The Transformer model, based on the attention mechanism, can automatically learn the relationships between elements in a sequence, making it highly suitable for time series modeling tasks and representing the current state of excellence in time series data forecasting. However, existing Transformer-based methods suffer from high time complexity and low prediction accuracy when dealing with long sequence inputs, making it difficult to improve the accuracy of short-term and medium-to-long-term photovoltaic power generation forecasts. Summary of the Invention
[0004] To address the aforementioned problem of low accuracy in photovoltaic power generation prediction, this invention proposes a photovoltaic power generation prediction method based on a deep time-series block model to improve prediction accuracy.
[0005] To achieve the above objectives, the present invention provides a photovoltaic power generation prediction method based on a deep time-series block model, characterized by comprising the following steps: Step 1: Obtain historical photovoltaic power generation data of the photovoltaic power station and historical meteorological data of the photovoltaic power station for the corresponding time period. The historical meteorological data includes wind speed, ambient temperature, ambient humidity, horizontal solar radiation intensity, tilted solar radiation intensity, and weather type data. Step 2: Perform one-hot encoding on the weather type data to map it to numerical variables, use relevant functions of the Pandas library to statistically obtain the missing data, and fill in the missing data; Step 3: Standardize all data variables and then convert the standardized multi-channel data to single-channel format. Step 4: Use the DFT signal processing method to decompose the photovoltaic power series into seasonal and trend partial series; Step 5: Perform time-domain partitioning on each univariate time series data, dividing it into a series of time series blocks, and use Whale Optimization (WOA) to find the optimal time series block size; Step 6: Input the obtained training data into the Transformer prediction backbone network for model training. The backbone network includes a position encoding embedding module, a Transformer encoder module, and a flattening and linear transformation module. The position encoding embedding module performs embedding operations on each time series block and then adds position encoding. The time series blocks after embedding and position encoding are input into the Transformer encoder module. The Transformer encoder module processes these time series blocks through a self-attention mechanism to capture the long-term dependencies of the time series. The flattening and linear transformation module flattens the output of the Transformer encoder module and then inputs it into a linear layer to generate the trend and seasonal prediction results of photovoltaic forecasts. The trend and seasonal prediction results of photovoltaic forecasts are merged to generate the final model output result. Step 7: Using the trained model, input the features of the prediction sample to obtain the prediction result.
[0006] This invention provides a photovoltaic power generation prediction method based on a deep temporal block model. It employs DeFi (DFT) to decompose the photovoltaic power sequence, introduces temporal blocks, and uses Whale Optimization (WOA) to optimize the block size, achieving rapid algorithm convergence. It modifies the input and architecture of the Transformer model, treating each temporal block as a processing unit, thereby maximizing the preservation of local dependencies within the processing unit to enhance the model's ability to capture local patterns. Furthermore, it utilizes a multi-head self-attention mechanism to capture long-term dependencies in the sequence. This invention simultaneously solves the problems of high time complexity and low prediction accuracy for long input sequences in existing Transformer models, significantly improving prediction accuracy. Attached Figure Description
[0007] Figure 1 A table containing detailed information about the historical data variables; Figure 2 Flowchart for intelligently filling in missing data with multiple conditions; Figure 3 A schematic diagram illustrating the single-channel processing of multi-channel data; Figure 4 This is a schematic diagram of the backbone network structure.
[0008] The present invention will now be described in further detail with reference to the accompanying drawings. Detailed Implementation
[0009] The present invention provides a photovoltaic power generation prediction method based on a deep time-series block model, comprising the following steps.
[0010] Step 1: Obtain historical photovoltaic power generation data and corresponding historical meteorological data for the photovoltaic power station during the relevant time period. (See also...) Figure 1The acquired historical meteorological data includes wind speed, ambient temperature, ambient humidity, horizontal solar radiation intensity, tilted solar radiation intensity, and weather type data. Except for the weather type data, which is a string, the other data are floating-point numbers. Weather type data is primarily obtained from weather stations through their web service interfaces. The weather type data from these stations directly includes labels such as sunny, cloudy, rainy, and snowy, and is hourly data. If the training data is at the 15-minute level, then hourly weather labels are used. Wind speed, ambient temperature, ambient humidity, horizontal solar radiation intensity, and tilted solar radiation intensity data are obtained from sensors or detection instruments installed at the photovoltaic power station. Photovoltaic power generation data is calculated based on the current and voltage data detected at the photovoltaic power station.
[0011] One-hot encoding is performed on weather data to map it to numerical variables. Pandas library functions are used to statistically identify missing data and fill in the missing data.
[0012] Because the obtained historical data contains non-numerical data such as weather types and missing data, the dataset was preprocessed using the following steps to ensure high-quality historical data for subsequent model input. First, the discrete integer variable weather type data was one-hot encoded. Weather types include four types: sunny, cloudy, rainy, and snowy. After encoding, these were mapped to numerical variables. Second, relevant functions from the Pandas library were used to statistically identify missing data and perform multi-condition intelligent imputation on the missing data. The obtained historical photovoltaic power generation data and historical meteorological data are multivariate time-series data, and were processed using... Figure 2 The method shown performs multi-condition intelligent imputation on missing data: 1) If a single variable in a multivariate sequence has missing records for more than 6 consecutive hours, with 4 records per hour, that is, there are 4*6=24 consecutive missing records, then the multivariate time series data for the missing time period is deleted; 2) If two or more single variables have missing records for 4 consecutive hours or more in the same time period, that is, there are greater than or equal to 4*4=16 consecutive missing records, then the multivariate time series data for the missing time period is deleted; 3) For data missing in cases other than 1) and 2), for single-point missing data (data missing with 1 timestamp), the mean of 1 hour is used for imputation; for missing data with multiple consecutive timestamps, the Xgboost ensemble learning algorithm is used to imput the missing values.
[0013] Step 3: Standardize all data variables and then convert the standardized multi-channel data to single-channel format.
[0014] After completing the missing value imputation, to avoid significant differences in the units and values of different input data, all data variables are standardized, i.e.: ,in, yes The average value; yes standard deviation These are the standardized values. The standardized multi-channel data is then processed into single-channel data, meaning each channel independently forms a time-series vector. This process... Figure 3 As shown.
[0015] Step 4: Use the DFT signal processing method to decompose the photovoltaic power series to generate seasonal partial series and trend partial series.
[0016] The Discrete Fourier Transform (DFT) is applied to process photovoltaic (PV) power series, decomposing the series into seasonal and trend components. Considering the inherent complex periodic patterns of PV data, the model processes these two components separately for prediction after decomposition. DFT decomposition of the input series data reduces the difficulty of modeling seasonal and trend periodic patterns, thus improving prediction accuracy. The DFT employs... The formula transforms a fixed-length photovoltaic power input sequence from the time domain to the frequency domain. Wherein, Indicates the DFT after the Complex amplitude and phase of each frequency component, Represents the sample index value in the time domain, ranging from 1 to... , Represents the sample index in the frequency domain, ranging from 0 to... , It represents the imaginary unit in the equation. This represents the original time series data, i.e., the discrete signal in the time domain.
[0017] Frequency domain signals can be used The formula uses IDFT (Inverse Discrete Fourier Transform) to transform back to the time domain. Wherein, It also represents time series data, but it is transformed from the frequency domain through an inverse transform. The original signal was recovered.
[0018] The result of DFT represents the amplitude and phase of each frequency component in the signal. Based on the signal length N, the Nyquist frequency is determined as N / 2. The top [N / 3] (2 / 3 of the Nyquist frequency values = N / 3) frequency components are taken, and IDFT is applied to these main frequency components to generate the seasonal portion of the time series. IDFT is then applied to the remaining low-frequency components to generate the trend portion of the time series.
[0019] Step 5: Perform time-domain partitioning on each univariate time series data point, dividing it into a series of time series blocks, and use Whale Optimization (WOA) to find the optimal time series block size.
[0020] After completing single-channel conversion and photovoltaic power sequence decomposition, multiple univariate time series were obtained. Each univariate time series data was then time-domain segmented into a series of subsequences, each called a time series block. Each time series block contains a series of sample points with consecutive time steps, and each time series block is processed as a whole. The time series block size setting in the model has a significant impact on prediction performance; therefore, whale optimization (WOA) is used to find the optimal time series block size.
[0021] Methods for finding the optimal time series block size using whale optimization (WOA) include: (1) Initialize parameters Define the whale population size (N), the maximum number of iterations (Max_iter), and the search range of the temporal block (lb and ub), i.e., the minimum and maximum values. Initialize the positions of the whale population, where each whale's position represents a potential temporal block size solution.
[0022] (2) Determine the fitness function The loss function of the Transformer model is used as the fitness function, and the mean squared error (MAE) is taken as the loss function. Its calculation formula is as follows: In the formula, express The true value of a moment Indicates the predicted value. This represents the total number of test samples.
[0023] (3) Iterative optimization For each iteration, calculate the fitness value of each whale, which is the loss function value corresponding to its temporal block size. Determine the current optimal whale position, i.e., the temporal block size corresponding to the minimum loss function value. Update the whale's position using the position update formula in WOA, simulating the whale's behavior of surrounding prey, spiraling position updates, and searching for prey. Based on the search results, update the position using the following formula: Surround the prey: ; Spiral update position: ; Searching for prey: .
[0024] This is the whale's current location. This is the current optimal position for the whale. It is a random number. It is a coefficient vector. It is the distance between the whale and the optimal whale. It is a constant that controls the shape of the spiral. Is A random number between [a certain number of points].
[0025] (5) Assessment and updating Evaluate the fitness value of each whale at its new location and compare it with the previous optimal solution. If the fitness value of the new location is better, then update the optimal solution.
[0026] (6) Termination conditions Check if the maximum number of iterations or other termination conditions have been reached. If they are met, stop the iteration and output the optimal timing block size; otherwise, return to step (3) to continue the iteration.
[0027] (7) Output the optimal solution After the iteration is complete, the time block size that minimizes the loss function is output as the optimal solution.
[0028] Step 6: Input the obtained training data into the Transformer prediction backbone network to train the model.
[0029] After completing the above steps, the obtained training data can be input into the Transformer prediction backbone network for model training. See also... Figure 4 The backbone network includes a location encoding embedding module, a Transformer encoder module, a flattening module, and a linear transformation module.
[0030] Each time series block is treated as a token (the basic unit for Transformer to process data). The position encoding embedding module performs an embedding operation on each time series block and then adds position encoding.
[0031] The embedded and position-encoded time series blocks are fed into a standard Transformer encoder module. The Transformer encoder module processes these time series blocks using a self-attention mechanism to capture long-term dependencies in the time series.
[0032] The flattening and linear transformation module flattens the output of the Transformer encoder module and then inputs it into a linear layer (prediction head) to generate the trend and seasonal prediction results of the photovoltaic forecast. The trend and seasonal prediction results of the photovoltaic forecast are then merged to generate the final model output.
[0033] Step 7: Using the trained model, input the features of the prediction sample to obtain the prediction result. The length of the prediction sample needs to be consistent with the length of the training sample.
[0034] This invention employs Directive Optimization (DFT) to decompose photovoltaic power sequences, introduces time-series blocks, and uses Whale Optimization (WOA) to optimize the block size, achieving rapid algorithm convergence. It modifies the input and architecture of the Transformer model, treating each time-series block as a processing unit, thereby maximizing the preservation of local dependencies within the processing unit to enhance the model's ability to capture local patterns. Furthermore, it utilizes a multi-head self-attention mechanism to capture long-term dependencies in the sequence. This invention simultaneously addresses the high time complexity and low prediction accuracy of existing Transformer models for long input sequences, significantly improving prediction accuracy.
Claims
1. A photovoltaic power generation prediction method based on a deep time-series block model, characterized in that, Includes the following steps: Step 1: Obtain historical photovoltaic power generation data of the photovoltaic power station and historical meteorological data of the photovoltaic power station for the corresponding time period. The historical meteorological data includes wind speed, ambient temperature, ambient humidity, horizontal solar radiation intensity, tilted solar radiation intensity, and weather type data. Step 2: Perform one-hot encoding on the weather type data to map it to numerical variables, use relevant functions of the Pandas library to statistically obtain the missing data, and fill in the missing data; Step 3: Standardize all data variables and then convert the standardized multi-channel data to single-channel format. Step 4: Use the DFT signal processing method to decompose the photovoltaic power series into seasonal and trend partial series; Step 5: Perform time-domain partitioning on each univariate time series data, dividing it into a series of time series blocks, and use Whale Optimization (WOA) to find the optimal time series block size; Step 6: Input the obtained training data into the Transformer prediction backbone network for model training. The backbone network includes a position encoding embedding module, a Transformer encoder module, and a flattening and linear transformation module. The position encoding embedding module performs embedding operations on each time series block and then adds position encoding. The time series blocks after embedding and position encoding are input into the Transformer encoder module. The Transformer encoder module processes these time series blocks through a self-attention mechanism to capture the long-term dependencies of the time series. The flattening and linear transformation module flattens the output of the Transformer encoder module and then inputs it into a linear layer to generate the trend and seasonal prediction results of photovoltaic forecasts. The trend and seasonal prediction results of photovoltaic forecasts are merged to generate the final model output result. Step 7: Using the trained model, input the features of the prediction sample to obtain the prediction result.
2. The photovoltaic power generation prediction method based on a deep time-series block model according to claim 1, characterized in that, In step 4, the DFT is employed. The formula transforms a fixed-length photovoltaic power input sequence from the time domain to the frequency domain, where, Indicates the DFT after the Complex amplitude and phase of each frequency component, Represents the sample index value in the time domain, ranging from 1 to... , Represents the sample index in the frequency domain, ranging from 0 to... , Represents the imaginary unit in the equation. This represents the raw time series data; Frequency domain signals can be used The formula uses IDFT to transform back to the time domain; Based on the signal length N, determine the Nyquist frequency = N / 2, take the top [N / 3] frequency components, apply IDFT to these main frequency components to generate the seasonal part of the time series, and apply IDFT to the remaining low-frequency components to generate the trend part of the time series.
3. The photovoltaic power generation prediction method based on a deep time-series block model according to claim 2, characterized in that, In step 5, the method of using whale optimization (WOA) to find the optimal time series block size includes: (1) Initialize parameters Set the whale population size (N), the maximum number of iterations, the search range of the temporal block, and initialize the position of the whale population. The position of each whale represents a potential temporal block size solution. (2) Determine the fitness function The loss function of the Transformer model is used as the fitness function, and the mean squared error (MAE) is taken as the loss function. Its calculation formula is as follows: In the formula, express The true value of a moment Indicates the predicted value. The total number of test samples; (3) Iterative optimization For each generation iteration, the fitness value of each whale is calculated, the current optimal whale position is determined, and the whale position is updated. The position update formula in WOA is used to simulate the whale's behavior of surrounding prey, spiraling position updates, and searching for prey. Based on the search results, the position is updated using the following formula: Surround the prey: , Spiral update position: , Searching for prey: , This is the whale's current location. This is the current optimal position for the whale. It is a random number. It is a coefficient vector. It is the distance between the whale and the optimal whale. It is a constant that controls the shape of the spiral. Is Random numbers between; (4) Assessment and updating Evaluate the fitness value of each whale at its new location and compare it with the previous optimal solution. If the fitness value of the new location is better, then update the optimal solution. (5) Termination conditions Check if the maximum number of iterations or other termination conditions have been reached. If they are met, stop the iteration and output the optimal time block size; otherwise, return to step (3) to continue the iteration. (6) Output the optimal solution After the iteration is complete, the time block size that minimizes the loss function is output as the optimal solution.
4. The photovoltaic power generation prediction method based on a deep time-series block model according to claim 3, characterized in that, In step 2, the following method is used to intelligently impute missing data under multiple conditions: 1) If a single variable in a multivariate sequence has missing records for more than 6 consecutive hours, the multivariate time series data for the missing time period is deleted; 2) If two or more single variables have missing records for 4 consecutive hours or more, the multivariate time series data for the missing time period is deleted; 3) For data missing in cases other than 1) and 2), for single-point missing data, the mean value within 1 hour is used for imputation; for missing data with multiple consecutive timestamps, the Xgboost ensemble learning algorithm is used to impute missing values.
5. The photovoltaic power generation prediction method based on a deep time-series block model according to claim 4, characterized in that, In step 1, the weather type data is obtained from the meteorological station by calling its web service interface. The wind speed, ambient temperature, ambient humidity, horizontal solar radiation intensity, and tilted solar radiation intensity data are obtained by sensors or detection instruments installed in the photovoltaic power station. The photovoltaic power generation data is calculated based on the current and voltage data of the photovoltaic power station.