Power grid carbon emission prediction method and system considering uncertainty of new energy output

By combining the carbon emission factor prediction model of LSTM and Transformer models, the carbon emission prediction deviation problem caused by uncertainty in new energy output is solved, and high-precision real-time prediction of power grid carbon emissions is achieved to meet the prediction needs of multiple time scales.

CN120450157APending Publication Date: 2025-08-08NORTHEASTERN UNIV FOSHAN GRADUATE SCHOOL OF INNOVATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510706487.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-29
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

Traditional carbon emission forecasting methods are difficult to accurately reflect the uncertainty of new energy output, resulting in deviations from actual carbon emissions, and lack of multi-time scale prediction capabilities, which cannot meet real-time and high-precision carbon emission needs.

Method used

The carbon emission factor prediction model combined with the LSTM model and the Transformer model is adopted to capture the short-term fluctuations and long-term dependencies of new energy output, and dynamic carbon emission factor calculation and multi-time scale prediction mechanism are introduced, combining online learning and adaptive mechanisms to dynamically update model parameters.

Benefits of technology

It significantly improves the accuracy and practicality of carbon emission forecasting, and can accurately predict grid carbon emission factors in real time and meet low-carbon operation needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120450157A_ABST
    Figure CN120450157A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of carbon emission prediction, in particular to a power grid carbon emission prediction method and system considering new energy output uncertainty, and the method comprises the steps: obtaining a data set of a new energy generator set and a carbon emission factor of each node of a power grid; the data set comprises multiple pieces of feature data, and the feature data comprises operation data, load demand data and power grid operation state data; a carbon emission factor prediction model is established, the carbon emission factor prediction model is trained through the data set and the carbon emission factor of each node of the power grid, a trained carbon emission factor prediction model is obtained, and the carbon emission factor prediction model comprises an LSTM module and a Transformer module; predicting the characteristic data obtained in real time through the trained carbon emission factor prediction model, and generating a carbon emission factor for predicting each node of the power grid in real time; according to the invention, high-precision and real-time carbon emission prediction can be realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of carbon emission prediction, and in particular to a method and system for predicting carbon emissions from a power grid taking into account the uncertainty of renewable energy output. Background Art

[0002] With the rapid development of renewable energy sources such as wind power and photovoltaics, their share in the power system has increased year by year, significantly changing the carbon emissions characteristics of the power grid. The introduction of renewable energy not only changes the operation of traditional power systems but also poses new challenges to the accurate prediction of carbon emissions.

[0003] In traditional power systems, carbon emission forecasting relies primarily on historical data statistics and physical models. These methods can meet demand in scenarios with a low proportion of renewable energy, but their limitations are becoming increasingly apparent as renewable energy penetration continues to increase. Renewable energy generation output is affected by natural factors such as weather and seasons, and exhibits significant volatility and randomness. This makes it difficult for traditional deterministic forecasting methods to accurately reflect the true state of grid carbon emissions. Furthermore, the operating state of the power system changes more frequently in scenarios with a high proportion of renewable energy integration, making real-time performance and forecast accuracy key requirements for carbon emission forecasting technology.

[0004] At the same time, with the rapid development of technologies such as big data and artificial intelligence, data-driven approaches are becoming increasingly widely used in power systems. Machine learning and deep learning techniques offer new approaches for processing high-dimensional, nonlinear data. However, many challenges remain in modeling and predicting the uncertainty of renewable energy output. Incorporating uncertainty into carbon emission prediction models and achieving high-precision, real-time carbon emission forecasts are both hot topics and challenges in current research. Summary of the Invention

[0005] The purpose of the present invention is to provide a method and system for predicting carbon emissions from power grids that takes into account the uncertainty of renewable energy output. This method aims to solve the problem of real-time prediction of carbon emissions from power grids, address the impact of uncertainty in renewable energy power generation output on prediction results, and achieve high-precision, real-time carbon emissions prediction.

[0006] In order to achieve the above object, the present invention provides the following technical solutions:

[0007] In a first aspect, an embodiment of the present invention provides a method for predicting carbon emissions from a power grid taking into account the uncertainty of renewable energy output, the method comprising the following steps:

[0008] S100, obtaining a data set of new energy generators and a carbon emission factor of each node in the power grid; the data set includes multiple characteristic data, including operation data, load demand data, and power grid operation status data;

[0009] S200, establishing a carbon emission factor prediction model, training the carbon emission factor prediction model using the data set and the carbon emission factors of each node in the power grid to obtain a trained carbon emission factor prediction model, wherein the carbon emission factor prediction model includes an LSTM module and a Transformer module;

[0010] S300, predicting the characteristic data obtained in real time through the trained carbon emission factor prediction model to generate a real-time predicted carbon emission factor for each node in the power grid.

[0011] Optionally, the dataset of the new energy generator set is obtained by:

