Short-term real-time electricity price forecasting method based on lstm-gru and cross-time domain multi-head attention mechanism
Patent Information
- Application Number
- CN202611090654.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-22
- Publication Date
- 2026-09-29
AI Technical Summary
现有的单向外推模型(如传统LSTM或GRU)仅能提取历史时刻对未来时刻的单向演化关系,忽略了未来已知边界条件对历史规律的回溯索引作用
1、本发明的预测模型通过“历史编码-未来解码-跨时域交互”的深度解耦架构,实现了对电价时序规律中“经验”与“场景”的差异化提取与深度融合。历史编码器通过双向LSTM专注于捕捉过去168小时的特征变化趋势和时间依赖关系;未来解码器则以历史上下文信息为引导,专注于对未来48小时的动态状态进行深度解析,实现历史运行状态向未来预测场景的语义传递。历史编码器与未来解码器通过跨时域多头注意力机制实现了互补与协同:如果仅利用历史特征进行外推,模型会因缺乏对未来突发工况的感知而产生明显的预测滞后;如果仅依赖未来特征进行预测,则会因忽视电力现货市场实时特有的随机波动性而导致预测结果过于趋近日前价格,无法还原实时出清的真实特征。本发明利用注意力机制建立的“跨时域桥梁”,使模型能以未来时间步的动态状态序列为查询,从历史序列中检索并对齐最相似的供需逻辑,极大地提升了模型在处理D+1天长跨度预测时的逻辑关联能力与时效性。
Smart Images

