Power system transient stability state and stability margin evaluation method and device based on graphormer multi-task learning, equipment and medium
By using the Graphormer multi-task learning method to generate standardized features and train the model, the problem of low cost and high accuracy in transient stability assessment under power system topology changes is solved, ensuring the safe and stable operation of the power system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHANGSHA UNIVERSITY OF SCIENCE AND TECHNOLOGY
- Filing Date
- 2025-08-15
- Publication Date
- 2026-07-14
AI Technical Summary
With a high proportion of new energy sources integrated into the power system, existing technologies struggle to achieve low-cost, high-accuracy transient stability assessments under conditions of frequent topology changes. Frequent updates to existing models lead to high computational costs, and machine learning models suffer from poor accuracy.
The Graphormer multi-task learning method is adopted. Node and edge features are generated by a pre-set time-domain simulation tool. An initial model is built using a global attention mechanism, graph position encoding and feedforward neural network. The model is trained by combining binary classification and regression labels to generate standardized features. The model is optimized using a multi-task loss function to evaluate the transient stability state and stability margin of the power system.
It enables low-cost and highly accurate assessment of the transient stability state and stability margin of power systems under topology changes, ensuring the safe and stable operation of power systems.
Smart Images

Figure CN121093874B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of power technology, and in particular to a method, apparatus, equipment, and medium for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning. Background Technology
[0002] With the high proportion of renewable energy integration, the power system exhibits significant "high-voltage" and "high-stability" characteristics, with stability approaching the critical point of imbalance. Transient instability caused by power system faults is the dominant factor in large-scale power outages, posing a significant challenge to the stable operation of the power system. Online safety and stability early warning is an important measure to ensure the safe and stable operation of the power system. Currently, there is an urgent need to conduct research on data-driven power system transient stability assessment with high accuracy, strong generalization, and high timeliness.
[0003] Currently, data-driven transient stability assessment has reached a saturation point in terms of accuracy. However, the large-scale integration of high-proportion renewable energy sources leads to frequent changes in power system topology, resulting in a massive sample space for transient stability assessment. Research on transient stability assessment that adapts to topology changes still needs breakthroughs. Existing technologies include transient stability assessment training frameworks based on active transfer learning, which efficiently update the model through active learning and transfer learning. However, frequent model updates still incur high computational costs. Additionally, there are methods based on K-means clustering (i.e., the K-means clustering algorithm) and MultiRocket (a time series classification tool) to cluster generator transient voltage / power angle and extract key features to adapt to transfer between different topologies, but the accuracy of these machine learning models is unsatisfactory.
[0004] As can be seen from the above, how to achieve transient stability assessment at low cost and with high accuracy while adapting to topological changes is an urgent problem to be solved. Summary of the Invention
[0005] In view of this, the purpose of this invention is to provide a method, apparatus, device, and medium for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning, which can achieve transient stability evaluation at low cost and with high accuracy while adapting to topology changes. The specific solution is as follows:
[0006] Firstly, this application provides a method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning, including:
[0007] Based on a preset time-domain simulation tool, node features corresponding to the bus in the power system under the target fault scenario are generated, and edge features related to transmission lines and transformer branches are generated. The node features and edge features are then standardized to obtain standardized features. The node features include the voltage amplitude, voltage phase angle, injected active power, injected reactive power, and electrical frequency of the bus, and the edge features include the current amplitude and current phase angle of the transmission lines and transformer branches.
[0008] The transient stability result is determined based on the power angle difference between each generator after the fault occurs, and the transient stability result is used to determine the binary classification label. The transient stability margin is determined based on the difference between the rotor angle trajectory and the inertia center trajectory of the generator within the preset fault duration, and the transient stability margin is used to determine the regression label.
[0009] An initial Graphormer multi-task learning model is constructed using a global attention mechanism, graph position encoding, a feedforward neural network, a pre-defined classifier, and a pre-defined regressor. This initial model is then trained using the standardized features, the binary classification labels, and the regression labels to obtain a trained Graphormer multi-task learning model. The trained model is then evaluated based on a multi-task loss function to determine the target Graphormer multi-task learning model. The multi-task loss function includes a pre-defined classification loss function and a pre-defined regression loss function.
[0010] Based on the real-time operating status of the power grid, corresponding real-time operating data is obtained, and based on the real-time operating data and the target Graphormer multi-task learning model, the transient stability state of the power system and the corresponding transient stability margin are determined.
[0011] Optionally, the step of generating node features of the power system corresponding to the bus in the target fault scenario based on a preset time-domain simulation tool, and generating edge features related to transmission lines and transformer branches, includes:
[0012] The target fault scenario corresponding to the power system is simulated using a preset time-domain simulation tool. Based on the target fault scenario and the preset acquisition frequency, the node features of the bus corresponding to the bus and the edge features related to the transmission line and transformer branch are collected before, during and after the target fault.
[0013] The target fault scenario includes the transmission line meeting preset topology change conditions, the fault type being a three-phase metallic ground fault, the load change range being within a preset change range, the voltage corresponding to the bus being within a preset voltage range, and the fault location being at the target location of the transmission line.
[0014] Optionally, the standardization of the node features and the edge features to obtain standardized features includes:
[0015] Determine the first mean and first standard deviation corresponding to the node features, and determine the standardized node features corresponding to the node features based on the first mean and first standard deviation;
[0016] Determine the second mean and the second standard deviation corresponding to the edge feature, and determine the standardized edge feature corresponding to the edge feature based on the second mean and the second standard deviation;
[0017] Standardized features are determined based on the standardized node features and the standardized edge features.
[0018] Optionally, the step of determining transient stability results based on the power angle difference between generators after a fault occurs, determining binary labels using the transient stability results, determining transient stability margins based on the difference between the rotor angular trajectory and the inertia center trajectory of the generators within a preset fault duration, and determining regression labels using the transient stability margins includes:
[0019] The target power angle difference is determined based on the power angle difference between each generator after the fault occurs, and it is determined whether the target power angle difference is greater than a preset power angle difference threshold.
[0020] If the target power angle difference is greater than the preset power angle difference threshold, the transient stability result of the power system is determined to be unstable.
[0021] If the target power angle difference is not greater than the preset power angle difference threshold, the transient stability result of the power system is determined to be stable, and a binary label is determined based on each transient stability result.
[0022] The deviation of the rotor angle of each generator relative to the center of inertia is determined by integrating the difference between the rotor angle trajectory and the trajectory of the center of inertia of the generator within a preset fault duration.
[0023] The deviation values are normalized to obtain transient stability margins, and regression labels are determined based on each transient stability margin.
[0024] Optionally, the construction of the initial Graphormer multi-task learning model using a global attention mechanism, graph position encoding, feedforward neural network, preset classifier, and preset regressor includes:
[0025] An input matrix is constructed based on the node features and edge features in the standardized features. The query matrix, key matrix, and value matrix are determined using the input matrix and a preset linear transformation matrix. The preset linear transformation matrix is a matrix obtained based on the standardized features and through backpropagation learning using a deep learning model.
[0026] The busbar is used as a node, and the transmission line or the transformer branch is used as an edge to construct a preset graph structure. The shortest path distance between any two nodes in the preset graph structure is determined, and the spatial code is determined based on the shortest path distance and a preset coding function.
[0027] Each node pair is determined based on each node, and feature extraction is performed using the set of edges on the shortest path of each node pair to obtain target edge features. The target edge features are then weighted and summed to determine the edge encoding.
[0028] Based on the spatial encoding and the edge encoding, a graph structure encoding corresponding to the preset graph structure is determined;
[0029] An initial attention score is determined using the query matrix and the key matrix, and the initial attention score is corrected based on graph structure encoding to obtain a corrected attention score;
[0030] The attention weight matrix is determined using the corrected attention score and the normalized exponential function, and the single-head attention output result is determined based on the attention weight matrix.
[0031] The single-head attention output results are concatenated to obtain a multi-head attention output result. The multi-head attention output result is then input into a feedforward neural network to obtain feature enhancement data. Layer normalization and residual connection operations are performed on the feature enhancement data to obtain the connected features.
[0032] The concatenated features are input into the preset classifier and the preset regressor respectively to obtain the classifier output and the regressor output. An initial Graphormer multi-task learning model is constructed based on the classifier output and the regressor output.
[0033] Optionally, the step of training the initial Graphormer multi-task learning model using the standardized features, the binary classification labels, and the regression labels to obtain a trained Graphormer multi-task learning model, and evaluating the trained Graphormer multi-task learning model based on the multi-task loss function to determine the target Graphormer multi-task learning model using the evaluation results, includes:
[0034] The standardized features are divided according to a preset division ratio to obtain a training set, a test set, and a validation set. The initial Graphormer multi-task learning model is then trained using the training set to obtain a trained Graphormer multi-task learning model.
[0035] The multi-task loss function is determined using the cross-entropy loss function and the mean squared error loss function, and the weights corresponding to the multi-task loss function are adjusted based on the homoscedasticity uncertainty method to obtain the target loss function.
[0036] The trained Graphormer multi-task learning model is evaluated based on the target loss function and target evaluation metric, using the test set and the validation set. Based on the evaluation results, the process jumps to the step of training the initial Graphormer multi-task learning model using the training set to obtain the target Graphormer multi-task learning model.
[0037] Optionally, the step of acquiring corresponding real-time operating data based on the real-time operating status of the power grid, and determining the transient stable state and corresponding transient stability margin of the power system based on the real-time operating data and using the target Graphormer multi-task learning model, includes:
[0038] Based on the real-time operating status of the power grid and using preset measurement tools to acquire real-time operating data, the voltage amplitude, phase angle, injected active power and reactive power in the real-time operating data are standardized to obtain model input data;
[0039] The model input data is input into the target Graphormer multi-task learning model to obtain transient stability or transient instability and the corresponding degree of transient stability or transient instability.
[0040] Secondly, this application provides a device for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning, comprising:
[0041] The feature generation module is used to generate node features corresponding to the bus in the power system under the target fault scenario based on a preset time-domain simulation tool, and to generate edge features related to transmission lines and transformer branches. The node features and edge features are then standardized to obtain standardized features. The node features include the voltage amplitude, voltage phase angle, injected active power, injected reactive power, and electrical frequency of the bus. The edge features include the current amplitude and current phase angle of the transmission lines and transformer branches.
[0042] The label determination module is used to determine the transient stability result based on the power angle difference between each generator after the fault occurs, and to determine the binary label using the transient stability result. It also determines the transient stability margin based on the difference between the rotor angular trajectory and the inertia center trajectory of the generator within a preset fault duration, and determines the regression label using the transient stability margin.
[0043] The target model determination module is used to construct an initial Graphormer multi-task learning model using a global attention mechanism, graph position encoding, a feedforward neural network, a preset classifier, and a preset regressor. The initial Graphormer multi-task learning model is then trained using the standardized features, the binary classification labels, and the regression labels to obtain a trained Graphormer multi-task learning model. Finally, the trained Graphormer multi-task learning model is evaluated based on a multi-task loss function to determine the target Graphormer multi-task learning model. The multi-task loss function includes a preset classification loss function and a preset regression loss function.
[0044] The stability margin determination module is used to acquire corresponding real-time operating data based on the real-time operating status of the power grid, and determine the transient stability state and corresponding transient stability margin of the power system based on the real-time operating data and the target Graphormer multi-task learning model.
[0045] Thirdly, this application provides an electronic device, comprising:
[0046] Memory, used to store computer programs;
[0047] A processor is used to execute the computer program to implement the aforementioned method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning.
[0048] Fourthly, this application provides a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning.
[0049] This application generates node features corresponding to the bus in a power system under a target fault scenario based on a preset time-domain simulation tool, and generates edge features related to transmission lines and transformer branches. The node features and edge features are then standardized to obtain standardized features. The node features include the voltage amplitude, voltage phase angle, injected active power, injected reactive power, and electrical frequency of the bus. The edge features include the current amplitude and current phase angle of the transmission lines and transformer branches. Transient stability results are determined based on the power angle difference between generators after the fault occurs, and binary classification labels are determined using these transient stability results. Transient stability margins are determined based on the difference between the generator rotor angular trajectory and the inertia center trajectory within a preset fault duration, and regression labels are determined using these transient stability margins. Global attention mechanisms, graph position encoding, and feedforward neural networks are utilized. An initial Graphormer multi-task learning model is constructed using a pre-defined classifier and a pre-defined regressor. This initial model is then trained using the standardized features, the binary classification labels, and the regression labels to obtain a trained Graphormer multi-task learning model. The trained model is then evaluated based on a multi-task loss function to determine a target Graphormer multi-task learning model. The multi-task loss function includes a pre-defined classification loss function and a pre-defined regression loss function. Real-time operating data is obtained based on the real-time operating status of the power grid. Based on this real-time operating data and the target Graphormer multi-task learning model, the transient stability state of the power system and the corresponding transient stability margin are determined.
[0050] As can be seen from the above, this application generates node features corresponding to the power system bus and edge features corresponding to transmission lines and transformer branches under topology changes using a preset time-domain simulation tool. The node and edge features are then standardized to ensure that the data input to the model has a consistent scale and distribution, avoiding adverse effects on model training caused by differences in the dimensions of different features. Next, the transient stability result is determined based on the power angle difference between generators after a fault occurs, and a binary classification label is generated. The classification label can clearly determine whether the system is stable. Finally, the transient stability margin is determined based on the difference between the generator's rotor angular trajectory and the inertia center trajectory within a preset fault duration, and a regression label is generated. The regression label can quantify the stability of the power system. Then, an initial Graphormer multi-task learning model is constructed using a global attention mechanism, graph position encoding, a feedforward neural network, a pre-defined classifier, and a pre-defined regressor. This model is trained using standardized features, binary labels, and regression labels. The global attention mechanism allows the model to focus on the important relationships between different nodes and edges, graph position encoding helps the model understand the positional information of nodes, and the feedforward neural network further performs nonlinear transformations on the standardized features. Through joint training, the model can better capture various patterns and features related to the transient stability of the power system. The trained model is evaluated based on a multi-task loss function to obtain the target Graphormer multi-task learning model. In this way, inputting real-time operating data into the target Graphormer multi-task learning model can more accurately and comprehensively assess the transient stability state and corresponding transient stability margin of the power system, ensuring the safe and stable operation of the power system. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0052] Figure 1 This is a flowchart of a method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning disclosed in this application;
[0053] Figure 2 This application discloses a specific method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning.
[0054] Figure 3 This is a schematic diagram of an initial Graphormer multi-task learning model architecture disclosed in this application;
[0055] Figure 4 This is a schematic diagram illustrating the accuracy of one of the different models disclosed in this application;
[0056] Figure 5 This is a schematic diagram of the evaluation indicators of a different model disclosed in this application;
[0057] Figure 6 This is a schematic diagram of the evaluation indicators for another different model disclosed in this application;
[0058] Figure 7 This is a schematic diagram of the mean square error of one of the different models disclosed in this application;
[0059] Figure 8 This is a schematic diagram of the structure of a power system transient stability state and stability margin assessment device based on Graphormer multi-task learning disclosed in this application;
[0060] Figure 9 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0061] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0062] Currently, existing technologies rely on active transfer learning-based transient stability assessment training frameworks, which efficiently update models through active learning and transfer learning. However, frequent model updates still incur high computational costs. Therefore, this application provides a method for assessing the transient stability state and stability margin of power systems based on Graphormer multi-task learning. By inputting real-time operating data into the target Graphormer multi-task learning model, it can more accurately and comprehensively assess the transient stability state and corresponding transient stability margin of the power system, thereby ensuring the safe and stable operation of the power system.
[0063] See Figure 1 As shown, this invention discloses a method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning, comprising:
[0064] Step S11: Generate node features of the power system corresponding to the bus under the target fault scenario based on a preset time-domain simulation tool, and generate edge features related to transmission lines and transformer branches. Standardize the node features and edge features to obtain standardized features. The node features include the voltage amplitude, voltage phase angle, injected active power, injected reactive power and electrical frequency of the bus. The edge features include the current amplitude and current phase angle of the transmission lines and transformer branches.
[0065] This embodiment focuses on the power system corresponding to the IEEE 39-node system, and uses a preset time-domain simulation tool to simulate the target fault scenario corresponding to the power system. In one specific implementation, the preset time-domain simulation tool is used to set a target fault scenario: 1 to 5 transmission lines are randomly disconnected, the fault type is set as a three-phase metallic ground fault, the load level varies from 80% to 120%, the bus voltage is maintained within the range of 0.95 to 1.05 pu, and fault points are set at 2%, 50%, and 98% of the transmission line's starting point, with fault durations of 0.1s, 0.15s, 0.2s, and 0.25s respectively, and the fault occurrence time is 0.02s, for a total simulation duration of 15s. Then, at a preset acquisition frequency of 100Hz, the node characteristics of the power grid bus corresponding to the bus before, during, and after the target fault, as well as the edge characteristics related to the transmission lines and transformer branches, are collected. The node characteristics include time-series data corresponding to voltage amplitude, voltage phase angle, injected active power, injected reactive power, and electrical frequency. The edge characteristics include time-series data corresponding to the current amplitude and current phase angle of the transmission lines and transformer branches.
[0066] Specifically, the step of generating node features of the power system corresponding to the bus in the target fault scenario based on a preset time-domain simulation tool, and generating edge features related to transmission lines and transformer branches, includes: simulating the target fault scenario corresponding to the power system using a preset time-domain simulation tool, and collecting node features of the bus corresponding to the bus before, during, and after the target fault, as well as edge features related to transmission lines and transformer branches, based on the target fault scenario and a preset acquisition frequency; wherein, the target fault scenario includes the transmission line satisfying preset topology change conditions, the fault type being a three-phase metallic ground fault, the load change range being within a preset change range, the voltage corresponding to the bus being within a preset voltage range, and the fault location being at the target location of the transmission line.
[0067] It is understandable that after obtaining the node features and edge features, Z-score standardization is performed on both the node features and the edge features. The corresponding formula for standardization is as follows:
[0068] ;
[0069] in, Features In time The corresponding original feature values; To Standardized feature values obtained through standardization; Features The mean at all time points; Features The corresponding standard deviation. The mean. The corresponding formula is as follows:
[0070] ;
[0071] in, Features In time In one specific implementation, the corresponding original feature value can be the temporal data corresponding to the edge feature. The formula corresponding to the standard deviation is as follows:
[0072] ;
[0073] in, Features In time The corresponding original feature values; The mean is given. After standardizing the node features and edge features respectively, the original feature values can be converted into a standard normal distribution with a mean of 0 and a standard deviation of 1.
[0074] Specifically, the standardization of the node features and the edge features to obtain standardized features includes: determining a first mean and a first standard deviation corresponding to the node features, and determining standardized node features corresponding to the node features based on the first mean and the first standard deviation; determining a second mean and a second standard deviation corresponding to the edge features, and determining standardized edge features corresponding to the edge features based on the second mean and the second standard deviation; and determining standardized features based on the standardized node features and the standardized edge features.
[0075] Step S12: Determine the transient stability result based on the power angle difference between each generator after the fault occurs, and use the transient stability result to determine the binary classification label. Determine the transient stability margin based on the difference between the rotor angle trajectory and the inertia center trajectory of the generator within the preset fault duration, and use the transient stability margin to determine the regression label.
[0076] In this embodiment, the power angle of the generator can directly reflect the safe and stable state of the power system. Therefore, the target power angle difference is determined based on the maximum power angle difference of each generator after the fault occurs. The formula corresponding to the target power angle difference is as follows:
[0077] ;
[0078] in, The maximum generator power angle difference; The duration of the time-domain simulation; In order to be in Time of the first The power angle of the generator; In order to be in Time of the first The power angle of the generator. In one specific implementation, if the target power angle difference exceeds 360 degrees, the transient stability result of the power system is determined to be unstable; otherwise, the transient stability result of the power system is determined to be unstable. Then, a binary classification label is determined based on each transient stability result. In order to quantify the stability of the power system, the difference between the rotor angular trajectory and the inertia center trajectory of the generator during the fault occurrence period (within the time domain simulation duration) is determined, and the corresponding formula is as follows:
[0079] ;
[0080] in, This represents the deviation of the generator rotor angle from the center of inertia. This refers to the rotor angle of a single generator. This is the rotor angle at the center of inertia, i.e., the trajectory of the center of inertia; It is the inertia constant; q represents the time-domain simulation duration; q represents the number of generators. After obtaining the deviation value, the deviation value is normalized. The normalization formula is as follows:
[0081] ;
[0082] in, The deviation value; The maximum value among the deviation values; This is the minimum value among the deviations. The transient stability margin index is obtained. Subsequently, the regression labels are determined based on the transient stability margins described above, wherein, The closer a value is to 1, the higher the stability margin; the closer it is to 0, the closer it is to instability.
[0083] Specifically, the process of determining transient stability results based on the power angle difference between generators after a fault occurs, determining binary labels using the transient stability results, determining transient stability margins based on the difference between the generator rotor angle trajectory and the inertia center trajectory within a preset fault duration, and determining regression labels using the transient stability margins includes: determining a target power angle difference based on the power angle difference between generators after a fault occurs, and determining whether the target power angle difference is greater than a preset power angle difference threshold; if the target power angle difference is greater than the preset power angle difference threshold, the transient stability result of the power system is determined to be unstable; if the target power angle difference is not greater than the preset power angle difference threshold, the transient stability result of the power system is determined to be stable, and binary labels are determined based on each transient stability result; the deviation value of the rotor angle of each generator relative to the inertia center is determined based on the integral of the difference between the generator rotor angle trajectory and the inertia center trajectory within a preset fault duration; the deviation value is normalized to obtain a transient stability margin, and regression labels are determined based on each transient stability margin.
[0084] Step S13: Construct an initial Graphormer multi-task learning model using a global attention mechanism, graph position encoding, feedforward neural network, preset classifier, and preset regressor. Train the initial Graphormer multi-task learning model using the standardized features, the binary classification labels, and the regression labels to obtain a trained Graphormer multi-task learning model. Evaluate the trained Graphormer multi-task learning model based on a multi-task loss function to determine the target Graphormer multi-task learning model using the evaluation results. The multi-task loss function includes a preset classification loss function and a preset regression loss function.
[0085] In this embodiment, the global attention mechanism of the Graphormer model (a deep learning model for graph-structured data modeling) is used to perform deep processing on the node features and edge features in the normalized features, that is, to construct an input matrix based on the node features and edge features in the normalized features. ,in, For the number of nodes, The feature dimension corresponding to each node; based on the standardized features and using a deep learning model backpropagation to learn and determine the preset linear transformation matrix. , , Then, the input matrix and the preset linear transformation matrix are used for mapping to obtain the query matrix Q, the key matrix K, and the value matrix V; the query matrix Q, the key matrix K, and the value matrix V are then split into single-head sub-matrices, i.e. , , The initial attention score for each single-head submatrix is determined. The corresponding formula is as follows:
[0086] ;
[0087] in, The dimensions of the query matrix and the key matrix; This is the transpose of the key matrix. After obtaining the attention score, the attention weights are determined based on the initial attention score, using the following formula:
[0088] ;
[0089] in, For query matrix; For the Softmax function; The initial attention score is used; the single-head attention output result is determined based on the attention weight, and the corresponding formula is as follows:
[0090] ;
[0091] in, The attention weights; The value matrix is used. After obtaining the single-head attention output results, the single-head attention output results are concatenated to obtain the multi-head attention output results, and the corresponding formula is as follows:
[0092] ;
[0093] in, Output results for multi-head attention; This refers to the `concat` function, which is a join function. This refers to the output result of the single-head attention; To be related to the preset linear transformation matrix , , Similarly, a linear transformation matrix is obtained.
[0094] Understandably, by using the busbar as a node and the transmission line or transformer branch as an edge, a preset graph structure is constructed. The shortest path distance (SPD) between any two nodes in the preset graph structure is determined, and then a preset encoding function is defined. ,like The value corresponding to the spatial encoding is Otherwise, it is -1, where, The target path threshold can be adjusted based on actual conditions. A node pair consists of two bus nodes. Edge encoding focuses on the edges along the shortest path of a given node pair. The weighted dot product of the features of all edges along the shortest path is then averaged to obtain the edge code. The specific calculation formula is as follows:
[0095] ;
[0096] in, For node pairs The edge encoding results between them; This represents the total number of edges along the shortest path. For the edge Features; For the edge Learnable weight vectors; This represents the total number of edges along the shortest path.
[0097] Furthermore, after obtaining the spatial encoding and the edge encoding, a graph structure encoding corresponding to the preset graph structure is determined based on the spatial encoding and the edge encoding. The spatial encoding is assigned a learnable scalar to serve as a bias term in the self-attention mechanism. That is, the first bias term, and the side encoding is used as another bias term in the self-attention mechanism, namely the second bias term.
[0098] In this embodiment, after obtaining the first bias term and the second bias term, the initial attention score is modified to obtain the corrected attention score, and the corresponding formula is as follows:
[0099] ;
[0100] in, For the nodes in the query-key dot product matrix A and Attention score; , The preset linear transformation matrix; , For nodes , Characteristic representations (such as bus voltage); This is the first bias term; This is the second bias term; The scaling factor is used to determine the dimension. After obtaining the corrected attention score, the target multi-head attention output is obtained, which is a new feature representation that integrates the global association information of nodes.
[0101] Understandably, a feedforward neural network (FNN) is used to perform a node-by-node nonlinear transformation on the target multi-head attention output. This feedforward neural network consists of two fully connected layers. The first layer maps the features of the target multi-head attention output to a higher dimension, and then activates it using ReLU (Rectified Linear Unit) to enhance its expressive power. The second layer maps it back to the original dimension. The corresponding formula is as follows:
[0102] ;
[0103] in, The output of the neural network, i.e., the feature enhancement data; It is a linear rectified function; , This is the learnable weight matrix of the feedforward neural network layer; , This is a bias term used for feature transformation in the fully connected layer. After obtaining the feature enhancement data, layer normalization is performed on the feature enhancement data, and the corresponding formula is as follows:
[0104] ;
[0105] in, The mean of the input features, i.e., the mean of the feature enhancement data; The number of neurons in each layer; The first of the input features dimension; The standard deviation of the input features; The decimal part is set to prevent the denominator from being 0; , These are learnable parameters.
[0106] Furthermore, after obtaining the layer normalization output result, the layer normalization output result is input into the residual connection structure, and the corresponding formula is as follows:
[0107] ;
[0108] ;
[0109] in, The standardized features; Output the multi-head attention result for the target; For layer normalization operation; The output of the neural network is the feature enhancement data; This is the output result of the first residual connection, i.e., the output result of the first residual connection. The second residual connection output result, i.e. the target residual connection output result, is used in this embodiment as a three-layer Graphormer. The process described above and the target residual connection output result of the first layer Graphormer are performed three times to obtain the target loop output result. The target loop output result is then input into the preset classifier and the preset regressor to obtain the classification result of transient stability and the regression result of transient stability margin. Based on the classification result and the output result, the initial Graphormer multi-task learning model is constructed.
[0110] Specifically, the construction of the initial Graphormer multi-task learning model using a global attention mechanism, graph position encoding, feedforward neural network, preset classifier, and preset regressor includes: constructing an input matrix based on the node features and edge features in the standardized features; determining the query matrix, key matrix, and value matrix using the input matrix and a preset linear transformation matrix; the preset linear transformation matrix is a matrix obtained by backpropagation learning based on the standardized features using a deep learning model; constructing a preset graph structure by using the bus as a node and the transmission line or transformer branch as an edge; determining the shortest path distance between any two nodes in the preset graph structure; determining the spatial encoding based on the shortest path distance and a preset encoding function; determining node pairs based on each node; extracting features using the set of edges on the shortest path of each node pair to obtain target edge features; and performing a weighted summation of the target edge features to determine the edge. The process involves: encoding; determining a graph structure encoding corresponding to the preset graph structure based on the spatial encoding and the edge encoding; determining an initial attention score using the query matrix and the key matrix, and correcting the initial attention score based on the graph structure encoding to obtain a corrected attention score; determining an attention weight matrix using the corrected attention score and a normalized exponential function, and determining a single-head attention output result based on the attention weight matrix; concatenating the single-head attention output results to obtain a multi-head attention output result, inputting the multi-head attention output result into a feedforward neural network to obtain feature enhancement data, and performing layer normalization and residual connection operations on the feature enhancement data to obtain concatenated features; inputting the concatenated features into the preset classifier and the preset regressor respectively to obtain the classifier output result and the regressor output result, and constructing an initial Graphormer multi-task learning model based on the classifier output result and the regressor output result.
[0111] In this embodiment, after obtaining the initial Graphormer multi-task learning model, the standardized features are divided according to a preset partitioning ratio to obtain a training set, a test set, and a validation set. The initial Graphormer multi-task learning model is then trained using the training set to obtain a trained Graphormer multi-task learning model. Next, a loss function for multi-task learning is defined. The trained Graphormer multi-task learning model contains two types of tasks: classification and regression. The initial total loss function is defined as follows:
[0112] ;
[0113] in, The number of samples corresponding to the standardized feature; The number of tasks corresponding to multi-task learning; For the first Standardized features corresponding to each sample; For the first The corresponding sample of the th sample Task tags; For the first Prediction function for each task; To enable multi-task sharing of model parameters; For task-related model parameters; For the task Learnable weight coefficients; This is the loss function.
[0114] Understandably, because the loss functions for these two types of tasks (cross-entropy loss function for classification tasks and mean squared error loss function for regression tasks) cannot be directly added due to their large scale differences, the homoscedastic uncertainty method is introduced to quantify the uncertainty between tasks. Its core assumption is that the model's prediction uncertainty for the input data remains constant across different tasks. By introducing a learnable task variance parameter, the loss functions of each task are weighted and harmonicly summed. The total loss function represents the loss of each task divided by the corresponding variance parameter, with an additional log-variance regularization term to prevent the variance from infinitely decreasing. Therefore, the target loss function formula is as follows:
[0115] ;
[0116] in, and For variance; The cross-entropy loss function; The target loss function is the mean squared error. After obtaining the target loss function, the parameters are optimized during the training of the initial Graphormer multi-task learning model based on the target loss function to improve the accuracy and robustness of the model's inference.
[0117] In addition, based on the confusion matrix The classification results of the model are comprehensively evaluated using accuracy, F1 score, precision, and recall. The formulas for calculating accuracy, F1 score, precision, and recall are as follows:
[0118] ;
[0119] ;
[0120] ;
[0121] ;
[0122] in, The overall prediction accuracy of the trained Graphormer multi-task learning model; It is the harmonic mean of precision and recall, which measures the overall performance of the model; For accuracy, that is, the recognition accuracy corresponding to stable samples; Recall rate, which is the coverage rate of identifying unstable samples; For actual stability, the model predicts the number of samples that are stable. For actual stability, the model predicts the number of samples that will become unstable. The actual instability is represented by the model's prediction of the number of samples that are instable. The model predicts a stable number of samples to represent the actual instability. Then, a grid search is used to traverse different combinations of hyperparameters to optimize model accuracy, including the number of iterations, batch size, learning rate, number of Graphermer layers, hidden layers in the classifier's fully connected layers and the regressor's fully connected layers, and dropout probability. The model is then evaluated using the validation set, and the combination with the best validation set metrics is selected as the target combination. Based on this target combination, the target evaluation metric, and the target loss function, the trained Graphermer multi-task learning model is evaluated. Based on the evaluation results, the process jumps to the step of training the initial Graphermer multi-task learning model using the training set to obtain the target Graphermer multi-task learning model.
[0123] Specifically, the step of training the initial Graphormer multi-task learning model using the standardized features, the binary classification labels, and the regression labels to obtain a trained Graphormer multi-task learning model, and evaluating the trained Graphormer multi-task learning model based on the multi-task loss function to determine the target Graphormer multi-task learning model using the evaluation results, includes: dividing the standardized features based on a preset partitioning ratio to obtain a training set, a test set, and a validation set; training the initial Graphormer multi-task learning model using the training set to obtain a trained Graphormer multi-task learning model; determining a multi-task loss function using the cross-entropy loss function and the mean squared error loss function, and adjusting the weights corresponding to the multi-task loss function based on the homoscedasticity uncertainty method to obtain a target loss function; evaluating the trained Graphormer multi-task learning model based on the target loss function and the target evaluation index using the test set and the validation set; and based on the evaluation results, proceeding to the step of training the initial Graphormer multi-task learning model using the training set to obtain the target Graphormer multi-task learning model.
[0124] Step S14: Obtain the corresponding real-time operating data based on the real-time operating status of the power grid, and determine the transient stability state and corresponding transient stability margin of the power system based on the real-time operating data and the target Graphormer multi-task learning model.
[0125] In this embodiment, based on the real-time operating status of the power grid and using measurement devices such as PMUs (Phasor Measurement Units), actual operating data is acquired. The voltage amplitude, phase angle, injected active power, and reactive power data within the actual operating data are standardized to obtain model input data. This model input data is then input into the target Graphormer multi-task learning model to obtain transient stability or transient instability, and the corresponding degree of transient stability or instability. Specifically, the process of acquiring corresponding real-time operating data based on the real-time operating status of the power grid, and determining the transient stability state and corresponding transient stability margin of the power system based on the real-time operating data and the target Graphormer multi-task learning model, includes: acquiring real-time operating data based on the real-time operating status of the power grid and using preset measurement tools; standardizing the voltage amplitude, phase angle, injected active power, and reactive power in the real-time operating data to obtain model input data; and inputting the model input data into the target Graphormer multi-task learning model to obtain transient stability or transient instability, and the corresponding degree of transient stability or instability.
[0126] As can be seen from the above, this application generates node features corresponding to the power system bus and edge features corresponding to transmission lines and transformer branches under topology changes using a preset time-domain simulation tool. The node and edge features are then standardized to ensure that the data input to the model has a consistent scale and distribution, avoiding adverse effects on model training caused by differences in the dimensions of different features. Next, the transient stability result is determined based on the power angle difference between generators after a fault occurs, and a binary classification label is generated. The classification label can clearly determine whether the system is stable. Finally, the transient stability margin is determined based on the difference between the generator's rotor angular trajectory and the inertia center trajectory within a preset fault duration, and a regression label is generated. The regression label can quantify the stability of the power system. Then, an initial Graphormer multi-task learning model is constructed using a global attention mechanism, graph position encoding, a feedforward neural network, a pre-defined classifier, and a pre-defined regressor. This model is trained using standardized features, binary labels, and regression labels. The global attention mechanism allows the model to focus on the important relationships between different nodes and edges, graph position encoding helps the model understand the positional information of nodes, and the feedforward neural network further performs nonlinear transformations on the standardized features. Through joint training, the model can better capture various patterns and features related to the transient stability of the power system. The trained model is evaluated based on a multi-task loss function to obtain the target Graphormer multi-task learning model. In this way, inputting real-time operating data into the target Graphormer multi-task learning model can more accurately and comprehensively assess the transient stability state and corresponding transient stability margin of the power system, ensuring the safe and stable operation of the power system.
[0127] As can be seen from the above embodiments, this application constructs a target Graphormer multi-task learning model based on a global attention mechanism, graph position encoding, and feedforward neural network to evaluate the transient stability state and transient stability margin of the power system. Therefore, the process of constructing a target Graphormer multi-task learning model based on a global attention mechanism, graph position encoding, and feedforward neural network is described.
[0128] See Figure 2 As shown, this invention discloses a specific method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning, including:
[0129] In this embodiment, a transient time-domain simulation is first performed using a preset time-domain simulation tool to simulate a target fault scenario corresponding to the power system. Based on the target fault scenario and a preset acquisition frequency, the node features of the bus corresponding to the bus before, during, and after the target fault, as well as the edge features related to the transmission line and transformer branch, are collected. The node features and edge features are then Z-score standardized to obtain standardized features. Then, based on the power angle difference between each generator after the fault occurs, a target power angle difference is determined, and it is determined whether the target power angle difference is greater than a preset power angle difference threshold. If the target power angle difference is greater than the preset power angle difference threshold, the transient stability result of the power system is determined to be unstable. If the target power angle difference is not greater than the preset power angle difference threshold, the transient stability result of the power system is determined to be stable, and a binary label is determined based on each transient stability result. The deviation value of the rotor angle of each generator relative to the inertia center is determined based on the integral of the difference between the rotor angle trajectory and the inertia center trajectory of the generator within a preset fault duration. The deviation value is normalized to obtain the transient stability margin, and a regression label is determined based on each transient stability margin.
[0130] Understandably, the global attention mechanism of the Graphermer model is used to perform deep processing on the node and edge features in the standardized features. Specifically, an input matrix is constructed based on the node and edge features in the standardized features. A preset linear transformation matrix is determined based on the standardized features and through backpropagation using a deep learning model. The input matrix and the preset linear transformation matrix are then mapped to obtain a query matrix, a key matrix, and a value matrix. These matrixes are then split into single-head sub-matrices, and an initial attention score is determined for each single-head sub-matrix. Attention weights are determined based on these initial attention scores, and single-head attention outputs are determined using these weights. Finally, the single-head attention outputs are concatenated to obtain a multi-head attention output. Using the busbar as a node and the transmission line or transformer branch as an edge, a preset graph structure is constructed. The shortest path distance between any two nodes in the preset graph structure is determined. Then, a preset encoding function is defined, and a spatial encoding is determined based on the preset encoding function. A node pair is formed by two busbar nodes. The features of all edges on the shortest path are weighted and averaged to obtain the edge encoding.
[0131] Furthermore, based on the spatial encoding and the edge encoding, a graph structure encoding corresponding to the preset graph structure is determined. The spatial encoding and the edge encoding are used as two bias terms in the self-attention mechanism to modify the initial attention score to obtain a corrected attention score. Based on the corrected attention score, a target multi-head attention output result is determined. Based on the target multi-head attention output result and using a feedforward neural network, the feature enhancement data is determined. Layer normalization and residual connection operations are performed on the feature enhancement data to obtain concatenated features. The concatenated features are input into the preset classifier and the preset regressor to obtain the classifier output result and the regressor output result, respectively. Based on the classifier output result and the regressor output result, an initial Graphormer multi-task learning model is constructed.
[0132] In this embodiment, multi-task learning is applied to transient stability classification and transient stability margin regression problems to establish an initial Graphormer multi-task learning model. This leverages the interrelationship between the two types of tasks to enhance model generalization ability, improve data utilization efficiency, and reduce overfitting risk, thereby optimizing overall performance while reducing parameter redundancy. Figure 3 As shown, the standardized data is processed by the upstream three-layer Graphormer feature layer and then input into the downstream fully connected classifier (i.e., the preset classifier) and regressor (i.e., the preset regressor). Next, the standardized features are divided according to a preset partitioning ratio to obtain a training set, a test set, and a validation set. The initial Graphormer multi-task learning model is trained using the training set to obtain a trained Graphormer multi-task learning model. The multi-task loss function is determined using the cross-entropy loss function and the mean squared error loss function, and the weights corresponding to the multi-task loss function are adjusted based on the homoscedasticity uncertainty method to obtain the target loss function. Based on the target loss function and the target evaluation metric, the trained Graphormer multi-task learning model is evaluated using the test set and the validation set. Based on the evaluation result, the process jumps to the step of training the initial Graphormer multi-task learning model using the training set to obtain the target Graphormer multi-task learning model.
[0133] Understandably, to comprehensively evaluate model performance, CNN (Convolutional Neural Network), Transformer (Self-Attention Mechanism Neural Network), and GCN (Global Communication Network) were selected as upstream feature aggregators for comparison. The downstream classifier and regressor designs were consistent with the Graphormer (Target Graphormer Multi-Task Learning Model), and all models were trained using a uniform configuration for fair comparison: batch size of 128, maximum training epochs of 100, Adam optimizer, initial learning rate of 0.002, and Dropout probability of 0.5. The CNN model consisted of 3 convolutional layers with 3×3 kernels and 32, 16, and 4 channels per layer, respectively. The Transformer model utilized an encoder, had 3 attention heads, and 2 Transformer submodules. The GCN consisted of two GCN layers and two fully connected layers, with hidden layer dimensions of 32 and 16, and used ReLU (Rectified Linear Array). The Unit (linear rectified function) activation function is used, with dropout set to a probability of 0.3. During training, the accuracy of each model changes with the number of iterations as follows: Figure 4 As shown, the performance of each converged model on the test set is as follows: Figure 5 and Figure 6 As shown, where, Figure 6 A_cc represents accuracy, F1-score represents the F1 score, P represents precision, and R represents recall; the mean squared error (MSE) changes during the training of different models as follows: Figure 7 As shown.
[0134] As can be seen from the above, this application first performs transient time-domain simulation based on the power system and using a pre-defined time-domain simulation tool. Then, it constructs an initial Graphormer multi-task learning model using a global attention mechanism, graph position encoding, feedforward neural network, pre-defined classifier, and pre-defined regressor. The initial Graphormer multi-task learning model is then trained using standardized features obtained from the simulation, enabling the resulting target Graphormer multi-task learning model to accurately capture various modes and features related to the transient stability of the power system. In this way, by inputting real-time operating data into the target Graphormer multi-task learning model, high-accuracy and high-precision transient stability assessment results of the power system's transient stability and stability margin can be achieved under different operating modes and topologies.
[0135] Accordingly, see Figure 8As shown, this application also provides a device for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning, comprising:
[0136] The feature generation module 11 is used to generate node features of the power system corresponding to the bus under the target fault scenario based on a preset time-domain simulation tool, and generate edge features related to transmission lines and transformer branches. The node features and edge features are then standardized to obtain standardized features. The node features include the voltage amplitude, voltage phase angle, injected active power, injected reactive power, and electrical frequency of the bus. The edge features include the current amplitude and current phase angle of the transmission lines and transformer branches.
[0137] The label determination module 12 is used to determine the transient stability result based on the power angle difference between each generator after the fault occurs, and to determine the binary label using the transient stability result. It also determines the transient stability margin based on the difference between the rotor angle trajectory and the inertia center trajectory of the generator within a preset fault duration, and determines the regression label using the transient stability margin.
[0138] The target model determination module 13 is used to construct an initial Graphormer multi-task learning model using a global attention mechanism, graph position encoding, a feedforward neural network, a preset classifier, and a preset regressor. The initial Graphormer multi-task learning model is trained using the standardized features, the binary classification labels, and the regression labels to obtain a trained Graphormer multi-task learning model. The trained Graphormer multi-task learning model is then evaluated based on a multi-task loss function to determine the target Graphormer multi-task learning model using the evaluation results. The multi-task loss function includes a preset classification loss function and a preset regression loss function.
[0139] The stability margin determination module 14 is used to obtain corresponding real-time operating data based on the real-time operating status of the power grid, and determine the transient stability state and corresponding transient stability margin of the power system based on the real-time operating data and using the target Graphormer multi-task learning model.
[0140] As can be seen from the above, this application generates node features corresponding to the power system bus and edge features corresponding to transmission lines and transformer branches under topology changes using a preset time-domain simulation tool. The node and edge features are then standardized to ensure that the data input to the model has a consistent scale and distribution, avoiding adverse effects on model training caused by differences in the dimensions of different features. Next, the transient stability result is determined based on the power angle difference between generators after a fault occurs, and a binary classification label is generated. The classification label can clearly determine whether the system is stable. Finally, the transient stability margin is determined based on the difference between the generator's rotor angular trajectory and the inertia center trajectory within a preset fault duration, and a regression label is generated. The regression label can quantify the stability of the power system. Then, an initial Graphormer multi-task learning model is constructed using a global attention mechanism, graph position encoding, a feedforward neural network, a pre-defined classifier, and a pre-defined regressor. This model is trained using standardized features, binary labels, and regression labels. The global attention mechanism allows the model to focus on the important relationships between different nodes and edges, graph position encoding helps the model understand the positional information of nodes, and the feedforward neural network further performs nonlinear transformations on the standardized features. Through joint training, the model can better capture various patterns and features related to the transient stability of the power system. The trained model is evaluated based on a multi-task loss function to obtain the target Graphormer multi-task learning model. In this way, inputting real-time operating data into the target Graphormer multi-task learning model can more accurately and comprehensively assess the transient stability state and corresponding transient stability margin of the power system, ensuring the safe and stable operation of the power system.
[0141] In some specific embodiments, the feature generation module 11 may specifically include:
[0142] The feature acquisition unit is used to simulate the target fault scenario corresponding to the power system using a preset time-domain simulation tool, and to acquire the node features of the bus corresponding to the bus before, during and after the target fault, as well as the edge features related to the transmission line and transformer branch, based on the target fault scenario and the preset acquisition frequency.
[0143] In some specific embodiments, the feature generation module 11 may specifically include:
[0144] The first feature standardization unit is used to determine the first mean and the first standard deviation corresponding to the node feature, and to determine the standardized node feature corresponding to the node feature based on the first mean and the first standard deviation.
[0145] The second feature standardization determines the second mean and the second standard deviation corresponding to the edge feature, and the standardized edge feature corresponding to the edge feature is determined based on the second mean and the second standard deviation;
[0146] A standardized feature determination unit is used to determine standardized features based on the standardized node features and the standardized edge features.
[0147] In some specific embodiments, the label determination module 12 may specifically include:
[0148] The power angle difference determination unit is used to determine the target power angle difference based on the power angle difference between each generator after the fault occurs, and to determine whether the target power angle difference is greater than a preset power angle difference threshold.
[0149] The first stability result determination unit is used to determine that the transient stability result of the power system is unstable if the target power angle difference is greater than the preset power angle difference threshold.
[0150] The second stability result determination unit is used to determine that the transient stability result of the power system is stable if the target power angle difference is not greater than the preset power angle difference threshold, and to determine a binary label based on each transient stability result.
[0151] The deviation value determination unit is used to determine the deviation value of the rotor angle of each generator relative to the center of inertia based on the integration of the difference between the rotor angle trajectory and the inertia center trajectory of the generator within a preset fault duration.
[0152] The regression label determination unit is used to normalize the deviation values to obtain transient stability margins, and to determine the regression labels based on each transient stability margin.
[0153] In some specific embodiments, the target model determination module 13 may specifically include:
[0154] A matrix determination unit is used to construct an input matrix based on the node features and edge features in the standardized features, and to determine a query matrix, a key matrix, and a value matrix using the input matrix and a preset linear transformation matrix; the preset linear transformation matrix is a matrix obtained based on the standardized features and through backpropagation learning using a deep learning model.
[0155] A spatial coding determination unit is used to construct a preset graph structure by taking the bus as a node and the transmission line or the transformer branch as an edge, to determine the shortest path distance between any two nodes in the preset graph structure, and to determine the spatial coding based on the shortest path distance and a preset coding function.
[0156] The edge coding determination unit is used to determine each node pair based on each node, extract features using the set of edges on the shortest path of each node pair to obtain target edge features, and perform a weighted summation of the target edge features to determine the edge coding.
[0157] The graph structure encoding determination unit is used to determine the graph structure encoding corresponding to the preset graph structure based on the spatial encoding and the edge encoding.
[0158] A score correction unit is used to determine an initial attention score using the query matrix and the key matrix, and to correct the initial attention score based on graph structure encoding to obtain a corrected attention score.
[0159] The output result determination unit is used to determine the attention weight matrix using the corrected attention score and the normalized exponential function, and to determine the single-head attention output result based on the attention weight matrix;
[0160] The feature connection unit is used to concatenate the single-head attention output results to obtain a multi-head attention output result, input the multi-head attention output result into the feedforward neural network to obtain feature enhancement data, and perform layer normalization and residual connection operations on the feature enhancement data to obtain the connected features.
[0161] The initial model building unit is used to input the concatenated features into the preset classifier and the preset regressor respectively to obtain the classifier output and the regressor output, and to build an initial Graphormer multi-task learning model based on the classifier output and the regressor output.
[0162] In some specific embodiments, the target model determination module 13 may specifically include:
[0163] The model training unit is used to divide the standardized features based on a preset division ratio to obtain a training set, a test set, and a validation set, and to train the initial Graphormer multi-task learning model using the training set to obtain a trained Graphormer multi-task learning model.
[0164] The weight adjustment unit is used to determine the multi-task loss function using the cross-entropy loss function and the mean squared error loss function, and to adjust the weights corresponding to the multi-task loss function based on the homoscedasticity uncertainty method to obtain the target loss function.
[0165] The target model determination unit is used to evaluate the trained Graphormer multi-task learning model based on the target loss function and target evaluation index, using the test set and the validation set, and based on the evaluation result, jump to the step of training the initial Graphormer multi-task learning model using the training set to obtain the target Graphormer multi-task learning model.
[0166] In some specific embodiments, the stability margin determination module 14 may specifically include:
[0167] The input data determination unit is used to obtain real-time operating data based on the real-time operating status of the power grid and using preset measurement tools, and to standardize the voltage amplitude, phase angle, injected active power and reactive power in the real-time operating data to obtain model input data.
[0168] The degree determination unit is used to input the model input data into the target Graphormer multi-task learning model to obtain transient stability or transient instability and the corresponding degree of transient stability or transient instability.
[0169] Furthermore, embodiments of this application also disclose an electronic device, Figure 9 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the power system transient stability state and stability margin assessment method based on Graphormer multi-task learning disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be a computer.
[0170] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0171] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0172] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the power system transient stability and stability margin assessment method based on Graphormer multi-task learning, which is executed by the electronic device 20 according to any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.
[0173] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0174] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0175] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0176] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0177] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0178] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning, characterized in that, include: Based on a preset time-domain simulation tool, node features corresponding to the bus in the power system under the target fault scenario are generated, and edge features related to transmission lines and transformer branches are generated. The node features and edge features are then standardized to obtain standardized features. The node features include the voltage amplitude, voltage phase angle, injected active power, injected reactive power, and electrical frequency of the bus, and the edge features include the current amplitude and current phase angle of the transmission lines and transformer branches. The transient stability result is determined based on the power angle difference between each generator after the fault occurs, and the transient stability result is used to determine the binary classification label. The transient stability margin is determined based on the difference between the rotor angle trajectory and the inertia center trajectory of the generator within the preset fault duration, and the transient stability margin is used to determine the regression label. Based on the node and edge features in the standardized features, and utilizing a global attention mechanism, graph position encoding, feedforward neural network, preset classifier, and preset regressor, an initial Graphormer multi-task learning model is constructed. The initial Graphormer multi-task learning model is then trained using the standardized features, the binary classification labels, and the regression labels to obtain a trained Graphormer multi-task learning model. Finally, the trained Graphormer multi-task learning model is evaluated based on a multi-task loss function to determine the target Graphormer multi-task learning model. The multi-task loss function includes a preset classification loss function and a preset regression loss function. Based on the real-time operating status of the power grid, corresponding real-time operating data is obtained, and based on the real-time operating data and the target Graphormer multi-task learning model, the transient stability state of the power system and the corresponding transient stability margin are determined.
2. The method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning according to claim 1, characterized in that, The process involves generating node features of the power system corresponding to the busbar under the target fault scenario based on a preset time-domain simulation tool, and generating edge features related to transmission lines and transformer branches, including: The target fault scenario corresponding to the power system is simulated using a preset time-domain simulation tool. Based on the target fault scenario and the preset acquisition frequency, the node features of the bus corresponding to the bus and the edge features related to the transmission line and transformer branch are collected before, during and after the target fault. The target fault scenario includes the transmission line meeting preset topology change conditions, the fault type being a three-phase metallic ground fault, the load change range being within a preset change range, the voltage corresponding to the bus being within a preset voltage range, and the fault location being at the target location of the transmission line.
3. The method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning according to claim 1, characterized in that, The standardization of the node features and the edge features to obtain standardized features includes: Determine the first mean and first standard deviation corresponding to the node features, and determine the standardized node features corresponding to the node features based on the first mean and first standard deviation; Determine the second mean and the second standard deviation corresponding to the edge feature, and determine the standardized edge feature corresponding to the edge feature based on the second mean and the second standard deviation; Standardized features are determined based on the standardized node features and the standardized edge features.
4. The method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning according to claim 1, characterized in that, The transient stability result is determined based on the power angle difference between generators after the fault occurs, and a binary classification label is determined using the transient stability result. The transient stability margin is determined based on the difference between the generator's rotor angular trajectory and the inertia center trajectory within a preset fault duration, and a regression label is determined using the transient stability margin. This includes: The target power angle difference is determined based on the power angle difference between each generator after the fault occurs, and it is determined whether the target power angle difference is greater than a preset power angle difference threshold. If the target power angle difference is greater than the preset power angle difference threshold, the transient stability result of the power system is determined to be unstable. If the target power angle difference is not greater than the preset power angle difference threshold, the transient stability result of the power system is determined to be stable, and a binary label is determined based on each transient stability result. The deviation of the rotor angle of each generator relative to the center of inertia is determined by integrating the difference between the rotor angle trajectory and the trajectory of the center of inertia of the generator within a preset fault duration. The deviation values are normalized to obtain transient stability margins, and regression labels are determined based on each transient stability margin.
5. The method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning according to claim 1, characterized in that, The initial Graphormer multi-task learning model is constructed using a global attention mechanism, graph position encoding, feedforward neural network, pre-defined classifier, and pre-defined regressor, including: An input matrix is constructed based on the node features and edge features in the standardized features. The query matrix, key matrix, and value matrix are determined using the input matrix and a preset linear transformation matrix. The preset linear transformation matrix is a matrix obtained based on the standardized features and through backpropagation learning using a deep learning model. The busbar is used as a node, and the transmission line or the transformer branch is used as an edge to construct a preset graph structure. The shortest path distance between any two nodes in the preset graph structure is determined, and the spatial code is determined based on the shortest path distance and a preset coding function. Each node pair is determined based on each node, and feature extraction is performed using the set of edges on the shortest path of each node pair to obtain target edge features. The target edge features are then weighted and summed to determine the edge encoding. Based on the spatial encoding and the edge encoding, a graph structure encoding corresponding to the preset graph structure is determined; An initial attention score is determined using the query matrix and the key matrix, and the initial attention score is corrected based on graph structure encoding to obtain a corrected attention score; The attention weight matrix is determined using the corrected attention score and the normalized exponential function, and the single-head attention output result is determined based on the attention weight matrix. The single-head attention output results are concatenated to obtain a multi-head attention output result. The multi-head attention output result is then input into a feedforward neural network to obtain feature enhancement data. Layer normalization and residual connection operations are performed on the feature enhancement data to obtain the connected features. The concatenated features are input into the preset classifier and the preset regressor respectively to obtain the classifier output and the regressor output. An initial Graphormer multi-task learning model is constructed based on the classifier output and the regressor output.
6. The method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning according to claim 1, characterized in that, The process of training the initial Graphormer multi-task learning model using the standardized features, the binary classification labels, and the regression labels to obtain a trained Graphormer multi-task learning model, and evaluating the trained Graphormer multi-task learning model based on a multi-task loss function to determine the target Graphormer multi-task learning model using the evaluation results, includes: The standardized features are divided according to a preset division ratio to obtain a training set, a test set, and a validation set. The initial Graphormer multi-task learning model is then trained using the training set to obtain a trained Graphormer multi-task learning model. The multi-task loss function is determined using the cross-entropy loss function and the mean squared error loss function, and the weights corresponding to the multi-task loss function are adjusted based on the homoscedasticity uncertainty method to obtain the target loss function. The trained Graphormer multi-task learning model is evaluated based on the target loss function and target evaluation metric, using the test set and the validation set. Based on the evaluation results, the process jumps to the step of training the initial Graphormer multi-task learning model using the training set to obtain the target Graphormer multi-task learning model.
7. The method for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning according to any one of claims 1 to 6, characterized in that, The process of acquiring corresponding real-time operating data based on the real-time operating status of the power grid, and determining the transient stability state and corresponding transient stability margin of the power system based on the real-time operating data and using the target Graphormer multi-task learning model, includes: Based on the real-time operating status of the power grid and using preset measurement tools to acquire real-time operating data, the voltage amplitude, phase angle, injected active power and reactive power in the real-time operating data are standardized to obtain model input data; The model input data is input into the target Graphormer multi-task learning model to obtain transient stability or transient instability and the corresponding degree of transient stability or transient instability.
8. A device for evaluating the transient stability state and stability margin of a power system based on Graphormer multi-task learning, characterized in that, include: The feature generation module is used to generate node features corresponding to the bus in the power system under the target fault scenario based on a preset time-domain simulation tool, and to generate edge features related to transmission lines and transformer branches. The node features and edge features are then standardized to obtain standardized features. The node features include the voltage amplitude, voltage phase angle, injected active power, injected reactive power, and electrical frequency of the bus. The edge features include the current amplitude and current phase angle of the transmission lines and transformer branches. The label determination module is used to determine the transient stability result based on the power angle difference between each generator after the fault occurs, and to determine the binary label using the transient stability result. It also determines the transient stability margin based on the difference between the rotor angular trajectory and the inertia center trajectory of the generator within a preset fault duration, and determines the regression label using the transient stability margin. The target model determination module is used to construct an initial Graphormer multi-task learning model based on the node features and edge features in the standardized features, and using a global attention mechanism, graph position encoding, feedforward neural network, preset classifier, and preset regressor. The initial Graphormer multi-task learning model is then trained using the standardized features, the binary classification labels, and the regression labels to obtain a trained Graphormer multi-task learning model. Finally, the trained Graphormer multi-task learning model is evaluated based on a multi-task loss function to determine the target Graphormer multi-task learning model using the evaluation results. The multi-task loss function includes a preset classification loss function and a preset regression loss function. The stability margin determination module is used to acquire corresponding real-time operating data based on the real-time operating status of the power grid, and determine the transient stability state and corresponding transient stability margin of the power system based on the real-time operating data and the target Graphormer multi-task learning model.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the power system transient stability state and stability margin assessment method based on Graphormer multi-task learning as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the method for evaluating transient stability and stability margin of a power system based on Graphormer multi-task learning as described in any one of claims 1 to 7.