A software architecture recovery method based on adaptive grid partitioning and clustering

By constructing software correlation networks and adaptive meshing, and using network embedding algorithms and clustering algorithms, the problems of clustering algorithms in initial center point selection and abnormal point processing are solved, and fast and accurate software architecture recovery is achieved.

CN114428632BActive Publication Date: 2024-09-17XI AN JIAOTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210074711.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-21
Publication Date
2024-09-17
Estimated Expiration
2042-01-21

AI Technical Summary

Technical Problem

The randomness of initial center point selection and sensitivity to abnormal points in existing clustering algorithms lead to low efficiency and reduced accuracy in software architecture recovery, and manual setting of parameters affects clustering quality.

Method used

By constructing a software correlation network, the network embedding algorithm is used to obtain feature vectors, adaptive meshing is used to determine the parameters of the clustering algorithm, abnormal points are removed, and iterative clustering is performed to obtain an accurate software architecture module description.

Benefits of technology

It improves the efficiency of feature vector extraction, automatically determines key parameters, effectively removes outliers, solves the problem of initial center point randomness, and quickly and accurately obtains software architecture module descriptions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114428632B
    Figure CN114428632B
Patent Text Reader

Abstract

The present invention discloses a software architecture recovery method based on adaptive grid partitioning and clustering, which utilizes the dependencies between software to reorganize its software architecture in order to restore its software architecture description. First, a software association network is constructed using software source code, and a suitable network embedding algorithm is selected to extract feature vectors; secondly, the extracted feature vectors are used for internal analysis to obtain relevant parameters required by the clustering algorithm, and the feature vectors are divided in the grid space, and the initial center point required for clustering iteration is determined by screening out dense grid areas; finally, the initial center point is used to perform partitioning and clustering iteration, and the final result is a description of the relevant software architecture with source files as nodes. The present invention can quickly and effectively cluster software source files, obtain relatively accurate clustering results as software framework descriptions, and solve the problems that the existing feature extraction operation based on code characteristics is cumbersome and the accuracy of clustering results is low.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of clustering algorithm research and software architecture recovery, and in particular relates to a software architecture recovery method based on adaptive grid partitioning clustering. Background Art

[0002] The architecture of a software system usually uses different module views to describe the process of different modules forming subsystems. For object-oriented systems, module views describe classes and their relationships. The architecture of a software system is very important. It can be used to determine whether a system is capable of meeting its overall needs, adapting to changing needs, and supporting component reuse. Although the description of the architecture is very important, there is no corresponding architecture description for most software systems. Therefore, in recent years, researchers have designed and developed technologies to provide automated support for software architecture recovery. Clustering, as a quasi-automatic technology for software architecture recovery, has been widely studied and used. As one of the top ten algorithms in the field of data mining, the K-Means algorithm has been widely used due to its simple and fast characteristics. However, the randomness of its initial center point selection is a big problem, because different initial point selections will have different degrees of impact on the clustering results and will greatly reduce the efficiency of the algorithm. On the other hand, the sensitivity of the partition clustering algorithm to outliers also greatly reduces the clustering accuracy. Therefore, the selection of the initial center point and the screening of outliers are two very important aspects. Since the grid-based clustering algorithm can effectively process various types of data sets and can effectively remove outliers, this clustering algorithm requires manual setting of multiple parameters, and since the clustering result depends on the number of units divided in each dimensional space, the quality and accuracy of the clustering will be reduced to a certain extent.

[0003] Currently, the existing methods for software architecture recovery using clustering algorithms mostly manually classify and extract features. They treat files as entities, and feature selection comes from the formal and informal characteristics of the entities. Formal characteristics include functions called by the entity, global variables, macros and user-defined types referenced by the entity, and files contained in the entity; informal characteristics include comments, identifiers, developer names, directory paths, LOCs, and the time of the last update. The final result is highly dependent on the selection of entity features. Summary of the invention

[0004] In order to solve the above problems, the present invention provides a software architecture recovery method based on adaptive grid partitioning and clustering, which extracts the software association network for network embedding to obtain feature vectors, constructs grid space for clustering, and quickly and effectively obtains the software architecture module description.