Figure CN122840994A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of real-time electricity price forecasting technology in the electricity market, specifically a short-term real-time electricity price forecasting method based on LSTM-GRU and cross-temporal multi-head attention mechanism. Background Technology
[0002] With the deepening of power market reform and the continuous increase in the proportion of new energy in the energy structure, real-time electricity prices, as a core indicator reflecting the immediate balance of supply and demand in the system, not only directly determine the profitability of the generation side and the transaction costs of the consumption side, but are also crucial for ensuring the safe and stable operation of the power system, optimizing unit dispatching plans, and guiding the absorption of new energy by regulatory resources such as energy storage. Therefore, accurate forecasting of short-term real-time electricity prices has become an important core basis for the power market to formulate bidding strategies, avoid price fluctuation risks, and maximize profits. However, real-time electricity prices are affected by multiple factors such as new energy fluctuations, load changes, thermal power unit ramp-up constraints, day-ahead price guidance, and meteorological information, exhibiting strong non-stationarity, random mutation, and high nonlinearity. Their time series show complex dynamic patterns, placing high demands on the long-range dependency information extraction, extreme condition capture, and multi-dimensional feature fusion capabilities of forecasting models.
[0003] In recent years, deep learning methods, represented by recurrent neural networks (RNNs), long short-term memory networks (LSTMs), and gated recurrent units (GRUs), have been widely used in time series forecasting. These methods significantly improve prediction accuracy by learning the time dependencies in historical sequences. However, directly applying these deep neural networks to real-time electricity price forecasting still presents the following significant problems: (1) Asymmetry and lag of temporal correlation information. Changes in real-time electricity prices are not only driven by the inertia of historical states, but also strongly constrained by future planned scenarios (such as day-ahead price guidance and load forecasting plans). Existing one-way extrapolation models (such as traditional LSTM or GRU) can only extract the one-way evolutionary relationship between historical moments and future moments, ignoring the backtracking indexing effect of known future boundary conditions on historical patterns. At the same time, real-time electricity price fluctuations often have obvious periodic symmetry. For example, similar price patterns will repeat in similar periods every day or week, and there is a symmetrical relationship between peaks, troughs, ramps, and declines within a day. Existing models often find it difficult to accurately retrieve and extract fluctuation patterns similar to future scenarios in historical sequences of up to 168 hours, resulting in insufficient accuracy in capturing supply and demand inflection points and price jumps.
[0004] (2) Lack of deep coupling and correlation modeling of multi-source heterogeneous features. Real-time electricity prices are affected by a variety of external factors, such as thermal power ramp-up plans, meteorological temperature changes, and predicted output of new energy sources. The coupling relationship between these factors and electricity prices has strong spatiotemporal dynamics. Traditional feature fusion methods often use simple feature splicing and lack deep alignment and cross-temporal correlation modeling of heterogeneous features of different dimensions. Especially when dealing with real-time price forecasting under the multi-source coupling background of "new energy-load-day-ahead electricity price", existing models have difficulty accurately identifying the nonlinear mapping pattern between future scenarios (such as high-temperature load peaks) and historical measured data, resulting in low feature utilization efficiency.
[0005] (3) Prediction smoothing phenomenon under extreme non-stationary signals. Real-time electricity price curves contain macro-evolutionary trends and micro-level drastic random jumps (such as frequent peak high prices or negative electricity prices). Most existing prediction methods adopt a single end-to-end network structure, attempting to learn both stationary trends and extreme fluctuations simultaneously using the same set of parameters. This inevitably leads to prediction smoothing during model training: if the model focuses too much on the overall error, it will lose its ability to respond to key peak electricity prices; if it focuses too much on fluctuations, it is prone to overfitting. In the electricity spot market, existing day-ahead electricity prices can serve as a preliminary price benchmark, but existing models usually start from scratch and cannot effectively utilize the feature predictions of future time steps for targeted cross-time domain retrieval and pattern alignment, resulting in poor prediction robustness when dealing with sudden extreme imbalances in electricity supply and demand. Summary of the Invention
[0006] To address the shortcomings of existing technologies, the technical problem this invention aims to solve is to propose a short-term real-time electricity price forecasting method based on LSTM-GRU and a cross-temporal multi-head attention mechanism.
[0007] The present invention solves the aforementioned technical problem by adopting the following technical solution: A short-term real-time electricity price forecasting method based on LSTM-GRU and cross-temporal multi-head attention mechanism is characterized by the following steps: Step 1: Collect historical multi-source feature measured sequences and future multi-source feature predicted sequences of the target area; obtain the future temperature predicted sequence of key areas; calculate the predicted value of thermal power ramp amount for the future time step according to formula (1) to obtain the future thermal power ramp amount predicted sequence; (1) In the formula, for Predicted values of thermal power plant ramp-up amount at time steps. , They are respectively , Predicted thermal power output at the time step; The marginal cost propensity coefficient of historical time steps is calculated according to equation (2), and the measured sequence of historical marginal cost propensity coefficient is obtained. (2) In the formula, for The marginal cost propensity factor for a time step. for Real-time electricity price at each time step; is the base of the natural logarithm; Each sequence is normalized, and each time step is time-encoded. Step 2: The sliding window method is used to reconstruct the samples and generate several samples. Each sample includes a historical feature matrix, a future feature matrix and a label. The historical feature matrix includes the multi-source features of the historical time step, the measured value of the marginal cost propensity coefficient and the time-coded features. The future feature matrix includes the multi-source features of the future time step, the predicted value of the thermal power ramp-up, the time-coded features and the predicted value of the temperature in the key area. The label is the 24-hour real-time electricity price measurement value of day D+1, where D represents the current prediction base day. The third step is to construct an electricity price prediction model, which includes a historical encoder, a future decoder, a cross-temporal multi-head attention module, and a fully connected layer. The historical encoder uses a bidirectional LSTM network to encode the historical feature matrix to obtain a sequence of historical context information. The future decoder uses a gated recurrent network, taking the future feature matrix as the input of the gated recurrent network and the context information of the last historical time step as the initial hidden state of the gated recurrent network to generate a sequence of future dynamic states. The cross-temporal multi-head attention module includes multiple attention heads. Each attention head uses the future dynamic state sequence as the query matrix and the historical context information sequence as the key matrix and value matrix. It uses cross attention to generate an enhanced future dynamic state sequence. The enhanced future dynamic state sequence output by the cross-temporal multi-head attention module is nonlinearly mapped through two fully connected layers to obtain the electricity price prediction sequence. Step 4: Train the electricity price prediction model and use the trained model for real-time electricity price prediction on day D+1.
[0008] Furthermore, the model loss is calculated using the ternary composite loss function of equation (5) during the training process; (5) (6) (7) (8) (9) In the formula, For the total loss, It is a step-weighted loss. For Wasserstein distance loss, For total variational smoothing loss, , These are the weighting coefficients. for Penalty weights for time steps , They are respectively The actual and predicted electricity prices at each time step. To take the absolute value, To predict the total number of time steps, , These are the actual electricity price series and the predicted electricity price series, sorted in ascending order. The actual electricity price and the predicted electricity price at the time step. for Electricity price forecast at the time step.
[0009] Furthermore, the historical multi-source characteristic measured sequence includes the measured sequences of real-time electricity price, directly regulated load, wind power output, centralized photovoltaic power output, thermal power output, distributed photovoltaic power output, and tie-line power received at historical time steps; the future multi-source characteristic predicted sequence includes the predicted sequences of day-ahead electricity price, directly regulated load, wind power output, centralized photovoltaic power output, thermal power output, distributed photovoltaic power output, and tie-line power received at future time steps.
[0010] Compared with the prior art, the beneficial effects of the present invention are: 1. The prediction model of this invention achieves differentiated extraction and deep fusion of "experience" and "scenario" in the time-series patterns of electricity prices through a deeply decoupled architecture of "historical encoding - future decoding - cross-temporal interaction". The historical encoder focuses on capturing the feature change trends and time dependencies of the past 168 hours through bidirectional LSTM; the future decoder, guided by historical context information, focuses on in-depth analysis of the dynamic state of the next 48 hours, realizing the semantic transmission of historical operating states to future prediction scenarios. The historical encoder and future decoder achieve complementarity and synergy through a cross-temporal multi-head attention mechanism: if only historical features are used for extrapolation, the model will produce obvious prediction lag due to the lack of perception of future sudden operating conditions; if only future features are relied upon for prediction, the prediction results will be too close to the current price due to ignoring the random volatility unique to the real-time electricity spot market, and will not be able to restore the true characteristics of real-time clearing. This invention utilizes an attention mechanism to establish a "cross-time domain bridge," enabling the model to use the dynamic state sequence of future time steps as a query to retrieve and align the most similar supply and demand logic from historical sequences. This greatly improves the model's logical correlation ability and timeliness when handling predictions spanning D+1 days.
[0011] 2. This invention addresses the problem of frequent extreme peaks and negative electricity prices in real-time electricity pricing by innovatively designing a ternary composite loss function of "step-weighted summation + distribution constraint + physical smoothing". First, the step-weighted loss addresses the "tendency towards the median" and "prediction smoothing" phenomena commonly found in traditional deep learning models during training. By applying higher penalty weights to extremely high electricity price ranges and negative electricity price ranges below zero, the model is forced to focus on these high-yield, high-risk price ranges, significantly improving the accuracy in capturing scenarios of extreme supply and demand tensions in the electricity market or new energy surplus. Second, the introduction of Wasserstein distance loss constrains the model output from a statistical probability distribution perspective, ensuring that the predicted electricity price values maintain consistency with the peak-trough characteristics of the actual market in a macroscopic distribution. Finally, the total variational smoothing term effectively suppresses non-physical random jumps in model predictions. This composite loss design makes the prediction curve not only more accurate at single points but also more robust in terms of statistical characteristics and physical ramp-up logic, resolving the contradiction that existing technologies often lose key trading signals when pursuing overall error minimization.
[0012] 3. This invention deeply explores the physical prior knowledge of power system operation. By introducing temperature and physical derivative characteristics of key regions, it significantly enhances the model's perception depth of external disturbances to price fluctuations. Most existing electricity price forecasting methods only consider local meteorological or load information, neglecting the strong marginal guiding effect of tie-line power reception on local prices. This invention, through data analysis, finds that temperature changes in tie-line areas are a key precursor to inter-regional power surplus / deficit shifts and real-time price jumps. When extreme temperature fluctuations occur at the endpoints of tie-lines, they directly affect the external power supply capacity or the load demand at the receiving end, leading to drastic disturbances in the local tie-line power reception capacity and clearing price. Therefore, by using the temperature forecast values of key areas distributed along the tie-lines as the core input, the model learns the deep prior knowledge of the "elastic impact of cross-regional temperature changes on local prices."
[0013] By physically deriving the characteristics of thermal power generation ramp-up and marginal cost propensity coefficient, this invention achieves a shift from being driven by a single numerical sequence to being driven by a synergistic approach of "spatial meteorological information, temporal pattern information, and physical operational characteristics." This helps the model simultaneously learn the comprehensive impact of external meteorological disturbances, changes in the power received by tie lines, local thermal power regulation pressure, and holiday time patterns on real-time electricity prices. This enhances the model's adaptability and predictive robustness under extreme weather, load fluctuations, or special date scenarios, providing market participants with more practical and valuable auxiliary decision-making support. Attached Figure Description
[0014] Figure 1 This is the overall flowchart; Figure 2This is a structural diagram of the electricity price forecasting model; Figure 3 This is a comparison curve between the predicted and actual electricity price series. Detailed Implementation
[0015] Specific embodiments are given below with reference to the accompanying drawings. These specific embodiments are only used to describe the technical solution of the present invention in detail and are not intended to limit the scope of protection of this application.
[0016] like Figure 1 As shown, this invention provides a short-term real-time electricity price forecasting method based on LSTM-GRU and a cross-temporal multi-head attention mechanism, comprising the following steps: Step 1: Using hours as the sampling step size, collect historical multi-source feature measured sequences and future multi-source feature predicted sequences for the target area; calculate the marginal cost propensity coefficient for the historical time step to obtain the historical marginal cost propensity coefficient measured sequence; calculate the predicted value of thermal power ramp-up for the future time step to obtain the future thermal power ramp-up predicted sequence; obtain the future temperature predicted sequence for key areas; and normalize each sequence using the min-max normalization method. The historical multi-source characteristic measured sequence includes the measured sequences of real-time electricity price, directly regulated load, wind power output, centralized photovoltaic power output, thermal power output, distributed photovoltaic power output, and tie-line power received at historical time steps; the future multi-source characteristic predicted sequence includes the predicted sequences of day-ahead electricity price, directly regulated load, wind power output, centralized photovoltaic power output, thermal power output, distributed photovoltaic power output, and tie-line power received at future time steps.
[0017] Among them, real-time electricity price refers to the real-time transaction price in the electricity spot market; direct-dispatch load refers to the power consumption of the target area directly monitored and controlled by the grid dispatching agency; wind power output refers to the active power output of wind power generation equipment; centralized photovoltaic power output refers to the active power output of centralized photovoltaic power generation equipment; thermal power output refers to the active power output of thermal power generating units; distributed photovoltaic power output refers to the active power output of distributed photovoltaic power generation equipment; tie-line receiving power refers to the active power input from other areas to the target area through tie lines, used to reflect the cross-regional power supply and demand balance; and day-ahead electricity price refers to the predicted price disclosed in advance by the electricity spot market based on the supply and demand situation and trading plan for the next day.
[0018] Since the regional power supply mainly comes from thermal power generation, the thermal power ramp amount in the future time step is calculated according to Equation (1) to characterize the future thermal power ramp adjustment pressure and obtain the future thermal power ramp amount prediction sequence. (1) In the formula, for Predicted values of thermal power plant ramp-up amount at time steps. , They are respectively , Predicted thermal power output at the time step; The ratio of real-time electricity price to thermal power output is used to characterize the marginal cost tendency of the system. The marginal cost tendency coefficient of the historical time step is calculated according to Equation (2) to obtain the measured sequence of historical marginal cost tendency coefficient. (2) In the formula, for The marginal cost propensity factor for a time step. for Real-time electricity price at each time step; The base of the natural logarithm is 2.71828.
[0019] The ramp-up rate of thermal power generation is used as a physical derivative feature to characterize the future changes in ramp-up adjustment pressure on the thermal power side, enhancing the model's ability to perceive future supply and demand tensions. It is used together with the future multi-source feature prediction sequence to construct the future feature matrix. The marginal cost propensity coefficient is used as another physical derivative feature to describe the relationship between electricity price level and thermal power supply capacity under historical operating conditions. It provides physical prior information for the model to retrieve historical similar price fluctuation patterns. It is used together with the historical multi-source feature measured sequence to construct the historical feature matrix. Power exchange between regions is achieved through interconnection lines. The temperature of other regions will affect the power received by the interconnection lines and the real-time electricity price of the target region. Therefore, based on the power exchange relationship between regions and the scope of meteorological influence, regions that have power interconnection channels with the target region, cover the main external power supply directions, and can reflect the regional meteorological change characteristics are selected as key regions, and future temperature prediction sequences of these key regions are obtained. Time encoding is performed on historical and future time steps to obtain time encoding features for each time step. These features include five dimensions: hour normalization feature (value equal to the hour of the time step divided by 23); weekday normalization feature (value equal to the weekday number of the time step (e.g., any value from 0 to 6) divided by 6, with Monday recorded as 0 and the weekday number as 6); month normalization feature (value equal to the month of the time step minus 1, then divided by 11); weekend identifier (value 1 if the date of the time step is a weekend, 0 otherwise); and public holiday identifier (value 1 if the date of the time step is a public holiday, 0 otherwise).
[0020] Step 2: Reconstruct the dataset by using the sliding window method to reconstruct samples across the time domain for each sequence; The historical step size is set to 168 hours, and the future prediction step size is set to 48 hours. Each sequence is sliced with a 24-hour sliding step to generate several samples. Each sample includes a historical feature matrix, a future feature matrix, and a label. The historical feature matrix is 168 in length and 13 in dimension, including measured values of real-time electricity prices, directly controlled load, wind power output, centralized photovoltaic output, thermal power output, distributed photovoltaic output, tie-line power receiving capacity, and marginal cost propensity coefficient for the historical time step, as well as 5-dimensional time-coded features. The future feature matrix is 48 in length and 13 in dimension. This includes predicted values for day-ahead electricity prices, directly controlled loads, wind power output, centralized photovoltaic output, thermal power output, distributed photovoltaic output, tie-line power receiving capacity, and thermal power ramp-up, as well as 5-dimensional time-coding features. Temperature prediction values for the dimension.
[0021] The prediction model uses the historical feature matrix from day D-1 to day D-7 and the future feature matrix for day D and day D+1 to predict the 24-hour real-time electricity price on day D+1. D represents the current prediction base day, so the sample label is the 24-hour real-time electricity price measurement on day D+1.
[0022] Step 3: Construct an electricity price prediction model based on BiLSTM and GRU, including a historical encoder, a future decoder, a cross-temporal multi-head attention module, and a fully connected layer. See [link to relevant documentation]. Figure 2 ; The historical encoder uses a bidirectional LSTM network to encode the historical feature matrix. The historical feature matrix is input into the bidirectional LSTM network, and forward and backward LSTMs are used respectively to extract the feature change trends and time dependencies of historical time steps, obtaining the forward and backward hidden states for each historical time step. The forward and backward hidden states of each historical time step are concatenated to obtain the context information of the historical time step, thus obtaining the historical context information sequence. ; The future decoder employs a gated recurrent network (GRU). The future feature matrix is input into the GRU, and the context information from the last historical time step is used as the initial hidden state of the GRU. Guided by the historical context information, a sequence of future dynamic states is generated. This enables the semantic transmission of historical operating states to future predicted scenarios.
[0023] To enhance the temporal correlation between historical operating states and future predicted scenarios, a multi-head attention mechanism is introduced to achieve cross-temporal information interaction. In the cross-temporal multi-head attention module, each attention head interacts with the future dynamic state sequence. For querying the matrix, the historical context information sequence Using the key matrix and value matrix, cross-attention is employed to calculate the matching weights between future prediction scenarios and historical operating states. The most relevant information to the future prediction scenario is extracted from the historical context information sequence and fused to generate an enhanced future dynamic state sequence. This module enables the model to dynamically retrieve similar price fluctuation patterns from the historical 168-hour operating state based on changes in load, weather, and energy status over the next 48 hours, thereby improving the electricity price prediction capability in complex market environments.
[0024] The enhanced future dynamic state sequence is nonlinearly mapped through two fully connected layers to transform it from the hidden state space to the electricity price space, resulting in an electricity price prediction sequence. The electricity price prediction value for the next 24 hours is taken as the real-time electricity price prediction value for day D+1. The first fully connected layer is used to compress the 256-dimensional sequence to 64 dimensions and enhance the nonlinear expressive power through the ReLU activation function. The second fully connected layer is used for single-point mapping to obtain the electricity price prediction value for each future time step. (3) (4) In the formula, This is a sequence of future dynamic states after dimensional compression. For the enhanced future dynamic state sequence, , These are the weight matrix and bias of the first fully connected layer, respectively. It is the ReLU activation function. This is a 48-hour electricity price forecast sequence. , These are the weight matrix and bias of the second fully connected layer, respectively.
[0025] Step 4: Train the electricity price prediction model. During the training process, use the ternary composite loss function to calculate the model loss until the loss converges to obtain the trained model. Then, use the trained model to predict the real-time electricity price for day D+1. To address the frequent spikes in real-time electricity prices, a ternary composite loss function is defined as follows: (5) In the formula, It is the total loss. It is a step-weighted loss. For Wasserstein distance loss, For total variational smoothing loss, , These are the weighting coefficients; The tiered weighted loss is used to apply targeted penalties to peak electricity price ranges. The calculation formula is as follows: (6) (7) In the formula, for Penalty weights for time steps , They are respectively The actual and predicted electricity prices at each time step. To take the absolute value, To predict the total number of time steps; The Wasserstein distance loss is used to constrain the distribution consistency of two sequences, making the distribution of the electricity price prediction sequence closer to the actual electricity price sequence. The actual and predicted electricity price sequences are sorted in ascending order, and then the absolute difference between the actual and predicted electricity price values at corresponding time steps is calculated. Finally, the absolute differences over all time steps are averaged. The Wasserstein distance loss calculation formula is as follows: (8) In the formula, , These are the sorted orders in ascending order. The actual electricity price and the predicted electricity price at each time step; The total variational smoothing loss is used to ensure the continuity of the electricity price forecast series in the time dimension, and the calculation formula is as follows: (9) In the formula, for Electricity price forecast at the time step.
[0026] Example This embodiment uses measured data from the Shandong provincial electricity market from January 1, 2022 to June 1, 2026 as an example, with a sampling interval of 1 hour and a total of approximately 38,700 sampling points. Data from January 2022 to April 22, 2026 is selected as the training set, and data from April 23, 2026 to June 1, 2026 is selected as the test set. A sliding window is used to construct cross-time-domain sample pairs of historical 168 hours and future 48 hours. The real-time electricity price prediction curve is shown below. Figure 3As shown, the mean absolute error (MAE) of the predicted electricity price is 78.04 yuan / MWh, and the root mean square error (RMSE) is 118.74 yuan / MWh. This indicates that the model can accurately capture the real-time electricity price trend and achieve high-precision real-time electricity price prediction. By retrieving historical similar operating conditions through a cross-temporal attention mechanism, it provides historical price evolution patterns for predicting future electricity price trends. It can effectively integrate historical operating patterns with future scenario information. While maintaining the continuity of the price curve, it has good predictive ability for high-volatility and high-risk price ranges, avoiding abnormal high-frequency oscillations in the prediction results. It can be directly applied to trading decisions and quotation guidance in the electricity spot market.
[0027] Any aspects not covered in this invention are applicable to existing technologies.
Claims
1. A short-term real-time electricity price forecasting method based on LSTM-GRU and cross-temporal multi-head attention mechanism, characterized in that, Includes the following steps: Step 1: Collect historical multi-source feature measured sequences and future multi-source feature predicted sequences of the target area; obtain the future temperature predicted sequence of key areas; calculate the predicted value of thermal power ramp amount for the future time step according to formula (1) to obtain the future thermal power ramp amount predicted sequence; (1) In the formula, for Predicted values of thermal power plant ramp-up amount at time steps. , They are respectively , Predicted thermal power output at the time step; The marginal cost propensity coefficient of historical time steps is calculated according to equation (2), and the measured sequence of historical marginal cost propensity coefficient is obtained. (2) In the formula, for The marginal cost propensity factor for a time step. for Real-time electricity price at each time step; is the base of the natural logarithm; Each sequence is normalized, and each time step is time-encoded. Step 2: The sliding window method is used to reconstruct the samples and generate several samples. Each sample includes a historical feature matrix, a future feature matrix and a label. The historical feature matrix includes the multi-source features of the historical time step, the measured value of the marginal cost propensity coefficient and the time-coded features. The future feature matrix includes the multi-source features of the future time step, the predicted value of the thermal power ramp-up, the time-coded features and the predicted value of the temperature in the key area. The label is the 24-hour real-time electricity price measurement value of day D+1, where D represents the current prediction base day. The third step is to construct an electricity price prediction model, which includes a historical encoder, a future decoder, a cross-temporal multi-head attention module, and a fully connected layer. The historical encoder uses a bidirectional LSTM network to encode the historical feature matrix to obtain a sequence of historical context information. The future decoder uses a gated recurrent network, taking the future feature matrix as the input of the gated recurrent network and the context information of the last historical time step as the initial hidden state of the gated recurrent network to generate a sequence of future dynamic states. The cross-temporal multi-head attention module includes multiple attention heads. Each attention head uses the future dynamic state sequence as the query matrix and the historical context information sequence as the key matrix and value matrix. It uses cross attention to generate an enhanced future dynamic state sequence. The enhanced future dynamic state sequence output by the cross-temporal multi-head attention module is nonlinearly mapped through two fully connected layers to obtain the electricity price prediction sequence. Step 4: Train the electricity price prediction model and use the trained model for real-time electricity price prediction on day D+1.
2. The short-term real-time electricity price forecasting method based on LSTM-GRU and cross-temporal multi-head attention mechanism according to claim 1, characterized in that, During training, the model loss is calculated using the ternary composite loss function of equation (5); (5) (6) (7) (8) (9) In the formula, For the total loss, It is a step-weighted loss. For Wasserstein distance loss, For total variational smoothing loss, , These are the weighting coefficients. for Penalty weights for time steps , They are respectively The actual and predicted electricity prices at each time step. To take the absolute value, To predict the total number of time steps, , These are the actual electricity price series and the predicted electricity price series, sorted in ascending order. The actual electricity price and the predicted electricity price at the time step. for Electricity price forecast at the time step.
3. The short-term real-time electricity price forecasting method based on LSTM-GRU and cross-temporal multi-head attention mechanism according to claim 1, characterized in that, The historical multi-source characteristic measured sequence includes the measured sequences of real-time electricity price, directly regulated load, wind power output, centralized photovoltaic power output, thermal power output, distributed photovoltaic power output, and tie-line power received at historical time steps; the future multi-source characteristic predicted sequence includes the predicted sequences of day-ahead electricity price, directly regulated load, wind power output, centralized photovoltaic power output, thermal power output, distributed photovoltaic power output, and tie-line power received at future time steps.