DC Power Transmission ( ACDC 2018 ) Study on quick judgment of power system stability using improved k-NN and LASSO method

Dynamic security assessment is widely used in dispatching operation systems, and calculation speed is one of its most important performance indices. In this study, an improved k-nearest neighbour (k-NN) method is proposed aiming to predict the stability indicators of power system, for example, critical clearing time. The method is much faster than the simulation and suitable for online analysis. Firstly, a simulation sample database is constructed based on historical online data and a logistic regression model with least absolute shrinkage and selection operator is trained to pick the stability features, which are chosen from static quantities like running state and active power of electric elements. While a new operation mode needs to be evaluated, a weighted k-NN is implemented to obtain the most familiar samples in the database using the chosen features; the final result will be determined comprehensively by the familiar samples. The validity of the proposed method is verified by simulation using online data of State Grid Corp of China and different key faults. It is proved that the method meets the requirements for speed and accuracy of online analysis system.


Introduction
Along with the development of ultra-high voltage (UHV) technology, the characteristic of the power system is facing profound changes.It has been proved that higher voltage, larger scale and capacity lead to greater harm and more complexity of the dynamic process while fault occurs.
In China, dynamic security assessment (DSA) has been widely applied in dispatching systems above the provincial level, which is also unknown as online security and stability analysis.A comprehensive security analysis will be made by DSA every 15 min, which includes more than 1000 transient stability simulation of pre-defined faults, and needs extremely large calculation.However, calculation speed is the main performance index, as the analysis result will become meaningless without timeliness.As calculation quantity and speed are contradictory, some kinds of quick judgment technologies need to be proposed which could calculate the stability indicators with small calculation cost and only pick the real dangerous faults to make the simulation, so the computing resource will be saved and early warning time of DSA will be shorten.
With the operation of DSA system, a great amount of historical data has been produced, which both includes the power flow data and stability analysis result.There are many regularities and experiences contained in the historical data, which could be applied in quick judgment of online stability analysis to improve the calculation speed and validity.Some analyses of quick judgment have already been made by using historical data and machine learning method [1][2][3][4][5][6][7].
In this paper, with the consideration that it is easy to find similar samples in the latest historical online data, the logistic regression with least absolute shrinkage and selection operator (LASSO) and improved k-NN method are introduced to extract the stability features and make the quick judgment.It is proved that the method could shorten the calculation time significantly with slight decrease of accuracy, and meets the requirements of online analysis.
The rest of the paper is organised as follows: Section 2 introduces the LASSO method for extracting features and the improved k-NN for quick judgment; Section 3 describes the main ideas and analysis steps of the method; results are illustrated and evaluated in Section 4 using actual data; and Section 5 concludes the paper.

Logistic regression
Logistic regression is a supervised learning method to solve the classification task.On the basis of linear regression, a sigmoid function is added to map the results of linear regression to (0.0, 1.0).By comparing the value and threshold value, for example, 0.5, the classification result will be determined.The sigmoid function transforms the numerical regression problem into a classification problem, and effectively improves the robustness of the algorithm.The sigmoid function formula is shown in the following formula: where x is the input state; and θ is a logistic regression parameter.The cost function J(θ) of simple binary classification problems can be defined as the formula (2).The optimal parameter of θ is obtained by minimizing J(θ) where x is sample input; y is labels of sample classification; m is the total number of samples.For multi-classification problems, formula (2) can be modified to a new form as where x is the sample input; y is sample label; m is the total number of samples; k is the number of classifications.'1{}' is a characteristic function which returns 1 if the condition is true and returns 0 otherwise.

LASSO
LASSO method adds a penalty function of L1-norm of the parameter matrix θ to the cost function of logistic regression.It depresses the unimportant coefficients to zero or near zero, and leads to a more refined model.After training the model, the primary parameters will be more prominent, so that the features are extracted out.The cost function of LASSO is shown in the following formula: where λ is a super parameter used for trade-off between the actual cost and the penalty value of parameter θ.

Improved k-NN
k-NN method is to find the most similar samples to determine the classification or regression result of the unknown data.The key issue is to obtain the distances between samples and unknown data that indicate the similarity.There are many algorithms for distance calculation like Euclidean distance, Manhattan distance etc. Normalisation should be implemented before the distance calculation because the ranges of static state values are different.In this paper, Euclidean distance is applied and two improvements are made to meet the requirement of online analysis: i. Weight of stability features.The absolute value of the parameter matrix θ is used as the weight of each stability feature.So the more important features have greater influence.ii.Deal with the unknown values.Sometimes, a few of static state values may be unknown which could not be simply ignored, because ignoring means the feature has the same value in the samples and target data.An additional factor should be considered while ignore the unknown feature.
With these considerations, formula ( 5) is proposed to determine the distance between samples where x is a historical sample; y is the target data; r is the weight of feature.
After the calculation of distances between all samples and target data, k samples with minimum distances will be pick out as the basis of prediction.Finally, weighted mean is applied to determine the critical clearing time (CCT) result using the reciprocal of distance as the weight.