[0012] S110, acquiring multi-source data of the new energy generator set, wherein the multi-source data includes operation data, load demand data, and grid operation status data;

[0013] S120, preprocessing the multi-source data, extracting key features from the preprocessed multi-source data, wherein the key features include fluctuation characteristics of renewable energy output and periodic characteristics of load demand;

[0014] S120 , associating key features in the multi-source data to generate feature data, and forming a data set from the plurality of feature data.

[0015] Optionally, the calculation formula of the carbon emission factor is as follows:

[0016] ;

[0017] in, Indicates the The carbon emission factor of electricity for each node; Indicates connection to Active power output of power plants at each node; is the carbon emission coefficient of the power plant; It is from Node to Active power input of each node; For the The branches of a node connect the set of nodes; It is The carbon emission factor of each node.

[0018] Optionally, the step of training a carbon emission factor prediction model using the data set and the carbon emission factors of each node in the power grid to obtain a trained carbon emission factor prediction model includes:

[0019] S210, obtaining the data set and the carbon emission factor of each node in the power grid;

[0020] S220, input the data in the dataset into the LSTM module to capture the short-term fluctuations and temporal dependencies of the time series and generate a hidden state sequence;

[0021] S230, inputs the hidden state sequence into the Transformer module, captures long-term dependencies and complex associations between multiple variables through self-attention mechanism and multi-head attention mechanism, and generates a context representation sequence;

[0022] S240, taking the hidden state sequence and the context representation sequence as the input time series, performing multi-scale division on the input time series, and capturing the features of the input time series at different time resolutions based on intra-segment attention and inter-segment attention;

[0023] S250, performing feature fusion on the features output by the hidden state sequence and the features output by the context representation sequence to generate a fused multi-scale feature representation;

[0024] S260 maps the multi-scale feature representations through a fully connected layer to obtain the predicted carbon emission factor. The model loss is calculated based on the carbon emission factors of each node in the power grid and the predicted carbon emission factors. The model parameters are dynamically updated through online learning and adaptive mechanisms.

[0025] S270, repeatedly executing S220 to S260 until a predetermined number of iterations or convergence conditions are reached, thereby obtaining a carbon emission factor prediction model.

[0026] Optionally, the step of inputting the data in the dataset into the LSTM module to capture the short-term fluctuations and temporal dependencies of the time series and generate a hidden state sequence includes:

[0027] Calculate the hidden state of multiple time steps through the LSTM module:

[0028] The hidden states of multiple time steps are formed into a hidden state sequence.

[0029] Optionally, the hidden state sequence is input into the Transformer module, and the long-term dependencies and complex associations between multiple variables are captured through the self-attention mechanism and the multi-head attention mechanism to generate a context representation sequence, including:

[0030] Calculate attention weights and context representations through the self-attention mechanism;

[0031] Through the multi-head attention mechanism, multiple self-attention heads are calculated in parallel to capture different subspace features and output a context representation sequence.

[0032] Optionally, the intra-segment attention is obtained by:

[0033] The input time series is divided into a set of segments at multiple scales, where each segment contains multiple time steps and multi-dimensional features;

[0034] Embed each fragment along the feature dimension to obtain the embedded fragment ,in, , Represents the dimension after embedding;

[0035] The embedded fragment is calculated by the following formula Perform trainable linear transformation to generate and segment The corresponding keys and values are:

[0036] ;

[0037] ;

[0038] in, and are the trainable weight matrices, and and fragments respectively The corresponding keys and values;

[0039] Using a trainable query matrix Contextual information of the aggregated fragment, ;

[0040] The temporal dependency within a segment is calculated using the cross-attention mechanism, as follows:

[0041] ;

[0042] in, Indicates intra-segment attention.

[0043] Optionally, the inter-segment attention is obtained by:

[0044] The input time series is divided into a set of segments at multiple scales, where each segment contains multiple time steps and multi-dimensional features;

[0045] Embed each fragment along the feature dimension to obtain the embedded fragment ,in, , Represents the dimension after embedding;

[0046] The embedded fragment is calculated by the following formula Perform trainable linear transformation to generate and segment The corresponding keys and values are:

[0047] ;

[0048] ;

[0049] in, and is a trainable weight matrix, and and fragments respectively The corresponding keys and values;

[0050] Using a trainable query matrix Contextual information of the aggregated fragment, ;

[0051] The temporal dependency between segments is calculated using the cross-attention mechanism, as follows:

[0052] ;

[0053] in, Represents inter-fragment attention.

[0054] Optionally, the dynamically updating model parameters through online learning and adaptive mechanisms includes:

[0055] An incremental update mechanism and an adaptive learning rate mechanism are used for online learning to dynamically update model parameters; the incremental update mechanism includes mini-batch gradient descent, batch normalization, and memory replay.

[0056] In a second aspect, an embodiment of the present invention provides a grid carbon emission prediction system that considers the uncertainty of renewable energy output, the system comprising:

