Power quality composite disturbance detection classification and time positioning method based on ms-tcn++
By combining the MS-TCN++ model with single-dilation and double-dilation temporal convolutional networks, the problem of detecting, classifying, and locating complex power quality disturbances in time is solved. This enables detailed detection and temporal location of power quality disturbances, supporting the tracing and mitigation of power quality disturbances.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG UNIV
- Filing Date
- 2025-06-03
- Publication Date
- 2026-07-28
AI Technical Summary
Existing technologies struggle to simultaneously detect, classify, and locate the timing of complex power quality disturbances, especially when multiple complex disturbances present insufficient accuracy.
A power quality composite disturbance detection model based on MS-TCN++ is adopted. By combining single-dilation and double-dilation temporal convolutional networks with probabilistic activation functions, a composite category encoding method is designed, and a loss function is constructed to train the model for detection, classification, and temporal localization.
It enables detailed detection and identification of power quality disturbances, providing information on the number and time interval of basic disturbance elements, and supports the tracing and mitigation of power quality disturbances.
Smart Images

Figure CN120632682B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of power systems and relates to a method for detecting, classifying, and locating composite power quality disturbances based on MS-TCN++. Background Technology
[0002] Under the dual-carbon environment, the continuous connection of various nonlinear loads containing power electronic equipment and intermittent power sources such as wind and solar power to the power grid has exacerbated the occurrence and complexity of power quality disturbances (PQDs). PQDs not only appear as single disturbances such as voltage interruptions, gaps, harmonics, and flicker, but also frequently manifest as complex disturbances with two or even three layers. These frequent and increasingly complex PQDs not only affect the stable operation of the power system but may also damage electrical equipment, causing significant economic losses. Timely and accurate detection, classification, and timing of power quality disturbances are crucial for tracing their causes and mitigating their impact.
[0003] In recent years, PQDs recognition methods have been extensively studied, mainly divided into traditional methods based on signal processing and signal classification, and deep learning algorithms based on artificial intelligence. Traditional methods are heavily influenced by the signal processing methods used to extract features, requiring manual selection of extracted features based on experience, which limits accuracy and generally results in poor performance in recognizing multiple complex PQDs. Deep learning methods achieve automatic feature extraction and classification in an end-to-end manner, achieving better classification results in PQDs recognition, and can be mainly divided into image classification models and temporal classification models. However, most of the above studies only consider the existence of each basic perturbation within the entire waveform, without considering the temporal location of each basic perturbation. Summary of the Invention
[0004] The technical problem to be solved by the present invention is to overcome the defects of the prior art and provide a model that can simultaneously complete the detection, classification and temporal localization of composite PQDs. By taking basic disturbances as the detection objects, hierarchical modeling of single disturbances and multiple disturbances is realized, and information such as the type, number and time interval of each basic disturbance element in PQDs is obtained, thus obtaining a more detailed description of PQDs.
[0005] To achieve the above objectives, the present invention adopts the following technical solution:
[0006] This invention provides a method for detecting, classifying, and locating power quality composite disturbances based on MS-TCN++, comprising the following steps:
[0007] S1: Based on the mathematical model of power quality disturbance, generate power quality disturbance composite signal samples, and divide the samples into training set, validation set and test set according to the proportion;
[0008] S2: Design a composite category coding method to represent the category of each sampling point of the power quality composite disturbance signal;
[0009] S3: Construct a power quality composite disturbance detection, classification, and time-based localization model based on MS-TCN++;
[0010] S4: Train the MS-TCN++ model using the training set, with loss functions including classification loss and smoothing loss;
[0011] S5: Post-process the point classification output of the model to obtain the final detection result, and evaluate the detection, classification and temporal localization performance of the model on the test set using multiple performance indicators.
[0012] The beneficial effects of this invention are: this invention can not only complete the detection and identification at the level of basic disturbance elements, but also provide information on the number and time interval of each basic disturbance, which helps to trace the cause and manage power quality disturbances. Attached Figure Description
[0013] Figure 1 This is a flowchart of a power quality composite disturbance detection, classification, and time localization method based on MS-TCN++, according to an embodiment of this application.
[0014] Figure 2 This is the overall structure of the MS-TCN++ model in the embodiments of this application.
[0015] Figure 3 This is a diagram of the single dilated convolutional network structure in an embodiment of this application.
[0016] Figure 4 This is a diagram of the double-dilated convolutional network structure in an embodiment of this application.
[0017] Figure 5 This is a comparison chart of the time positioning errors of amplitude disturbance and oscillation disturbance under different noise levels in the model of the embodiment of this application.
[0018] Figure 6 This is a comparison chart of the time positioning error of transient basic disturbances under different noise levels in the model of the embodiment of this application. Detailed Implementation
[0019] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] like Figure 1As shown in the figure, this application provides a method for detecting, classifying, and locating power quality composite disturbances based on MS-TCN++, including the following steps:
[0021] S1: Based on the mathematical model of power quality disturbance, generate power quality disturbance composite signal samples, and divide the samples into training set, validation set and test set according to the proportion.
[0022] Furthermore, the power quality disturbance composite signal samples comprise 64 types, including 11 types of single disturbance signals, 28 types of double disturbance signals, and 25 types of triple disturbance signals, among which the normal signal is regarded as a special single disturbance signal.
[0023] Table 1 shows the mathematical models for 10 basic power quality perturbation elements in 4 categories.
[0024] Table 1 Classification of Basic Power Quality Disturbances
[0025]
[0026] The composite perturbation is generated according to equation (1). To ensure sample quality, at most one perturbation is considered for each class.
[0027]
[0028] Wherein, sin(t) is the standard sinusoidal signal; sag(t), swl(t), and itr(t) are the voltage sag, voltage swell, and voltage interruption disturbance factors, respectively; imp(t), osc(t), and nth(t) are the transient impact, transient oscillation, and voltage gap disturbance factors, respectively; flk(t) and hmy(t) are the flicker and harmonic disturbance factors, respectively; and noise(t) is the noise signal.
[0029] The samples were divided into training, validation, and test sets in a 4:1:1 ratio. In the training and validation sets, the proportion of samples with each type of perturbation signal—noise-free, 50dB, 40dB, and 30dB—was equal. Noise signals were added to the test set as needed for testing.
[0030] S2: Design a composite category encoding method to represent the category of each sampling point of the power quality composite disturbance signal.
[0031] This application proposes a hybrid encoding method for sampling points in PQDs sequences. Each sampling point in the perturbation signal sequence is encoded individually, and the category label of the sampling point is represented by a combination of the categories of the basic perturbation to which that sampling point is located. Specifically:
[0032] First, a multi-label classification coding method is employed to decouple the sampling point classification task into four sub-tasks, corresponding to the identification of four basic perturbations: transient perturbations, amplitude perturbations, flicker perturbations, and harmonic perturbations. Since perturbations of the same category do not occur simultaneously, multi-class coding is used within the transient and amplitude perturbation sub-tasks. The coding vectors corresponding to the four sub-tasks form a total coding vector of length 12, used to represent the composite category of the sampling point. Transient perturbations are encoded using a 6-length one-hot vector, with the six elements corresponding to normal, spike, gap, oscillation, positive pulse, and negative pulse, respectively. Similarly, amplitude perturbations are represented using a 4-length one-hot vector, with the four elements corresponding to normal, temporary rise, temporary fall, and interruption, respectively. The labels for flicker perturbations and harmonic perturbations are both represented by 1-0 codes of length 1 to indicate presence or absence. Furthermore, the "normal" category in the one-hot vectors for transient and amplitude perturbations indicates that the sampling point does not contain any of the basic perturbations of the corresponding category.
[0033] S3: Construct a power quality composite disturbance detection, classification, and temporal localization model based on MS-TCN++. The model includes a single-dilated temporal convolutional network, a double-dilated temporal convolutional network, and a probabilistic activation function.
[0034] like Figure 3 As shown, the kernel size of the first convolutional layer of the single-dilation temporal convolutional network is 1×1, used to map the dimension of the input sequence to the dimension of the hidden layer features; the last 1×1 convolutional layer is used to map the dimension of the hidden layer features to the dimension of the output layer features. In this embodiment, the dimension of the output layer features is 12, corresponding to the 12-length encoding vector described in step S2.
[0035] The middle of the network consists of a stack of L single-dilated convolutional residual blocks. Each single-dilated convolutional residual block is composed of a one-dimensional dilated convolutional layer, a ReLU activation layer, a 1×1 convolutional layer, and a Dropout layer connected in series. The residual connection structure is introduced to alleviate the gradient vanishing problem.
[0036] All one-dimensional dilated convolutions have a kernel size of 1×3, and the dilation coefficient of the l-th single dilated convolution layer is 2. l ReLU activation layers increase the nonlinear fitting ability of neural networks; 1×1 convolutional layers within residual blocks are used to model feature channels; Dropout is a regularization technique that only works during model training.
[0037] During model training, the Dropout layer causes each neuron to have a certain probability of failure, and the combination of neurons retained in each forward propagation is different. This can greatly reduce the dependence between features, prompting the model to learn more robust features, thereby achieving a regularization effect. In this embodiment, the neuron loss probability is set to 0.5.
[0038] The dual-dilation temporal convolutional network adds a new dilation convolutional layer to the single-dilation temporal convolutional network, and its structure is as follows: Figure 4 As shown. Specifically, the double-dilated convolutional residual block contains two dilated convolutional layers. The dilation coefficient of one layer increases with the number of layers, while the dilation coefficient of the other layer decreases with the number of layers. The convolution results of the two layers are fused by concatenation, which can extract features at more time scales. The rest of the structure is the same as that of the single-dilated temporal convolutional network.
[0039] When the neural network outputs the composite class probability for each sampling point, different output activation functions are needed to map the output vector into a probabilistic form. The first 6 elements and the 7th to 10th elements of the output vector are activated by Softmax to output the class probability predictions of transient perturbations and amplitude perturbations, respectively. The last 2 elements are activated by the Sigmoid activation function to obtain the probability predictions of flicker perturbations and harmonic perturbations. The expressions for the Softmax and Sigmoid activation functions are shown in equations (2) and (3), respectively:
[0040]
[0041] In the formula, x i The output vector is the i-th element belonging to either the transient perturbation or the amplitude perturbation, N. c This is the class label length, which is 6 for transient perturbations and 4 for amplitude perturbations. The Softmax function transforms each element in the input vector into its probability value, while the Sigmoid function transforms a single element into a probability value.
[0042] like Figure 2 As shown in the embodiment of this application, an MS-TCN++ network is proposed, which includes a prediction generation stage and multiple refinement stages.
[0043] The prediction generation stage takes a one-dimensional sequence of PQDs as input. After passing through a double-dilated temporal convolutional network, the output vector is mapped to a probability form using the output activation functions of equations (2) and (3) to obtain the initial category prediction results for each sampling point of the PQDs sequence. The probability activation operation is represented by Map in the figure.
[0044] Each subsequent refinement stage uses the perturbation class prediction probability of each sampling point in the PQDs sequence output from the previous stage as input, and continuously optimizes the prediction probability using a single-dilated temporal convolutional network. The number of refinement stages is represented by N in the figure. r The input-output relationship of each stage in the MS-TCN++ model is shown in equation (4):
[0045]
[0046] In the formula, s represents the number of stages; F represents the temporal convolutional network described in Section 3.1, where F is a double-dilated temporal convolutional network only when s = 1, and a single-dilated temporal convolutional network for the remaining stages; M represents the probabilistic activation operation; z 1:T The input time series is a PQDs sequence; T is the length of the input time series; Z is the length of the input time series. s Y represents the output of the s-th stage network. s This represents the predicted class probability of the sequence in stage s.
[0047] S4: Train the MS-TCN++ model using the training set, with loss functions including classification loss and smoothing loss.
[0048] Each stage of the temporal convolutional network has a corresponding loss value, and the total model loss L... M The sum of the loss values for each stage, where the loss value for each stage includes the classification loss L. cls and smoothing loss L smooth Two parts, represented as equation (5):
[0049]
[0050] In the formula, L s λ is the loss value of the model in stage s; S is the total number of stages in the model; λ is the weight coefficient of the smoothing loss.
[0051] The classification loss is calculated separately for the sub-labels corresponding to the four major categories of disturbances. The classification loss for transient disturbances and amplitude disturbances uses multi-class cross-entropy loss, while the classification loss for flicker and harmonic disturbances uses binary cross-loss, as shown in equations (6) and (7).
[0052]
[0053] In the formula, Let be the classification loss corresponding to the i-th class of perturbation at each sampling point in the sequence; i = 1, 2 are the predicted probabilities of the model at time step t for the actual perturbation category c in the i-th perturbation category; i = 3, 4 are the predicted probability values of the model for flicker or harmonic disturbance at time step t; i = 3, 4 are the corresponding label values.
[0054] The smoothing loss penalizes the difference in predicted probabilities between adjacent sampling points, reducing jumps in predicted probabilities caused by perturbations between adjacent sampling points, thereby reducing misclassification. The smoothing loss uses the mean squared error truncated on the logarithmic probability, and its expression is as follows:
[0055]
[0056] △ t,c =|lny t,c -lny t-1,c | (10)
[0057] The smoothing loss is calculated in the same way for the 10 basic disturbances and the two normal categories among amplitude disturbances and transient disturbances. Therefore, the predicted probability y of the sampling point category c at time step t is calculated in equations (8), (9) and (10). t,c No superscript is used for differentiation. C represents the total number of categories, which is 12; τ represents the cutoff threshold for the smoothing loss.
[0058] S5: Post-process the point classification output of the model to obtain the final detection result, and use multiple performance indicators on the test set to evaluate the detection, classification and localization performance of the model.
[0059] The MS-TCN++ model ultimately provides the class probability of each fundamental perturbation in the four major categories for each sampling point in the PQDs sequence. To obtain the types and time intervals of each fundamental perturbation present in the PQDs signal, the point classification results need to be processed as follows.
[0060] For power quality composite disturbance signals containing transient and amplitude disturbances, since disturbances within a major category do not occur simultaneously, the disturbance category with the highest probability in each category is taken as the disturbance category label for that sampling point. Based on the change of the sampling point category label over time, the entire PQDs segment is divided into multiple time intervals, with the start and end times of each time interval corresponding to the times when the sampling point category changes.
[0061] For power quality composite disturbance signals containing flicker and harmonic disturbances, since these are long-term steady-state disturbances, the timing problem is not studied; only the occurrence of both is detected. The average confidence level of flicker or harmonic disturbances at all sampling points in the signal is used to represent the probability of the corresponding disturbance occurring in the entire signal segment. When the probability confidence level is greater than 0.5, the corresponding disturbance is considered to exist.
[0062] The detection and classification performance of the model is evaluated using precision, recall, and F1 score, which are expressed as follows:
[0063]
[0064] In the formula, TP, FP, and FN represent the number of correctly identified, falsely identified, and missed identified targets, respectively. Precision is the proportion of the model's predictions that hit the real target, used to measure the model's ability to find only relevant targets; recall indicates how many real targets the model's predictions can cover at most, used to measure the model's ability to find all relevant targets; the F1 score is the harmonic mean of the two, which can comprehensively evaluate the model's detection performance.
[0065] For each type of fundamental perturbation, the mean absolute error η of the start / end time is calculated for the correctly identified sample TP. b and η e :
[0066]
[0067] Where TP represents the number of correctly identified items, and f s Sampling frequency, and These represent the predicted coordinates of the start and end points of each TP. and The actual values of the starting and ending point coordinates, respectively.
[0068] To verify the effectiveness of the power quality composite disturbance detection, classification, and timing method based on MS-TCN++ described in this application, an application example is also provided. Table 2 shows the generation of 64 types of power quality disturbance signals, including 11 single disturbance signals, 28 double disturbance signals, and 25 triple disturbance signals, where normal signals are considered as a special type of single disturbance signal.
[0069] Table 2. PQDs signal types used in the sample set.
[0070]
[0071] In the dataset, the fundamental frequency was set to 50Hz, the sampling frequency to 6.4kHz, and the sampling duration for each PQDs sequence was 0.28s, totaling 1792 sampling points. Each perturbation class contained 2400 samples, and the dataset was then divided into training, validation, and test sets in a 4:1:1 ratio. The training and validation sets had equal proportions of samples with no noise, a signal-to-noise ratio (SNR) of 50dB, a SNR of 40dB, and a SNR of 30dB for each perturbation signal. Noise signals were added to the test set as needed for subsequent experiments.
[0072] After comparison and debugging, the total number of stages in the model is set to 4, including 1 prediction generation stage and 3 refinement stages. The number of double dilated convolutional residual blocks in the prediction generation stage is 11, and the number of dilated convolutional residual blocks in the refinement stage is 10. The feature dimension of the hidden layer is uniformly set to 64, and the smoothing loss weight coefficient λ and the cutoff value τ are set to 0.05 and 4, respectively.
[0073] In the training, validation, and testing of the model, the batch size was 64, the optimizer was Adam, and the initial learning rate was 5×10⁻⁶. -4 The learning rate decays to 0.9 of the previous generation for each generation of training. An early stopping mechanism is used during training to prevent overfitting; training stops when the validation set loss of five consecutive generations exceeds the historical minimum, and the model with the historical minimum validation loss is selected as the final model. The model was trained for a total of 44 generations, so the 39th generation model is chosen as the final model.
[0074] Different signal-to-noise ratio noises were added to the test set, and the F1 score was tested. The results are shown in Table 3.
[0075] Table 3. F1 scores at different noise levels
[0076]
[0077]
[0078] As can be seen, under the above signal-to-noise ratio conditions, the overall F1 score of the model in this application is above 99.2%, and the occurrence of false detections and false negatives is relatively small.
[0079] The mean absolute error η of the start / end time is calculated using correctly identified samples of each type of fundamental perturbation. b and η e As an evaluation metric for the model in time positioning tasks at the level of basic perturbations.
[0080] Statistical analysis of start / end time positioning errors was performed on correctly identified samples. The η values of eight basic perturbations with clearly defined start and end times were analyzed across different signal-to-noise ratio test sets. b η e like Figure 5 and Figure 6 As shown.
[0081] Figure 5 and Figure 6 The graph shows the mean absolute error of the start / end times for eight basic perturbations, with the vertical axis in units of sampling points (pts). At a sampling frequency of 6.4 kHz, one sampling point corresponds to an error of 0.156 ms. As shown in the graph, under different noise levels, the model's mean absolute error in locating the start / end times of amplitude perturbations is less than one sampling point.
[0082] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. For those skilled in the art, other variations or modifications can be made based on the above description. It is impossible to exhaustively list all the implementation methods here. All obvious variations or modifications derived from the technical solutions of the present invention are still within the protection scope of the present invention.
Claims
1. A method for detecting, classifying, and locating power quality composite disturbances based on MS-TCN++, characterized in that, Includes the following steps: Step 1: Based on the mathematical model of power quality disturbance, generate power quality disturbance composite signal samples and divide the samples into training set, validation set and test set; Step 2: Design a composite category coding method to represent the category of each sampling point of the power quality composite disturbance signal; Step 3: Construct a power quality composite disturbance detection, classification, and time-based localization model based on MS-TCN++; Step 4: Train the MS-TCN++ model using the training set; Step 5: Post-process the point classification output of the model to obtain the final detection result; Step 2 specifically involves: Multi-label classification coding is adopted to decouple the sampling point classification task into four sub-tasks, which correspond to the identification tasks of four basic types of disturbances: transient disturbance, amplitude disturbance, flicker disturbance, and harmonic disturbance. Multi-class coding is used within the transient disturbance and amplitude disturbance categories. The coding vectors corresponding to the four sub-tasks are combined to form the total coding vector, which is used to represent the composite category of the sampling point. The MS-TCN++ model includes a single-dilated temporal convolutional network, a double-dilated temporal convolutional network, and a probabilistic activation function. The double-dilated temporal convolutional network is used to obtain the initial class prediction results for each sampling point of the PQDs sequence; The single dilatation temporal convolutional network is used to optimize the prediction probability; The probabilistic activation function is used to obtain the probability of each basic perturbation type at the sampling point; The single dilated temporal convolutional network has 1×1 convolutional layers at the beginning and end. The beginning layer is used to map the dimension of the input sequence to the dimension of the hidden layer features, and the end layer is used to map the dimension of the hidden layer features to the dimension of the output layer features. The middle of the network is A stack of single-dilated convolutional residual blocks As set, each single dilated convolution residual block consists of a one-dimensional dilated convolutional layer, a ReLU activation layer, a 1×1 convolutional layer, and a Dropout layer connected in series; The dual-dilation temporal convolutional network adds a new dilation convolutional layer to the single-dilation temporal convolutional network. The double-dilated convolutional residual block contains two dilated convolutional layers. The dilation coefficient of one layer increases with the number of layers, while the dilation coefficient of the other layer decreases with the number of layers. The convolution results of the two layers are fused by splicing. The rest of the structure is the same as that of a single dilated temporal convolutional network.
2. The method for detecting, classifying, and locating power quality composite disturbances based on MS-TCN++ according to claim 1, characterized in that, The power quality disturbance composite signal sample includes single disturbance signals, double disturbance signals, and triple disturbance signals; among which the normal signal is regarded as a special single disturbance signal.
3. The method for detecting, classifying, and locating power quality composite disturbances based on MS-TCN++ according to claim 1 or 2, characterized in that, In step 1, the samples are divided into training set, validation set and test set in a ratio of 4:1:1; each perturbation sample in the training set and validation set contains four noise levels: no noise, 50dB signal-to-noise ratio, 40dB signal-to-noise ratio and 30dB signal-to-noise ratio, and the proportions are equal.
4. The method for detecting, classifying, and locating power quality composite disturbances based on MS-TCN++ according to claim 1, characterized in that, The MS-TCN++ model works as follows: First, in the prediction generation stage, a one-dimensional sequence of PQDs is taken as input, and after passing through a double-dilated temporal convolutional network, the output activation function is used to map the output vector into the form of probability to obtain the initial class prediction results of each sampling point of the PQDs sequence. Each subsequent refinement stage takes the perturbation category prediction probability of each sampling point in the PQDs sequence output from the previous stage as input, and uses a single-dilation temporal convolutional network to continuously optimize the prediction probability.
5. The method for detecting, classifying, and locating power quality composite disturbances based on MS-TCN++ according to claim 1, characterized in that, Step 4 specifically involves: The MS-TCN++ model is trained using the training set. The total loss of the model is the sum of the loss values corresponding to the temporal convolutional networks at each stage. The loss value of each stage includes classification loss and smoothing loss. ; in, The total loss of the model, For the first The loss value of the stage model, This represents the total number of stages in the model. For classifying losses, To smooth out the loss, These are the weighting coefficients for smoothing the loss.
6. The method for detecting, classifying, and locating power quality composite disturbances based on MS-TCN++ according to claim 1, characterized in that, Step 5 further includes: The model's detection, classification, and temporal localization performance were evaluated using performance metrics on the test set. The performance metrics include evaluation metrics for detection and classification tasks and evaluation metrics for time localization tasks. Precision, recall, and F1 score are used as evaluation metrics for the model in detection and classification tasks at the basic perturbation level, while the mean absolute error of the start / end time of correctly identified samples for each basic perturbation is used as the evaluation metric for the model in time localization tasks at the basic perturbation level.