A photovoltaic prediction method
By integrating spatiotemporal sparse attention and temporal neural networks, the problems of insufficient data heterogeneity, computational efficiency, and dynamic environment adaptability in photovoltaic power generation prediction are solved, achieving high-precision, real-time photovoltaic power generation prediction, which is suitable for power system dispatching and edge devices.
Patent Information
- Application Number
- CN202510974776.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-15
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2045-07-15
AI Technical Summary
Existing photovoltaic power generation prediction methods have shortcomings in terms of data heterogeneity, computational efficiency, physical interpretability, and dynamic environment adaptability, making it difficult to achieve high-precision, real-time photovoltaic power generation prediction, especially on edge devices where they cannot meet the requirements for computational resources and prediction accuracy.
We employ a method that integrates spatiotemporal sparse attention and temporal neural networks. Through data preprocessing, spatiotemporal embedding, local-global attention layers, joint attention fusion layers, and edge optimization techniques, we design a local-global sparse attention mechanism. We introduce interpretable double KAN activation functions and meteorological sensing location encoding, combined with physical regularization terms, to achieve efficient feature transformation and prediction.
While maintaining accuracy, the computational complexity is reduced, enabling the model to run in real time on embedded GPUs, improving the robustness and interpretability of predictions, meeting the needs of power system dispatch and grid stability, and supporting offline prediction for edge devices.
Smart Images