Methodology
A kind of fast searching algorithm is implemented in this paper using static state values of power system as its input and CCT as its predicting target.As there are so many static state values that have different influences on the stability, it is impossible to use all of the static state values.Instead, the stability features must be the most influential ones that should be picked out by feature engineering.There are two kinds of feature engineering: model-driven method that uses professional domain knowledge and data-driven method that finds out relationships between data like machine learning.In this paper, the logistic regression with LASSO is proposed for feature engineering, and k-NN is used for quick judgment, the detailed process is as follows: 3. 1 Step 1: establish the historical database i. Inputs: This step will be done with the operation of the DSA system.The online data is produced every 15 min, which both includes the power flow data and stability analysis result.The static state values including single values and compound values are listed in Tables 1 and 2. ii.Predicting target: Three-phase short circuit is the most common fault type in power system; the CCT of three-phase short circuit means the maximum fault clearing time that keeps the whole power system stable.CCT represents the boundary of stability: the bigger CCT means the more stable power system.We use the CCT as the stability indicator and predicting target.As the CCTs are discrete values with the interval of simulation step size, the predicting task can be considered as a multi classification problem.

LASSO model training
LASSO algorithm is solved by iteration process: i. Determine the input as well as the number of classification, and then determine the dimensions of the parameter matrix θ; ii.Define the cost function as formula (4); iii.Use the iterative method to minimise the cost function.In each step, calculate the cost function and gradient to updating θ.
where λ is a super parameter: a larger λ means emphasis on the penalty term of θ, which may lead to a bigger actual error that unable to reflect the stability characteristics of the power grid.Therefore, the selection of λ is the key issue.
In this paper, the model is trained for many times to seek the optimal value of λ.When the penalty term is not considered (λ = 0), the error rate will be the lowest that is defined as the base line.The parameter λ can be equidistant values in exponential coordinate, for example 1, 0.1, 0.01 etc.

Feature selection
According to the characteristics of logistic regression, parameter matrix θ represents the weight of each input.The greater value means the more important input.The dimensions of the matrix θ are m*k, that is: each raw corresponds to one input, and each column corresponds to a classification type.Therefore, the algorithm sums the absolute values of each row of the matrix θ, and selects the largest number of the results as the stability features.

K-NN
While a new operation mode is received, the k-NN will be started to predict the CCT result.As the k-NN could be executed highly parallel, this step will be very fast, always <1 s.Main procedure is list as below: i. Get the stability features and their weights from LASSO model.ii.Calculate the distances between historical samples and online data by formula (5).iii.Sort the distances and pick out the k nearest samples which are the most similar ones.iv.Calculate the weighted mean to determine the final CCT result.

Time domain simulation
Calculate the real CCT result by time-domain simulation to verify the method.Then, put the latest power flow data and real CCT result into the historical database for the next prediction.Algorithm flow chart is shown in Fig. 1.

Examples
The validity of proposed method is verified by simulation using online data of State Grid Corp of China for 10 months and different key faults.All the power element models above 220 kV have been included in the online data.The number of static state values is 43,114 which are listed in Tables 1 and 2, the number of predefined faults is 10.The test is done month by month: take the data of last month as historical data to predict the CCT result of this month.

LASSO model training
Choose seven different λ for model learning, respectively: 0, 1, 0.1, 0.01, 0.001, 0.0001 and 0.00001.Take Gegang Line as an example: the inputs are the active power of the generators that have 1325 variables; the range of Gegang Line's CCT is 0.19-0.36with the interval of 0.01, so there are 18 possibilities; the parameter matrix is 1325*18, which has 23,850 parameters.The results are shown in Table 3.
The error rate while λ = 0.1 or λ = 1 is obviously too large, indicating that the model cannot reflect the stability characteristics of the power grid, so it needs to be ignored.The rest results show that the error rate increases with the increase of λ, while the compression ratio of θ also increases as expected.We choose the LASSO model with λ = 0.0001 as the best model.

Feature selection
We use the sum of the absolute value of the parameter matrix θ to extract features, and the results are shown in Table 4.
As the Gegang Line is very close to the SX Power Plant, the instability form is always the angle instability of the SX generator and the generators in North China (such as Shandong or Hebei Province).Therefore, the most important features must be in or near SX Power Plant that is consistent with the general rule of stability analysis.

K-NN
The test is done for k = 1, 3, 5, 7 and 9 separately.The error rate of predicting Gegang Line's CCT is shown in Table 5, as well as Table 6 for predicting Huangbin Line's CCT.The error rate is defined as formula (6).
Tables 5 and 6 show that the average errors are very low: 0.49% for Gegang Line (k = 1) and 2.88% for Huangbin Line (k = 3).However, the maximum errors are always high that means the method still has room for improvement.The calculation time for each online data is <1 s.The examples show that the method has got good effect on calculation accuracy and speed.

Conclusion
An improved k-NN method is proposed to predict the stability degree of power system based on historical database, which is very appropriate for online stability analysis.Simulation and experimental results verify the correctness and effectiveness of the proposed method.It is also necessary to make further improvements, such as: i. Try more features that make influence on the angle stability of power system; ii.Study on rapid and automatic methods for searching the optimal value of super parameter λ.

Table 3 LASSO
model training result of Gegang Line λ