[0057] at least one processor;

[0058] at least one memory for storing at least one program;

[0059] When the at least one program is executed by the at least one processor, the at least one processor implements any one of the methods described above.

[0060] The present invention achieves the following beneficial effects: It uses a carbon emission factor prediction model based on the LSTM and Transformer models to predict carbon emissions in real time for power grids. By combining the strengths of the LSTM and Transformer models, this method effectively captures both short-term fluctuations and long-term dependencies in renewable energy output. It also incorporates dynamic carbon emission factor calculation and a multi-timescale prediction mechanism, significantly improving prediction accuracy and practicality. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0062] Figure 1 1 is a flow chart of a method for predicting carbon emissions from a power grid taking into account uncertainty in the output of renewable energy sources according to an embodiment of the present invention;

[0063] Figure 2 is a loss function convergence curve diagram for training the carbon emission factor prediction model in an embodiment of the present invention;

[0064] Figure 3 This is a comparison chart of the actual value and predicted value of the carbon emission factor in an embodiment of the present invention;

[0065] Figure 4 is a graph showing the carbon emission factor prediction results for the training set and the test set in an embodiment of the present invention;

[0066] Figure 5 3 is a schematic structural diagram of a grid carbon emission prediction system that takes into account the uncertainty of renewable energy output in an embodiment of the present invention. DETAILED DESCRIPTION

[0067] The following will be combined with the embodiments and drawings to clearly and completely describe the concept, specific structure and technical effects of the present invention so as to fully understand the purpose, scheme and effect of the present invention. It should be noted that the embodiments and features in the embodiments of the present invention can be combined with each other unless there is any conflict.

[0068] The methods in the related art have the following problems:

[0069] It mostly relies on static carbon emission factors and cannot reflect the dynamic changes in the real-time output of different energy sources in the power grid, resulting in deviations between the predicted results and actual carbon emissions.

[0070] Traditional forecasting models find it difficult to simultaneously capture the short-term fluctuations and long-term trends of renewable energy output, and the forecast results are less robust.

[0071] The lack of multi-time scale forecasting capabilities makes it impossible to simultaneously meet the needs of carbon emission forecasting in the short, medium and long term.

[0072] The issues of multi-source coordination and uncertainty modeling of new energy are not fully considered, and its applicability is limited.

[0073] The technical problem to be solved by the present invention is to propose a carbon emission factor prediction method that can effectively consider the uncertainty of renewable energy power generation output, improve prediction accuracy, and meet the needs of real-time prediction and low-carbon operation. To solve the above technical problems, the present invention uses a carbon emission factor prediction model based on the LSTM model and the Transformer model to perform real-time prediction of power grid carbon emissions. By combining the advantages of the long short-term memory network (LSTM) and the Transformer model, this method can effectively capture the short-term fluctuations and long-term dependencies of renewable energy output, while introducing dynamic carbon emission factor calculation and multi-time scale prediction mechanisms, significantly improving prediction accuracy and practicality.

[0074] LSTM's memory cells can capture long-term dependencies, while Transformer's self-attention mechanism can understand both fine-grained and macro-level context. Thanks to the synergistic effect of LSTM's memory cells and Transformer's self-attention mechanism, the carbon emission factor prediction model performs well in capturing sequential patterns and a wider range of contextual information.

[0075] The present invention effectively considers the uncertainty of renewable energy power generation output, improves prediction accuracy, and meets the needs of real-time prediction of carbon emission factors and low-carbon operation of power grids.

[0076] See Figure 1 The present invention provides a method for predicting carbon emissions from a power grid taking into account the uncertainty of renewable energy output, the method comprising the following steps:

[0077] S100, obtaining a data set of new energy generators and a carbon emission factor of each node in the power grid; the data set includes multiple characteristic data, including operation data, load demand data, and power grid operation status data;

[0078] S200, establishing a carbon emission factor prediction model, training the carbon emission factor prediction model using the data set and the carbon emission factors of each node in the power grid to obtain a trained carbon emission factor prediction model, wherein the carbon emission factor prediction model includes an LSTM module and a Transformer module;

[0079] S300, predicting the characteristic data obtained in real time through the trained carbon emission factor prediction model to generate a real-time predicted carbon emission factor for each node in the power grid.

[0080] The present invention establishes a carbon emission factor prediction model based on the LSTM model and the Transformer model, and solves the problem through the trained carbon emission factor prediction model; in order to realize the multi-time scale prediction of the carbon emissions of the power grid, the present invention proposes a carbon emission factor prediction model based on the LSTM model and the Transformer model. By combining the advantages of the long short-term memory network LSTM model and the Transformer model, the short-term fluctuations and long-term dependencies of the renewable energy output are effectively captured, and at the same time, the dynamic carbon emission factor calculation and multi-time scale prediction mechanism are introduced to significantly improve the prediction accuracy and practicality.