Figure CN120470547B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of smart grid and energy management, and particularly relates to a photovoltaic prediction method. BACKGROUND
[0002] Under the background of global energy structure gradually transforming towards cleaner and more sustainable direction, photovoltaic power generation as a key renewable energy solution, its position is increasingly prominent. With the photovoltaic installed capacity in various parts of the country growing at an alarming rate, accurate prediction of photovoltaic power generation is essential to ensure the stability of the power system, optimize power grid scheduling and improve system economy. However, photovoltaic power generation essentially has significant intermittency and uncertainty, which is mainly affected by factors such as light intensity, environmental temperature, cloud coverage, etc., making it difficult to accurately predict its output power. These uncertainties pose a serious challenge to the planning, real-time scheduling and stable operation of the power system, especially when considering large-scale integration of photovoltaic power generation into existing power grids. In this case, not only is it necessary to accurately assess the photovoltaic power generation capacity, but also to conduct in-depth research on photovoltaic power generation behavior under different weather conditions to overcome its inherent prediction difficulties. Therefore, exploring and developing high-precision and high-reliability photovoltaic power generation prediction technology has become the key to promoting photovoltaic power generation technology, improving photovoltaic power generation utilization, and ensuring the safe and stable operation of the power system. Further, by combining big data analysis, deep learning algorithms and refined weather models, the accuracy and reliability of photovoltaic power generation prediction can be significantly improved. This not only helps to alleviate the power grid fluctuations caused by the intermittency of photovoltaic power generation, but also promotes the efficient use of renewable energy, providing strong technical support for the green transformation of global energy structure. Developing photovoltaic power generation prediction methods with strong adaptability and high precision has far-reaching strategic significance for promoting the development and application of clean energy.
[0003] The existing photovoltaic prediction methods can be divided into four types from the perspective of technical development: physical model-based prediction methods, statistical model-based prediction techniques, traditional machine learning-based prediction methods, deep learning techniques, and comprehensive prediction methods. Among them, the physical model-based prediction method mainly simulates the physical process of photovoltaic cells, establishes an electrical model of photovoltaic cells, and combines meteorological data for power prediction. This method has clear physical meaning, but has many model parameters, high requirements for meteorological data accuracy, and difficulty in accurately describing the output characteristics of photovoltaic under complex weather conditions. The statistical model-based prediction method mainly analyzes the statistical and logical relationship between historical photovoltaic power generation data and meteorological data, and establishes a prediction model. Common statistical models include autoregressive model (AR), moving average model (MA), autoregressive moving average model (ARMA), etc. This method is simple to use, but it is difficult to handle nonlinear relationships and has strong dependence on historical data. The machine learning-based prediction method mainly trains a learning model based on neural networks to learn the complex nonlinear relationship between photovoltaic power generation data and meteorological data and perform power prediction. Common machine learning models usually involve support vector machines (SVM), random forests (RF), neural networks (NN), etc. This method has strong nonlinear mapping ability, but model training requires a large amount of historical data, and the model has poor interpretability. Deep learning technology represents the frontier of photovoltaic prediction methods, and is particularly good at handling complex, nonlinear relationships. This technology mainly relies on multi-layer neural network structures such as convolutional neural networks (CNN), recurrent neural networks (RNN), and their improved versions long short-term memory networks (LSTM) and gated recurrent units (GRU). These models can automatically learn and extract features from a large amount of historical data without manual feature engineering. In photovoltaic prediction, deep learning models can effectively capture the dynamic changes in time series data by learning the power generation patterns under different weather conditions, thereby achieving more accurate power prediction. In addition, deep learning models can adapt to changes in different weather conditions and geographical locations, improving the robustness of the prediction. However, deep learning models usually require a large amount of training data and have high computational costs during the training process, and their complex structure leads to poor interpretability. Comprehensive prediction methods aim to combine the advantages of the above different types of methods to overcome the limitations of single methods. This type of prediction method can improve prediction performance by combining the advantages of physical model-based, statistical model-based, and machine learning or deep learning model-based methods. For example, a common strategy is to use a physical-based model for preliminary estimation, and then use a machine learning or deep learning model to correct the error. This method not only retains the clear physical meaning of the physical model, but also takes advantage of the powerful nonlinear mapping ability of data-driven models to make up for the poor performance of physical models under complex conditions.In addition, ensemble learning is also an important comprehensive method that integrates the prediction results of multiple base models, such as using average method, weighted average method or more complex meta-learning algorithm, to further improve the accuracy and stability of prediction. Comprehensive methods emphasize the flexible selection and combination of different prediction techniques and strategies according to the needs of specific application scenarios, so as to achieve the best prediction effect. This makes them particularly suitable for dealing with the challenges brought by the high variability and uncertainty of photovoltaic system output.
[0004] Photovoltaic power generation prediction not only requires predicting the power generation at a single time, but also requires predicting the trend of power generation in a future period of time, maintaining the consistency and continuity of the prediction results in the time dimension. Currently, photovoltaic power generation prediction technology has increasingly prominent application advantages in power system dispatching, power grid stability control, and power market transactions. High-precision prediction in this regard can reduce the risk of power grid frequency fluctuation, and the root mean square error (RMSE) of 24-hour prediction is required to be low (commonly required is RMSE < 3%) in day-ahead market transactions, and there are certain requirements for edge computing deployment in the industry, and some need to be implemented on low-power devices such as photovoltaic inverters built-in chips for millisecond-level real-time inference. Photovoltaic output is affected by multiple sources of heterogeneous data such as weather, device status, and spatiotemporal correlation, and traditional models such as LSTM and CNN networks are difficult to effectively fuse cross-modal features. Traditional methods rely on fixed time window modeling and are difficult to cope with sudden output mutations caused by rapid cloud cover or weather time. Although models like Transformer can capture long sequence dependencies, their global self-attention mechanism results in a computational complexity of O(T 2 ), which is difficult to meet the real-time requirements of photovoltaic power generation prediction, especially in the application of minute-level prediction scenarios. In addition, existing data-driven deep neural network model architectures are mostly black-box operations and cannot effectively embed the physical laws of photovoltaic power generation, such as temperature attenuation effects, which can easily lead to large prediction biases in extreme weather or device aging. In view of the above problems, the existing mainstream methods have obvious deficiencies, such as pure physical models that are highly dependent on accurate device parameters and environmental measurements but cannot real-time calibrate dynamic factors such as dust shading and component aging; hybrid statistical-machine learning models that are difficult to capture the impact of local cloud movement on distributed photovoltaics due to the lack of spatial resolution in numerical weather prediction; and Transformer models that consume a lot of computing resources, such as 16GB of video memory for predicting 24-hour minute-level sequences, limiting their deployment on the edge side, and their position encoding does not fuse weather time series features, resulting in modeling bias in spatiotemporal correlation. Therefore, exploring and researching efficient photovoltaic power generation prediction methods to automatically achieve accurate prediction of photovoltaic power generation, so that the prediction results maintain high precision and high reliability in the time dimension, has become a major problem that needs to be solved in the current photovoltaic power generation application field. SUMMARY
[0005] To solve at least one of the technical problems in the above background art, the purpose of the present application is to provide a new photovoltaic intelligent prediction method fusing spatio-temporal sparse attention and a time sequence neural network, aiming to solve the problems of data heterogeneity, computational efficiency, physical interpretability and insufficient dynamic environment adaptability in the prior art.
[0006] The technical problems solved by the present application adopt the following technical solutions:
[0007] A photovoltaic prediction method, comprising the following steps:
[0008] Step S1, data preprocessing: mainly aligning the time series of historical power generation data and meteorological data through time series normalization strategy, designing feature engineering, extracting the cumulative change rate of irradiance, and constructing a device health index, and inputting the input layer;
[0009] Step S2, based on the preprocessing result of step S1, design a spatio-temporal embedding layer, and perform spatio-temporal coding on the data transmitted by the input layer and all meteorological data branches according to time series features and spatial sequence features;
[0010] Step S3, define a neural network module, design a local-global attention layer in the module, and increase an attention window parameter for capturing key information of the spatio-temporal features of the data in the spatio-temporal embedding layer, then design a network layer for efficient feature transformation and enhancement, and inject meteorological condition constraints through a physical regularization term to ensure that the model output is more in line with the physical law;
[0011] Step S4, design a joint attention fusion layer, complete meteorological cross-attention calculation, gate weight generation and attention result fusion in the layer to effectively integrate key features from different sources and processed by the network layer;
[0012] Step S5, design an output layer after step S4, complete feature integration, linear transformation, set an activation function, physical regularization, and finally generate an output of photovoltaic power prediction in the layer;
[0013] Step S6, edge optimization, compress the improved neural network model to a memory device through INT8 quantization and model pruning technology, so as to realize offline prediction.
[0014] Further, in step S1, first give any input data I in ={P1,P2,P3,……,P m ,R n}, wherein P i ={d i1 ,d i2 ,…,d im|1≤i≤m,m∈N + ,d im ∈ },P i is the inputted i-th column photovoltaic data set, m is the number of inputted photovoltaic feature columns, d im is the m-th photovoltaic data value of the i-th column, R n is the set of all influencing factors n, which supports dynamic addition, mainly including meteorological data and user behavior patterns.
[0015] Further, in step S1, it is necessary to accurately find the best alignment path between the two sequences through the time series alignment strategy, and to complete the processing of missing values and outliers, and the specific method is:
[0016] First, the time series of historical power generation data and meteorological data are established into a two-dimensional cost matrix, and the elements in the matrix represent the difference between the corresponding points in the two sequences; second, starting from the starting point of the matrix, the cumulative cost matrix is calculated step by step, and the elements of the cumulative cost matrix represent the best path cost from the starting point to the current point, starting from the end point of the cumulative cost matrix, along the best path backtracking, find the best alignment path between the two time series data; then check the missing values in the aligned data, use interpolation filling to process, and identify outliers, and process outliers by excluding the mean value; then calculate the cumulative change rate of irradiance using the following formula:
[0017] , (1)
[0018] Where s is the size of the time window, V is the change rate of irradiance, is the cumulative change rate of irradiance reflecting the trend of irradiance change over time, which is used to assist in analyzing its impact on power generation; in constructing the device health index, select irradiance, power generation, temperature, wind speed, wind direction, humidity, device running time, maintenance records and fault history records as key features, and perform maximum and minimum value feature normalization on these features to make them on the same scale, and the normalized feature set obtained after processing is set as Nor, then use the following formula function to calculate the health index:
[0019] (2)
[0020] Where w i is the weight of feature i.
[0021] Further, in step S2, the time sequence feature encoding involves setting different kernel numbers of multi-column one-dimensional convolution operations according to the number of input features to capture local features, and dynamically setting the weights of different time steps; the space sequence feature encoding mainly extracts input features of spatial relationships within the range of linear fitting as space sequence feature encoding according to the time resolution of input data and the fluctuation law of sample sampling; then the outputs of the time encoding layer and the space encoding layer are structurally fused to form a unified spatio-temporal encoding structure, and the information feature representation after spatio-temporal encoding is output.
[0022] Further, in step S3, the self-defined neural network module is first initialized, and two parameters, model dimension d_model and attention head number n_heads, are set; a local-global attention layer is created in the module to implement the local-global attention mechanism, and the attention window parameter w_size=24 is added to the layer; multiple neural network sublayers are created in the network layer; in each neural network sublayer, the input data first undergoes a linear transformation to expand the dimension from d_model to d_model×4, which uses a dynamically learnable radial basis function as an activation function to introduce nonlinearity and enhance physical interpretability; after the activation function, the data passes through another linear transformation to restore the dimension from d_model×4 to d_model.
[0023] Further, in step S3, a physical constraint module is created after the model output to implement a physical regularization term, and the output of the physical constraint module conforms to the physical law; the parameter coef=0.1 is set to control the influence degree of the regularization term on the model output; then the output of the network layer is added to the physical regularization term calculated by the physical constraint module, and meteorological condition constraints are injected to obtain the final output of the physical constraint module.
[0024] Further, in step S4, a joint attention fusion layer is first designed, in which meteorological cross-attention calculation is first performed, meteorological data is taken as Key, and historical power generation data is taken as Query, by comparing the similarity between each power generation data point and all meteorological data points, the attention degree of each power generation data point to different meteorological conditions is determined; then an attention weight matrix is generated to represent the attention degree of each power generation data point to each meteorological data point; secondly, the gate weight is generated, and the meteorological cross-attention result obtained in the first step is input into the adaptive kernel network structure together with the local-global attention result of the previous step; by learning the features of the input data, the weight distribution of the three attentions is generated; then a weight vector is output, which contains the weight values of the three attentions; then the attention result fusion is performed, and the weight vector generated in the last step is used to weight and sum the three attention results.
[0025] Further, the key features in step S4 include spatio-temporal data, meteorological data and equipment state data.
[0026] Further, in step S5, the features output by the joint attention fusion layer are further integrated by an output layer, and the input features are dimensionally adjusted to ensure that they match the expected input of the output layer; meanwhile, multiple fully connected layers are set, and their weight and bias parameters are learned during the training process to realize nonlinear transformation of the features and map the fused features to the target output space; a linear activation function is used in the fully connected layer, and the above physical regularization term is called before the final prediction result is generated to output additional adjustments to ensure that the prediction result conforms to the physical law.
[0027] Further, in step S6, the edge optimization method includes:
[0028] In step S61, first, the size of the current neural network model is evaluated, including the weights and biases, and a benchmark test is performed on the uncompressed model to record the performance indicators as a reference; the absolute value of each weight is calculated to identify small and unimportant weights; then, a pruning threshold is set according to the model size and performance requirements, and weights smaller than the threshold are set to 0, removing the corresponding connections, removing redundant weights and connections, and reconstructing the model structure; the importance of each layer is evaluated by removing it layer by layer and performance testing, and then the layers with less impact on performance are removed according to the evaluation results, and the model is fine-tuned by iterative pruning;
[0029] In step S62, a small calibration dataset is prepared for parameter adjustment during quantization; the weights of the model are converted from floating-point numbers to INT8 representation; the scaling factor and zero point are calculated for each weight layer to maintain numerical stability; the activation values of the model are converted from floating-point numbers to INT8 representation; the model is reconstructed according to the results after pruning and quantization to ensure the correctness of the model structure; then, the inference engine TensorRT optimized for INT8 is used, and the quantized model is converted to a format supported by the edge device; the model is deployed to an edge device with 256KB memory, and offline prediction testing is performed on the edge device to verify the performance and accuracy of the model; finally, performance analysis and iterative optimization are performed.
[0030] The beneficial effects of the present application are:
[0031] 1. A local-global sparse attention mechanism is proposed, which aims to reduce the computational complexity from O(T 2 ) to O(TlogT), while ensuring accuracy, so that the model can run in real time on an embedded GPU; the algorithm structure designs a joint dynamic fusion based on multiple attentions, which adaptively weights the spatio-temporal, meteorological and equipment state attentions through a gated KAN network to improve the efficiency of cross-modal feature fusion.
[0032] 2. An interpretable dual KAN activation function is proposed, and a dynamically learnable radial basis function is introduced to replace ReLU to introduce nonlinear characteristics and improve physical interpretability. Combined with photovoltaic equation constraints, the model can simultaneously satisfy data-driven and physical consistency, thereby improving the interpretability of the model and making it easier for users to understand and trust the model's prediction results. Meteorological sensing location coding is integrated, and real-time meteorological parameters such as irradiance and cloud cover are cross-transformed in multiple steps and embedded with location coding to enhance the model's sensitivity to microclimate changes and improve the robustness of predictions.
[0033] 3. Through improved neural network structure and algorithm, the joint attention fusion layer can effectively fuse multi-source heterogeneous data, improve prediction accuracy, and meet the requirements of grid connection stability and power trading economy; the method of this invention can support edge-optimized version, that is, support INT8 quantization and model pruning, and can run on 256KB memory devices to meet the offline prediction needs of scenarios without network coverage. Attached Figure Description
[0034] Figure 1 This is a flowchart of the method of the present invention;
[0035] Figure 2 This is a diagram of the deep neural network structure for photovoltaic prediction in this invention.
[0036] Figure 3 This is a multi-column convolution design diagram used in photovoltaic prediction methods. Detailed Implementation
[0037] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0038] refer to Figure 1 This invention provides a photovoltaic prediction method, comprising the following steps:
[0039] Step S1, Data Preprocessing: First, given arbitrary input data I in ={P1,P2,P3,……,P m ,R n}, where P i ={d i1 ,d i2 ,…,d im |1≤i≤m,m∈N + ,d im ∈R},P iFor the input of the i-th column of photovoltaic data set, m is the number of input photovoltaic feature columns, d im For the i-th column of the m-th photovoltaic data value, R n For the set of all influencing factors n, dynamic addition is supported, which mainly includes meteorological data and user behavior patterns. The historical power generation data and the time series of meteorological data are aligned through time series alignment strategy, the feature engineering is designed, the cumulative change rate of irradiance is extracted, and the device health index is constructed, which is input into the input layer;
[0040] The best alignment path between the two sequences needs to be accurately found through the time series alignment strategy, and the missing values and abnormal values are processed, the specific method is:
[0041] Firstly, the time series of historical power generation data and meteorological data are established into a two-dimensional cost matrix, and the elements in the matrix represent the difference between the corresponding points in the two sequences; Secondly, starting from the starting point of the matrix, the cumulative cost matrix is calculated step by step, and the elements of the cumulative cost matrix represent the best path cost from the starting point to the current point, starting from the end point of the cumulative cost matrix, along the best path backtracking, find the best alignment path between the two time series data; Then check the missing values in the aligned data, use interpolation filling to process, and identify abnormal values, and process abnormal values by excluding mean value; Then calculate the cumulative change rate of irradiance by the following formula:
[0042] , (1)
[0043] Where s is the size of the time window, set to 15 minutes, V is the change rate of irradiance, The cumulative change rate of irradiance reflects the trend of irradiance change over time, which is used to assist in analyzing its influence on power generation; In constructing the device health index (HI), the irradiance, power generation, temperature, wind speed, wind direction, humidity, equipment running time, maintenance records and fault history records are selected as key features, and the maximum and minimum values of these features are normalized, so that they are on the same scale, and the normalized feature set obtained after processing is set as Nor, and then the health index is calculated using the following formula function:
[0044] (2)
[0045] Where w i is the weight of feature i, which can be determined by expert experience or machine learning.
[0046] Step S2, based on the pre-processing result of step S1, a spatio-temporal embedding layer is designed to time and space encode the data transmitted by the input layer and all meteorological data branches according to time series features and spatial sequence features;
[0047] , reference Figure 3 , time sequence feature encoding involves setting different kernel numbers of multi-column one-dimensional convolution operation according to the number of input features to capture local features, and dynamically setting the weight of different time steps; spatial sequence feature encoding, mainly according to the time resolution of input data and the fluctuation law of sample sampling, within the range of linear fitting law, extract the input features of spatial relationship as spatial sequence feature encoding; then the outputs of time encoding layer and space encoding layer are fused, forming a unified space-time coding structure, and outputting the information feature representation after space-time coding.
[0048] Step S3, define a neural network module, reference Figure 2 In this module, a local-global attention layer is designed, and an attention window parameter is added to capture the key information of the data space-time features in the space-time embedding layer, then a network layer is designed to realize efficient feature transformation and enhancement, and a physical regularization term is injected to inject meteorological condition constraints to ensure that the model output is more consistent with the physical law;
[0049] In step S3, the custom neural network module is first initialized, and its acceptance of two parameters, model dimension d_model and attention head number n_heads, is set. A local-global attention layer is created in the module to implement the local-global attention mechanism, which adds an attention window parameter w_size=24, i.e., the model performs attention calculation within a 24-hour time window. A class named KAN_MLP network layer is designed in the neural network module, which is the first time in this field to not only simultaneously fuse the structure and features of double KAN, i.e., the Kernel-Adaptive Network structure and the core features of the Kolmogorov-Arnold network, but also inherits the structural advantages of MLP (Multi-Layer Perceptron). Multiple neural network sublayers are created in the network layer, i.e., the network layer is stacked by multiple neural network sublayers, forming a multi-level subnetwork structure. This design aims to gradually deepen the feature representation and enhance the learning ability of the model through layer stacking; in each neural network sublayer, the input data first undergoes a linear transformation, expanding the dimension from d_model to d_model*4, which uses a dynamically learnable radial basis function as the activation function to introduce nonlinearity and enhance physical interpretability; the activation function and weights can be dynamically adjusted to better match the distribution of input data. After the activation function, the data is transformed by another linear transformation to restore the dimension from d_model*4 to d_model, i.e., d_model is the input and output dimension, and d_model*4 is the intermediate layer dimension; the multi-layer structure composed of each neural network sublayer can effectively transform and enhance the features, which cleverly designs the fusion of the characteristics of double KAN and the multi-layer structure of MLP, enabling the KAN_MLP layer to implement various function combinations and approximations, efficiently learn the representation of complex functions, have stronger feature transformation capability, while maintaining physical interpretability, thereby improving network performance.
[0050] A physical constraint module is created after the model output to implement the physical regularization term, and the output of the physical constraint module conforms to the physical law; the parameter coef=0.1 represents that the coefficient of the regularization term is 0.1, which is used to control the influence degree of the regularization term on the model output; then the output of the network layer is added to the physical regularization term calculated by the physical constraint module, and the meteorological condition constraint is injected to obtain the final output of the physical constraint module.
[0051] In step S4, a joint attention fusion layer is designed to complete meteorological cross-attention calculation, gate weight generation, and attention result fusion to effectively integrate key features from different sources and processed by the network layer, including spatiotemporal data, meteorological data, and device status data.
[0052] In step S4, a joint attention fusion layer is first designed. In the fusion layer, meteorological cross-attention calculation is first performed. Meteorological data is taken as the key, and historical power generation data is taken as the query. By comparing the similarity between each power generation data point and all meteorological data points, the attention degree of each power generation data point to different meteorological conditions is determined. Then, an attention weight matrix is generated to represent the attention degree of each power generation data point to each meteorological data point. Second, the meteorological cross-attention result obtained in the first step is input into the adaptive kernel network structure together with the local-global attention result of the previous step. By learning the characteristics of the input data, the weight distribution of the three attentions is generated. These weights represent the importance of different attention results in the final fusion output. Then, a weight vector is output, which contains the weight values of the three attentions. Then, attention result fusion is performed. The weight vector generated in the previous step is used to weight and sum the three attention results. Specifically, each attention result is multiplied by its corresponding weight, and then added to obtain the fused output. This output considers meteorological cross-attention, local-global attention and other information, which is used for subsequent photovoltaic power prediction.
[0053] In step S5, an output layer is designed after step S4. In this layer, feature integration, linear transformation, setting of activation function, physical regularization, and finally photovoltaic power prediction output generation are completed.
[0054] The features output by the joint attention fusion layer are further integrated through the output layer to adjust the dimension of the input features to ensure that they match the expected input of the output layer, so that the output layer can extract key information for final prediction. At the same time, multiple fully connected layers are set, and their weights and bias parameters are learned during the training process to realize nonlinear transformation of features and map the fused features to the target output space. Linear activation function is used in this fully connected layer. Before the final prediction result is generated, the above physical regularization term is called to output additional adjustments to ensure that the prediction result conforms to the physical law.
[0055] The entire prediction neural network selects mean square error (MSE) as the loss function during training to measure the difference between the predicted value and the true value. During training, the gradient of the loss function with respect to the model parameters is calculated, and the model parameters are updated through the backpropagation algorithm to optimize the prediction performance.
[0056] In step S6, edge optimization is performed by INT8 quantization and model pruning techniques to compress the improved neural network model to a memory device to realize offline prediction. The specific methods include:
[0057] Step S61, first, evaluate the size of the current neural network model, including parameters such as weights and biases, and benchmark on the uncompressed model, record the performance index as a reference; Calculate the absolute value of each weight, identify small, unimportant weights; Then set the pruning threshold according to the model size and performance requirements, set the weights less than the threshold to 0, remove the corresponding connection, remove redundant weights and connections, and reconstruct the model structure; Through layer-by-layer removal and performance test, evaluate the importance of each layer, then remove the layer with less impact on performance according to the evaluation result, and gradually iterate pruning, fine-tune the model;
[0058] Step S62, prepare a small calibration data set for parameter adjustment in the quantization process; Convert the weights of the model from floating-point numbers to INT8 representation; Calculate the scaling factor and zero point for each weight layer to maintain numerical stability; Convert the activation values of the model from floating-point numbers to INT8 representation; Reconstruct the model according to the results after pruning and quantization to ensure the correctness of the model structure; Then use the inference engine TensorRT optimized for INT8, and convert the quantized model to the format supported by the edge device, deploy the model to the edge device with 256KB memory, and perform offline prediction test on the edge device to verify the performance and accuracy of the model; Finally, perform performance analysis and iterative optimization.
[0059] The application proposes a photovoltaic prediction method for power system scheduling, renewable energy management and smart grid optimization, which simultaneously considers the Kernel-Adaptive Network (KAN) structure and the core characteristics of Kolmogorov-Arnold Network (KAN), and introduces the feature efficient extraction of multi-core Conv1D and the improved Transformer encoder structure. In order to avoid confusion, the Kernel-Adaptive Network structure will be referred to as KAN_1, and the Kolmogorov-Arnold Network will be referred to as KAN_2. Considering that the traditional photovoltaic prediction model mainly relies on linear statistical model, single deep learning architecture, or combination method of the above frameworks, these existing prediction methods have certain limitations in dealing with complex spatio-temporal correlation and variable influencing factors, the application designs a neural network named TransKANs-Fusion, which captures the complex relationship between different influencing factors by considering the double KAN structure and characteristics, and uses the improved network encoder with multi-core one-dimensional convolution connection to process the coupling time dependence and spatial correlation in historical time series photovoltaic characteristics and influencing factors, to realize more accurate and reliable long-short photovoltaic output prediction.
[0060] 1) Improved Transformer encoder-TransKANs, although the traditional Transformer encoder has achieved great success in natural language processing, there is still room for improvement in complexity and effectiveness in processing time series data. Therefore, the encoder of the Transformer is improved as follows:
[0061] (a) Position encoding: add position information based on time and spatial sequence to input elements, embed meteorological features as position bias, so that the model can understand the order and spatial-temporal relationship of the sequence, and enhance the sensitivity to environmental changes.
[0062] (b) Local-global sparse attention: when processing long sequence multi-dimensional data, sliding window technology is used to limit the local calculation range, reduce the calculation amount and improve the efficiency and accuracy of global attention allocation.
[0063] (c) Adaptive dynamic data quantile normalization: in view of the non-Gaussian distribution characteristics of photovoltaic data, the data stability is optimized, and the traditional normalization standardization layer is modified into an element-wise dynamic control layer, that is, the core idea of reference, the output of the layer is defined as output=σ(x)∗tanh(x), wherein σ is a sigmoid function, and x is a feature output from the previous network layer. The main design of this is that the layer normalization in the Transformer often produces an input-output mapping similar to the tanh shape.
[0064] (d) In order to effectively extract the time dependence and spatial correlation features in the photovoltaic output sequence, the invention adopts a multi-kernel one-dimensional convolution layer. This design not only can capture the local patterns in the input sequence, but also can enhance the understanding ability of global characteristics. The multi-kernel strategy allows the model to analyze the data from different scales, improving the comprehensiveness and accuracy of feature extraction.
[0065] (e) KAN_1 is used to adapt to the characteristics of non-stationary data, and the invention aims to capture complex patterns in input data by dynamically adjusting its kernel function. It is particularly suitable for processing rapidly changing factors such as weather conditions. The network designed based on KAN_2 super theorem can decompose multivariate continuous functions into single-variable continuous functions and their combinations, thereby more flexibly adapting to different input patterns. It is mainly used to identify long-term trends and short-term fluctuations in historical photovoltaic output data. By replacing the traditional activation function with a dynamically learnable radial basis function, and by considering the KAN_2 characteristics, the learnable parameters are placed on the connection edges instead of the nodes. For the KAN_2 operation of the Lth layer, its formula can be expressed as:
[0066] Output=f (W edge *x+b edge ) (3)
[0067] where f is a nonlinear activation function, W edge and b edge are the weights and bias on the edge to adapt the nonlinearity under different meteorological conditions. At this time, the photovoltaic equation regularization term is injected to force the physical relationship P = η G (1 - kΔT) to be satisfied. The activation function designed in this way breaks through the traditional black box model and can show the influence weight of the prediction under the physical condition.
[0068] (f) Reduce the computational complexity and improve the efficiency, the neural network neural network module of the application introduces MatMul-free Channel Mixer layer, uses ternary weight (-1, 0, +1) instead of traditional floating-point weight in network layer calculation, converts matrix multiplication into efficient ternary accumulation operation, thereby greatly reduces the computational complexity, effectively improves the computational efficiency of the neural network model, and makes it more suitable for application in resource-constrained environment.
[0069] The key module structure of the improved Transformer encoder is compared with the key module of the traditional Transformer encoder. The improved advantages are summarized in Table 1.
[0070] Table 1
[0071] Module Traditional Transformer Improvements of TransKANs-Fusion scheme Advantages explanation Attention mechanism Global self-attention Local-global sparse attention Limit local computation range by sliding window, long sequence processing efficiency improved by 40% Position encoding Sine function encoding Learnable weather-aware position encoding Embedding temperature, irradiance, etc. weather features as position bias Normalization layer Layer Normalization Adaptive dynamic data quantile normalization Optimize stability for non-Gaussian distribution of photovoltaic data
[0072] 2) Design a multi-attention joint fusion mechanism to connect TransKANs, dynamically fuse space-time, meteorological, and equipment state attention, and through a specific fusion strategy (dynamic weight gating (weight generated by KAN)), effectively integrate different types of attention results, form a comprehensive feature representation, and capture the long and short term dependencies of the power generation sequence. The specific calculation method, fusion strategy and role of the multi-attention joint fusion mechanism are shown in Table 2.
[0073] Table 2
[0074] Attention type Calculation method Fusion strategy Effect explanation Space-time attention Multi-head self-attention + time convolution Dynamic weight gating (weight generated by KAN) Capture long and short term dependencies of power generation sequence Weather cross-attention Query-Key weather feature cross Attention scaling based on Pearson correlation coefficient Focus on high impact factors (such as cloud cover) Device state attention Graph attention network (GAT) Adjacency matrix combined with device topology relationship Model the spatial correlation between photovoltaic arrays
[0075] The multi-attention joint fusion mechanism takes the output of the TransKANBlock as input, and the output formula is as follows:
[0076] (4)
[0077] where w i is a learnable weight, and sigma is a Sigmoid function to realize dynamic weighting.
[0078] Finally in the output layer, the feature maps from different channels are spliced together to form a more rich feature representation, containing information of multiple time scales, and after multiple fully connected layers, the fused feature is mapped to the target output space to generate the final photovoltaic prediction result.
[0079] Finally, it should be noted that: the above examples are only used to illustrate the technical solutions of the present application, but not to limit them; although the present application has been described in detail with reference to the foregoing examples, those skilled in the art should understand that: it can still modify the technical solutions recorded in the foregoing examples, or make equivalent replacement for part of the technical features; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A photovoltaic prediction method, characterized in that, Includes the following steps: Step S1, Data Preprocessing: This mainly involves aligning the historical power generation data with the time series of meteorological data using a time series normalization strategy, designing feature engineering, extracting the cumulative rate of change of irradiance, and constructing an equipment health index, which is then input into the input layer. Specifically, in step S1, it is necessary to accurately find the optimal alignment path between two sequences using a time series normalization strategy, and to handle missing values and outliers. The specific method is as follows: First, a two-dimensional cost matrix is constructed by combining historical power generation data and meteorological data time series. The elements of the matrix represent the differences between corresponding points in the two series. Second, starting from the beginning of this matrix, the cumulative cost matrix is calculated iteratively. The elements of the cumulative cost matrix represent the optimal path cost from the starting point to the current point. Starting from the end of the cumulative cost matrix, the optimal alignment path between the two time series data is found by backtracking along the optimal path. Then, missing values in the aligned data are checked and filled using interpolation. Outliers are identified and removed by removing the mean. Finally, the cumulative rate of change of irradiance is calculated using the following formula: , (1); Where s is the size of the time window, and V is the rate of change of irradiance. The cumulative rate of change of irradiance, which reflects the trend of irradiance over time, is used to assist in the analysis of its impact on power generation. When constructing the equipment health index, irradiance, power generation, temperature, wind speed, wind direction, humidity, equipment operating time, maintenance records, and fault history are selected as key features. These features are then normalized by maximizing and minimizing their values to ensure they are on the same scale. The resulting normalized feature set is denoted as Nor. The health index is then calculated using the following formula function: (2); Where w i It is the weight of feature i; Step S2: Based on the preprocessing results of step S1, a spatiotemporal embedding layer is designed to spatiotemporally encode the data transmitted from the input layer and all meteorological data branches according to time series characteristics and spatial series characteristics. Step S3: Define a neural network module, design a local-global attention layer in the module, and add an attention window parameter to capture key information of the spatiotemporal features of the data in the spatiotemporal embedding layer. Then design a network layer to achieve efficient feature transformation and enhancement, and inject meteorological condition constraints through physical regularization term to ensure that the model output is more in line with physical laws. Specifically, in step S3, the custom neural network module is first initialized and set to accept two parameters: the model dimension d_model and the number of attention heads n_heads. A local-global attention layer is created in this module to implement the local-global attention mechanism. This layer adds an attention window parameter w_size=24. Multiple neural network sub-layers are created in the network layer. In each neural network sub-layer, the input data first undergoes a linear transformation to expand the dimension from d_model×4. It uses a dynamically learnable radial basis function as the activation function to introduce non-linearity and enhance physical interpretability. After the activation function, the data undergoes another linear transformation to restore the dimension from d_model×4 back to d_model. Step S4: Design a joint attention fusion layer. In this layer, meteorological cross-attention calculation, gating weight generation, and attention result fusion are completed to effectively integrate key features from different sources and processed by the network layer. Step S5: After step S4, design the output layer. In this layer, feature integration, linear transformation, setting activation function, physical regularization, and finally generating the photovoltaic power prediction output are completed. Step S6, edge optimization, compresses the improved neural network model into a memory device through INT8 quantization and model pruning techniques, enabling it to make predictions offline.
2. The photovoltaic prediction method as described in claim 1, characterized in that, In step S1, firstly, arbitrary input processing data I is given. in ={P1,P2,P3,……,P m ,R n }, where P i ={d i1 ,d i2 ,…,d im |1≤i≤m,m∈N + ,d im ∈ }, P i Let m be the number of input photovoltaic feature columns, and d be the number of input photovoltaic feature columns. im R represents the m-th photovoltaic data value in the i-th column. n It is a set of n influencing factors, which can be dynamically added and mainly includes meteorological data and user behavior patterns.
3. The photovoltaic prediction method as described in claim 1, characterized in that, Step S2, time series feature encoding involves multi-column one-dimensional convolution operations with different kernel numbers based on the number of input features to capture local features, and dynamically setting and allocating weights for different time steps; spatial sequence feature encoding mainly extracts spatial relationship input features as spatial sequence feature encoding based on the temporal resolution of the input data and the fluctuation pattern of sample sampling, within the range of linear fitting patterns. The outputs of the temporal coding layer and the spatial coding layer are then structurally fused to form a unified spatiotemporal coding structure, and the spatiotemporally coded information feature representation is output.
4. A photovoltaic prediction method as described in claim 1, characterized in that, Step S3: After the model output, create a physical constraint module to implement the physical regularization term. The output of the physical constraint module conforms to physical laws. Set the parameter coef=0.1 to control the degree of influence of the regularization term on the model output. Then, add the output of the network layer to the physical regularization term calculated by the physical constraint module and inject meteorological condition constraints to obtain the final output of the physical constraint module.
5. The photovoltaic prediction method as described in claim 1, characterized in that, In step S4, a joint attention fusion layer is first designed. This layer first performs meteorological cross-attention calculation, using meteorological data as the key and historical power generation data as the query. By comparing the similarity between each power generation data point and all meteorological data points, the degree of attention it receives from different meteorological conditions is determined. Then, an attention weight matrix is generated to represent the degree of attention each power generation data point receives from each meteorological data point. Next, gating weights are generated, inputting the meteorological cross-attention result obtained in the first step along with the local-global attention result from the previous step into the adaptive kernel network structure. By learning the features of the input data, weight assignments for the three attention types are generated. Then, a weight vector containing the weight values of the three attention types is output. Finally, attention results are fused, and the weight vector generated in the previous step is used to weight and sum the three attention results.
6. The photovoltaic prediction method as described in claim 1, characterized in that, Key features in step S4 include spatiotemporal data, meteorological data, and equipment status data.
7. The photovoltaic prediction method as described in claim 4, characterized in that, In step S5, the features output by the joint attention fusion layer are further integrated through the output layer, and the dimensions of the input features are adjusted to ensure that they match the expected input of the output layer. At the same time, multiple fully connected layers are set, and their weights and bias parameters are learned during training to achieve non-linear transformation of the features and map the fused features to the target output space. A linear activation function is used in this fully connected layer, and the above-mentioned physical regularization term is called before the final prediction result is generated, and the output is further adjusted to ensure that the prediction result conforms to physical laws.
8. The photovoltaic prediction method as described in claim 1, characterized in that, In step S6, the edge optimization methods include: Step S61: First, evaluate the size of the current neural network model, including weights and biases, and benchmark it on the uncompressed model, recording the performance metrics as a reference; calculate the absolute value of each weight to identify small, unimportant weights; then set a pruning threshold according to the model size and performance requirements, setting weights smaller than the threshold to 0, removing the corresponding connections, removing redundant weights and connections, and reconstructing the model structure; evaluate the importance of each layer through layer-by-layer removal and performance testing, then remove layers based on the evaluation results, and iteratively prune and fine-tune the model. Step S62: Prepare a small calibration dataset for parameter tuning during quantization; convert the model weights from floating-point numbers to INT8 representation; calculate scaling factors and zeros for each weight layer to maintain numerical stability; convert the model activation values from floating-point numbers to INT8 representation; reconstruct the model based on the pruning and quantization results to ensure correct model structure; then use TensorRT, an inference engine optimized for INT8, and convert the quantized model to a format supported by edge devices. Deploy the model to an edge device with 256KB of memory and perform offline prediction tests on the edge device to verify the model's performance and accuracy; finally, perform performance analysis and iterative optimization.
Citation Information
Patent Citations
Photovoltaic forecasting method based on deep attention network and clear sky radiation prior fusion
CN114971058A
Photovoltaic power prediction method based on multi-scale space-time diagram attention convolutional network
CN117154704A