Method for predicting harmonic pollution in distribution box
By constructing a harmonic pollution prediction model composed of local attention and global attention, the problem of real -time monitoring and prediction of harmonic pollution in the power distribution system has been solved, and the accurate identification and prediction of harmonic pollution are realized. Operation and maintenance efficiency.
Patent Information
- Application Number
- CN202411400918.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-09
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-10-09
AI Technical Summary
The prior art is difficult to meet the real-time monitoring and prediction needs of harmonic pollution in power distribution systems, especially under the influence of complex load changes and a variety of environmental factors.
Adopt a harmonic pollution prediction model composed of local attention and global attention. By squeezing and encouraging operations to capture the relationship between local windows, combined with query selection and self -attention to capture the Grandpa dependency relationship in the capture time sequence. In the end Training model through reverse communication.
It achieves accurate identification of harmonic pollution and prediction of future trends, provides scientific basis to prevent potential harm caused by harmonic pollution, and improves the operation and maintenance efficiency of the power system.
Smart Images

Figure CN119357822A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of pollution prediction, and in particular relates to a method for predicting harmonic pollution in a distribution box. Background Art
[0002] In modern power systems, with the widespread application of various nonlinear load devices, the problem of harmonic pollution in distribution systems is becoming increasingly serious. Harmonics refer to components in current or voltage whose frequencies are integer multiples of the fundamental wave. These harmonics will cause the quality of power to deteriorate, which in turn will cause a series of problems, including equipment heating, increased noise, reduced system efficiency, and grid resonance. With the rapid development of power electronics technology and the promotion of smart grids, how to effectively monitor and predict harmonic pollution in distribution systems has become a technical problem that needs to be solved urgently.
[0003] Traditional harmonic analysis methods mainly rely on offline Fourier transform (FFT) technology to identify harmonic components by analyzing the spectrum of current and voltage waveforms. However, with the increasing complexity of distribution systems, harmonic detection and analysis based solely on Fourier transform has been unable to meet the needs of real-time monitoring and prediction. In addition, the generation of harmonic pollution is closely related to multiple factors such as load changes and environmental conditions in the distribution system. These complex relationships make the prediction of harmonic pollution very challenging.
[0004] In recent years, with the rapid development of artificial intelligence and big data technology, harmonic pollution prediction methods based on machine learning have gradually attracted attention. Through the analysis and modeling of a large amount of historical data, the machine learning model can effectively capture the changing laws of harmonic pollution and predict possible harmonic pollution problems in advance. Therefore, the present invention proposes a harmonic pollution prediction method for distribution boxes. This method can accurately identify the characteristics of harmonics by learning a large amount of collected data to capture the laws contained in the data, and has the ability to predict future harmonic trends, thereby providing a scientific basis for the operation and maintenance of the power system and preventing the potential hazards caused by harmonic pollution. Summary of the invention
[0005] The main purpose of the present invention is to provide a method for predicting harmonic pollution in a distribution box, aiming to construct a harmonic pollution prediction model for a distribution box, wherein the harmonic pollution prediction model consists of local attention and global attention, wherein the local attention captures the relationship between local windows through squeezing and encouragement operations to extract local significant features, the global attention reduces the amount of calculation through query selection, and captures the global long-range dependencies in the time series through attention calculation, and finally the model is trained by back propagation.
[0006] To achieve the above object, the technical solution of the present invention is: a method for predicting harmonic pollution in a distribution box, the method comprising: S1. Monitor and collect data sets related to harmonic pollution in distribution boxes. The data sets include total harmonic distortion rate of each related feature value and label column. The collection frequency is once an hour. S2, preprocessing the harmonic pollution related data set, wherein the preprocessing is to perform a time series segmentation operation; S3. Construct a prediction model for harmonic pollution in distribution boxes. The specific steps include: S31. A local attention mechanism is proposed to extract local salient features by capturing the relationship between local windows through squeezing and encouraging operations. S32. A global attention mechanism is proposed to reduce the amount of computation through query selection and capture the global long-term dependencies in the time series through attention calculation; S4, training the distribution box harmonic pollution prediction model, calculating the Loss value during the training process, and minimizing the Loss value by the model; S5. Test the harmonic pollution prediction model of the distribution box, and use the test set to detect the prediction accuracy of the pollution prediction model.
[0007] Furthermore, in the steps S3 and S31, local significant features are extracted by capturing the relationship between local windows, and the steps are divided into squeezing and encouraging operations; The squeeze operation obtains the weight of each window through global average pooling, averaging all time blocks in each window to calculate the weight of each window. The calculation formula is as follows: In the formula, Z and F jy (X) is the final output result of the squeezing operation on the input data X, C is the number of channels, c is the current number of channels, w is the number of time blocks in the current window, W is the number of time blocks in the window, and X is the input variable time series; through the Z formula, the local attention mechanism generates a global context descriptor Z for each window, and the descriptor reflects the importance of each window.
[0008] Furthermore, in the steps S3 and S31, the purpose of the encouragement operation is to learn the weight of the context descriptor through two linear projections, thereby adjusting the feature representation of each window. The encouragement operation maps the context descriptor Z obtained by the squeezing operation to a new space and uses the activation function ReLU for nonlinear transformation. The formula of the encouragement operation is as follows: H=F jl (Z) = W 2 ReLU(W 1 Z); Where W 1 , W 2is the learning parameter of linear projection, and the ReLU function is a nonlinear activation function used to introduce nonlinear transformation. Z is the final output result of the squeezing operation on the input data X. Through the encouragement operation, the local attention mechanism generates the adjusted context weight H, which is used to weight the original features.
[0009] Furthermore, in the steps S3 and S31, after obtaining the context weight H, the local attention mechanism dynamically adjusts the feature representation of each window by applying the H weight to the original feature X; the specific operation is completed by element-by-element multiplication, and the formula is as follows: S=F win (H, X) = X·Sigmoid(H); Where Sigmoid(H) maps the context weight H to the interval [0,1] to control the importance of each window, X is the input variable time series, and S is the result of applying the normalized weight to the original input feature X, that is, the final weighted feature.
[0010] Furthermore, in the steps S3 and S32, the global attention mechanism mainly includes two steps: query calculation and self-attention calculation, and the query, key, and value matrix are used as inputs of the global attention mechanism; The first is query selection, which selects the most significant queries in the window by averaging the metrics. The purpose of this process is to identify the queries that are most important for attention calculation, so that only these queries are used for subsequent self-attention calculation. The average metric formula is as follows: In the formula, q i is the i-th query vector, K j is the jth key vector, d is the dimension of the query and key vector, L k is the number of key vectors, To calculate the maximum dot product value between the i-th query and all keys, reflecting the maximum response of the query on the key, Calculate the average of the dot products of the i-th query and all keys, reflecting the average response of the query on the key.
[0011] Furthermore, in the steps S3 and S32, after selecting the significant query, the global attention mechanism performs attention calculation on the query to capture the global long-range dependency, and the unselected query uses the mean of the value matrix as a substitute to further reduce the amount of calculation. The attention calculation formula is as follows: Where V is the value matrix, K T is the transpose of the key matrix. If the query q iAmong the top-u significant queries, the dot product with the key is calculated and normalized by the Softmax function, and finally multiplied with the value matrix V to obtain the attention feature map S. If the query q i If the query is not in the top-u significant query, the mean of the value matrix V is used as a substitute, which greatly reduces the computational overhead.
[0012] Furthermore, in step S4, the final output S of step S3 is passed to the fully connected layer to map the high-dimensional features to the numerical value of the prediction target. The output of the fully connected layer can be expressed as: O = W·S + b; Where W is the weight matrix of the fully connected layer, b is the bias term, and O is the final predicted output value; The prediction model described in step S4 uses the mean square error loss function (MSE) as the prediction model objective function, and the MSE calculation formula is as follows: In the formula, Loss and MES are the loss function values, batch_size is the hyperparameter batch size value, which is 32, Y is the true value of the sample, O is the predicted value of the prediction model, and i is the i-th sample; the prediction model minimizes the Loss value to achieve the purpose of model training. During the training process, the hyperparameter learning rate learn_rate = 0.005, and the optimizer uses the stochastic gradient descent method.
[0013] In summary, due to the adoption of the above technical solution, the beneficial effects of the present invention are: In the present invention, a harmonic pollution prediction model for a distribution box is constructed, and the harmonic pollution prediction model consists of local attention and global attention, wherein the local attention captures the relationship between local windows through squeezing and encouragement operations to extract local significant features, and the global attention reduces the amount of calculation through query selection, and captures the global long-range dependency in the time series through attention calculation, and finally the model is trained by back propagation. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 The present invention is a flowchart of the steps of a method for predicting harmonic pollution in a distribution box.
[0015] Figure 2 The present invention is a flow chart of the steps of a harmonic pollution prediction model for a distribution box in a method for predicting harmonic pollution in a distribution box.
[0016] Figure 3 The structure diagram of a distribution box harmonic pollution prediction model used in a method for predicting harmonic pollution in a distribution box.
[0017] Figure 4This is a comparison between the predicted value and the true value of the distribution box harmonic pollution prediction model on the test set in a method for predicting harmonic pollution in the distribution box. DETAILED DESCRIPTION
[0018] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0019] See also Figure 1-Figure 4 The present invention provides a technical solution: a method for predicting harmonic pollution in a distribution box, the method comprising the steps of monitoring and collecting harmonic pollution-related data sets in the distribution box, preprocessing the harmonic pollution-related data sets, constructing a distribution box harmonic pollution prediction model, training the distribution box harmonic pollution prediction model, and testing the distribution box harmonic pollution prediction model.
[0020] Please refer to Figure 1 As shown, a method for predicting harmonic pollution in a distribution box in an embodiment of the present application, the specific steps are as follows:
[0021] S1. Monitor and collect data sets related to harmonic pollution in distribution boxes. The data sets include total harmonic distortion rate of each related feature value and label column. The collection frequency is once an hour.
[0022] Furthermore, in step S1, current and voltage sensors are installed in the distribution box to collect real-time current and voltage wave form data, and send them to the collection center via 5G communication. The collection center further determines the accuracy and reliability of the data and discards data with missing values. In addition, environmental factors such as temperature, humidity, and load conditions are also collected, which are also the causes of harmonics. The collection frequency is set to once an hour to fully collect the changing patterns of harmonic pollution.
[0023] S2. Preprocessing the harmonic pollution related data set, wherein the preprocessing is performing a time series segmentation operation.
[0024] Furthermore, in step S2, the harmonic pollution-related data set collected in step S1 is segmented into a sequence, and the segmentation method adopts a fixed time window method, and every 6 hours of data is used as a sample, that is, the sample data of the first 6 hours is used to predict the value of the total harmonic distortion rate of the 7th hour, and the sample at time t is X t ={..., x t-1 , x t}; Subsequently, the samples after the time segmentation are divided into a training set and a test set in a ratio of 7:3. The training set is used to train the distribution box harmonic pollution prediction model, and the test set is used to test the performance of the trained distribution box harmonic pollution prediction model.
[0025] S3, construct a distribution box harmonic pollution prediction model, the pollution prediction model steps are as follows Figure 2 As shown, the prediction model structure is as follows Figure 3 As shown, the specific steps include:
[0026] S31. A local attention mechanism is proposed to extract local salient features by capturing the relationship between local windows through squeezing and encouragement operations.
[0027] Furthermore, in the steps S3 and S31, local significant features are extracted by capturing the relationship between local windows, and the steps are divided into squeezing and encouraging operations; The squeeze operation obtains the weight of each window through global average pooling, averaging all time blocks in each window to calculate the weight of each window. The calculation formula is as follows: In the formula, Z and F jy (X) is the final output result of the squeezing operation on the input data X, C is the number of channels, c is the current number of channels, w is the number of time blocks in the current window, W is the number of time blocks in the window, and X is the input variable time series; through the Z formula, the local attention mechanism generates a global context descriptor Z for each window, and the descriptor reflects the importance of each window.
[0028] Furthermore, in the steps S3 and S31, the purpose of the encouragement operation is to learn the weight of the context descriptor through two linear projections, thereby adjusting the feature representation of each window. The encouragement operation maps the context descriptor Z obtained by the squeezing operation to a new space and uses the activation function ReLU for nonlinear transformation. The formula of the encouragement operation is as follows: H=F jl (Z) = W 2 ReLU(W 1 Z); Where W 1 , W 2 is the learning parameter of linear projection, and the ReLU function is a nonlinear activation function used to introduce nonlinear transformation. Z is the final output result of the squeezing operation on the input data X. Through the encouragement operation, the local attention mechanism generates the adjusted context weight H, which is used to weight the original features.
[0029] Furthermore, in the steps S3 and S31, after obtaining the context weight H, the local attention mechanism dynamically adjusts the feature representation of each window by applying the H weight to the original feature X; the specific operation is completed by element-by-element multiplication, and the formula is as follows: S=F win (H, X) = X·Sigmoid(H); Where Sigmoid(H) maps the context weight H to the interval [0,1] to control the importance of each window, X is the input variable time series, and S is the result of applying the normalized weight to the original input feature X, that is, the final weighted feature.
[0030] Furthermore, in steps S3 and S31, the local attention mechanism squeezes and encourages the two steps, effectively capturing the dependencies between different windows in the time series, and enhancing the model's sensitivity to key time periods by adjusting context weights. At the same time, it can dynamically adjust the feature representation of windows in time series data, highlighting important time blocks while suppressing insignificant time blocks, so that the model can pay more attention to the discriminative local features in the time series, thereby improving the performance of multivariate time series prediction tasks.
[0031] S32. A global attention mechanism is proposed to reduce the amount of computation through query selection and capture the global long-term dependencies in time series through attention calculation.
[0032] Furthermore, in the steps S3 and S32, the global attention mechanism mainly includes two steps: query calculation and self-attention calculation, and the query, key, and value matrix are used as inputs of the global attention mechanism; The first is query selection, which selects the most significant queries in the window by averaging the metrics. The purpose of this process is to identify the queries that are most important for attention calculation, so that only these queries are used for subsequent self-attention calculation. The average metric formula is as follows: In the formula, q i is the i-th query vector, K j is the jth key vector, d is the dimension of the query and key vector, L k is the number of key vectors, To calculate the maximum dot product value between the i-th query and all keys, reflecting the maximum response of the query on the key, Calculate the average of the dot products of the i-th query and all keys, reflecting the average response of the query on the key.
[0033] Furthermore, in the steps S3 and S32, the global attention mechanism mainly includes two steps: query calculation and self-attention calculation, and the query, key, and value matrix are used as inputs of the global attention mechanism; The first is query selection, which selects the most significant queries in the window by averaging the metrics. The purpose of this process is to identify the queries that are most important for attention calculation, so that only these queries are used for subsequent self-attention calculation. The average metric formula is as follows: In the formula, q i is the i-th query vector, K j is the jth key vector, d is the dimension of the query and key vector, L k is the number of key vectors, To calculate the maximum dot product value between the i-th query and all keys, reflecting the maximum response of the query on the key, Calculate the average of the dot products of the i-th query and all keys, reflecting the average response of the query on the key.
[0034] Furthermore, in the steps S3 and S32, after selecting the significant query, the global attention mechanism performs attention calculation on the query to capture the global long-range dependency, and the unselected query uses the mean of the value matrix as a substitute to further reduce the amount of calculation. The attention calculation formula is as follows: Where V is the value matrix, K T is the transpose of the key matrix. If the query q i Among the top-u significant queries, the dot product with the key is calculated and normalized by the Softmax function, and finally multiplied with the value matrix V to obtain the attention feature map S. If the query q i If the query is not in the top-u significant query, the mean of the value matrix V is used as a substitute, which greatly reduces the computational overhead.
[0035] Furthermore, in steps S3 and S32, the global attention mechanism effectively captures the global long-range dependencies in the time series through the sparse attention mechanism, while avoiding the computational complexity problem of the traditional attention mechanism under large windows. By selecting the most significant queries and performing attention calculations on them, the global attention mechanism can enhance the model's sensitivity to global information without significantly increasing the computational cost.
[0036] S4. Train the distribution box harmonic pollution prediction model, calculate the Loss value during the training process, and minimize the Loss value by the model.
[0037] Furthermore, in step S4, the final output S of step S3 is passed to the fully connected layer to map the high-dimensional features to the numerical value of the prediction target. The output of the fully connected layer can be expressed as: O = W·S + b; Where W is the weight matrix of the fully connected layer, b is the bias term, and O is the final predicted output value; The prediction model described in step S4 uses the mean square error loss function (MSE) as the prediction model objective function, and the MSE calculation formula is as follows: In the formula, Loss and MES are the loss function values, batch_size is the hyperparameter batch size value, which is 32, Y is the true value of the sample, O is the predicted value of the prediction model, and i is the i-th sample; the prediction model minimizes the Loss value to achieve the purpose of model training. During the training process, the hyperparameter learning rate learn_rate = 0.005, and the optimizer uses the stochastic gradient descent method.
[0038] S5. Test the harmonic pollution prediction model of the distribution box, and use the test set to detect the prediction accuracy of the pollution prediction model.
[0039] Furthermore, in step S5, the performance of the distribution box harmonic pollution prediction model is tested using a test set, such as Figure 4 As shown in the figure, the model predicts the total harmonic distortion rate value of 20 samples in the next hour. The solid line is the true value of the sample, and the dotted line is the predicted value of the prediction model. It can be seen from the figure that the predicted value of the prediction model is slightly different from the true value, which proves that the model has accurate prediction ability.
Claims
1. A method for predicting harmonic pollution in a distribution box, characterized in that: The following steps are involved: S1. Monitor and collect data sets related to harmonic pollution in distribution boxes. The data sets include total harmonic distortion rate of each related feature value and label column. The collection frequency is once an hour. S2, preprocessing the harmonic pollution related data set, wherein the preprocessing is to perform a time series segmentation operation; S3. Construct a prediction model for harmonic pollution in distribution boxes. The specific steps include: S31. A local attention mechanism is proposed to extract local salient features by capturing the relationship between local windows through squeezing and encouraging operations. S32. A global attention mechanism is proposed to reduce the amount of computation through query selection and capture the global long-term dependencies in the time series through attention calculation; S4, training the distribution box harmonic pollution prediction model, calculating the Loss value during the training process, and minimizing the Loss value by the model; S5. Test the harmonic pollution prediction model of the distribution box, and use the test set to detect the prediction accuracy of the pollution prediction model.
2. A method for predicting harmonic pollution in a distribution box according to claim 1, characterized in that: In step S1, the current and voltage wave form data in the distribution box are collected and sent to the collection center via 5G communication; in addition, temperature, humidity, and load condition environmental factors are also collected, and the collection frequency is set to once an hour.
3. A method for predicting harmonic pollution in a distribution box according to claim 2, characterized in that: In the steps S3 and S31, local significant features are extracted by capturing the relationship between local windows, and the steps are divided into squeezing and encouraging operations; The squeeze operation obtains the weight of each window through global average pooling, averaging all time blocks in each window to calculate the weight of each window. The calculation formula is as follows: In the formula, Z and F jy (X) is the final output result of the squeezing operation on the input data X, C is the number of channels, c is the current number of channels, w is the number of time blocks in the current window, W is the number of time blocks in the window, and X is the input variable time series; through the Z formula, the local attention mechanism generates a global context descriptor Z for each window, and the descriptor reflects the importance of each window.
4. A method for predicting harmonic pollution in a distribution box according to claim 3, characterized in that: In the steps S3 and S31, the purpose of the encouragement operation is to learn the weight of the context descriptor through two linear projections, thereby adjusting the feature representation of each window. The encouragement operation maps the context descriptor Z obtained by the squeezing operation to a new space and uses the activation function ReLU for nonlinear transformation. The formula of the encouragement operation is as follows: H=F jl (Z)=W2 ReLU(W1 Z); Where W1 and W2 are the learning parameters of linear projection, ReLU function is a nonlinear activation function used to introduce nonlinear transformation, and Z is the final output result of the squeezing operation on the input data X; Through the encouragement operation, the local attention mechanism generates the adjusted context weights H, which are used to weight the original features.
5. A method for predicting harmonic pollution in a distribution box according to claim 4, characterized in that: In the steps S3 and S31, after obtaining the context weight H, the local attention mechanism dynamically adjusts the feature representation of each window by applying the H weight to the original feature X; the specific operation is completed by element-by-element multiplication, and the formula is as follows: S=F win (H,X)=X·Sigmoid(H); Where Sigmoid(H) maps the context weight H to the interval [0,1] to control the importance of each window, X is the input variable time series, and S is the result of applying the normalized weight to the original input feature X, that is, the final weighted feature.
6. A method for predicting harmonic pollution in a distribution box according to claim 5, characterized in that: In the steps S3 and S32, the global attention mechanism mainly includes two steps: query calculation and self-attention calculation, and the query, key, and value matrix are used as inputs of the global attention mechanism; The first is query selection, which selects the most significant queries in the window by averaging the metrics. The purpose of this process is to identify the queries that are most important for attention calculation, so that only these queries are used for subsequent self-attention calculation. The average metric formula is as follows: In the formula, q i is the i-th query vector, K j is the jth key vector, d is the dimension of the query and key vector, L k is the number of key vectors, To calculate the maximum dot product value between the i-th query and all keys, reflecting the maximum response of the query on the key, Calculate the average of the dot products of the i-th query and all keys, reflecting the average response of the query on the key.
7. A method for predicting harmonic pollution in a distribution box according to claim 6, characterized in that: In the steps S3 and S32, after selecting the significant query, the global attention mechanism performs attention calculation on the query to capture the global long-range dependency. The unselected query uses the mean of the value matrix as a substitute to further reduce the amount of calculation. The attention calculation formula is as follows: Where V is the value matrix, K T is the transpose of the key matrix. If the query q i Among the top-u significant queries, the dot product with the key is calculated and normalized by the Softmax function, and finally multiplied with the value matrix V to obtain the attention feature map S. If the query q i If the query is not in the top-u significant query, the mean of the value matrix V is used as a substitute, which greatly reduces the computational overhead.
8. A method for predicting harmonic pollution in a distribution box according to claim 7, characterized in that: Furthermore, in step S4, the final output S of step S3 is passed to the fully connected layer to map the high-dimensional features to the numerical value of the prediction target. The output of the fully connected layer can be expressed as: O = W·S + b; Where W is the weight matrix of the fully connected layer, b is the bias term, and O is the final predicted output value; The prediction model described in step S4 uses the mean square error loss function (MSE) as the prediction model objective function, and the MSE calculation formula is as follows: In the formula, Loss and MES are the loss function values, batch_size is the hyperparameter batch size value, which is 32, Y is the true value of the sample, O is the predicted value of the prediction model, and i is the i-th sample; the prediction model minimizes the Loss value to achieve the purpose of model training. During the training process, the hyperparameter learning rate learn_rate = 0.005, and the optimizer uses the stochastic gradient descent method.
Citation Information
Patent Citations
Two-channel wind power prediction method integrated with extrusion incentive attention mechanism
CN115577748A
MOOCs science prediction model construction method based on attention mechanism
CN116028861A
Power load prediction method based on multivariable time sequence information interaction
CN118333232A
Water supply pipeline microbial pollution dynamic monitoring and disinfection response prediction method
CN118568448A
Time-series image description method for dam defects based on local self-attention
US20230368500A1