[0081] Specifically, the real-time data is first fused and processed;

[0082] To achieve real-time prediction of grid carbon emissions, it's first necessary to obtain real-time operational data from renewable energy generators, such as wind and photovoltaic power plants. This operational data includes, but is not limited to: renewable energy output data, such as the real-time power generation of wind farms and photovoltaic power plants; load demand data, such as the real-time load demand of the grid and user power consumption; grid operating status data, such as grid frequency, voltage, and power flow; and environmental data, such as meteorological data like wind speed, sunlight intensity, and temperature.

[0083] To ensure real-time data quality and high quality, this paper utilizes Apache Kafka, a streaming data processing technology, to transmit collected data in real time to a data processing center. A message queue mechanism ensures efficient data transmission and low latency. Raw data is cleaned to remove noise, outliers, and missing values, and missing data is filled using sliding window averaging or interpolation. Timestamps from different data sources are aligned to ensure data consistency across the temporal dimension. Min-Max normalization is also used to normalize the data to eliminate dimensionality effects.

[0084] After acquiring data, key features are extracted from multiple data sources, such as fluctuations in renewable energy output and periodic load demand. Features from different data sources are correlated to generate a unified input dataset. Edge computing devices are deployed at the data collection end to perform local preprocessing and initial fusion of data, reducing data transmission volume and latency. The fused data is stored using the real-time database InfluxDB, enabling efficient time series data query and analysis.

[0085] Through the above-mentioned real-time data fusion processing mechanism, the present invention can provide high-quality, real-time input data for real-time prediction of power grid carbon emissions, laying a solid foundation for subsequent modeling and prediction.

[0086] In some embodiments, in S100, the dataset of the new energy generator set is obtained by:

[0087] S110, acquiring multi-source data of the new energy generator set, wherein the multi-source data includes operation data, load demand data, and grid operation status data;

[0088] S120, preprocessing the multi-source data, extracting key features from the preprocessed multi-source data, wherein the key features include fluctuation characteristics of renewable energy output and periodic characteristics of load demand;

[0089] S120 , associating key features in the multi-source data to generate feature data, and forming a data set from the plurality of feature data.

[0090] Next, the dynamic carbon emission factor calculation is performed;

[0091] The grid carbon emission factor is an important indicator for measuring the carbon emission intensity of the power system and is usually used to evaluate the low-carbon performance of the power grid. Traditional methods mostly use static carbon emission factors, which cannot reflect the dynamic changes in the real-time output of different energy sources in the power grid, resulting in a deviation between the predicted results and the actual carbon emissions. To solve this problem, the present invention uses a dynamic carbon emission factor calculation method, which can update the dynamic carbon emission factor in real time according to the real-time output ratio of different energy sources in the power grid, thereby improving the accuracy of carbon emission prediction. The calculation of the carbon emission factor requires the power flow, generated power and power plant type of the power grid.

[0092] In some embodiments, the carbon emission factor is calculated as follows:

[0093] ;

[0094] in, Indicates the The carbon emission factor of electricity for each node; Indicates connection to Active power output of power plants at each node; is the carbon emission coefficient of the power plant; It is from Node to Active power input of each node; For the The branches of a node connect the set of nodes; It is The carbon emission factor of each node.

[0095] In some embodiments, the carbon emission factor prediction model is trained using the data set and the carbon emission factors of each node in the power grid to obtain a trained carbon emission factor prediction model, including:

[0096] S210, obtaining the data set and the carbon emission factor of each node in the power grid;

[0097] S220, input the data in the dataset into the LSTM module to capture the short-term fluctuations and temporal dependencies of the time series and generate a hidden state sequence;

[0098] S230, inputs the hidden state sequence into the Transformer module, captures long-term dependencies and complex associations between multiple variables through self-attention mechanism and multi-head attention mechanism, and generates a context representation sequence;

[0099] S240, taking the hidden state sequence and the context representation sequence as the input time series, performing multi-scale division on the input time series, and capturing the features of the input time series at different time resolutions based on intra-segment attention and inter-segment attention;

[0100] S250, performing feature fusion on the features output by the hidden state sequence and the features output by the context representation sequence to generate a fused multi-scale feature representation;

[0101] S260 maps the multi-scale feature representations through a fully connected layer to obtain the predicted carbon emission factor. The model loss is calculated based on the carbon emission factors of each node in the power grid and the predicted carbon emission factors. The model parameters are dynamically updated through online learning and adaptive mechanisms.

[0102] S270, repeatedly executing S220 to S260 until a predetermined number of iterations or convergence conditions are reached, thereby obtaining a carbon emission factor prediction model.

[0103] In some embodiments, inputting data from the dataset into the LSTM module to capture short-term fluctuations and temporal dependencies of the time series and generate a hidden state sequence includes:

