Power system transient stability adaptive evaluation method based on dynamic adversarial migration
Through the transient stability evaluation model of the power system and dynamic adversarial transfer learning based on Swin Transformer, the problem of insufficient speed and accuracy in the transient stability analysis of the power system is solved, and efficient adaptation and accurate evaluation of the changes in the power grid operating conditions are achieved.
Patent Information
- Application Number
- CN202510219142.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-26
- Publication Date
- 2025-07-04
AI Technical Summary
The existing transient stability analysis methods for power systems are insufficient in terms of speed and accuracy, and the traditional model lacks generalization ability in the face of changes in the power grid operation mode, so the transfer learning method cannot effectively characterize the distribution differences between domains.
The transient stability evaluation model based on Swin Transformer is adopted, combined with dynamic adversarial transfer learning, and global modeling is realized by performing self-attention calculations in fixed windows and mobile windows, and the model is adjusted through dynamic adversarial adaptive transfer learning to adapt to changes in the grid operation conditions.
The rapidity and accuracy of the power system's transient stability evaluation is improved, the model's ability to adapt to changes in the power grid operating conditions is enhanced, and the efficient evaluation of the temporary stability trend is achieved.
Smart Images

Figure CN120262358A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power systems, and more particularly, to a method and system for adaptive evaluation of power system transient stability based on dynamic adversarial transfer. Background Art
[0002] With the continuous increase in the penetration rate of new energy, the safety and stability mechanism of modern power systems has become increasingly complex. Traditional methods for analyzing power system transient stability are all based on physical analysis methods, which cannot simultaneously meet the requirements for the accuracy and rapidity of transient stability analysis results. Therefore, artificial intelligence methods provide a new idea for solving the problem of power system transient stability. Artificial intelligence methods deeply explore the internal mapping rules from massive, diverse, and low-value-density power data features to depict the stability boundary of the power system. Compared with traditional methods, this data-driven model has the characteristics of high efficiency and fast speed when put into online practical applications, and can achieve predictions within milliseconds, effectively meeting the requirements for rapidity and accuracy of online safety assessment. However, at the model level, the global modeling ability of the convolutional neural network (CNN) is weak, the position information processing ability of the long short-term memory network is insufficient, the Transformer can better grasp the position information, but its global modeling ability is strong, resulting in a high computational complexity, and its learning of multi-scale features is relatively weak.
[0003] In addition, a single model cannot adapt to the open and uncertain power grid environment. At the same time, in the actual operation scenario of the power system, all possible operation modes are exhausted, and the training data cannot cover all possible power system operation scenarios, resulting in the problem of insufficient generalization ability of the model during application. Therefore, in view of the time-varying characteristics of the power system, a transfer learning method is introduced to retrain the transient stability assessment model to improve the model's ability to evaluate the transient stability situation under new power grid operation conditions. Currently, in transfer learning methods, the pre-defined distance cannot represent the differences in inter-domain distributions to a certain extent. Summary of the Invention
[0004] According to the present invention, there is provided a method and system for adaptive evaluation of power system transient stability based on dynamic adversarial transfer to solve the problem that the pre-defined distance cannot represent the differences in inter-domain distributions to a certain extent in current transfer learning methods.
[0005] According to a first aspect of the present invention, there is provided a method for adaptive evaluation of power system transient stability based on dynamic adversarial transfer, including:
[0006] Build a transient stability evaluation model based on Swin Transformer, and globally model the relationship between power data features and power system transient stability by performing self-attention calculations on power data features within fixed windows and moving windows;
[0007] Based on dynamic adversarial adaptive transfer learning, perform self-optimizing adjustment on the transient stability evaluation model based on Swin Transformer to achieve the optimal evolution of the original model when the grid operating conditions change;
[0008] Evaluate the power system transient stability evaluation model based on dynamic adversarial adaptation.
[0009] Optionally, build a transient stability evaluation model based on Swin Transformer, and globally model the relationship between power data features and power system transient stability by performing self-attention calculations on power data features within fixed windows and moving windows, including:
[0010] Determine the formula for multi-head self-attention with relative position bias as follows:
[0011]
[0012] H i = Attention(Q, K, V) (27)
[0013] MultiHead(Q, K, V) = [H1, …, H h W O (28)
[0014] where X is the input matrix; W Q , W K and W V are linear transformation matrices; d is the reduction factor; the query matrix Q, the key matrix K, and the value matrix V are obtained through the above matrix transformations respectively; B refers to the matrix containing relative position information; H i is the single-head attention value of the i-th subspace;
[0015] Determine the multi-head self-attention based on a fixed window: evenly divide the 4×4 matrix feature map into 4 non-overlapping 2×2 windows, and independently perform self-attention calculation operations in each window;
[0016] The determination of the multi-head self-attention based on a moving window is as follows: The window-based self-attention mechanism W-MSA evenly divides the moving window into non-overlapping windows. After the divided windows are respectively moved a distance of half the window size to the right and down to obtain new windows, and each window is labeled 0-8. First, the windows numbered 0-2 are moved to the bottommost of the feature map, then the windows numbered 0, 3, and 6 are moved to the rightmost. The windows numbered 3 and 5, the windows numbered 1 and 7, and the windows numbered 0, 2, 6, and 8 are respectively merged into 1 window. A position window of the same size as W-MSA is established, and then the self-attention is calculated under their corresponding windows respectively. At the same time, the mask mechanism is used to limit the self-attention calculation within the sub-windows, and the feature map is restored.
[0017] Optionally, based on dynamic adversarial adaptive transfer learning, the self-optimizing adjustment of the transient stability assessment model based on the Swin Transformer is realized to achieve the optimized evolution of the original model when the grid operation conditions change, including:
[0018] Define a labeled source domain dataset in transfer learning and an unlabeled target domain dataset and their joint probability distributions are different, that is, P s (x, y) ≠ P t (x, y), where and respectively represent the i-th sample in the source domain dataset and the j-th sample in the target domain dataset, is the sample label corresponding to ; n s and n t are respectively the numbers of samples in their datasets;
[0019] The overall representation of the power system transient stability assessment model based on dynamic adversarial adaption is:
[0020] L(θ e , θ j , θ m , θ c ) = L j (θ e , θ j ) - λ((1 - ω)L m (θ e , θ m ) + ωL c (θ e , θ c )) (29)
[0021] In the formula: L j , L m and L cThey are the label classifier loss, the global domain classifier loss, and the local sub-domain classifier loss respectively; λ is the trade-off parameter; ω ∈ [0, 1] is the dynamic adversarial factor; θ e , θ j , θ m and θ c are the internal parameters of the feature extractor f e , the label classifier f j , the global domain discriminator f m and the local sub-domain discriminator f c respectively, and the training optimization objective is:
[0022]
[0023] The global domain discriminator aligns the marginal distributions between the source domain and the target domain through adversarial learning, and the calculation formula of its loss function is:
[0024]
[0025] In the formula: L s is the cross-entropy loss function, b i is the domain label of the input sample, the source domain b i is 0, and the target domain b i is 1;
[0026] The local sub-domain discriminator aligns the conditional distributions between the source domain and the target domain through adversarial learning. The local sub-domain discriminator f c is a discriminator f s p containing M categories, which is responsible for aligning the source domain and target domain data related to class p. The calculation formula of its loss function is:
[0027]
[0028] In the formula: and are the cross-entropy loss function and the domain discriminator related to class p respectively, the predicted probability of the input data on class p;
[0029] The label classifier is used to learn the data knowledge of the source domain, and its loss function is expressed as:
[0030]
[0031] In the formula: y i is the transient label of the source domain sample.
[0032] Optionally, based on dynamic adversarial adaptive transfer learning, self-optimizing adjustment of the transient stability assessment model based on Swin Transformer is performed to achieve the optimal evolution of the original model after the power grid operation condition changes, and it further includes:
[0033] For the global domain discriminator and the local sub-domain discriminator The calculation formulas are as follows:
[0034] d A,m (D s , D t ) = 2(1 - 2(L m ))
[0035]
[0036] In the formula: and are respectively samples related to class p, is the local sub-domain discriminator loss related to class p;
[0037] The dynamic adversarial factor is calculated as:
[0038]
[0039] Optionally, evaluating the power system transient stability assessment model based on dynamic adversarial adaptation includes:
[0040] Based on the historical operation mode data of the power system and the corresponding fault information, the transient stability state of the power system is judged by the time-domain simulation method to determine the power grid operation data including the stable state, where the stability criterion adopts the transient stability index TSI:
[0041]
[0042] In the formula: △δ max is the maximum value of the relative power angle difference between any two generators. When TSI > 0, the sample is judged to be stable; otherwise, it is judged to be unstable;
[0043] Select the bus voltage, generator power, load power, and line transmission power at the steady-state operation moment of the power grid as characteristic data, use the cross-entropy loss function as the loss function of the Swin Transformer model, and use L2 regularization for constraint. Based on the AdamW optimizer, the model parameters are iteratively updated to determine the steady-state characteristic variables;
[0044] Process the power grid operation data including the stable state into a multi-channel matrix feature map and input it into the Swin Transformer model for evaluation;
[0045] When the operating conditions of the power grid change and the model cannot meet the evaluation requirements, corresponding target domain samples are generated for the power system under the new operating conditions;
[0046] Use the source domain training model to extract domain-invariant features for adversarial training, calculate and optimize the model parameters based on the losses of the label classifier and each discriminator until the model converges and then enter online evaluation.
[0047] According to another aspect of the present invention, there is also provided a power system transient stability adaptive evaluation system based on dynamic adversarial transfer, including: a model establishment module for establishing a transient stability evaluation model based on Swin Transformer, and realizing global modeling between power data features and power system transient stability by performing self-attention calculations on power data features within a fixed window and a moving window;
[0048] An adjustment model module for self-optimizing adjustment of the transient stability evaluation model based on Swin Transformer based on dynamic adversarial adaptive transfer learning, so as to realize the optimal evolution of the original model when the operating conditions of the power grid change;
[0049] An evaluation model module for evaluating the power system transient stability evaluation model based on dynamic adversarial adaptation.
[0050] Optionally, the model establishment module includes:
[0051] A relative position bias multi-head self-attention sub-module for determining the multi-head self-attention calculation formula containing relative position bias as follows:
[0052]
[0053] H i =Attention(Q,K,V) (39)
[0054] MultiHead(Q,K,V)=[H1,…,H h W O (40)
[0055] where X is the input matrix; W Q 、W K and W V are linear transformation matrices; d is a reduction factor; the query matrix Q, the key matrix K, and the value matrix V are respectively obtained through the above matrix transformations; B refers to a matrix containing relative position information; H i is the single-head attention value of the i-th subspace;
[0056] Determine the fixed-window multi-head self-attention sub-module, which is used to determine the multi-head self-attention based on a fixed window: evenly divide the 4×4 matrix feature map into 4 non-overlapping 2×2 windows, and independently perform self-attention calculation operations in each window;
[0057] Determine the moving-window multi-head self-attention sub-module, which is used to determine the multi-head self-attention based on a moving window: the window-based self-attention mechanism W-MSA evenly divides the moving window into non-overlapping windows, and after moving the divided windows half a window size to the right and down respectively to obtain new windows, and label each window from 0 to 8. First, move the windows numbered 0-2 to the bottom of the feature map, then move the windows numbered 0, 3, and 6 to the rightmost side, and merge the windows numbered 3 and 5, 1 and 7, and 0, 2, 6, and 8 into 1 window respectively to establish a position window of the same size as W-MSA. Then, calculate self-attention under their corresponding windows respectively, and at the same time use the mask mechanism to limit the self-attention calculation within the sub-windows and restore the feature map.
[0058] Optionally, the adjustment module includes:
[0059] Determine the dataset sub-module, which is used to define a labeled source domain dataset in transfer learning and an unlabeled target domain dataset and their joint probability distributions are different, that is, P s (x,y)≠P t (x,y), where and represent the i-th sample in the source domain dataset and the j-th sample in the target domain dataset respectively, is the sample label corresponding to ; n s and n t are the numbers of samples in their respective datasets;
[0060] Determine the overall representation sub-module, which is used to represent the overall of the dynamic adversarial adaptive power system transient stability assessment model as:
[0061] L(θ e ,θ j ,θ m ,θ c )=L j (θ e ,θ j )-λ((1-ω)L m (θ e ,θ m )+ωL c (θ e ,θ c )) (41)
[0062] Where: L j , L m and L c are the losses of the label classifier, the global domain classifier, and the local sub-domain classifier, respectively; λ is the trade-off parameter; ω ∈ [0, 1] is the dynamic adversarial factor; θ e , θ j , θ m and θ c are the internal parameters of the feature extractor f e , the label classifier f j , the global domain discriminator f m and the local sub-domain discriminator f c respectively. The training optimization objective is:
[0063]
[0064] The global domain discriminator aligns the marginal distributions between the source domain and the target domain through adversarial learning. The calculation formula of its loss function is:
[0065]
[0066] Where: L s is the cross-entropy loss function, b i is the domain label of the input sample. The source domain b i is 0, and the target domain b i is 1;
[0067] The local sub-domain discriminator aligns the conditional distributions between the source domain and the target domain through adversarial learning. The local sub-domain discriminator f c is a discriminator f s p that contains M categories and is responsible for aligning the source domain and target domain data related to class p. The calculation formula of its loss function is:
[0068]
[0069] Where: and are the cross-entropy loss function and the domain discriminator related to class p, respectively, is the predicted probability of the input data on class p;
[0070] The label classifier is used to learn the data knowledge of the source domain, and its loss function is expressed as:
[0071]
[0072] Where: y i is the transient stability label of the source domain sample.
[0073] Optionally, the adjustment model module further includes:
[0074] The calculation formulas of the global domain discriminator and the local sub-domain discriminator are as follows: respectively:
[0075] d A,m (D s , D t ) = 2(1 - 2(L m ))
[0076]
[0077] In the formula: and are samples related to class p respectively, is the local sub-domain discriminator loss related to class p;
[0078] The dynamic adversarial factor is calculated as:
[0079]
[0080] Optionally, the evaluation model module includes:
[0081] A sample generation sub-module, which is used to judge the transient stability state of the power system by the time-domain simulation method based on the historical operation mode data of the power system and the corresponding fault information, and determine the power grid operation data including the stable state, where the stability criterion adopts the transient stability index TSI:
[0082]
[0083] In the formula: △δ max is the maximum value of the relative power angle difference between any two generators. When TSI > 0, the sample is judged to be stable; otherwise, it is judged to be unstable;
[0084] A feature selection and model training sub-module, which is used to select the bus voltage, generator power, load power, and line transmission power at the steady-state operation moment of the power grid as feature data, use the cross-entropy loss function as the loss function of the Swin Transformer model, and use L2 regularization for constraint, and iteratively update the model parameters based on the AdamW optimizer to determine the steady-state feature variables;
[0085] An online evaluation sub-module, which is used to process the power grid operation data including the stable state into a multi-channel matrix feature map and input it into the Swin Transformer model for evaluation;
[0086] A target domain sample generation sub-module, which is used to generate corresponding target domain samples for the power system under the new working condition when the power grid operation condition changes and the model cannot meet the evaluation requirements;
[0087] The dynamic adversarial transfer training sub-module is used to extract domain-invariant features using the source domain training model for adversarial training, calculate and optimize the model parameters based on the losses of the label classifier and each discriminator until the model converges and then enters online evaluation.
[0088] Thus, a transient stability evaluation model based on Swin Transformer is established. Based on its hierarchical model structure, global modeling between power data features and the transient stability of the power system is achieved by performing self-attention calculations on power data features within fixed windows and moving windows. Secondly, to ensure that the transient stability evaluation model can quickly track changes in the operating conditions of the power system, a dynamic adversarial adaptive transfer learning method is adopted. The adversarial learning method is used to learn the implicit metric function of the inter-domain differences and dynamically measure the relative importance of the inter-domain marginal distribution and conditional distribution, thereby realizing the self-optimizing adjustment of the transient stability evaluation model. BRIEF DESCRIPTION OF THE DRAWINGS
[0089] The exemplary embodiments of the present invention can be more fully understood by referring to the following drawings:
[0090] Figure 1 It is a schematic flow chart of a method for adaptively evaluating the transient stability of a power system based on dynamic adversarial transfer according to this embodiment;
[0091] Figure 2 It is a schematic diagram of the overall framework of Swin Transformer according to this embodiment;
[0092] Figure 3 It is a schematic diagram of Patch Merging according to this embodiment;
[0093] Figure 4 It is a schematic diagram of window-based multi-head self-attention calculation according to this embodiment;
[0094] Figure 5 It is a schematic diagram of multi-head self-attention calculation based on a moving window according to this embodiment
[0095] Figure 6 It is a structural diagram of a transient stability evaluation model of a power system based on dynamic adversarial adaption according to this embodiment;
[0096] Figure 7 It is a flow chart of the adaptive evaluation of the transient stability of a power system based on dynamic adversarial transfer according to this embodiment;
[0097] Figure 8 It is a schematic diagram of a system for adaptively evaluating the transient stability of a power system based on dynamic adversarial transfer according to this embodiment. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0098] Reference is now made to the accompanying drawings to describe exemplary embodiments of the present invention. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. These embodiments are provided to disclose the present invention in detail and completely, and to fully convey the scope of the present invention to those skilled in the art. The terms in the exemplary embodiments shown in the drawings are not limitations on the present invention. In the drawings, the same units / components are denoted by the same reference numerals.
[0099] Unless otherwise specified, the terms used herein (including scientific and technical terms) have the ordinary meaning understood by those skilled in the art. In addition, it can be understood that the terms defined in the commonly used dictionary should be understood to have a meaning consistent with the context of their related fields, and should not be understood as idealized or overly formal meanings.
[0100] According to a first aspect of the present invention, there is provided a method 100 for adaptively evaluating the transient stability of a power system based on dynamic adversarial transfer. Referring Figure 1 as shown, the method 100 includes:
[0101] S101: Establish a transient stability evaluation model based on Swin Transformer, and globally model the relationship between power data features and the transient stability of the power system by performing self-attention calculations on power data features within a fixed window and a moving window.
[0102] S102: Based on dynamic adversarial adaptive transfer learning, perform self-optimizing adjustment on the transient stability evaluation model based on Swin Transformer to achieve the optimal evolution of the original model when the grid operating conditions change.
[0103] S103: Evaluate the transient stability evaluation model of the power system based on dynamic adversarial adaptation.
[0104] Specifically, 1. Transient stability evaluation of the power system based on Swin Transformer
[0105] The present invention is specifically introduced from five aspects: the overall framework, Patch Merging, multi-head self-attention calculation with relative position bias, window-based multi-head self-attention layer (Windows Multi-head Self-Attention, W-MSA), and shifted window-based multi-head self-attention layer (Shifted Windows Multi-Head Self-Attention, SW-MSA).
[0106] (1) Overall framework
[0107] The Swin Transformer model established by the present invention is composed of a Swin Transformer module, a Patch Merging module, a Patch Partition module, and a Linear Embeding module. The overall framework is as Figure 2 shown. The data first undergoes a chunking operation through Patch Partition, and then enters Linear Embeding to increase the number of channels. After that, self-attention calculation is performed in the Swin Transformer module, and the two are mainly implemented through a convolutional layer. Secondly, the output after the above steps will first undergo Patch Merging for chunk merging and then enter the Swin Transformer module for self-attention calculation. This process goes through three times successively, and finally the output value is obtained. At the same time, the number of Swin Transformer modules is always even, aiming to connect the Swin Transformer module containing W-MSA and the Swin Transformer module containing SW-MSA together as a basic unit, so as to achieve the global modeling ability of the model. Among them, two consecutive Swin Transformer modules contain three main parts: W-MSA, SW-MSA, and a multi-layer perceptron, and also contain residual connections and layer normalization to effectively transfer and update model parameters, preventing the problems of gradient disappearance and feature deviation. Layer normalization is applied before W-MSA, SW-MSA, and the multi-layer perceptron, and residual connections are applied after the three respectively. The multi-layer perceptron contains Dropout, GELU activation function, and a linear layer inside, and is between W-MSA and SW-MSA.
[0108] (2)Patch Merging
[0109] Patch Merging builds a flexible hierarchical model structure by referring to the pooling operation in CNN. It can not only increase the receptive field of the model but also extract multi-scale feature information of the data.
[0110] The specific process of Patch Merging is as Figure 3 shown. Assume that the data input to Patch Merging is a single-channel matrix feature map with a size of 4×4. First, the elements of the same color in the feature map are spliced together to form 4 feature maps with a size of 2×2; secondly, the 4 feature maps with a size of 2×2 are spliced in the channel direction; finally, after passing through a layer normalization and then a linear layer for linear transformation, the number of channels becomes 2.
[0111] In summary, after the Patch Merging operation, the height and width of the feature map are halved, and the number of channels is doubled. Multiple uses of Patch Merging in the Swin Transformer can achieve sampling of data features at different granularities, thereby obtaining multi-scale feature information. Therefore, it is ensured that the extracted features contain both global overall information and local detailed information.
[0112] (3) Multi-head self-attention calculation with relative position bias
[0113] Self-attention calculation, as the basis of the Swin Transformer, dynamically allocates attention by calculating the correlation weights between each position of the input sequence data and other positions, thereby determining the importance of each element. The multi-head self-attention mechanism maps the data into multiple different subspaces, forming multiple "heads" to calculate multiple self-attentions in parallel, enabling the model to capture feature information from multiple angles, thus enriching the model's expressive ability.
[0114] The relative position bias is incorporated into the self-attention calculation in the form of a bias based on the relative positions between the input data, and it is a trainable parameter. The formula for multi-head self-attention with relative position bias is as follows:
[0115]
[0116] H i = Attention(Q, K, V) (51)
[0117] MultiHead(Q, K, V) = [H1, …, H h W O (52)
[0118] In the formula: X is the input matrix; W Q 、W K and W V are linear transformation matrices; d is the reduction factor; the query matrix Q, the key matrix K, and the value matrix V are obtained through the above matrix transformations in 1 respectively; B refers to the matrix containing relative position information; H i is the single-head attention value of the i-th subspace.
[0119] (4) Window-based multi-head self-attention layer
[0120] In the matrix feature map, different parts of the same object or different objects with similar semantics are likely to appear in adjacent locations. Swin Transformer draws on the prior knowledge of locality in CNN, that is, the connection or correlation between elements in spatial positions is greater for nearby elements and smaller for distant elements. The local information in the three-channel matrix feature map obtained after the power flow topology mirroring encoding of power grid steady-state variables can, to a certain extent, reflect the characteristics of power grid transient stability. At the same time, calculating self-attention locally can control the complexity of the model and reduce the computational amount.
[0121] The calculation of window-based multi-head self-attention is as Figure 4 shown. The 4×4 matrix feature map is evenly divided into 4 non-overlapping 2×2 windows, and self-attention calculation operations are independently performed in each window.
[0122] (5) Multi-head self-attention layer based on shifted windows
[0123] Since W-MSA calculates self-attention in non-overlapping windows, the elements in each window cannot notice the element information of other windows. It lacks cross-window connections and always performs isolated self-attention calculations, which limits the modeling ability of the model. Therefore, calculating multi-head self-attention based on shifted windows can achieve cross-window connection and interaction while maintaining the high-efficiency calculation of non-overlapping windows.
[0124] The calculation of multi-head self-attention based on shifted windows is as Figure 5 shown. First, it is evenly divided into non-overlapping windows in the same way as W-MSA, that is, step 1. Secondly, the divided windows are respectively moved a distance of half the window size to the right and down to obtain new windows, and each window is numbered 0 - 8, that is, step 2. To reduce the computational amount, self-attention is calculated in windows of the same size as W-MSA. Therefore, according to steps 3 and 4, the windows numbered 0 - 2 are first moved to the bottom of the feature map, and then the windows numbered 0, 3, and 6 are moved to the rightmost side. At the same time, the windows numbered 3 and 5, the windows numbered 1 and 7, and the windows numbered 0, 2, 6, and 8 are respectively merged into 1 window to establish position windows of the same size as W-MSA. Then, self-attention is calculated under their corresponding windows respectively, and the self-attention is restricted to be calculated within the sub-windows using the masking mechanism. Finally, the feature map is restored.
[0125] In summary, SW-MSA calculates self-attention using the cyclic shift of windows and the masking mechanism, realizes cross-window connection and interactive communication between windows, reduces the computational complexity, and enhances the global modeling ability of the model.
[0126] 2. Power system transient stability assessment based on dynamic adversarial distribution adaptation
[0127] Dynamic adversarial adaptation embeds adversarial learning into deep networks, utilizes the idea of generative adversarial networks to learn transferable features between the source domain and the target domain, and adaptively adjusts the relative importance of the marginal probability distribution and the conditional probability distribution of the source domain and the target domain in the joint probability distribution adaptation process for each specific dataset. Among them, the source domain and the target domain respectively refer to the power systems before and after the change in the operation mode or topological original structure. This section introduces from three aspects: the overall representation of dynamic adversarial adaptation, the global domain discriminator and the local domain discriminator, as well as the label discriminator and the dynamic adversarial factor.
[0128] (1) Overall representation
[0129] In this paper, a dynamic adversarial model containing Swin Transformer is established to achieve the optimal evolution of the original model when the grid operation condition changes. Its specific structure is as Figure 6 shown. The dynamic adversarial adaptation model mainly includes a feature extractor f e based on Swin Transformer, a label classifier f j , a global domain discriminator f m and a local sub-domain discriminator f c . The feature extractor f e confuses the domain discriminator by extracting domain-invariant features between the source domain and the target domain, thereby increasing the loss of the domain discriminator. The domain discriminator tries to minimize its own loss to distinguish domain features. At the same time, the loss of the label classifier will be minimized to learn the transient stability knowledge of the source domain. Therefore, the feature extractor and the domain discriminator conduct a game confrontation through the alternating optimization of maximization and minimization, and then realize the self-optimization process of the original model.
[0130] Given that the computational efficiency of power system transient stability simulation calculation is relatively low in terms of sample generation, when the grid operation condition changes, the model cannot track the grid operation state in time due to the lack of a complete data scale. Therefore, to minimize the time cost, a labeled source domain dataset and an unlabeled target domain dataset are defined in transfer learning, and their joint probability distributions are different, that is, P s (x, y) ≠ P t (x, y). Among them, and respectively represent the i-th sample in the source domain dataset and the j-th sample in the target domain dataset, is the sample label corresponding to ; n s and n t are respectively the numbers of samples in their datasets.
[0131] After the power grid operation mode or topological structure changes, the joint distribution of the source domain and target domain datasets shows differences, and the applicability of the original model in transient stability assessment under the new power grid operation conditions will inevitably decline. According to the relationship between joint probability and marginal probability and conditional probability, it is necessary to dynamically adjust the relative importance of the two for adversarial transfer learning. Figure 7 In it, the global domain discriminator and the local sub-domain discriminator correspond to the marginal distribution and the conditional distribution respectively. Therefore, the overall representation of the loss function of the dynamic adversarial adaptation model is as follows:
[0132] L(θ e ,θ j ,θ m ,θ c ) = L j (θ e ,θ j ) -
[0133] λ((1 - ω)L m (θ e ,θ m ) + ωL c (θ e ,θ c )) (53)
[0134] In the formula: L j , L m and L c are the loss of the label classifier, the loss of the global domain classifier, and the loss of the local sub-domain classifier respectively; λ is the trade-off parameter; ω ∈ [0, 1] is the dynamic adversarial factor; θ e , θ j , θ m and θ c are the internal parameters of the feature extractor f e , the label classifier f j , the global domain discriminator f m and the local sub-domain discriminator f c respectively. The training optimization objective is as follows:
[0135]
[0136] (2) The global domain discriminator and the local domain discriminator
[0137] The global domain discriminator aligns the marginal distributions between the source domain and the target domain through adversarial learning. The calculation formula of its loss function is as follows:
[0138]
[0139] In the formula: L s is the cross-entropy loss function, b iis the domain label of the input sample (source domain b i is 0, and the target domain b i is 1).
[0140] The local sub-domain discriminator aligns the conditional distributions between the source domain and the target domain through adversarial learning. The local sub-domain discriminator f c is a discriminator f that contains M categories s p (M is 2 in this paper), which is responsible for aligning the source domain and target domain data related to class p. The calculation formula of its loss function is as follows:
[0141]
[0142] In the formula: and are the cross-entropy loss function and the domain discriminator related to class p respectively, is the predicted probability of the input data on class p.
[0143] (3) Label classifier and dynamic adversarial factor
[0144] The label classifier is used to learn the data knowledge of the source domain. Therefore, it is trained using the transient labels of the samples, and its loss function can be expressed as:
[0145]
[0146] In the formula: y i is the transient label of the source domain sample.
[0147] In addition, the present invention calculates the dynamic adversarial factor ω to measure the relative importance between the marginal distribution and the conditional distribution. Therefore, the calculation formulas of the global domain discriminator and the local sub-domain discriminator are as follows respectively:
[0148] d A,m (D s ,D t ) = 2(1 - 2(L m ))
[0149]
[0150] In the formula: and are the samples related to class p respectively, is the local sub-domain discriminator loss related to class p.
[0151] Therefore, the dynamic adversarial factor can be calculated as:
[0152]
[0153] The present invention proposes a power system transient stability adaptive evaluation process based on dynamic adversarial transfer, which includes three parts: offline training, online evaluation, and model optimization adjustment. Among them, offline training includes sample generation, feature selection, and model training; at the same time, model optimization adjustment includes transfer learning sample generation, feature selection, feature extraction based on Swin Transformer, and dynamic adversarial training, specifically as Figure 7 shown.
[0154] Figure 6 Power System Transient Stability Adaptive Evaluation Process Based on Dynamic Adversarial Transfer
[0155] (1) Sample generation. Based on the historical operation mode data of the power system collected by PMU and the corresponding fault information, the transient stability state of the power system is judged by the time-domain simulation method, where the stability criterion adopts the transient stability index (TSI):
[0156]
[0157] In the formula: △δ max is the maximum value of the relative power angle difference between any two generators. When TSI > 0, the sample is judged to be stable; otherwise, it is judged to be unstable.
[0158] (2) Feature selection and model training. Select the bus voltage, generator power, load power, and line transmission power at the steady-state operation moment of the power grid. The cross-entropy loss function is used as the loss function of the Swin Transformer model, and L2 regularization is used for constraint to prevent model overfitting. In addition, the AdamW optimizer is used to iteratively update the model parameters to reduce the size of the loss function.
[0159] (3) Online evaluation. The dispatching control center receives the steady-state feature variables collected by PMU through WAMS, processes them into a multi-channel matrix feature map through the power flow topology mirroring encoding method, and finally inputs them into the Swin Transformer model for evaluation.
[0160] (4) Transfer learning sample generation and feature selection. When the operating conditions of the power grid change and the model cannot meet the evaluation requirements, target domain samples corresponding to the power system under the new operating conditions are generated.
[0161] (5) Feature extraction based on Swin Transformer and dynamic adversarial transfer training. Use the source domain training model to extract domain-invariant features. Use the extracted domain-invariant features for adversarial training, calculate and optimize the model parameters based on the label classifier and the losses of each discriminator until the model converges and then enter online evaluation.
[0162] Optionally, a transient stability evaluation model based on Swin Transformer is established to globally model the relationship between power data features and the transient stability of the power system by performing self-attention calculations on power data features within fixed and moving windows, including:
[0163] Determine the formula for multi-head self-attention with relative position bias as follows:
[0164]
[0165] H i = Attention(Q, K, V) (63)
[0166] MultiHead(Q, K, V) = [H1, …, H h W O (64)
[0167] where X is the input matrix; W Q 、W K and W V are linear transformation matrices; d is a reduction factor; the query matrix Q, key matrix K, and value matrix V are obtained through the above matrix transformations in 1; B refers to a matrix containing relative position information; H i is the single-head attention value of the i-th subspace;
[0168] Determine the multi-head self-attention based on a fixed window: evenly divide the 4×4 matrix feature map into 4 non-overlapping 2×2 windows, and perform self-attention calculation operations independently in each window;
[0169] Determine the multi-head self-attention based on a moving window: the window-based self-attention mechanism W-MSA evenly divides the moving window into non-overlapping windows. After the divided windows are moved half a window size to the right and down respectively to obtain new windows, and each window is numbered 0 - 8. First, move the 0 - 2 windows to the bottom of the feature map, then move the 0, 3, and 6 windows to the rightmost side. Combine the 3 and 5 windows, 1 and 7 windows, and 0, 2, 6, and 8 windows into 1 window respectively to establish a position window of the same size as W-MSA. Then calculate self-attention under their corresponding windows respectively, and at the same time use the mask mechanism to limit the self-attention calculation within the sub-windows and restore the feature map.
[0170] Optionally, based on dynamic adversarial adaptive transfer learning, self-optimizing adjustment of the transient stability evaluation model based on Swin Transformer is performed to achieve the optimal evolution of the original model when the grid operating conditions change, including:
[0171] Define a labeled source domain dataset in transfer learning and an unlabeled target domain dataset and their joint probability distributions are different, i.e., P s (x,y) ≠ P t (x,y), where and represent the i-th sample in the source domain dataset and the j-th sample in the target domain dataset respectively, is the sample label corresponding to ; n s and n are the numbers of samples in their respective datasets;
[0172] The overall representation of the power system transient stability assessment model based on dynamic adversarial adaptation is:
[0173] L(θ e , θ j , θ m , θ c ) = L j (θ e , θ j ) -
[0174] λ((1 - ω)L m (θ e , θ m ) + ωL c (θ e , θ c )) (65)
[0175] In the formula: L j , L m and L c are the label classifier loss, the global domain classifier loss, and the local sub-domain classifier loss respectively; λ is the trade-off parameter; ω ∈ [0,1] is the dynamic adversarial factor; θ e , θ j , θ m and θ c are the internal parameters of the feature extractor f e , the label classifier f j , the global domain discriminator f m and the local sub-domain discriminator f c respectively, and the training optimization objective is:
[0176]
[0177] The global domain discriminator aligns the marginal distributions between the source domain and the target domain through adversarial learning, and the calculation formula of its loss function is:
[0178]
[0179] where: L s is the cross - entropy loss function, b i is the domain label of the input sample, the source domain b i is 0, and the target domain b i is 1;
[0180] The local sub - domain discriminator aligns the conditional distributions between the source domain and the target domain through adversarial learning. The local sub - domain discriminator f c is a discriminator f that contains M categories s p , which is responsible for aligning the source - domain and target - domain data related to class p. Its loss - function calculation formula is:
[0181]
[0182] where: and are the cross - entropy loss function and the domain discriminator related to class p, respectively is the predicted probability of the input data on class p;
[0183] The label classifier is used to learn the data knowledge of the source domain, and its loss function is expressed as:
[0184]
[0185] where: y i is the transient - stability label of the source - domain sample.
[0186] Optionally, based on dynamic adversarial adaptive transfer learning, the self - optimizing adjustment of the transient - stability assessment model based on Swin Transformer is carried out to achieve the optimal evolution of the original model when the grid operating conditions change. It also includes:
[0187] The calculation formulas of the global domain discriminator and the local sub - domain discriminator are as follows respectively:
[0188] d A,m (D s ,D t ) = 2(1 - 2(L m ))
[0189]
[0190] where: and are the samples related to class p respectively is the local sub - domain discriminator loss related to class p;
[0191] The dynamic adversarial factor is calculated as:
[0192]
[0193] Optionally, evaluating the power system transient stability assessment model based on dynamic adversarial adaptation includes:
[0194] Judging the transient stability state of the power system by the time-domain simulation method based on the historical operation mode data of the power system and the corresponding fault information, and determining the power grid operation data including the stable state, where the stability criterion uses the transient stability index TSI:
[0195]
[0196] In the formula: △δ max is the maximum value of the relative power angle difference between any two generators. When TSI>0, the sample is judged to be stable; otherwise, it is judged to be unstable;
[0197] Select the bus voltage, generator power, load power, and line transmission power at the steady-state operation moment of the power grid as characteristic data, use the cross-entropy loss function as the loss function of the Swin Transformer model, and use L2 regularization for constraint. Iteratively update the model parameters based on the AdamW optimizer to determine the steady-state characteristic variables;
[0198] Process the power grid operation data including the stable state into a multi-channel matrix feature map and input it into the Swin Transformer model for evaluation;
[0199] When the power grid operation condition changes and the model cannot meet the evaluation requirements, generate corresponding target domain samples for the power system under the new condition;
[0200] Use the source domain training model to extract domain-invariant features for adversarial training, calculate and optimize the model parameters based on the label classifier and the losses of each discriminator until the model converges and then enter online evaluation.
[0201] The present invention establishes a transient stability assessment model based on Swin Transformer, realizes global modeling by alternately calculating self-attention through a fixed window and a mobile window, and generates multi-scale features using a hierarchical model structure, having strong non-linear mapping modeling ability and classification performance.
[0202] Aiming at the time-varying characteristics of the power system and the dynamic change of the transient stability data distribution, this patent adopts a dynamic adversarial adaptive transfer learning method to learn the implicit metric function between domains through adversarial learning, and dynamically adjusts the relative importance of the marginal distribution and the conditional distribution to improve the transfer performance of the transient stability assessment model based on Swin Transformer, so as to realize the optimization adjustment of the transient stability model.
[0203] According to another aspect of the present invention, there is also provided a power system transient stability adaptive evaluation system 800 based on dynamic adversarial transfer, as shown in reference Figure 8 The system 800 includes:
[0204] A model establishment module 810, configured to establish a transient stability evaluation model based on Swin Transformer, and realize global modeling between power data features and power system transient stability by performing self-attention calculation on power data features within a fixed window and a moving window;
[0205] A model adjustment module 820, configured to perform self-optimizing adjustment on the transient stability evaluation model based on Swin Transformer based on dynamic adversarial adaptive transfer learning, so as to realize the optimizing evolution of the original model when the grid operation condition changes;
[0206] An evaluation model module 830, configured to evaluate the power system transient stability evaluation model based on dynamic adversarial adaptation.
[0207] Optionally, the model establishment module includes:
[0208] A relative position bias multi-head self-attention sub-module, configured to determine the multi-head self-attention calculation formula containing relative position bias as follows:
[0209]
[0210] H i =Attention(Q,K,V) (75)
[0211] MultiHead(Q,K,V)=[H1,…,H h W O (76)
[0212] where X is the input matrix; W Q , W K and W V are linear transformation matrices; d is a reduction factor; the query matrix Q, the key matrix K, and the value matrix V are respectively obtained through the above matrix transformation; B refers to a matrix containing relative position information; H i is the single-head attention value of the i-th subspace;
[0213] A fixed window multi-head self-attention sub-module, configured to determine the multi-head self-attention based on a fixed window as: evenly dividing the 4×4 matrix feature map into 4 non-overlapping 2×2 windows in a non-overlapping manner, and independently performing self-attention calculation operations in each window;
[0214] Determine the moving window multi-head self-attention sub-module, which is used to determine the multi-head self-attention based on the moving window as follows: The window-based self-attention mechanism W-MSA evenly divides the moving window into non-overlapping windows. After the divided windows are moved half of the window size to the right and down respectively to obtain new windows, and each window is numbered from 0 to 8. First, move the windows numbered 0 to 2 to the bottom of the feature map, then move the windows numbered 0, 3, and 6 to the rightmost side. Combine the windows numbered 3 and 5, the windows numbered 1 and 7, and the windows numbered 0, 2, 6, and 8 into 1 window respectively to establish a position window of the same size as W-MSA. Then calculate the self-attention under their corresponding windows respectively, and at the same time use the masking mechanism to limit the self-attention calculation within the sub-windows, and restore the feature map.
[0215] Optionally, the adjustment module includes:
[0216] Determine the dataset sub-module, which is used to define a labeled source domain dataset in transfer learning and an unlabeled target domain dataset and their joint probability distributions are different, that is, P s (x, y) ≠ P t (x, y), where and represent the i-th sample in the source domain dataset and the j-th sample in the target domain dataset respectively, is the sample label corresponding to ; n s and n are the numbers of samples in their respective datasets;
[0217] Determine the overall representation sub-module, which is used to represent the overall representation of the power system transient stability assessment model based on dynamic adversarial adaptation as:
[0218] L(θ e , θ j , θ m , θ c ) = L j (θ e , θ j ) - λ((1 - ω)L m (θ e, θ m ) + ωL c (θ e , θ c )) (77)
[0219] In the formula: L j , L m and L c are the label classifier loss, the global domain classifier loss, and the local sub-domain classifier loss respectively; λ is the trade-off parameter; ω ∈ [0, 1] is the dynamic adversarial factor; θe , θ j , θ m and θ c are the internal parameters of the feature extractor f e , the label classifier f j , the global domain discriminator f m and the local sub-domain discriminator f c respectively, and the training optimization objective is:
[0220]
[0221] The global domain discriminator aligns the marginal distributions between the source domain and the target domain through adversarial learning, and the calculation formula of its loss function is:
[0222]
[0223] In the formula: L s is the cross-entropy loss function, b i is the domain label of the input sample, the source domain b i is 0, and the target domain b i is 1;
[0224] The local sub-domain discriminator aligns the conditional distributions between the source domain and the target domain through adversarial learning. The local sub-domain discriminator f c is a discriminator f containing M categories s p , which is responsible for aligning the source domain and target domain data related to class p, and the calculation formula of its loss function is:
[0225]
[0226] In the formula: and are the cross-entropy loss function and the domain discriminator related to class p respectively, the predicted probability of the input data on class p;
[0227] The label classifier is used to learn the data knowledge of the source domain, and its loss function is expressed as:
[0228]
[0229] In the formula: y i is the transient label of the source domain sample.
[0230] Optionally, adjusting the model module also includes:
[0231] The calculation formulas of the global domain discriminator and the local sub-domain discriminator are as follows respectively:
[0232] d A,m (Ds , D t ) = 2(1 - 2(L m ))
[0233]
[0234] Wherein: and are respectively samples related to class p, is the local sub-domain discriminator loss related to class p;
[0235] Calculate the dynamic adversarial factor as:
[0236]
[0237] Optionally, the evaluation model module includes:
[0238] A sample generation sub-module, which is used to judge the transient stability state of the power system by the time-domain simulation method based on the historical operation mode data of the power system and the corresponding fault information, and determine the power grid operation data including the stable state, where the stability criterion adopts the transient stability index TSI:
[0239]
[0240] Wherein: △δ max is the maximum value of the relative power angle difference between any two generators. When TSI > 0, the sample is judged to be stable; otherwise, it is judged to be unstable;
[0241] A feature selection and model training sub-module, which is used to select the bus voltage, generator power, load power, and line transmission power at the steady-state operation moment of the power grid as feature data, use the cross-entropy loss function as the loss function of the Swin Transformer model, and use L2 regularization for constraint, and iteratively update the model parameters based on the AdamW optimizer to determine the steady-state feature variables;
[0242] An online evaluation sub-module, which is used to process the power grid operation data including the stable state into a multi-channel matrix feature map and input it into the Swin Transformer model for evaluation;
[0243] A target domain sample generation sub-module, which is used to generate corresponding target domain samples for the power system under the new working condition when the power grid operation condition changes and the model cannot meet the evaluation requirements;
[0244] A dynamic adversarial transfer training sub-module, which is used to extract domain-invariant features by using the source domain training model for adversarial training, calculate and optimize the model parameters based on the label classifier and the losses of each discriminator until the model converges and then enters the online evaluation.
[0245] An adaptive transient stability evaluation system 800 for a power system based on dynamic adversarial transfer according to an embodiment of the present invention corresponds to an adaptive transient stability evaluation method 100 for a power system based on dynamic adversarial transfer according to another embodiment of the present invention, which will not be elaborated here.
[0246] Those skilled in the art should understand that the embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk memories, CD-ROMs, optical memories, etc.) containing computer-usable program codes. The solutions in the embodiments of the present application can be implemented in various computer languages. For example, object-oriented programming languages such as Java and interpreted scripting languages such as JavaScript.
[0247] The present application is described with reference to the flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processors of general-purpose computers, special-purpose computers, embedded processors, or other programmable data processing devices to generate a machine, such that the instructions executed by the processors of the computer or other programmable data processing devices generate means for implementing the specified functions in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0248] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including instruction means, and the instruction means implements the specified functions in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0249] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, and thus the instructions executed on the computer or other programmable device provide steps for implementing the specified functions in Figure 1 one flow or multiple flows and / or blocks Figure 1 one block or multiple blocks.
[0250] Although the preferred embodiments of the present application have been described, additional changes and modifications can be made by those skilled in the art once they learn the basic creative concept. Therefore, the appended claims are intended to be construed to include the preferred embodiments as well as all changes and modifications falling within the scope of the present application.
[0251] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application is also intended to include these modifications and variations.
Claims
1. An adaptive evaluation method for power system transient stability based on dynamic adversarial transfer, characterized in that Including: Establish a transient stability assessment model based on Swin Transformer, and globally model the relationship between power data features and power system transient stability by performing self-attention calculations on power data features within fixed windows and moving windows; Based on dynamic adversarial adaptive transfer learning, perform self-optimizing adjustment on the transient stability assessment model based on Swin Transformer to achieve the optimized evolution of the original model when the grid operating conditions change; Evaluate the power system transient stability assessment model based on dynamic adversarial adaptation.
2. The method according to claim 1, wherein Establish a transient stability assessment model based on Swin Transformer, and globally model the relationship between power data features and power system transient stability by performing self-attention calculations on power data features within fixed windows and moving windows, including: Determine the calculation formula for multi-head self-attention with relative position bias as follows: H i = Attention(Q, K, V) (3) MultiHead(Q,K,V)=[H1,…,H h W O (4) Among them, X is the input matrix; W Q , W K and W V are linear transformation matrices; d is the reduction factor; the query matrix Q, the key matrix K, and the value matrix V are respectively obtained through the matrix transformation in the above 1; B refers to the matrix containing relative position information; H i is the single-head attention value of the i-th subspace; Determine the multi-head self-attention based on the fixed window: Uniformly divide the 4×4 matrix feature map into 4 non-overlapping 2×2 windows, and independently perform self-attention calculation operations in each window; Determine the multi-head self-attention based on the moving window: The window-based self-attention mechanism W-MSA uniformly divides the moving window into non-overlapping windows. After the divided windows are moved half of the window size to the right and down respectively to obtain new windows, and label each window from 0 to 8. First, move the windows numbered 0-2 to the bottom of the feature map, then move the windows numbered 0, 3, and 6 to the rightmost side. Combine the windows numbered 3 and 5, 1 and 7, and 0, 2, 6, and 8 into one window respectively to establish a position window of the same size as W-MSA. Then calculate self-attention under their corresponding windows respectively, and at the same time use the mask mechanism to limit the self-attention calculation within the sub-windows and restore the feature map.
3. The method according to claim 2, wherein Based on dynamic adversarial adaptive transfer learning, perform self-optimizing adjustment on the transient stability assessment model based on Swin Transformer to achieve the optimized evolution of the original model when the grid operating conditions change, including: Define a labeled source domain dataset in transfer learning and an unlabeled target domain dataset and their joint probability distributions are different, i.e., P s (x, y) ≠ P t (x, y), where and represent the i-th sample in the source domain dataset and the j-th sample in the target domain dataset respectively, is the sample label corresponding to ; n s and n t are the numbers of samples in their respective datasets; The overall representation of the power system transient stability assessment model based on dynamic adversarial adaptation is: L(θ e ,θ j ,θ m ,θ c ) = L j (θ e ,θ j ) - λ((1 - ω)L m (θ e , θ m ) + ωL c (θ e , θ c )) (5) where: L j , L m and L c are the losses of the label classifier, the global domain classifier, and the local sub-domain classifier, respectively; λ is the trade-off parameter; ω ∈ [0, 1] is the dynamic adversarial factor; θ e , θ j , θ m and θ c are the internal parameters of the feature extractor f e , the label classifier f j , the global domain discriminator f m and the local sub-domain discriminator f c respectively, and the training optimization objective is: The global domain discriminator aligns the marginal distributions between the source domain and the target domain through adversarial learning, and its loss function calculation formula is: Where: L s is the cross-entropy loss function, b i is the domain label of the input sample, the source domain b i is 0, and the target domain b i is 1; The local sub-domain discriminator aligns the conditional distributions between the source domain and the target domain through adversarial learning. The local sub-domain discriminator f c is a discriminator containing M categories responsible for aligning the source domain and target domain data related to class p. The calculation formula of its loss function is as follows: Wherein: and are the cross-entropy loss function and the domain discriminator related to class p respectively, the predicted probability of the input data on class p; The label classifier is used to learn the data knowledge of the source domain, and its loss function is expressed as: where: y i is the transient stability label of the source domain sample.
4. The method according to claim 3, characterized in that, Based on dynamic adversarial adaptive transfer learning, perform self-optimizing adjustment on the transient stability assessment model based on Swin Transformer to achieve the optimized evolution of the original model when the grid operating conditions change, and also include: For the global domain discriminator and the local sub-domain discriminator, the calculation formulas are as follows: Wherein: and are respectively samples related to class p, is the local sub-domain discriminator loss related to class p; Calculate the dynamic adversarial factor as:
5. The method according to claim 1, wherein Evaluate the power system transient stability assessment model based on dynamic adversarial adaptation, including: Based on the historical operation mode data of the power system and the corresponding fault information, judge the transient stability state of the power system through the time-domain simulation method, and determine the grid operation data containing the stable state, where the stability criterion adopts the transient stability index TSI: Where: △δ max is the maximum value of the relative power angle difference between any two generators. When TSI > 0, the sample is judged to be stable; otherwise, it is judged to be unstable. Select the bus voltage, generator power, load power, and line transmission power at the steady-state operation moment of the power grid as characteristic data. Use the cross-entropy loss function as the loss function of the Swin Transformer model, and use L2 regularization for constraint. Iteratively update the model parameters based on the AdamW optimizer to determine the steady-state characteristic variables; Process the power grid operation data containing the stable state into a multi-channel matrix feature map and input it into the Swin Transformer model for evaluation; When the operating condition of the power grid changes and the model cannot meet the evaluation requirements, the power system under the corresponding new condition generates corresponding target domain samples; Use the source domain training model to extract domain-invariant features for adversarial training, calculate and optimize the model parameters based on the losses of the label classifier and each discriminator until the model converges and then enter the online evaluation.
6. A transient stability adaptive evaluation system for power systems based on dynamic adversarial transfer, characterized in that, Including: A model building module for building a transient stability evaluation model based on Swin Transformer, which realizes the global modeling between the power data features and the transient stability of the power system by performing self-attention calculations on the power data features within a fixed window and a moving window; An model adjustment module for self-optimizing adjustment of the transient stability evaluation model based on Swin Transformer based on dynamic adversarial adaptive transfer learning to achieve the optimal evolution of the original model when the operating condition of the power grid changes; An model evaluation module for evaluating the transient stability evaluation model of the power system based on dynamic adversarial adaption.
7. The system according to claim 6, characterized in that, The model building module includes: A relative position bias multi-head self-attention sub-module for determining the multi-head self-attention calculation formula containing relative position bias as follows: H i = Attention(Q, K, V) (15) MultiHead(Q,K,V)=[H1,…,H h W O (16) Among them, X is the input matrix; W Q , W K and W V are linear transformation matrices; d is the reduction factor; the query matrix Q, the key matrix K, and the value matrix V are respectively obtained through the matrix transformation in the above 1; B refers to the matrix containing relative position information; H i is the single-head attention value of the i-th subspace; A fixed window multi-head self-attention sub-module for determining the multi-head self-attention based on a fixed window: evenly divide the 4×4 matrix feature map into 4 non-overlapping 2×2 windows in a non-overlapping manner, and independently perform self-attention calculation operations in each window; A moving window multi-head self-attention sub-module for determining the multi-head self-attention based on a moving window: the window-based self-attention mechanism W-MSA evenly divides the moving window into non-overlapping windows, and after the divided windows are moved half of the window size to the right and down respectively to obtain new windows, and label each window 0-8. First, move the 0-2 windows to the bottom of the feature map, then move the 0, 3, and 6 windows to the rightmost side, respectively merge the 3 and 5 windows, the 1 and 7 windows, and the 0, 2, 6, and 8 windows into 1 window, establish a position window of the same size as W-MSA, and then calculate self-attention under their corresponding windows respectively. At the same time, use the mask mechanism to limit the self-attention calculation within the sub-window and restore the feature map.
8. The system according to claim 7, characterized in that, The adjustment module includes: A determining data set sub-module, which is used to define a labeled source domain data set in transfer learning and an unlabeled target domain data set and their joint probability distributions are different, that is, P s (x, y) ≠ P t (x, y), where and represent the i-th sample in the source domain data set and the j-th sample in the target domain data set respectively, is the sample label corresponding to ; n s and n are the numbers of samples in their respective data sets; A general representation sub-module for determining the general representation of the transient stability evaluation model of the power system based on dynamic adversarial adaption as: L(θ e ,θ j ,θ m ,θ c ) = L j (θ e ,θ j ) - λ((1 - ω)L m (θ e, θ m ) + ωL c (θ e , θ c )) (17) Where: L j , L m and L c are the losses of the label classifier, the global domain classifier, and the local sub-domain classifier, respectively; λ is the trade-off parameter; ω ∈ [0, 1] is the dynamic adversarial factor; θ e , θ j , θ m and θ c are the internal parameters of the feature extractor f e , the label classifier f j , the global domain discriminator f m and the local sub-domain discriminator f c respectively, and the training optimization objective is: The global domain discriminator aligns the marginal distributions between the source domain and the target domain through adversarial learning, and its loss function calculation formula is: Where: L s is the cross-entropy loss function, b i is the domain label of the input sample, the source domain b i is 0, and the target domain b i is 1; The local sub-domain discriminator aligns the conditional distributions between the source domain and the target domain through adversarial learning. The local sub-domain discriminator f c is a discriminator with M categories responsible for aligning the source domain and target domain data related to class p. The calculation formula of its loss function is as follows: Wherein: and are the cross-entropy loss function and the domain discriminator related to class p, respectively, the predicted probability of the input data on class p; The label classifier is used to learn the data knowledge of the source domain, and its loss function is expressed as: where: y i is the transient stability label of the source domain sample.
9. The system according to claim 8, wherein The adjustment model module further includes: For the global domain discriminator and the local sub-domain discriminator, the calculation formulas are as follows: Wherein: and are respectively samples related to class p, is the local sub-domain discriminator loss related to class p; The dynamic confrontation factor is calculated as:
10. The system according to claim 6, wherein The evaluation model module includes: A sample generation sub-module, which is used to judge the transient stability state of the power system by means of time-domain simulation based on the historical operation mode data of the power system and the corresponding fault information, and determine the power grid operation data including the stable state, where the stability criterion adopts the transient stability index TSI: Where: △δ max is the maximum value of the relative power angle difference between any two generators. When TSI > 0, the sample is judged to be stable; otherwise, it is judged to be unstable. A feature selection and model training sub-module, which is used to select the bus voltage, generator power, load power and line transmission power at the steady-state operation moment of the power grid as feature data, use the cross-entropy loss function as the loss function of the Swin Transformer model, and use L2 regularization for constraint, and iteratively update the model parameters based on the AdamW optimizer to determine the steady-state feature variables; An online evaluation sub-module, which is used to process the power grid operation data including the stable state into a multi-channel matrix feature map and input it into the Swin Transformer model for evaluation; A target domain sample generation sub-module, which is used to generate corresponding target domain samples for the power system under the new working conditions when the power grid operation conditions change and the model cannot meet the evaluation requirements; A dynamic confrontation transfer training sub-module, which is used to extract domain-invariant features from the source domain training model for confrontation training, calculate and optimize the model parameters based on the label classifier and the losses of each discriminator until the model converges and then enters the online evaluation.
Citation Information
Cited By
Power system transient voltage stability assessment method based on gain-swin transformer
CN120782296A
A method for evaluating transient voltage stability in power systems based on GAF-SWIN transformers
CN120782296B
Power system multi-scene adaptive transient stability assessment method based on active transfer learning
CN120851390A
Power system transient stability assessment method and system based on space-time diagram transfer learning
CN121216391A