Power grid safety margin prediction and risk assessment method and system based on double-layer LSTM-XGBoost model
Through the dual-layer LSTM-XGBoost model, the problem of single time scale and model error accumulation in traditional methods is solved, dynamic quantification of grid safety margin and real-time risk assessment are realized, the safety and stability of the power grid are improved, and timely decision-making support is provided.
Patent Information
- Application Number
- CN202510462131.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-14
- Publication Date
- 2025-07-25
AI Technical Summary
Traditional grid safety margin prediction methods have single time scale limitations, model error accumulation and risk assessment lag, and cannot effectively capture the hourly fluctuations and dynamic risk changes in the power grid, resulting in delays in emergency response.
The grid safety margin prediction method based on the double-layer LSTM-XGBoost model is adopted. The power grid data is collected by scales, and the daily and time-degree data sets are constructed. The LSTM prediction model is trained separately and the residuals are corrected using XGBoost. The warning signal is generated based on real-time risk rate calculation, and the emergency resource configuration is optimized.
It realizes dynamic quantification of grid safety margin and real-time risk assessment, improves the safety and stability of the grid, provides timely decision-making support, and ensures rapid response and emergency measures of the grid.
Smart Images

Figure CN120373860A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a method and system for predicting power grid security margin and risk assessment, and particularly to a method and system for predicting power grid security margin and risk assessment based on a double-layer LSTM-XGBoost model. Background Art
[0002] The security margin of the power system is a key indicator to measure the stable operation ability of the power grid. Traditional methods have the following limitations: single time scale limitation: relying only on daily or annual data, it is impossible to capture the impact of hourly fluctuations on the power grid security; model error accumulation: it is difficult for a single prediction model (such as LSTM or XGBoost) to capture both long-term time series dependencies and non-linear residual characteristics at the same time; risk assessment lag: the static threshold method cannot dynamically reflect short-term risk changes, resulting in delayed emergency response. Summary of the Invention
[0003] Object of the Invention: The object of the present invention is to provide a method and system for predicting power grid security margin and risk assessment based on a double-layer LSTM-XGBoost model, which dynamically quantifies the power grid security risk and optimizes the allocation of emergency resources through the coordination of daily prediction and hourly prediction.
[0004] Technical Solution: A method for predicting power grid security margin and risk assessment based on a double-layer LSTM-XGBoost model according to the present invention includes the following steps:
[0005] (1) Collect power grid operation data at different scales, perform data cleaning, and construct a daily dataset and an hourly dataset, where the daily dataset is 24-hour aggregated data and the hourly dataset is hourly sampled data;
[0006] (2) Perform standardization processing on the daily dataset and the hourly dataset respectively, and reshape them into the LSTM input format to obtain a daily input sequence and an hourly input sequence;
[0007] (3) Based on a double-layer LSTM network, train a daily prediction model and an hourly prediction model respectively, and output a daily security margin prediction value and an hourly security margin prediction value;
[0008] (4) Train an XGBoost residual correction model to correct the residuals of the daily and hourly prediction models, and generate a combined prediction result;
[0009] (5) By comparing the hourly prediction values in the next 24 hours with the daily prediction benchmark value, count the number of times the hourly prediction value is lower than the daily prediction benchmark value, and calculate the real-time risk rate; generate a warning signal according to the real-time risk rate, and trigger an emergency resource scheduling instruction when the risk rate exceeds a preset threshold.
[0010] Preferably, in step (1), the data cleaning fills in the missing data through a missing value processing method and uses an outlier detection technique to identify and remove the outlier data.
[0011] Preferably, the normalization processing in step (2) is as follows: The maximum absolute value scaling method is used to normalize the daily data and the hourly data respectively, and each eigenvalue is scaled to the interval [-1, 1]. The formula is as follows:
[0012]
[0013] where X is the original eigenvalue, and X norm is the normalized eigenvalue.
[0014] Preferably, the structure of the double-layer LSTM network in step (3) is as follows: The number of LSTM units in the first layer is 64, the number of LSTM units in the second layer is 32, and a Dropout layer is inserted between the layers;
[0015] When training the LSTM network model, the normalized daily or hourly data is input into the model. After passing through multiple LSTM units and the Dropout layer, the predicted value of the power grid safety margin is output. The training objective of the model is to minimize the mean square error. The formula is as follows:
[0016]
[0017] where n is the number of samples, y i is the actual safety margin, is the safety margin predicted by the double-layer LSTM model.
[0018] Preferably, in step (4), the residual correction uses the XGBoost model to correct the residuals of the double-layer LSTM, and calculates the residuals of the double-layer LSTM model:
[0019]
[0020] Taking the residuals as the regression target of XGBoost, using the XGBoost model to model and correct the residuals, and obtaining the comprehensive predicted value:
[0021]
[0022] where, is the correction result of the XGBoost model for the residuals.
[0023] Preferably, the calculation formula of the real-time risk rate in step (5) is:
[0024]
[0025] where, It is an indicator function that takes the value of 1 when the condition is met and 0 otherwise.
[0026] A power grid security margin prediction and risk assessment system based on a double-layer LSTM-XGBoost model, comprising:
[0027] A data acquisition module: used to access the daily and hourly operation data streams of the power grid SCADA system in real time;
[0028] A prediction module: deploying a double-layer LSTM daily and hourly prediction model to output the prediction results of the security margin;
[0029] A residual correction module: integrating the XGBoost model to dynamically correct the prediction residuals;
[0030] A risk assessment module: calculating the real-time risk rate for the next 24 hours and generating a visual risk heat map;
[0031] An early warning execution module: triggering resource scheduling or operation and maintenance intervention instructions according to the risk rate threshold.
[0032] Preferably, the visual risk heat map maps the hourly prediction value, the daily prediction reference value and the risk rate into a color gradient, and combines with the geographic information system to display the risk distribution of the power grid nodes.
[0033] A computer device, comprising one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and when the program is executed by the processor, the steps of the power grid security margin prediction and risk assessment method are implemented.
[0034] A computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the power grid security margin prediction and risk assessment method are implemented.
[0035] Advantageous effects: Compared with the prior art, the present invention has the following remarkable advantages: using a missing value processing method to fill in the missing data and applying an outlier detection technique to identify and eliminate the outlier data to ensure the accuracy and integrity of the data; aggregating the hourly data by day to generate daily data, and taking the minimum value of the security margin of the current day as the target variable, which helps to capture the stability change trend of the system in a long cycle; adopting a training and prediction based on a double-layer LSTM-XGBoost hybrid model, evaluating the potential risks of the power grid by calculating the security margin prediction and the risk rate, automatically triggering an early warning and prompting the dispatcher to take emergency measures. The present invention can provide efficient decision-making support for power system dispatching and effectively improve the security and stability of the power grid. Description of the Drawings
[0036] Figure 1 This is the flowchart of the method described in the present invention.
[0037] Figure 2 This is a schematic diagram of the normalization processing of daily and hourly data.
[0038] Figure 3 This is the structure diagram of the double-layer LSTM network described in the present invention.
[0039] Figure 4 This is a line chart of the daily prediction results of the double-layer LSTM-XGBoost hybrid model and common prediction models.
[0040] Figure 5 This is a comparison chart of daily indicators between the double-layer LSTM-XGBoost hybrid model and common prediction models.
[0041] Figure 6 This is a line chart of the hourly prediction results of the double-layer LSTM-XGBoost hybrid model and common prediction models.
[0042] Figure 7 This is a comparison chart of hourly indicators between the double-layer LSTM-XGBoost hybrid model and common prediction models. Detailed implementation manner
[0043] The technical solution of the present invention will be further described below with reference to the accompanying drawings.
[0044] As Figure 1 shown, a method for predicting the power grid security margin and risk assessment based on a double-layer LSTM-XGBoost model includes the following steps:
[0045] (1) Collect power grid operation data at different scales, perform data cleaning, and construct a daily dataset and an hourly dataset. The daily dataset is 24-hour aggregated data, and the hourly dataset is hourly sampled data;
[0046] (2) Perform normalization processing on the daily dataset and the hourly dataset respectively, and reshape them into the LSTM input format to obtain the daily input sequence and the hourly input sequence;
[0047] (3) Based on the double-layer LSTM network, train the daily prediction model and the hourly prediction model respectively, and output the daily security margin prediction value and the hourly security margin prediction value;
[0048] (4) Train the XGBoost residual correction model to correct the residuals of the daily and hourly prediction models and generate combined prediction results;
[0049] (5) By comparing the hourly prediction values for the next 24 hours with the daily prediction benchmark values, count the number of times the hourly prediction values are lower than the daily prediction benchmark values, and calculate the real-time risk rate; generate an early warning signal based on the real-time risk rate, and when the risk rate exceeds the preset threshold, trigger an emergency resource scheduling instruction.
[0050] The above steps are specifically described as follows:
[0051] Data collection and cleaning:
[0052] Data collection: Obtain the operating data of the power grid in real time. These data are transmitted to the monitoring center through the standard interfaces of the power system (such as the SCADA system or PMU data). The obtained data includes but is not limited to key information such as bus voltage, load, generator output, and branch power flow. These data are updated in real time, and the time step can be adjusted as needed, commonly hourly or at a higher frequency.
[0053] Data cleaning: Since the real-time collected data may be affected by factors such as transmission delay and signal noise, resulting in some data being missing or abnormal. At this stage, first fill in the missing data through missing value processing methods (such as interpolation method, mean filling, etc.); at the same time, apply outlier detection techniques (such as Z-score method or box plot method) to identify and remove abnormal data to ensure the accuracy and integrity of the data. Finally, the cleaned data will be used for subsequent feature extraction and model training.
[0054] Feature extraction and data preprocessing:
[0055] The feature extraction of the data mainly includes the following steps:
[0056] Voltage data: Extract the voltage magnitude (VM) and voltage angle (VA) of each bus. These data directly reflect the stability of the power grid.
[0057] Power data: Extract the active power (PG) and reactive power (QG) of each generator, as well as the active power flow (PF) and reactive power flow (QF) of each branch. These data are used to reflect the load distribution and power flow situation of the power system.
[0058] Safety margin index: The stability margin of the power grid is an important indicator to measure whether the system is in a safe state. Comprehensively evaluate the safety margin of the power grid by calculating the voltage margin (η_vd) and transient stability margin (η_vs) of the power grid.
[0059] Data Normalization: Before model training, all feature data need to be normalized to ensure that features with different dimensions have the same influence during training. The MaxAbsScaling method is used to scale each feature value to the range [-1, 1]. The formula is as follows:
[0060]
[0061] where X is the original feature value, and X norm is the normalized feature value.
[0062] Data Splitting and Daily Aggregation: After data preprocessing, the system aggregates the hourly data by day to generate daily data. For the 24-hour data of each day, the mean value of each feature is taken as the new feature, and the minimum value of the safety margin on that day is taken as the target variable. This helps to capture the stability change trend of the system over a long period.
[0063] Model Training and Prediction:
[0064] Training and Prediction of the Double-Layer LSTM Model: To capture the temporal features in power grid operation data, the present invention uses a double-layer LSTM (Long Short-Term Memory Network) model. LSTM is a deep learning model suitable for time series data and can effectively process data with strong time dependence. When training the double-layer LSTM model, the normalized daily or hourly data is input into the model. After passing through multiple LSTM units and Dropout layers, the predicted value of the power grid safety margin is output. The training objective of the model is to minimize the mean squared error (MSE), and the formula is as follows:
[0065]
[0066] where n is the number of samples, y i is the actual safety margin, is the safety margin predicted by the double-layer LSTM model.
[0067] XGBoost Residual Correction: Although the LSTM model can capture temporal features, it may still produce certain prediction errors when facing the complex nonlinear relationships in the power system. To solve this problem, the present invention uses the XGBoost model to perform secondary correction on the residuals of the double-layer LSTM. First, calculate the residuals of the double-layer LSTM model:
[0068]
[0069] Then, take the residuals as the regression target of XGBoost, and use the XGBoost model to model and correct the residuals. Finally, the comprehensive predicted value is obtained:
[0070]
[0071] Among them, is the correction result of the XGBoost model for the residuals.
[0072] Model prediction and output: After the model training is completed, the system will predict the safety margin based on the new real-time data and output the predicted values of the daily and hourly safety margins. These predicted values will provide reference for power grid dispatching and help evaluate whether there are potential safety hazards in the power grid.
[0073] Calculation and evaluation of the risk rate:
[0074] The purpose of calculating the risk rate is to evaluate the risk of the power grid safety margin within the next 24 hours and ensure real-time performance in actual operation. The training time window for the hourly data is 168 hours, which provides the power grid dispatching personnel with the ability to respond and adjust quickly. The following are the definition and calculation method of the risk rate:
[0075] Definition of the risk rate: The risk rate refers to the proportion of the predicted value of the hourly safety margin lower than the corresponding daily predicted value within the next 24 hours. By calculating the difference between the hourly predicted value and the daily predicted value, the potential safety hazards that may exist in the power grid in the short term can be quantified. The risk rate calculation will only compare the data within the next 24 hours and does not involve past data, thus ensuring its real-time performance and pertinence.
[0076] Risk rate calculation formula: When making each prediction, the system will compare the predicted value of the hourly within the next 24 hours with the corresponding daily predicted value and calculate their difference:
[0077]
[0078] If Δy t < 0, it indicates a relatively high safety risk at this moment. On this basis, the risk rate R hourly The calculation formula within the next 24 hours is:
[0079]
[0080] Among them, I(·) is the indicator function, which returns 1 when the hourly predicted value is lower than the daily predicted value, and returns 0 otherwise. Through this calculation, R hourly represents the proportion of the hourly predicted value lower than the daily predicted value within the next 24 hours.
[0081] Decision support and risk assessment:
[0082] Decision Support: The daily prediction data provides a long-term safety margin trend for power grid operation and dispatch. At the beginning of each prediction cycle, the system provides an estimate of the power grid's safety margin for the next 24 hours through the daily prediction data. Based on this prediction result, dispatchers can deploy relevant measures in advance, such as adjusting load distribution, arranging equipment maintenance, or activating standby power generation units, to ensure the stable operation of the power grid. If the daily prediction shows a low safety margin during certain periods, the system can recommend that dispatchers strengthen monitoring or take corresponding preventive measures during these periods.
[0083] Risk Assessment: During the actual operation of the power grid, the system continuously calculates the risk rate within the next 24 hours. The calculation of the risk rate is based on the comparison between the hourly safety margin prediction value and the daily prediction value. Specifically, when the hourly prediction value is lower than the daily prediction value, it is considered that there is a high safety risk during that period, and then the risk rate R within the next 24 hours is calculated. hourly The risk rate reflects the safety hazards of the power grid within the next 24 hours. The higher the value, the lower the safety margin of the power grid during that period and the greater the risk.
[0084] During the real-time assessment process, if the risk rate exceeds the preset threshold, the system will automatically trigger a risk warning to notify the power grid dispatcher of potential safety hazards. The dispatcher can take timely response measures based on this warning, such as conducting local dispatching optimization, strengthening power grid monitoring during specific periods, or quickly deploying an emergency response plan to reduce the risk of power grid operation. In addition, the system can also compare historical data to help dispatchers identify and prevent possible fault periods or abnormal patterns.
[0085] The present invention also provides a power grid safety margin prediction and risk assessment system based on a double-layer LSTM-XGBoost model, including:
[0086] Data Acquisition Module: Used to access the daily and hourly operation data streams of the power grid SCADA system in real time;
[0087] Prediction Module: Deploy a double-layer LSTM daily and hourly prediction model to output the safety margin prediction result;
[0088] Residual Correction Module: Integrate the XGBoost model to dynamically correct the prediction residuals;
[0089] Risk Assessment Module: Calculate the real-time risk rate within the next 24 hours and generate a visual risk heat map;
[0090] Early Warning Execution Module: Trigger resource scheduling or operation and maintenance intervention instructions according to the risk rate threshold.
[0091] The following is a specific description in combination with the embodiments:
[0092] In this embodiment, grid data is collected in real time through the SCADA system of the power system. The data covers key parameters of a 9-node power system, such as bus voltage (VM), load (PD), generator output (PG), branch power flow (PF), etc. During the simulation process, the outputs of the load and the generator are randomly perturbed within a range of ±10%, simulating the load fluctuations and power flow changes in the power grid. After the simulation data is generated, it is updated and recorded hourly as the basis for subsequent analysis.
[0093] The data generated by the simulation is cleaned and processed to ensure data integrity and accuracy. First, rows containing missing or abnormal data are deleted to ensure the quality of the analysis data. Then, features related to the power grid security margin are extracted, including bus voltage, generator output, branch power flow, etc. All data is normalized using the maximum absolute value normalization to ensure that the model training process is not affected by dimensional differences. The preprocessed data prepares a clean and standardized dataset for subsequent model training.
[0094] For hourly data, the system generates 9,600 training samples and 400 test samples from the hourly data. During the generation of daily data, the data for every 24 hours is aggregated by taking the mean to form 320 training samples and 80 test samples of daily data. To ensure that the model can respond in real time, the hourly data also adopts a time window strategy. By selecting the most recent 168 training samples and 24 test samples, the real-time nature and timeliness of the training are guaranteed. This time window strategy enables the model to focus on the latest power grid operating conditions and ensures the timeliness of the prediction results.
[0095] After the data preprocessing is completed, a double-layer LSTM neural network is used to predict the security margin. The LSTM model is suitable for processing the time series characteristics in power grid data and can capture the time dependence in power grid operation. During the training process, we input 168 hours of data and set the training period to 300 epochs. Through training, the double-layer LSTM model successfully predicts the security margin within the next 24 hours and achieves good results on the test set. The prediction error is controlled within a small range, and it can accurately reflect the operating state of the power grid.
[0096] To further improve the prediction accuracy, this embodiment combines the XGBoost model to correct the prediction residuals of the double-layer LSTM. The residual refers to the difference between the predicted value and the actual value of the LSTM model. The XGBoost model trains on the residuals and outputs the corrected residual values. By combining the prediction results of the double-layer LSTM with the residuals corrected by XGBoost, we obtain a more accurate predicted value of the security margin. The use of XGBoost effectively improves the prediction accuracy and reduces the prediction error of the double-layer LSTM model in certain periods.
[0097] After the safety margin prediction is completed, the system begins to evaluate the risks for the next 24 hours. By calculating the difference between the hourly prediction value and the daily prediction value, the system can evaluate the safety risks of the power grid in real time. If the hourly prediction value for a certain period is lower than the daily prediction value, it is considered that there is a relatively high safety risk during that period. The system calculates the risk rate within the next 24 hours, which represents the proportion of the safety margin of the power grid being lower than the daily prediction value during this period.
[0098] For example, in a certain evaluation, the risk rate calculated by the system is 66.67%, indicating that the safety margin of 16 periods within the next 24 hours is lower than the daily prediction value. When the risk rate exceeds the preset risk threshold (such as 20%), the system will automatically trigger an early warning, prompting the dispatcher to pay attention to these periods and possibly take emergency measures. In this way, the power grid dispatcher can timely discover potential safety hazards and conduct effective intervention.
[0099] Through this embodiment, the power grid dispatcher can obtain the safety margin prediction value for the next 24 hours in real time and evaluate potential safety hazards through the risk rate. The system performs well during the testing process, with the prediction error controlled within an acceptable range, and it can issue an early warning in a timely manner when the hourly prediction value is lower than the daily prediction value. By combining the prediction capabilities of the double-layer LSTM and XGBoost models with the real-time risk assessment mechanism, the system can provide accurate and timely decision-making support for the power grid dispatcher.
Claims
1. A method for predicting power grid security margin and risk assessment based on a double-layer LSTM-XGBoost model, characterized in that, It includes the following steps: (1) Collect power grid operation data at different scales, perform data cleaning, and construct daily and hourly datasets. The daily dataset is 24-hour aggregated data, and the hourly dataset is hourly sampled data; (2) Perform standardization processing on the daily and hourly datasets respectively, and reshape them into the LSTM input format to obtain the daily input sequence and the hourly input sequence; (3) Based on the double-layer LSTM network, train the daily prediction model and the hourly prediction model respectively, and output the predicted values of the daily safety margin and the hourly safety margin; (4) Train the XGBoost residual correction model to correct the residuals of the daily and hourly prediction models and generate a combined prediction result; (5) By comparing the hourly predicted values in the next 24 hours with the daily prediction benchmark value, count the number of times the hourly predicted value is lower than the daily prediction benchmark value, and calculate the real-time risk rate; generate a warning signal according to the real-time risk rate. When the risk rate exceeds the preset threshold, trigger an emergency resource scheduling instruction.
2. The power grid security margin prediction and risk assessment method according to claim 1, wherein In step (1), the data cleaning fills the missing data through the missing value processing method and uses the outlier detection technology to identify and eliminate the outlier data.
3. The power grid security margin prediction and risk assessment method according to claim 1, characterized in that The standardization processing in step (2) is as follows: The maximum absolute value scaling method is used to normalize the daily data and the hourly data respectively, and each feature value is scaled to the interval [-1, 1]. The formula is as follows: Among them, X is the original eigenvalue, and X norm is the eigenvalue after normalization.
4. The method for predicting power grid safety margin and risk assessment according to claim 1, wherein The structure of the double-layer LSTM network in step (3) is: the number of LSTM units in the first layer is 64, the number of LSTM units in the second layer is 32, and a Dropout layer is inserted between the layers; When training the double-layer LSTM network model, input the normalized daily or hourly data into the model. After passing through multiple LSTM units and the Dropout layer, output the predicted value of the power grid safety margin. The training objective of the model is to minimize the mean square error. The formula is as follows: where n is the number of samples, and y i is the actual safety margin, is the safety margin predicted by the double-layer LSTM model.
5. The power grid security margin prediction and risk assessment method according to claim 1, characterized in that In step (4), the residual correction uses the XGBoost model to correct the residuals of the double-layer LSTM, and calculate the residuals of the double-layer LSTM model: Take the residuals as the regression target of XGBoost, use the XGBoost model to model and correct the residuals, and obtain the comprehensive predicted value: Among them, is the correction result of the XGBoost model for the residuals.
6. The power grid security margin prediction and risk assessment method according to claim 1, characterized in that The calculation formula of the real-time risk rate in step (5) is: Among them, is an indicator function, which takes the value of 1 when the condition is satisfied and 0 otherwise.
7. A power grid security margin prediction and risk assessment system based on a double-layer LSTM-XGBoost model, characterized in that, It includes: Data acquisition module: used to access the daily and hourly operation data streams of the power grid SCADA system in real time; Prediction module: Deploy double-layer LSTM daily and hourly prediction models to output the predicted results of the safety margin; Residual correction module: Integrate the XGBoost model to dynamically correct the prediction residuals; Risk assessment module: Calculate the real-time risk rate in the next 24 hours and generate a visual risk heat map; Warning execution module: Trigger resource scheduling or operation and maintenance intervention instructions according to the risk rate threshold.
8. The power grid security margin prediction and risk assessment system according to claim 7, characterized in that The visual risk heat map maps the hourly predicted value, the daily prediction benchmark value, and the risk rate into a color gradient, and combines with the geographic information system to display the risk distribution of the power grid nodes.
9. A computer device, characterized in that, Comprising one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and when the program is executed by the processor, the steps of the method for predicting power grid security margin and risk assessment as described in any one of claims 1-6 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, the steps of the method for predicting power grid security margin and risk assessment as described in any one of claims 1-6 are implemented.
Citation Information
Cited By
Method and system for predicting daily blood collection amount of blood collection and supply based on residual learning and fusion
CN122364827A
Blood collection quantity prediction method and system based on residual learning and fusion
CN122364827B