{'fraction_non_alphanumeric': 0.03359375, 'fraction_numerical': 0.01421875, 'mean_word_length': 4.736779205258441, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Hierarchical Agglomerative Clustering of Selected Hungarian Medium Voltage Distribution Networks

Nowadays the increase of photovoltaic penetration and simultaneously, the decentralization of electricity system, poses a number of challenges for distribution system developers and operators. The spread of high output power photovoltaic power plant connections demands the development of a network infrastructure. The analysis of development directions can be done with software simulation, for which network models are needed, which can characterize real networks well. To create such reference networks, knowing existing topologies, hierarchical agglomerative clustering can be a solution. When the parameters of the clusters are specified well, their software implementation can be done. In this study, a possible clustering process of selected Hungarian medium voltage overhead networks (including the determination of the optimal cluster number too), and the formulated network clusters are presented. The clustering of twenty selected 22 kV medium voltage networks was done using hierarchical agglomerative clustering. Then the optimal cluster number was determined. Based on Davis-Bouldin and Silhouette criterions, this cluster number was four. Two of the four generated clusters are single clusters, containing only one feeder. The size and looping of the characterized sample networks are well observable. In this paper a method has been created to generate medium voltage distribution network models, which can be used to simulate the effects of the growing photovoltaic penetration in the Hungarian distribution network.


Introduction
Nowadays, in both domestic and international energy market trends, photovoltaic penetration quickly increases. Photovoltaic systems, considering their output power, covering the entire power plant range (from household size small to size small and over that). A large amount of this (approx. 333 MWp, which is 56%) is household size small power plants. Due to a change of the renewable support system at the end of 2016, the number of "applications for licenses for the installation" of photovoltaic power plants with 500 kVA output power increased significantly. Based on the photovoltaic market predictions, in the next decade, the number of small power plants is going to increase, which will increasingly decentralize the structure of the electricity infrastructure (firstly at the distribution voltage level) [1] [2]. In Table 1, the increasing tendency of the built-in photovoltaic capacity is shown. In order for the low, and medium voltage networks to approximate the smart grid structure, electricity infrastructure development is necessary. Modeling of these distribution networks (here on medium voltage level) is essential to determine development directions and to answer emerging questions. For these simulations, the software implementation of medium voltage networks is recommended. Because in the examined area, there is a significant number of varied topology medium voltage networks, their software implementation and running simulations is a powerful time and resource consuming task. It is recommended to formulate reference networks with which the real feeders can well be described. Such reference networks can be created by clustering real networks. These distribution network models can be approximated more precisely than the mathematical models described in the literature [5]. Thus, real decision situations can be handled by the generated reference networks. In this paper a method has been created to generate Hungarian medium voltage distribution network models.
In Section 2 the used hierarchical agglomerative clustering method is presented, with which the numerous medium voltage networks are decreased to a manageable number of clusters. In Section 3.1, the examined distribution feeders are presented. In Section 3.2, the clustering method and principal component analysis are used, in Section 3.3 the determination process of the optimal cluster number are presented. Section 4 d the results of clustering and the generated clusters are presented.

Data Analysis Techniques
Data mining techniques can be used to get significant information from the examined database. [2].By reviewing a number of studies (Table 2) in which some kin fog these techniques (typically clustering methods) were used for grouping low or medium voltage electricity network, it can be said that classification, Kmeans (and K-medoids) clustering and hierarchical clustering are the most frequently used methods. [3]  The description of the mentioned methods are not presented in this paper, the clustering processes, the advantages and disadvantages of them can be found in another review paper of the authors [3].
The number of the examined feeders is relatively small (20), hierarchical agglomerative clustering can be used.

Hierarchical Agglomerative Clustering
"In hierarchical clustering, clusters are determined with the relative distance (Euclidean distance) between the examined data points. The main concept is that a selected item is more tied to a closer data point that to a farther one." [3] [15] At the beginning of this process, all the data points (n) are considered as a single cluster. At each step of the algorithm, all data points are moved to a larger cluster. The clustering algorithms stop when all the n points are in the same cluster. As the graphical representation of the clustering, a tree-structure (dendrogram) can be used, which can be cut off at any level. At this level, the leave elements of the tree represent the clusters [2] [3] [4] [14].
The advantage of the algorithm is that "it corrects the distance errors between the local minimum and the center of the clusters" [3] [4]. Besides the positive attributions, there are many negative ones too. The greatest one is the irrevocability of cluster merges. In one step if two clusters are combined, they cannot be divided again later, since the new cluster is used in the future steps of the algorithm. These steps are critical because incomplete mergers give incorrect results (clusters) [3] [4] [14] 3 Clustering Method

Input Network Data
In this publication, 20 selected Hungarian medium voltage, 22 kV overhead distribution feeders which can be found in the same distribution system operator area, but at four different locations were examined. At the selection of the feeders, the most important criteria were to be able to physically accommodate (approx. 500 kVA) photovoltaic small power plants (output power approx. at least 500 kVA, area is at least 1 ha). Half of the examined networks are located in rural areas and the other half of them are located in suburban settings.
Here, the examined networks are handled as graphs. These graphs can be characterized by specific mathematical variables, such as: The average node degree can be defined with Eq. 1.
"where E is the number of edges, N is the number of nodes of the graph". [4] The clustering coefficient can be defined with Eq. 2.
"where e j,k is edge between vertex v j with v k ; N i is the set of immediately connected neighboring vertices for a vertex v i ; k i is the element number of N i and n is the size of the graph". [4] The CPL is interpreted as the impedance values of the lines (feeders). It can be defined with Eq. 3.
"where n is the size of the graph, and d is the distance between any two nodes of the graph". [4] The values of these parameters can be found in Table 3. To calculation they, the built-in functions of MATLAB R2018b were used. Based on the parameters, it can be said that the feeders have a varied size (node number) and topology.
According to the confidentiality agreement signed between the Centre for Energy Research and the Distribution System Operator (DSO), the authors are not allowed to publish raw data.

Principal Component Analysis
In this article, hierarchical agglomerative clustering is used.
The most frequently used variables to describe clusters are the size of the network (number of nodes), the degree distribution of feeders (average node degree), the clustering coefficient and the characteristic path length of the feeders. The values of the parameters can be seen in Table 3.
The network analysis is a procedure, in which often more than two variables are taken into account. The handling of a large dataset of multiple variables as a compact unit is a tough assignment. It is recommended to decrease the number of variables, without losing information. A solution can be for this reduction is the principal component analysis (PCA). Using PCA the nature of the array can be written with fewer mathematical parameters (factors) that contain most of the original information. Another task is to describe the nature of correlation between the original variables with the principal components [15] [18].
In this case, the feeders are characterized by four variables. Treating them as a unit is not easy, it is recommended to complete the principal component analysis.
To get the values of the principal components, MINITAB 18.0, a statistical software was used. [4] The description of the algorithm used in the MINITAB software can be found at [36].
Based on the scree plot of the main components (seen in Figure 1) and using the "Elbow" criterion, the optimal number of principal components can be determined, which is equal to 2. This means that the examined feeders can be described with the first and second principal components [4]. The numeric values of the principal components for the original parameters and for the examined networks can be seen in Tables 4 and 5, respectively [4]. These values can be used in the clustering process, using a hierarchical agglomerative clustering algorithm.

Optimal Cluster Number
At the first step of the agglomerative clustering, the cluster number is decided. The determination of the optimal cluster number is based on the simultaneous application of Davies-Bouldin (DB) validity criteria and Silhouette (Si) validity criteria [4] [21] [28]. For the determination of DB and Si values the built-in functions of MATLAB R2018b academic version is used.

Determination of the Optimal Cluster Number
Empirically, in the case of a small number of data sets (around some 10 to 100), the optimal cluster number is between 2 and 5. It coincides with what was described in [28]. Therefore, the minimum number of the clusters can be determined with Eq. 4, and the maximum number of clusters can be determined with Eq. 5.
"where M min is the minimal number of the clusters" [28].
In this paper, the optimal cluster number has been investigated in the range, defined in Eq. 6 (cluster number is 2, 3, 4 or 5), their values are calculated with the simultaneous application of Davies-Bouldin and Silhouette criterions.

Davies-Bouldin Criterion
"The Davies-Bouldin evaluation is an object consisting of sample data, clustering data, and Davies-Bouldin criterion values used to evaluate the optimal number of clusters. This criterion is based on a ratio of within-and between-cluster distances." [4] [31] The Davies-Bouldin index can be defined with Eq. 7 [4] [28] [31] [32].
"where D i,j is the within-to-between cluster distance ratio for the i th and j th clusters" [28]. The mathematical description of this distance can be seen in Eq. 8 [24] [25] [28].
"where is the average distance between each point i and the centroid of the i th cluster, is the average distance between each point and the centroid of the j th cluster, d i,j is the Euclidean distance between the centroids of the i th and j th clusters" [24] [25] [28].
There is the worst-case for cluster i when D i,j has a global maximum at within-tobetween cluster ratio. The optimal cluster number can be identified when the Davies-Bouldin index has a global minimum [4] [24] [25] [28].
The objective function of the optimization problem based on Davies-Bouldin validity index is defined with Eq. 9.
"where M opt is the optimal number of the clusters, m is the number of clusters" [28].

Silhouette Criterion
"The value of the Silhouette criterion is a metric of how similar is the examined point to the other points in the same cluster, compared to points in other clusters." [4] [33] The Silhouette value (Si) for the point i, can be defined with Eq. 10 [4] [28] [33].
"where a i is the average distance from point i to the other points of the cluster, b i is the minimum average distance from point i to the points in another cluster" [4] [28] [33].
The value of the Si can be in the range from -1 to +1. If it is closer to +1, point i is well-matched to its own, and poorly-matched to the other clusters. The optimal cluster number is then when the Silhouette index has a global maximum [4] [28] [33].
The objective function of the optimization problem based on Davies-Bouldin validity index is defined with Eq. 11.
"where M opt is the optimal number of the clusters, m is the number of clusters" [28].
The results of the two methods described above can be seen in Figure 2. The values of the validity indexes for each cluster number are depicted in Figure 2. Based on these, the optimal cluster number is 4 [4] [28] [33]. The clustering algorithm was run 20 times to avoid local minima. The result of clustering was always the same. The clustering algorithm was convergent.

Results
In this publication, from the previously presented 20 medium voltage networks described above, by using principal component analysis and hierarchical agglomerative clustering algorithm, 4 network clusters were created. Clustering was done using the tutorial version of MINITAB 18.0 statistical software.
In MINITAB 18.0, the agglomerative clustering method is based on the complete linkage method (also called furthest neighbor method), in which "the distance between two clusters is the maximum distance between an observation (feeder or data point) in one cluster and an observation (feeder or data point) in the other cluster" [37]. The complete distance is calculated with Eq. 10 [37].
where d m,j is the distance between clusters m and j; m is a merged cluster that consists of clusters k and l, with m = (k,j); d k,j distance between clusters k and j; d l,j distance between clusters l and j [37].
The graphical representation of the clustering (dendrogram), can be seen in Fig. 3. In this figure, the clusters are colored respectively.  The score plot for the eigenvalues of principal components for the clustered feeders The score plot for the values of principal components for the clustered feeders In Figure 5, the centroids of the non-single element clusters are marked with black square markers, and the markers of real networks closest to the centroids are labeled too. The values of the centroids (see Table 6), were determined as the average of the data points in a cluster with them. The centroids of the one element clusters are the feeders, included in each cluster. The final partition of clustering and the various distance metrics of the clusters can be seen in Table 7. For the average numeric values of the variables, see Table 8. In order to illustrate the characteristics of the typical network topology of clusters, the representation of sample networks, which are the closest to the previously defined centroids, are presented. These networks with their identifier are shown in Figure 5, and their topology can be seen in Figures 6-9.
In Cluster 1, there are 4 weakly looped networks. While the element number of the cluster is not too large (4) and the feeders are fairly similar, the sum of squares of distances within the cluster is approximately the quarter of the same value in Cluster 2. The distances from the centroids are in the same range for Clusters 1 and 2, so it can be said that these clusters are compact. The graphical representation of feeder N9 is shown in Figure 6. Topology N9 is a medium-sized, weakly looped medium voltage (22 kV) overhead network, located in a suburban area. In Figure 6, the HV/MV (132 kV/22 kV) substation is marked with red.  Topology N11 is a radial network, placed in the rural area. From the four reference networks, this is the smallest one (smallest node number and CPL value). In Figure 7, the HV/MV (132kV/22kV) substation is marked with cyan.
Clusters 3 and 4 are single clusters. The networks in these clusters are fairly large, and the CCs are the biggest ones too. These networks are located in a suburban area (Cluster 3). These clusters cannot be as relevant as Clusters 1 and 2, because the element number is only 1. The graphical representation of feeder N6 can be seen in Figure 8. The topological representation of feeder N6 in Cluster 3

Figure 9
The topological representation of feeder N16 in Cluster 4 Topology N6 is a large, and heavily looped medium voltage network, located near the suburban area of the capital city of the county. Out of the four reference networks, this is the biggest one (highest node number and CPL value). In Fig. 8, the HV/MV (132 kV/22 kV) substations are marked with red (the two substations are different).
Topology N16 is similar to N9, but the node number is much higher. This topology is a large (not as large as N6), weakly looped medium voltage network, in a suburban area of a town. As in the case of N6 (Cluster 3), this topology also contains loops, but less. In Figure 9, the HV/MV (132 kV/22 kV) substations are marked with red (the two substations are different).

Conclusions
In this study, a network clustering method on Hungarian medium voltage distribution feeders has been displayed, which is suitable for the efficient processing of smaller or larger amounts of a data array. Found on the international studies published in the literature, at the formulation of network groups the agglomerative hierarchical clustering and PCA were used. With PCA, the number of the original variables space was reduced from four to two, and this twodimensional component space was clustered. At the first step, as an input parameter of the clustering algorithm, the optimal number of the clusters was described using the Davies-Bouldin and Silhouette criterions. Both methods led to the same result, the optimal cluster number is 4. The results of the clustering were presented in Section 4. As the topologies of feeders are fairly varied, distinct clusters have been formulated. Two of the clusters (Clusters 3 and 4) are single clusters because in each of these clusters the is only one feeder.
The data processing and clustering method presented in this paper can be well used for clustering networks that cover a physically large area (eg. a country), formulating network topologies specific to the examined area.
Herein, a method has been created to generate Hungarian medium voltage distribution network models, which can be used to simulate the effects of the growing photovoltaic penetration within the Hungarian distribution network. In addition, these results can also help in modeling the voltage and power changing effects on these networks. On the reference networks the effects of growing electrical car numbers, the energy storage penetration and the opportunities for smart grid development can also be simulated.