[0104] Specifically, the description of the LSTM-Transformer algorithm is as follows;

[0105] The LSTM module is used to capture the short-term fluctuations and temporal dependencies of the time series.

[0106] The LSTM module calculates the hidden state and cell state using the following formula:

[0107] ;

[0108] ;

[0109] ;

[0110] ;

[0111] ;

[0112] ;

[0113] in: 、 、 Represent the activation values of the forget gate, input gate, and output gate respectively; represents the candidate cell state, Represents the cell state at the current time step, the previous cell state controlled by the forget gate and candidate cell states controlled by the input gate Updated together, used to store long-term time series information; Represents the activation value of the output gate, generated by the Sigmoid function, used to control the current cell state Which information will be output to the hidden state?

[0114] represents the Sigmoid activation function, represents the hyperbolic tangent function, 、 、 、 and 、 、 、 are the trainable weight matrix and bias term, represents element-wise multiplication, Indicates the The hidden state of time steps, , is the dimension of the hidden state;

[0115] The T hidden states are formed into a hidden state sequence H, .

[0116] The output of the LSTM module is a hidden state sequence ,in Indicates the The hidden state of time steps, is the dimension of the hidden state.

[0117] In some embodiments, the step of inputting the hidden state sequence into the Transformer module, capturing long-term dependencies and complex associations between multiple variables through a self-attention mechanism and a multi-head attention mechanism, and generating a context representation sequence includes:

[0118] The attention weight and context representation are calculated through the self-attention mechanism. The formula is:

[0119] The multi-head attention mechanism calculates multiple self-attention heads in parallel to capture the features of different subspaces. The formula is:

[0120] ;

[0121] in, represents the context sequence, is the i-th attention head, is the output weight matrix, .

[0122] Specifically, the description of the Transformer module is as follows;

[0123] The Transformer module is used to capture long-term dependencies in time series and complex associations between multiple variables. The output of the LSTM module is converted into a hidden state sequence H as the input of the Transformer module. The self-attention mechanism calculates the attention weight and context representation using the formula:

[0124] ;

[0125] ;

[0126] ;

[0127] ;

[0128] in, 、 、 Represents query, key and value respectively; 、 、 is a trainable weight matrix; is the dimension of the key, Used to scale dot product attention. H represents the hidden state sequence output by the LSTM module, , where T is the number of time steps, is the hidden state dimension, which serves as the input of Transformer.

[0129] The multi-head attention mechanism captures different subspace features by computing multiple self-attention heads in parallel:

[0130] ;

[0131] in, It is a context representation sequence output by multi-head attention, integrating multi-view feature information. is the i-th attention head, To output the weight matrix, the concatenated multi-head output is projected to the final dimension, and the calculation of each attention head is:

[0132] .

[0133] The multi-time scale Transformer module is described below;

[0134] This paper introduces a multi-scale division mechanism. By dividing the input time series into multiple scales, it captures features at different time resolutions and combines it with the dual attention mechanism of the Transformer model for multi-scale modeling.

[0135] Assume that the input time series is , where H represents the length of the time series and d represents the dimension of the feature. For example, H can be the time step of the past 24 hours, and d includes multi-dimensional features such as renewable energy output, load demand, and weather data. Define a set of M different scales (patch size) , each scale Corresponding to a time resolution. For each scale , the input time series Divided into Patches, that is , where each fragment Include time step data.

[0136] In order to better model temporal dependencies based on multi-scale partitioning, a dual-headed attention mechanism is used to capture local details and global dependencies through intra-patch attention and inter-patch attention, respectively, thereby achieving multi-level modeling of time series.

[0137] Intra-segment attention is used to capture the dependencies between time steps within each segment, thereby modeling local details.

[0138] Intra-episode attention is obtained in the following way:

[0139] For the input time series Perform multi-scale division to obtain a set of fragments , where each fragment Include time steps and dimensional features;

[0140] Embed each fragment along the feature dimension d to obtain the embedded fragment ,in, , Represents the dimension after embedding;

[0141] For embedded fragments Perform a trainable linear transformation to generate keys and values:

[0142] ;

[0143] ;

[0144] in, and are the trainable weight matrices, and and fragments respectively The corresponding keys and values;

[0145] Using a trainable query matrix Contextual information of the aggregated fragment, ;

[0146] The temporal dependencies within a segment are calculated using the Cross-Attention mechanism:

[0147] ;

[0148] in, Indicates intra-segment attention.

[0149] This operation captures the dependencies between time steps within a segment, such as minute-level fluctuations in renewable energy output.

[0150] Inter-segment attention is used to capture the dependencies between different segments, thereby modeling global temporal dependencies.

[0151] Inter-fragment attention is obtained in the following way:

[0152] A set of fragments is obtained by multi-scale division , where each fragment ;

[0153] For each fragment Embed along the feature dimension d to obtain the embedded fragment ,in, , Represents the dimension after embedding;