[0005] In order to achieve the above object, the technical solution adopted by the present invention is:

[0006] A software architecture recovery method based on adaptive grid partitioning and clustering includes the following steps:

[0007] S1: Construct class dependency network and file coupling network as feature extraction object;

[0008] S2: Use network embedding algorithm to convert nodes in the software association network into vector representation;

[0009] S3: Use the vector representation result as a data set, and determine the number of grid divisions of the clustering algorithm and the density threshold for removing outliers according to the discreteness of the data set;

[0010] S4: Use the grid division number to process the sample points in the data set, determine the grid index of each sample point, calculate the grid coordinate array G corresponding to each data point, and count the density of each grid;

[0011] S5: Use the density threshold to divide the grids for screening and classification, separate the grids into dense grids and non-dense grids, perform mean processing on the sample points in the dense grids, and obtain a relatively accurate center point;

[0012] S6: The center point is used as the initial center point of the clustering method for iteration, the data set is clustered, and the clustering result is the framework structure of the software.

[0013] A further improvement of the present invention is that: in the step S1, the classes or interfaces in the object-oriented system are used as the vertices of the network, and the dependencies between the classes or interfaces are used as the edges of the network to construct a class dependency network, and the dependencies include inheritance dependency, interface implementation dependency, method call dependency, return value dependency and parameter dependency; the source files in the software system are used as the vertices of the network, the common modification records of the source files in the software version control system are used as the edges of the network, and the common modification frequency between the source files is used as the weight of the network to construct a file coupling network.

[0014] The present invention is further improved in that: in the step S2, the nodes in the software association network are converted into vector representations using a network embedding algorithm. The choice of the network embedding algorithm depends on whether the processed network is an undirected unweighted graph. If it is an undirected unweighted graph, the Struc2Vec algorithm is selected, focusing on the spatial structural similarity of the vertices in the graph; otherwise, the Node2Vec algorithm is selected, and the graph is sampled by combining DFS and BFS random walks. Among them, the hyperparameter p of the Node2Vec algorithm is selected to be 0.5 to control the probability of repeatedly visiting the vertices that have just been visited, and the hyperparameter q is selected to be 5 to control the walk tendency to visit the vertices that are biased towards BFS.

[0015] A further improvement of the present invention is that in step S3, in order to obtain reasonable segmentation parameters so as to achieve good results in subsequent clustering, the algorithm calculates the dimension segmentation parameters according to the characteristics of the data set to be clustered. Step S3 specifically includes:

[0016] S301: Calculate the degree of dispersion of each dimension: First, use the standard deviation coefficient to calculate the degree of dispersion of data in each dimension. The specific calculation formula used is as follows:

[0017]

[0018] Among them, V i is the standard deviation coefficient of the i-th dimension data, S i is the standard deviation of the i-th dimension data, X i is the mean of the i-th dimension data;

[0019] S302: Calculate the discretization degree of the data set: The specific calculation formula used is as follows:

[0020]

[0021] Where d is the dimension of the data object in the data set; V is the discretization degree of the data set. The smaller the value of V, the greater the discreteness of the data set.

[0022] S303: Calculate the number of grid divisions: The specific calculation formula used is as follows:

[0023]

[0024] Among them, GNum is the number of grid divisions, d is the dimension of the data object in the data set, and N is the number of samples in the data set.

[0025] S304: Determine the density threshold: Using the average density of the data set as the density threshold can effectively remove outliers. The specific calculation formula used is as follows:

[0026]

[0027] Among them, Threshold is the density threshold. The density of the noise grid point is less than the average density of the entire grid point in the sample space. The method of using the average density as the threshold can effectively remove the noise points. At the same time, the threshold is also adjusted with the change of GNum. The dynamically changing threshold can remove the noise points more accurately.

[0028] A further improvement of the present invention is that: in the step S4, the data set is divided using the grid division number calculated in step S3, firstly, the data range of each dimension is calculated by calculating the maximum and minimum values ​​of each dimension, thereby calculating the grid size of each dimension, establishing a grid coordinate array, calculating the grid coordinate array corresponding to each data point, and dividing all data points into each grid space using the grid division idea. The specific calculation formula used is as follows:

[0029]

[0030] Among them, G ij is the grid coordinate corresponding to each data point, N is the number of samples in the data set, d is the dimension of the data object in the data set, x ij is the specific data value of each dimension of each data point in the data set, x jmax is the maximum value of each dimension, x jmin is the minimum value of each dimension.

[0031] A further improvement of the present invention is that: in the step S5, a grid density array is established, the density value corresponding to each grid is calculated, and the established grid space is density-divided according to the Threshold density threshold calculated in S3 to separate dense grids and non-dense grids, and the non-dense grids are screened out based on the grid coordinate array; the data points in the dense grid area are calculated separately, and the center point of each dense grid area is found by using the mean processing.

[0032] A further improvement of the present invention is that in step S6, clustering is performed using the center point obtained in step S5 as the initial center point of the partitioning clustering method. The selection of the clustering method is not limited to the traditional partitioning clustering method. A relatively accurate initial center point is used for iteration, and the clustering result obtained is a collection of files in the software source code. The files are clustered into a cluster in the result, which means that the files are classified as a category in the software framework structure. The final clustering result is the final recovery result of the software framework.

[0033] Compared with the prior art, the present invention has the following beneficial effects:

[0034] (1) A software architecture recovery method based on adaptive grid partitioning and clustering is provided. By extracting the software association network in the software source code and using the network embedding algorithm to obtain the feature vector, the efficiency of feature vector extraction is improved.

[0035] (2) The effect of the clustering algorithm based on grid density depends on the selection of the number of grid divisions and the density threshold. The internal distribution information of the data set is used to automatically determine the two key parameters: the number of grid divisions and the density threshold.

[0036] (3) Using the grid clustering algorithm to spatially divide the data set can effectively remove outliers.

[0037] (4) The randomness of the initial center point selection is effectively solved, and the initial center point is quickly and effectively found for subsequent clustering operations. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 The overall flow chart of the method of the present invention is DETAILED DESCRIPTION

[0039] In order to make the purpose, features and advantages of the present invention more obvious and understandable, the specific implementation of the present invention is described in detail below with reference to the accompanying drawings and examples.

[0040] Take the known open source software system Aion as an example.

[0041] like Figure 1 As shown, a software architecture recovery method based on adaptive grid partitioning and clustering includes the following steps:

[0042] Step S1: According to the source code of the known open source software system Aion, the software association network is extracted and output as a file containing variable variables and cell variables, wherein the variable variables contain member variables, member functions, etc. in each file as a node, and the cell variables contain the dependency relationship between classes or interfaces as the weighted edges between each node; the file is read to generate a corresponding class dependency network or a file coupling network as a feature extraction object, a directed weighted graph or an undirected unweighted graph Graph.

[0043] Step S2: The extracted software association network is input as a parameter into the network embedding algorithm. The choice of network embedding algorithm depends on whether the processed network is an undirected and unweighted graph. If it is an undirected and unweighted graph, the Struc2Vec algorithm is selected, focusing on the spatial structural similarity of the vertices in the graph. The random walk step length is selected as 10 and the number of steps is selected as 80 in the hyperparameters; otherwise, the Node2Vec algorithm is selected, and the graph is sampled by combining DFS and BFS random walks. Among them, the hyperparameter p of the Node2Vec algorithm is selected as 0.5 to control the probability of repeating visits to the vertices just visited, and the hyperparameter q is selected as 5 to control the walk tendency to visit the vertices biased towards BFS; generate the feature vector corresponding to each node, and use the network embedding algorithm to convert the nodes in the software association network into vector representations.

[0044] Step S3: The transformed feature vector set is used as a data set for feature engineering. The gridding score and the density threshold for removing outliers required by the clustering algorithm are calculated according to the discrete degree of the data set. The specific steps are as follows:

[0045] Step S301: First, calculate the standard deviation and mean of each dimension, and then calculate the standard deviation coefficient of each dimension to obtain the data discretization degree V of each dimension. i ;