[0154] The embedded fragment is calculated by the following formula Perform trainable linear transformation to generate and segment The corresponding keys and values are:

[0155] ;

[0156] ;

[0157] in, and is a trainable weight matrix, and and fragments respectively The corresponding keys and values.

[0158] Using a trainable query matrix Contextual information of the aggregated fragment, ;

[0159] Compute the temporal dependencies between segments through the cross-attention mechanism:

[0160] ;

[0161] in, Represents inter-fragment attention.

[0162] This operation captures the dependencies between time steps between different segments, such as hourly or daily load demand variations.

[0163] The outputs of intra-fragment attention and inter-fragment attention are fused to generate the final multi-scale feature representation.

[0164] The fused feature representation is used for subsequent prediction tasks, such as short-term, medium-term, and long-term carbon emissions forecasting. By using intra-segment and inter-segment attention, it is possible to simultaneously capture local details and global dependencies. The segment size and attention mechanism design can be adjusted to suit different prediction scenarios.

[0165] By leveraging the parallel computing capabilities of Transformers, efficient multi-scale modeling is achieved. Through the aforementioned dual-attention mechanism, the present invention can effectively capture the multi-level dependencies of time series, providing a more comprehensive and accurate solution for real-time prediction of grid carbon emissions.

[0166] In some embodiments, dynamically updating model parameters through online learning and adaptive mechanisms includes:

[0167] An incremental update mechanism and an adaptive learning rate mechanism are used for online learning to dynamically update model parameters; the incremental update mechanism includes mini-batch gradient descent, batch normalization, and memory replay.

[0168] Online learning mechanism;

[0169] To address the real-time prediction of carbon emissions from power grids that include wind and photovoltaic power generation, the online learning mechanism dynamically updates model parameters, effectively addressing the difficulty traditional batch training methods have in adapting to the random fluctuations in renewable energy output. Specifically, the online learning mechanism has the following technical details:

[0170] The incremental update mechanism is described as follows:

[0171] Traditional prediction models become static entities after training, with fixed knowledge systems that are difficult to adapt to the dynamic characteristics of wind and solar power generation. The model proposed in this paper uses a continuous learning mechanism to continuously evolve and improve its knowledge system.

[0172] (1) Mini-batch gradient descent algorithm:

[0173] Given the loss function L, the model parameter update rule can be expressed as:

[0174] ;

[0175] in, represents the model parameters, is the learning rate, is the gradient of the loss function with respect to the parameters.

[0176] The data is divided into multiple mini-batches, and the gradient is calculated for each batch and the model parameters are incrementally updated to ensure that the model is always synchronized with the latest data.

[0177] (2) Batch Normalization:

[0178] Normalized output The calculation formula is:

[0179] ;

[0180] Where x is the input, μ is the mean of the input, is the variance, A small constant to prevent division by zero.

[0181] Batch normalization layers are embedded in the network. These layers adjust and scale the activation values to ensure the consistency of the distribution and promote stable and fast convergence of the model.

[0182] (3) Memory playback:

[0183] To ensure that the model retains its memory of historical data, a memory buffer mechanism is used. This buffer acts as a repository of historical experience, periodically replaying old data alongside new data, allowing the model to retain its grasp of past learning while absorbing new knowledge.

[0184] The memory playback mechanism is implemented through the following steps:

[0185] Step 1: Initialize the memory buffer M and set the buffer capacity N;

[0186] Step 2: For each new data sample (x_t, y_t), perform the following steps:

[0187] a. Store the sample in the buffer: ;

[0188] b. If |M|>N, remove the oldest sample;

[0189] c. Randomly sample small batches of data from M for model training;

[0190] Step 3: Repeat step 2 to achieve continuous integration of new and old knowledge;

[0191] The incremental update mechanism effectively solves the problem that traditional static models are difficult to adapt to the uncertainty of renewable energy output by combining three technologies: small-batch gradient descent, batch normalization, and memory replay, and realizes the continuous optimization and dynamic update of the power grid carbon emission prediction model.

[0192] Adaptive learning rate mechanisms include;

[0193] By combining the momentum method and the adaptive learning rate adjustment strategy, the learning rate of each parameter is dynamically adjusted;

[0194] By gradually reducing the learning rate, the model can learn quickly in the early stages of training and make fine adjustments in the later stages;

[0195] Gradient clipping technology is used to obtain the clipped gradient, which is limited to a preset threshold.

[0196] The complexity and uncertainty of engineering systems require models to be fully adaptable during the learning process, especially in terms of dynamic adjustment of the learning rate. A fixed learning rate can lead to inefficient model learning, failure to capture key changes, or induce oscillations, resulting in unstable model training. Therefore, the present invention adopts an adaptive learning rate mechanism to dynamically adjust the learning rate, ensuring that the model can converge quickly and maintain stability during training.

[0197] (1) Adam optimizer:

[0198] The Adam optimizer dynamically adjusts the learning rate of each parameter by combining the momentum method and the adaptive learning rate adjustment strategy.

[0199] The learning rate of each parameter is updated by the following formula:

[0200] ;

[0201] ;

[0202] ;

[0203] in, represents the gradient at time t, and are the first-order and second-order moment estimates of the gradient, , is an exponential decay rate.

[0204] The Adam optimizer ensures that the model can quickly respond to data changes while maintaining training stability during the learning process by maintaining the moving average of the gradient and its square value.

[0205] (2) Learning rate annealing mechanism:

[0206] The learning rate annealing mechanism ensures that the model learns quickly in the early stages of training and makes fine adjustments in the later stages by gradually reducing the learning rate.

[0207] Learning rate after annealing The calculation formula is:

[0208] ;

[0209] in, is the initial learning rate, is the decay rate, and t is the current training round.

[0210] This mechanism effectively avoids the problem of the model failing to converge due to excessive learning rate in the later stages of training.

[0211] 3) Gradient Clipping:

[0212] To prevent the gradient explosion problem, the algorithm uses gradient clipping technology to limit the gradient to a preset threshold.

[0213] Clipped gradient The calculation formula is:

[0214] ;

[0215] Where g is the calculated gradient, is the preset threshold.

[0216] Gradient clipping technology ensures the stability of the model training process by limiting the maximum value of the gradient and preventing training divergence caused by gradient explosion.

[0217] Technical advantages:

[0218] Dynamic adaptability: The Adam optimizer can dynamically adjust the learning rate based on gradient changes to adapt to the non-stationary characteristics of renewable energy output data;

[0219] Stability assurance: Learning rate annealing and gradient clipping techniques effectively avoid oscillation and divergence problems during training;

[0220] Efficient convergence: Combined with adaptive learning rate and gradient clipping, the model can achieve fast convergence while ensuring stability.

[0221] Through the above-mentioned adaptive learning rate mechanism, the robustness and prediction accuracy of the power grid carbon emission prediction model under the uncertainty conditions of renewable energy output will be significantly improved.

[0222] refer to Figure 2 、 Figure 3 and Figure 4 Compared with the related art, the present invention has the following technical improvements and effects:

[0223] By introducing the LSTM model and the Transformer model, the present invention can effectively capture the uncertainty of renewable energy output, and significantly improve the prediction accuracy by combining the dynamic carbon emission factor calculation and multi-time scale prediction mechanism.

[0224] The proposed algorithm can predict the carbon emission factor of the power grid in real time according to the real-time output ratio of different energy sources in the power grid.

[0225] and Figure 1 Corresponding to the method, refer to Figure 5 The embodiment of the present invention provides a grid carbon emission prediction system that considers the uncertainty of renewable energy output, including:

[0226] at least one processor;

[0227] at least one memory for storing at least one program;

[0228] When the at least one program is executed by the at least one processor, the at least one processor implements the above method.

[0229] It can be seen that the contents of the above method embodiments are all applicable to the present system embodiments. The functions specifically implemented by the present system embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.

[0230] In addition, an embodiment of the present invention further discloses a computer program product or computer program, which is stored in a computer-readable storage medium. A processor of a computer device can read the computer program from the computer-readable storage medium, and the processor executes the computer program, causing the computer device to perform the above-mentioned method. Similarly, the contents of the above-mentioned method embodiment are applicable to the present storage medium embodiment. The functions specifically implemented by the present storage medium embodiment are the same as those of the above-mentioned method embodiment, and the beneficial effects achieved are also the same as those achieved by the above-mentioned method embodiment.

[0231] Those skilled in the art will appreciate that all or some of the methods and systems disclosed above can be implemented as software, firmware, hardware, or any suitable combination thereof. Some or all of the physical components may be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on computer-readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). As is well known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information, such as computer-readable instructions, data structures, program modules, or other data. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVDs) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. Furthermore, as is well known to those skilled in the art, communication media typically embodies computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0232] The above is a specific description of the preferred implementation of the present disclosure, but the present disclosure is not limited to the above-mentioned implementation mode. Technical personnel familiar with the art can also make various equivalent modifications or substitutions without violating the spirit of the present disclosure. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present disclosure.

Claims

1. A method for predicting carbon emissions from power grids considering the uncertainty of renewable energy output, characterized in that: The method comprises the following steps: S100, obtaining a data set of new energy generators and a carbon emission factor of each node in the power grid; the data set includes multiple characteristic data, including operation data, load demand data, and power grid operation status data; S200, establishing a carbon emission factor prediction model, training the carbon emission factor prediction model using the data set and the carbon emission factors of each node in the power grid to obtain a trained carbon emission factor prediction model, wherein the carbon emission factor prediction model includes an LSTM module and a Transformer module; S300, predicting the characteristic data obtained in real time through the trained carbon emission factor prediction model to generate a real-time predicted carbon emission factor for each node in the power grid.