[0046] Step S302: Using V i Calculate the discretization degree V of the overall data set;

[0047] Step S303: Calculate the number of grid divisions GNum using V;

[0048] Step S304: using GNum to calculate the average density of the tree army level as the density threshold Threshold;

[0049] Step S4: Use the grid division number to process the sample points in the data set, determine the grid index of each sample point, and calculate the grid coordinate array G corresponding to each data point ij , as shown below:

[0050]

[0051] Step S5: Use the density threshold to divide the grids for screening, classify the grids, separate dense grids and non-dense grids, perform mean processing on the sample points in the dense grids, and obtain a relatively accurate center point Center, as shown below:

[0052] [[6,6,2],[0,8,3],[3,8,3],[1,9,4],[3,6,7],[1,8,11],[4,7,12],[2,7,41],[2,8,41],[3,7,52]]

[0053] Step S6: Use the center point obtained in step S5 as the initial center point of the partitioning clustering method for clustering. The clustering method selected is K-Means++. Use the relatively accurate initial center point for iteration. The clustering result obtained is a collection of files in the software source code. The result clusters these files into one cluster, which means that these files are classified into a category in the software framework structure. The final clustering result is the final recovery result of the software framework, as shown below:

[0054] contain 0 org.aion.zero.impl.core.TimeVaryingRewardsCalculatorTest.RewardsCalculatorTimespanMinusoneTest

[0055] contain 0 org.aion.zero.inlpl.core.TimeVarvingRewardsCalculatorTest.RewardsCalculatorTimespanZerotest

[0056] contain 0 org.aion.zero.impl.core.TimeVarvingRewardsCalculatorTest.RewardsCalculatorTimespanOneTest

[0057] contain 0 org.aion.zero.inlpl.core.TimeVarvingRewardsCalculatorTest.RewardsCalculatorTimespanTenTest ...

[0059] contain 1 org.aion.crypto.ecdsa.ECKeySecp256k1.decryptAES.engine

[0060] contain 1 org.aion.crypto.ecdsa.ECKeysecp256k1.decryptAES.ctrEngine

[0061] contain 1 org.aion.crypto.ecdsa.ECKeySecp256k1.decryptAES.key ...

[0063] contain 17 org.aion.util.math.Benchmark.test100000RandomLogs.rng

[0064] contain 17 org.aion.util.math.Benchmark.test100000RandomLogs.seed

[0065] contain 17 org.aion.util.math.Benchmark.test100000RandomLogs.value

[0066] Compared with the existing methods, the method of the present invention, given the source file of the software system, uses the network embedding method to extract feature vectors for adaptive grid division and clustering, so as to obtain the corresponding software framework description more quickly, simplify the tedious operation of feature extraction, and speed up and accurately obtain the clustering results of the clustering method.

Claims

1. A software architecture recovery method based on adaptive grid partitioning and clustering, characterized in that: The steps include: S1: Construct class dependency network and file coupling network as feature extraction object; S2: Use network embedding algorithm to convert nodes in the software association network into vector representation; S3: Use the vector representation result as a data set, and determine the number of grid divisions of the clustering algorithm and the density threshold for removing outliers according to the discreteness of the data set; S4: Use the grid division number to process the sample points in the data set, determine the grid index of each sample point, calculate the grid coordinate array G corresponding to each data point, and count the density of each grid; S5: Use the density threshold to divide the grids for screening and classification, separate the grids into dense grids and non-dense grids, perform mean processing on the sample points in the dense grids, and obtain a relatively accurate center point; S6: The center point is used as the initial center point of the clustering method for iteration, the data set is clustered, and the clustering result is the framework structure of the software.

2. The software architecture recovery method based on adaptive grid partitioning and clustering according to claim 1 is characterized in that: In the step S1, the classes or interfaces in the object-oriented system are used as the vertices of the network, and the dependencies between the classes or interfaces are used as the edges of the network to construct a class dependency network, wherein the dependencies include inheritance dependency, interface implementation dependency, method call dependency, return value dependency and parameter dependency; The source files in the software system are taken as the vertices of the network, the common modification records of the source files in the software's version control system are taken as the edges of the network, and the common modification frequency between source files is taken as the weight of the network to construct a file coupling network.