2. The method according to claim 1, characterized in that The dataset of the new energy generator set is obtained in the following way: S110, acquiring multi-source data of the new energy generator set, wherein the multi-source data includes operation data, load demand data, and grid operation status data; S120, preprocessing the multi-source data, extracting key features from the preprocessed multi-source data, wherein the key features include fluctuation characteristics of renewable energy output and periodic characteristics of load demand; S120 , associating key features in the multi-source data to generate feature data, and forming a data set from the plurality of feature data.

3. The method according to claim 1, characterized in that The calculation formula of the carbon emission factor is as follows: ; in, Indicates the The carbon emission factor of electricity for each node; Indicates connection to Active power output of power plants at each node; is the carbon emission coefficient of the power plant; It is from Node to Active power input of each node; For the The branches of a node connect the set of nodes; It is The carbon emission factor of each node.

4. The method according to claim 1, wherein The carbon emission factor prediction model is trained using the data set and the carbon emission factors of each node in the power grid to obtain a trained carbon emission factor prediction model, including: S210, obtaining the data set and the carbon emission factor of each node in the power grid; S220, input the data in the dataset into the LSTM module to capture the short-term fluctuations and temporal dependencies of the time series and generate a hidden state sequence; S230, inputs the hidden state sequence into the Transformer module, captures long-term dependencies and complex associations between multiple variables through self-attention mechanism and multi-head attention mechanism, and generates a context representation sequence; S240, taking the hidden state sequence and the context representation sequence as the input time series, performing multi-scale division on the input time series, and capturing the features of the input time series at different time resolutions based on intra-segment attention and inter-segment attention; S250, performing feature fusion on the features output by the hidden state sequence and the features output by the context representation sequence to generate a fused multi-scale feature representation; S260 maps the multi-scale feature representations through a fully connected layer to obtain the predicted carbon emission factor. The model loss is calculated based on the carbon emission factors of each node in the power grid and the predicted carbon emission factors. The model parameters are dynamically updated through online learning and adaptive mechanisms. S270, repeatedly executing S220 to S260 until a predetermined number of iterations or convergence conditions are reached, thereby obtaining a carbon emission factor prediction model.

5. The method according to claim 4, characterized in that The data in the dataset is input into the LSTM module to capture the short-term fluctuations and temporal dependencies of the time series and generate a hidden state sequence, including: Calculate the hidden state of multiple time steps through the LSTM module: The hidden states of multiple time steps are formed into a hidden state sequence.

6. The method according to claim 4, characterized in that The hidden state sequence is input into the Transformer module, and the long-term dependencies and complex associations between multiple variables are captured through the self-attention mechanism and the multi-head attention mechanism to generate a context representation sequence, including: Calculate attention weights and context representations through the self-attention mechanism; Through the multi-head attention mechanism, multiple self-attention heads are calculated in parallel to capture different subspace features and output a context representation sequence.

7. The method according to claim 4, characterized in that The intra-segment attention is obtained in the following way: The input time series is divided into a set of segments at multiple scales, where each segment contains multiple time steps and multi-dimensional features; Embed each fragment along the feature dimension to obtain the embedded fragment ,in, , Represents the dimension after embedding; The embedded fragment is calculated by the following formula Perform trainable linear transformation to generate and segment The corresponding keys and values are: ; ; in, and are the trainable weight matrices, and and fragments respectively The corresponding keys and values; Using a trainable query matrix Contextual information of the aggregated fragment, ; The temporal dependency within a segment is calculated using the cross-attention mechanism, as follows: ; in, Indicates intra-segment attention.

8. The method according to claim 4, characterized in that The inter-fragment attention is obtained in the following way: The input time series is divided into a set of segments at multiple scales, where each segment contains multiple time steps and multi-dimensional features; Embed each fragment along the feature dimension to obtain the embedded fragment ,in, , Represents the dimension after embedding; The embedded fragment is calculated by the following formula Perform trainable linear transformation to generate and segment The corresponding keys and values are: ; ; in, and is a trainable weight matrix, and and fragments respectively The corresponding keys and values; Using a trainable query matrix Contextual information of the aggregated fragment, ; The temporal dependency between segments is calculated using the cross-attention mechanism, as follows: ; in, Represents inter-fragment attention.

9. The method according to claim 4, characterized in that The dynamic updating of model parameters through online learning and adaptive mechanisms includes: An incremental update mechanism and an adaptive learning rate mechanism are used for online learning to dynamically update model parameters; the incremental update mechanism includes mini-batch gradient descent, batch normalization, and memory replay.

10. A grid carbon emission prediction system considering the uncertainty of renewable energy output, characterized by: The system comprises: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the method according to any one of claims 1 to 9.