3. The software architecture recovery method based on adaptive grid partitioning and clustering according to claim 1 is characterized in that: In step S2, a network embedding algorithm is used to convert nodes in the software association network into vector representations. The selection of the network embedding algorithm depends on whether the processed network is an undirected unweighted graph. If it is an undirected unweighted graph, the Struc2Vec algorithm is selected, focusing on the spatial structural similarity of the vertices in the graph; otherwise, the Node2Vec algorithm is selected, and the DFS and BFS random walks are combined to perform vertex sequence sampling on the graph, wherein the hyperparameter p of the Node2Vec algorithm is selected as 0.5 to control the probability of repeatedly visiting the vertices just visited, and the hyperparameter q is selected as 5 to control the walk tendency to visit the vertices biased towards BFS.

4. The software architecture recovery method based on adaptive grid partitioning and clustering according to claim 1 is characterized in that: In step S3, in order to obtain reasonable segmentation parameters so as to achieve good results in subsequent clustering, the algorithm calculates the dimension segmentation parameters according to the characteristics of the data set to be clustered. Step S3 specifically includes: S301: Calculate the degree of dispersion of each dimension: First, use the standard deviation coefficient to calculate the degree of dispersion of data in each dimension. The specific calculation formula used is as follows: Among them, V i is the standard deviation coefficient of the i-th dimension data, S i is the standard deviation of the i-th dimension data, X i is the mean of the i-th dimension data; S302: Calculate the discretization degree of the data set: The specific calculation formula used is as follows: Where d is the dimension of the data object in the data set; V is the discretization degree of the data set. The smaller the value of V, the greater the discreteness of the data set. S303: Calculate the number of grid divisions: The specific calculation formula used is as follows: Among them, GNum is the number of grid divisions, d is the dimension of the data object in the data set, and N is the number of samples in the data set; S304: Determine the density threshold: Using the average density of the data set as the density threshold can effectively remove outliers. The specific calculation formula used is as follows: Among them, Threshold is the density threshold. The density of the noise grid point is less than the average density of the entire grid point in the sample space. The method of using the average density as the threshold can effectively remove the noise points. At the same time, the threshold is also adjusted with the change of GNum. The dynamically changing threshold can remove the noise points more accurately.

5. The software architecture recovery method based on adaptive grid partitioning and clustering according to claim 1 is characterized in that: In step S4, the data set is divided using the grid division number calculated in step S3. First, the data range of each dimension is calculated by calculating the maximum and minimum values ​​of each dimension, thereby calculating the grid size of each dimension, establishing a grid coordinate array, and calculating the grid coordinate array corresponding to each data point. All data points are divided into each grid space using the grid division idea. The specific calculation formula used is as follows: Among them, G ij is the grid coordinate corresponding to each data point, N is the number of samples in the data set, d is the dimension of the data object in the data set, x ij is the specific data value of each dimension of each data point in the data set, x jmax is the maximum value of each dimension, x jmin is the minimum value of each dimension.

6. The software architecture recovery method based on adaptive grid partitioning and clustering according to claim 1 is characterized in that: In the step S5, a grid density array is established, and the density value corresponding to each grid is calculated. The established grid space is density-divided according to the Threshold density threshold calculated in S3 to separate dense grids and non-dense grids. The non-dense grids are filtered out based on the grid coordinate array; the data points in the dense grid area are calculated separately, and the center point of each dense grid area is found by using the mean processing.

7. The software architecture recovery method based on adaptive grid partitioning and clustering according to claim 6 is characterized in that: In step S6, clustering is performed using the center point obtained in step S5 as the initial center point of the partitioning clustering method. The selection of the clustering method is not limited to the traditional partitioning clustering method. A relatively accurate initial center point is used for iteration, and the obtained clustering result is a collection of files in the software source code. The files are clustered into a cluster in the result, which means that the files are classified as a category in the software framework structure. The final clustering result is the final recovery result of the software framework.