A software maintainability prediction model generation method and prediction method

The software maintenance prediction model constructed through fuzzy networks and fuzzy clustering solves the problems of difficulty in obtaining knowledge and insufficient adaptability in the existing technology, and achieves efficient and transparent software maintenance prediction.

CN115562720BActive Publication Date: 2025-08-12ARMY ENG UNIV OF PLA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211175518.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-26
Publication Date
2025-08-12
Estimated Expiration
2042-09-26

AI Technical Summary

Technical Problem

The existing software maintenance prediction models are complicated to obtain knowledge, poor adaptability, strong uninterpretation of neural network systems, and difficult to deal with fuzzy and unstructured data, resulting in insufficient prediction accuracy and transparency.

Method used

The fuzzy network and fuzzy clustering method is adopted to obtain numerical and semantic indicators that characterize the maintenance of software, and to construct membership functions and rule databases. The fuzzy network merges the rule database to build a fuzzy system with multiple inputs and single outputs, and combines the genetic algorithm to optimize parameters to generate a software maintenance prediction model.

Benefits of technology

Improves the accuracy and transparency of software maintenance predictions, simplifies the complexity of model construction, can effectively process different types of data, and provide interpretable prediction results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115562720B_ABST
    Figure CN115562720B_ABST
Patent Text Reader

Abstract

The present invention provides a method for generating a software maintainability prediction model and a method for predicting software maintainability. The method comprises obtaining an indicator representing software maintainability, constructing a membership function, obtaining historical data as a training set, constructing a rule base based on a fuzzy network, optimizing the parameter values of all membership functions, constructing a software maintainability prediction model based on the membership function and the rule base, and calculating a predicted value of software maintainability using the constructed software maintainability prediction model. The present invention achieves a dual-driven approach of data and knowledge in the software maintainability prediction calculation process, improving both prediction accuracy and the transparency of the prediction model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of repair and maintenance of software-intensive equipment, and mainly relates to a method for generating a software maintainability prediction model based on a fuzzy clustering network and a prediction method. Background Art

[0002] Software-intensive systems (SIS) refer to equipment in which the software within the system plays a primary role in the equipment's development and mission accomplishment. Software assurance for these systems is costly and risky, but plays a crucial role in maintaining the equipment's long-term performance and maintaining and regenerating its mission-enabling capabilities. As a fundamental aspect of software assurance, conducting software maintainability prediction for software-intensive equipment is of great significance.

[0003] Software maintainability, that is, the ease of maintaining software, is an important software quality attribute and is intrinsically linked to the software maintenance process. The main goal of software maintainability prediction is to estimate the cost of software project maintenance or the ease of software maintenance process.

[0004] Existing software maintainability prediction models all solve specific problems in specific fields and are not very universal; secondly, traditional software maintainability prediction methods mainly include fuzzy logic method and neural network method.

[0005] For example, using fuzzy logic to predict software maintainability primarily involves assigning membership functions, inference rule bases, and defuzzification algorithms to maintainability metrics based on expert knowledge. Fuzzy logic adapts to changes in the external environment of software maintainability by using fuzzy semantic rules between metrics. It only requires a partial filling of the semantic rule matrix to describe structured knowledge. The rule base is composed of independent rules, and dozens of fuzzy inference mapping algorithms are used to perform rule synthesis operations. Fuzzy logic suffers from problems such as cumbersome knowledge acquisition and poor adaptability. Rule acquisition and fuzzy inference are the two core issues of fuzzy inference systems. Rule acquisition requires experience and expert knowledge and is the most challenging part. Sometimes, it is impossible to describe rules in the form of "IF..., THEN..." verbally. This manual rule acquisition process is time-consuming and labor-intensive. The performance of a fuzzy system depends on both the quality and quantity of the rules. Rule explosion can sometimes require tens of thousands of rules to cover the required space or function. This rule explosion is particularly problematic in function approximation.

[0006] Secondly, fuzzy inference systems lack the ability to adapt to environmental changes and lack learning capabilities, resulting in lower accuracy when the environment changes. In particular, the membership function's quantization factors have poor self-correction capabilities. The system's accuracy decreases even more when the inference path is long. While rules, as a generalized mathematical model, can describe general system models, there are some situations where rules are difficult to generalize or impossible to describe.

[0007] For neural networks, they use network structure and weight matrices to describe the rules of mutual connection, rely on strict mathematical algorithms to achieve input-output mapping, need to obtain and repeatedly learn enough training sample sets to reflect the training samples in the model, and adapt to changes in the external environment through structural variability.

[0008] However, neural network methods place high demands on the quantity and quality of training samples, requiring them to possess good orthogonality and completeness. Neural networks require that all problem features be numerically represented, but some of the deep knowledge (uncertain information) inherent in human reasoning is difficult to represent numerically. Training samples themselves are often uncertain, fuzzy, and noisy, making it difficult to extract features for learning.

[0009] Secondly, due to the complexity of neural network systems, it's sometimes impossible to determine how to extract the initial training sample set, let alone the distribution of these samples. This makes it difficult to guarantee the neural network's generalization capabilities. The advantages of neural networks, such as distributed memory, high nonlinearity, and the lack of modeling, come at the cost of difficult understanding of the system's behavior. In other words, model designers don't know the reasoning path that leads from input data to output. When it comes to the neural network's learning process, designers only see the input and output data, leaving the intermediate analytical and deductive processes opaque.

[0010] Within the internal structure of a neural network, neurons lack clear boundaries. They intertwine, constraining and stimulating each other, interfering with each other and simultaneously promoting each other. Parameter adjustment knowledge is unclear, making it unclear which internal weights, nodes, and layers should be modified. As a black-box system of unstructured computing, we don't know what the neural network memorizes during training, what it will learn and forget in subsequent learning, and what it will learn. Furthermore, neural networks themselves lack the ability to explain their learning process. They cannot explain the reasoning process or the basis for their reasoning to the user, nor can they respond to necessary inquiries.

[0011] Neural networks have convergence and stability issues. Because neural networks are inherently nonlinear systems, they converge at different speeds and in different regions for different initial values. Assigning reasonable initial values remains a research question, making neural network learning complex and slow.

[0012] In addition, there is a capacity problem with neural networks. The associative memory ability of neural networks, that is, the capacity of stable storage models, is limited.

[0013] It can be seen that the common existing software maintainability prediction models have the above-mentioned deficiencies and cannot meet the users' needs for software maintainability prediction. Summary of the Invention

[0014] The purpose of the present invention is to provide a method for generating a software maintainability prediction model and a prediction method to address the deficiencies of the prior art.

[0015] In order to solve the above technical problems, the present invention adopts the following technical solutions:

[0016] The present invention provides a method for generating a software maintainability prediction model, comprising the following steps:

[0017] S1: Obtain indicators that characterize software maintainability, wherein the indicators include m first-category indicators and n second-category indicators, wherein the first-category indicators are numerical measurement indicators, and the second-category indicators are semantic measurement indicators, and m and n are natural numbers;

[0018] S2: Obtain historical data as a training set, including obtaining the value of the first type of indicator and obtaining the input variable x i , where 1≤i≤m, and the corresponding software maintainability is used as the output value, where the software maintainability is measured by the number of lines of code changed; obtain the semantic metric value of the second type of indicator, and obtain the input variable x j , where m+1≤j≤m+n, preprocess the data;

[0019] S3: Construct the membership function and convert the input variable x of the first type of indicator obtained in step S2 into i , cluster the m inputs and their corresponding output values into data pairs, where 1≤i≤m; the input variable x of the second type of indicator obtained in step S2 j Classification, where m+1≤j≤m+n;

[0020] S4: constructing a rule base and merging the rule base based on the fuzzy network;

[0021] S5: Optimizing the parameter value of the membership function;

[0022] S6: Constructing a software maintainability prediction model based on the membership function and the rule base.

[0023] Preferably, in step S3, the first category of indicators adopts fuzzy C-means clustering, and the second category of indicators adopts expert knowledge or expert system classification. The number of classes of the first category of indicators and the second category of indicators is 2K+1, where K is a natural number.

[0024] Preferably, the step of using fuzzy C-means clustering for the first type of indicators in step S3 specifically includes:

[0025] Step S31: Each input variable of the first category of indicators is spatially divided into 2K+1 categories;

[0026] Step S32: When the fuzzy C-means clustering algorithm reaches the maximum number of iterations or the objective function improvement between two consecutive iterations is less than the specified minimum improvement, the clustering process stops and the generation of clusters and membership functions is completed.

[0027] Preferably, step S4 specifically includes:

[0028] Step S41: Input variable x i According to the first and second indicators, it is divided into two parts: variable set 1 and variable set 2. Variable set 1 consists of numerical metrics x i Composition, 1≤i≤m, variable set 2 is composed of semantic metric x i Composition, m+1≤i≤m+n;

[0029] Step S42: For variable set 1, construct a node N based on the fuzzy clustering algorithm 11 ;

[0030] Node N 11 The first type of indicator rule base is generated by machine learning algorithm from the input and output data pairs as training set, N 11 The rule base contains 2K+1 rules:

[0031] Rule j: If x1 is C 1j and x2 is C 2j and…and x j is C mj then z 1j is C zj , where C ij is the i-th indicator and the j-th class, C zj is the jth category of the corresponding software maintainability output value, 1≤i≤m, 1≤j≤2K+1;

[0032] For variable set 2, the first two indicators in variable set 2 are used as node N 21 Input, N 21 The output z2 and the third index in variable set 2 are used as node N 22 Input, N 22 The output z3 is the next index as N 23 Input, and so on, each time only one indicator is added, thus obtaining n-1 nodes N21 、N 22 ...N 2,n-1 During the merging and combining process, an identity node is added to adjust the timing and order of the various indicators of variable set 2 as input variables; the identity node is a node with the same input and output;

[0033] Among them, the rule base node N 21 Generated by expert knowledge, the structure is as follows:

[0034] If x m+1 is C p1 and x m+2 is C p2 then z2 is C p3

[0035] Where p is a positive integer and 1≤p≤(2K+1) 2 , C p1 、C p2 、C p3 Take a value from {1, 2, ..., 2K+1};

[0036] Rule Base N 22 Generated by expert knowledge, the structure is as follows:

[0037] If x m+3 is C q1 and z2 is C q2 then z3 is C q3

[0038] Where q is a positive integer and 1≤q≤(2K+1) 2 , C q1 、C q2 、C q3 Take a value from {1, 2, ..., 2K+1};

[0039] Step S43: merging rule bases based on the fuzzy network;

[0040] The rule bases of all nodes are first merged vertically and then merged horizontally to obtain a rule base for the entire software maintainability prediction model. The topological structure of the rule base is formula (4):

[0041] [(N 11 +N 21 +I 31 +…I n,1 )*(I 12 +N 22 +…+I n-1,2 +I n,2 )*…*(I 1,n-2+N 2,n-2 +I n,n-2 )*

[0042] (I 1,n-1 +N 2,n-1 )*N 1,n ](x1,…,x m+n |y) (4)

[0043] Among them, the content in “[]” represents the topological expression of a node, '+' represents vertical merging, '*' represents horizontal merging, and N ij Represents the node in the i-th row and j-th column; I ij represents the identity node at row i and column j; “()” represents the input and output of the node, x1,…,x m+n represents input and y represents output.

[0044] Preferably, step S3 specifically includes: the first type of indicator uses a Gaussian function as its membership function; the second type of indicator uses a triangular membership function as its membership function.

[0045] Preferably, the triangular membership function is:

[0046]

[0047]

[0048]

[0049] Among them, x ij is the input variable x i The jth value of f ij is the corresponding membership of this value, f ij ma t h mid Is the range R h a The center point, t h-1 mid Is the left value range R h-1 a The center point, t h+1 mid The right value range R h+1 a The symbol ' / ' represents the "division operation" in arithmetic operations, the superscript h represents the value range of the h-th class, and the subscript a represents its input variable, m+1≤i≤m+n.

[0050] The present invention also provides a method for predicting software maintainability, which uses the model generated by the above-mentioned method for generating a software maintainability prediction model to calculate the predicted value of software maintainability.

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

[0052] (1) The present invention adopts fuzzy network (FN) and fuzzy clustering as the theoretical basis, and integrates fuzzy clustering method, fuzzy network method, genetic algorithm, etc. into a whole by means of information fusion, thereby reducing the problems of fuzzy logic method in terms of cumbersome knowledge acquisition and poor adaptability; making up for the unexplainable defects brought by neural network as a black box system of unstructured computing; and at the same time fusing numerical information and semantic information to construct an interpretable artificial intelligence model, thereby improving the accuracy and transparency of software maintainability prediction.

[0053] (2) According to the different properties of indicators, the indicators are classified into the first category indicator data and the second category indicator data, which is convenient for data classification, representation and processing; when clustering, the number of expected clusters is specified as 2K+1, and the number of clusters of the first category indicator data and the second category indicator data is unified to facilitate the subsequent merging of nodes and data analysis and processing.

[0054] (3) For the first type of indicator data, the fuzzy C-means clustering algorithm is used, which does not require a priori setting of clustering features. The power of the clustering algorithm lies in that it does not rely on predefined clusters, but rather analyzes and searches for implicit structures in the data itself.

[0055] (4) Using fuzzy networks to synthesize rule bases. A multi-input, single-output fuzzy system is established using fuzzy network theory. The inference engine processes these semantic values based on the knowledge base in the fuzzy domain, simplifying the complexity of model construction.

[0056] (5) The rule bases of all nodes are first merged vertically and then horizontally. This reduces the difficulty of constructing a rule base using expert knowledge, fully utilizes the physical relationship between various indicators to construct the organizational structure between the corresponding rule bases, and merges the constructed rule bases into an overall rule base through the fuzzy network merging algorithm.

[0057] (6) Different membership functions are selected for different indicator data. For the first type of indicators, i.e., the input variables of numerical measurement indicators, the Gaussian function is selected as its membership function. This is because the parameters of the Gaussian function are determined by the machine learning method from the characteristics of the numerical data. For the second type of indicators, i.e., the input variables of semantic measurement indicators, the triangular membership function is selected as its membership function. This is because: the triangular membership function has the best interface design performance and has complete semantic value attributes. The present invention creatively applies the triangular membership function to the method for generating a software maintainability model, especially for semantic indicators, and achieves accurate prediction and high prediction efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 Schematic diagram of the complete algorithm process of the present invention;

[0059] Figure 2 It is a complete algorithm flow chart of the present invention;

[0060] Figure 3 A schematic diagram of the fuzzy network model used in the present invention;

[0061] Figure 4 A schematic diagram of the triangular membership function used in the present invention;

[0062] Figure 5 The horizontal merging method of nodes used in the present invention;

[0063] Figure 6 This is the vertical merging method of nodes used in the present invention. DETAILED DESCRIPTION

[0064] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative efforts shall fall within the scope of protection of the present invention.

[0065] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features therein may be combined with each other.

[0066] The present invention will be further described below with reference to specific examples, but they are not intended to limit the present invention.

[0067] The present invention uses fuzzy networks (FN) and fuzzy clustering as theoretical basis. Among them, the fuzzy network (FN) completely networks the rule base, and all inputs are mapped to outputs through link relationships, with complete "white box" characteristics. The fuzzy network (FN) can be regarded as a combination of a standard fuzzy system (SFS) and a hierarchical fuzzy system (HFS): on the one hand, FN has a structure similar to that of HFS, accurately expressing the subsystems and the relationship between subsystems; on the other hand, FN has similar operations to SFS, because FN can simplify the rule bases of each subsystem into a single rule base through operations. The simplified operation in the present invention is mainly through the method of semantic synthesis, which vertically and horizontally merges the multi-rule base system similar to HFS to form FN, which has a single rule base system similar to SFS.

[0068] The present invention utilizes the single rule base system of SFS. SFS is the most widely used fuzzy system with only one rule base. Inputs are directly mapped to outputs, and users do not need to consider any internal connections. SFS has high accuracy because all inputs act on the output simultaneously. However, as the number of rules increases, the transparency of SFS decreases rapidly, and it becomes very unclear how the model input affects the output. To address this problem, the present invention also introduces a hierarchical fuzzy system (HFS). HFS is a special type of chained fuzzy system (CFS). CFS can handle hierarchically structured rule bases. Inputs are mapped to output variables through links between internal variables, and the hierarchical structure between subsystems and these links is unconstrained. CFS can generally express the details of SFS subsystems and their link relationships through a hierarchical structure, thereby improving the transparency of the model. Because the input variables are divided into separate rule bases, the execution efficiency of the model is also improved. As a special type of CFS, each subsystem of HFS has only two inputs and one output.

[0069] Theory 1 is an important theoretical basis of the fuzzy network used in the present invention.

[0070] Theory 1 A hierarchical fuzzy system (HFS) has m inputs {x1, x2, ..., x m}, m-1 network nodes {N 11 ,N 12 ,...,N 1,m-1}, m-2 links {z1,z2,...,z m-2}, and a single output y, recorded as topological expression (1)

[0071] [N 11 ](x1,x2|z1)*[N 12 ](z1,x3|z2)*...*[N 1,m-1 ](z m -2,xm |y). (1)

[0072] Topological expression (1) is a model expression method, in which the content in “[]” represents the topological expression of a node, “*” represents the horizontal merging between nodes, the content in “()” represents the input and output of each node, and “|” represents the separator between input and output, such as [N 11 ](x1,x2|z1) means two inputs (x1,x2) are connected through N 11 The output after the node is z1.

[0073] After merging the nodes, the fuzzy network (FN) can be expressed as an SFS with the same m inputs, a single network node N, no links, and the same single output y, which can be expressed as topological expression (2):

[0074]

[0075] in, Node I qp It is the identity node of the pth level and qth layer. The identity node is a special node in the fuzzy network (FN) whose input and output remain the same. This is mainly to maintain the consistency of the horizontal and vertical structure of the nodes and the order of the nodes during the node merging process.

[0076] Example 1

[0077] See also Figure 1 and Figure 2 Embodiment 1 of the present invention provides a method for generating a software maintainability prediction model, comprising the following steps:

[0078] Step S1: Obtain indicators that characterize software maintainability, which include m first-category indicators and n second-category indicators. The first-category indicators are numerical measurement indicators, such as the number of lines of code, data abstraction coupling, cohesion loss, message passing coupling, and other commonly used software maintainability indicators. These indicators have standard formulas to calculate specific values; the second-category indicators are semantic measurement indicators, such as programming language complexity, software application complexity, and software dependence on the environment. These commonly used software measurement indicators do not have a unified calculation formula and need to be expressed by expert knowledge or expert systems into semantic values similar to {good, medium, poor}.

[0079] In step S1, the indicators representing software maintainability data are divided into two categories. This is because: first, different software maintainability prediction models focus on different software metric systems; second, different maintenance tasks require different software development paradigms, including object-oriented programming, aspect-oriented programming, context-oriented programming, and the earlier process-oriented programming. To meet different needs, different models need to collect and analyze different types of data. The selection of data types and processing methods are crucial. The present invention divides these into two categories: one is derived from the metrics of the software to be maintained, also known as "numerical information" indicators, and the other is based on semantic information evaluated by domain experts, also known as "fuzzy information" indicators. "Numerical information" indicators are derived from precise numerical information in historical data, while "fuzzy information" indicators are derived from imprecise semantic information evaluated by domain experts. By selecting and classifying indicator data to facilitate processing using different analysis methods, the present invention simplifies the difficulty and complexity of model data processing and improves the versatility of model processing.

[0080] Step S2: Obtain historical data as a training set, including obtaining the value of the first type of indicator and obtaining the input variable x i , where 1≤i≤m, and the corresponding software maintainability is used as the output value, and the software maintainability is measured by the number of lines of code modified or changed; the second type of indicator is the semantic metric value, which is given by expert knowledge or expert system, and the input variable x is obtained j , where m+1≤j≤m+n, and preprocess the data.

[0081] Preferably, step S2 specifically includes:

[0082] Step S21: Collect first-category indicator data and corresponding software maintainability as output values, and second-category indicator data as training data. Preferably, the software maintainability is measured by the number of lines of code changed.

[0083] Step S22: Data preprocessing, specifically including:

[0084] Step S221: Data cleaning. Review the completeness and accuracy of the raw data, fill in missing values, smooth noisy data, identify or delete outliers, and resolve inconsistencies to "clean" the data, standardize the format, remove abnormal data, correct errors, etc.

[0085] Step S222: Variable screening: Select metrics that have a significant impact on maintainability as model input. For actual software maintainability metrics, the importance of these metrics can be ranked based on expert knowledge or by existing correlation analysis methods.

[0086] Step S223: Perform data normalization on the first type of indicator data, map the filtered data to [0,1], and eliminate the influence of dimension (unit). Where min and max are the minimum and maximum values of the attribute value respectively. So far, the normalized numerical measurement value is obtained. i (i=1,2,…,m) constitutes the numerical input variable set X1.

[0087] Step S3: Construct a membership function and transform the first-class input variable x obtained in step S2 into i , cluster the m inputs and their corresponding output values into data pairs, where i = 1, 2, ..., m; the second type of input variables x obtained in step S2 j Classification, where j = m+1, m+2,…, m+n.

[0088] Preferably, "constructing a membership function" in step S3 is to specify the type of membership function to prepare for subsequent data processing and calculation, specifically: for the first type of indicators, that is, the input variables of numerical measurement indicators, the Gaussian function is selected as its membership function. This is because the parameters of the Gaussian function are determined by the machine learning method from the characteristics of the numerical data; for the second type of indicators, that is, the input variables of semantic measurement indicators, the triangular membership function is selected as its membership function. This is because: the triangular membership function has the best interface design performance and has complete semantic value attributes.

[0089] Preferably, for the second type of indicators, the present invention provides a preferred triangular membership function, see Figure 4 , where x ij is the input variable x i The jth value of f ij is the membership degree of this value (m+1≤i≤m+n). ij The membership degree f ij The range of the input value R h a Decision(0 <h≤2K+1,R h a ∈R a ), where the superscript h represents the range of the hth class, and the subscript a represents its input variable. Since the range has multiple classes (segments), different classes (segments) have different membership functions, f ij max is x ij The maximum value among all possible memberships.

[0090] Using the triangular membership function as the membership function, we get x ij In the range R h aWith membership degree f ij . The present invention uses the following three equations to completely represent the relationship between x ij and f ij :

[0091]

[0092]

[0093]

[0094] where t h mid is the center point of the value range area R h a , t h-1 mid is the center point of the left value range area R h-1 a , t h+1 mid is the center point of the right value range area R h+1 a . The symbol ' / ' represents "division operation" in arithmetic operations. The superscript h represents the value range interval of the h-th class, and the subscript a represents the input variable it is for, where m + 1 ≤ i ≤ m + n.

[0095] Specifically, when x ij is equal to t h mid , f ij reaches the maximum membership degree value of 1. All output variables and input variables also have similar membership degrees of triangular membership functions. The membership degree of the output variable z1 in the value range area R h b (0 < h ≤ 2L + 1) is f z1 j , and z 1j is within the value range area R 1j b . The subscript b represents the output variable it is for.

[0096] Preferably, when clustering the input variables of the first type of indicators, each indicator is divided into 2K + 1 segments according to the value range of its input variable, and each segment represents a cluster; for the second type of indicators, expert knowledge or an expert system is used for classification, and the number of classes is 2K + 1, where K is a natural number.

[0097] Preferably, for the first type of indicators, the fuzzy C-means clustering algorithm is used. The fuzzy C-means clustering algorithm only needs to specify the expected number of clusters 2K + 1 and does not require a priori setting of clustering characteristics. It does not depend on predefined classes but analyzes and searches for the underlying structure from the data itself. Specifically, it includes:

[0098] Step S31: Variable space division: Divide each input variable space of the first category indicator into 2K+1 categories.

[0099] Step S32: Generation: When the fuzzy C-means clustering algorithm reaches the maximum number of iterations or the objective function improvement between two consecutive iterations is less than the specified minimum improvement, the clustering process stops and the generation of clusters and membership functions is completed.

[0100] Preferably, expert knowledge or an expert system is used to classify the second category of indicators, specifying a number of categories of 2K+1, where K is a natural number. Because the second category of indicators are semantic metrics, such as programming language complexity, software application complexity, and software's dependence on the environment, there is no unified calculation formula. Instead, expert knowledge or an expert system must be used to express them as semantic values similar to {good, average, poor}.

[0101] Step S4: construct a rule base and merge the rule base based on the fuzzy network.

[0102] The present invention adopts a multi-input single-output fuzzy system to construct a rule base, see Figure 1 and Figure 2 The fuzzy system mainly consists of four modules: fuzzifier, inference engine, knowledge base and defuzzification module. The fuzzifier converts the numerical input of the dependent variable into semantic values in a semantic term set. The inference engine processes these semantic values based on the knowledge base in the fuzzy domain. The knowledge base consists of a rule base and a database. The rule base represents the control objectives and control strategies through a set of semantic control rules, and the database contains a semantic term set and the membership function that defines its semantics. The defuzzification module converts the output value in the fuzzy domain into a clear domain and expresses it in a numerical value.

[0103] For the problem of software maintainability prediction, each rule in the rule base only contains "AND" operations, that is, all input variables affect the output variable at the same time, and the result will output the corresponding single output variable only when the premise rules are met at the same time.

[0104] Based on this, preferably, Figure 3 As shown, step 4 specifically includes:

[0105] Step S41: Use the metric as the input variable x of the software maintainability prediction model i (i=1,2,…,m+n), divided into variable set 1 and variable set 2 according to the first and second type indicators. Variable set 1 has numerical measurement x i (i=1,2,…,m), variable set 2 consists of semantic metrics x i (i=m+1,m+2,…,m+n).

[0106] Step S42: For variable set 1, a node N is constructed using the fuzzy clustering algorithm. 11 .

[0107] See also Figure 3 , node N 11 It is the first type of indicator rule base, which is based on the first type of indicator data, that is, the data x of the "numerical information" indicator i (i=1,2,…,m) generates. Node N 11 The rule base is generated by machine learning algorithms from input-output data pairs as training sets. 11 The rule base contains 2K+1 rules, which are described as follows:

[0108] Rule j: If x1 is C 1j and x2 is C 2j and…and x j is C mj then z 1j is C zj , where C ij is the i-th indicator and the j-th class, C zj is the jth category of the corresponding software maintainability output value, 1≤i≤m, 1≤j≤2K+1.

[0109] Preferably, for variable set 2, its rule base is derived from expert knowledge or an expert system.

[0110] See also Figure 3 , the first two indices in variable set 2 are used as node N 21 Input, N 21 The output z2 and the third index in variable set 2 are used as node N 22 Input, N 22 The output z3 is the next index as N 23 Input, and so on, each time only one indicator is added, and n-1 nodes (N 21 、N 22 ...N 2,n-1 ) combination; in the combination process, an identity node is added to adjust the timing and order of each indicator of variable set 2 as an input variable so that its position and order meet user needs; the identity node is a node with the same input and output.

[0111] Preferably, the identity node is the identity matrix.

[0112] Preferably, the rule base N 21 Generated by expert knowledge, the number of specific rules is no more than (2K+1) 2 The structure is as follows:

[0113] If x m+1 is C p1 and x m+2 is C p2 then z2 is C p3

[0114] Where p is a positive integer and 1≤p≤(2K+1) 2 , C p1 、C p2 、C p3 The value is taken from {1, 2, ..., 2K+1}. This is because the second indicator is a semantic metric, and its classification is preferably carried out using expert knowledge or an expert system. The classification result is a level, preferably {1, 2, ..., 2K+1}, a total of 2K+1 levels.

[0115] Rule Base N 22 Generated by expert knowledge, the number of specific rules is no more than (2K+1) 2 The structure is as follows:

[0116] If x m+3 is C q1 and z2 is C q2 then z3 is C q3

[0117] Where q is a positive integer and 1≤q≤(2K+1) 2 , C q1 、C q2 、C q3 Take a value from {1, 2, ..., 2K+1}.

[0118] Step S43: merging rule bases based on the fuzzy network.

[0119] See also Figure 3 , get n-1 nodes (N 21 、N 22 ...N 2,n-1 ), the rule bases of all nodes are first merged vertically and then merged horizontally to obtain the rule base of the entire software maintainability prediction model. The topological structure of the rule base is formula (4):

[0120] [(N 11 +N 21 +I 31 +…I n,1 )*(I 12 +N 22 +…+I n-1,2 +I n,2 )*…*(I 1,n-2 +N2,n-2 +I n,n-2 )*

[0121] (I 1,n-1 +N 2,n-1 )*N 1,n ](x1,…,x m+n |y) (4)

[0122] Among them, '+' indicates vertical merging, '*' indicates horizontal merging, and N 11 Indicates the node at row 1 and column 1, N 21 Represents the node in the 2nd row and 1st column, and so on, N i,j Represents the node in the i-th row and j-th column; I is the identity node, I 31 Indicates the identity node at row 3 and column 1, I n,1 Indicates the identity node at the nth row and the first column, and so on. ij represents the identity node in row i and column j; x1,…,x m+n represents input and y represents output.

[0123] According to formula (4), the nodes in the rule base are merged to obtain a rule base node.

[0124] Step S5: Optimize the parameter value of the membership function.

[0125] The parameter values generated in the above steps are used as the initial values of the membership function, and the parameters are optimized using a genetic algorithm.

[0126] Genetically encode the initial value, set the generation g = 1 and initialize the population, and judge whether the termination condition is met. If it is "no", set g = g + 1 and perform genetic operations such as selection, crossover, and mutation. Bring the new parameters into the membership function, recalculate and judge whether the optimization termination condition is met. If it is still "no", continue the genetic operation. If it is "yes", assign the optimized value to the membership function in the knowledge base.

[0127] Step S6: Constructing a software maintainability prediction model based on the membership function and the rule base.

[0128] When these multiple rule bases are merged into a single semantic rule base, the software maintainability prediction model based on fuzzy networks becomes a simple model system with m+n input variables, one output variable, membership function, and rule database RB.

[0129] Example 2

[0130] The present invention also provides a software maintainability prediction method, which uses the software maintainability prediction model provided in the first embodiment to calculate the predicted value of software maintainability and determine the difficulty of different software maintainability. Figure 1 and Figure 2 , specifically including the following steps:

[0131] Step 1: Collect data and obtain the input data of relevant indicators - variable set 1 and variable set 2. The input variables in variable set 2 are all subjective product assessment quantities (SPA). Preprocess and normalize variable set 1. Normalize the subjective assessment quantity of each input variable in variable set 2 to eliminate the influence of dimension (unit) and facilitate the subsequent unified processing of variable set 1 and variable set 2.

[0132] Step 2: After inputting all the input variables of the indicator data, namely variable set 1 and variable set 2, into the software maintainability prediction model provided in Example 1, the inference engine is guided to perform fuzzy reasoning according to the knowledge base to obtain the predicted value of software maintainability.

[0133] Preferably, see Figure 1 , the data is processed using the four modules of the fuzzy system: fuzzifier, inference engine, knowledge base, and defuzzification module. The fuzzifier converts the numerical input of the dependent variable into semantic values in a semantic term set. The inference engine processes these semantic values in the fuzzy domain based on the knowledge base. The knowledge base consists of a rule base and a database. The rule base represents the control objectives and control strategies through a set of semantic control rules, and the database contains a semantic term set and the membership function that defines its semantics. The defuzzification module converts the output value in the fuzzy domain into a clear domain, represents it with a numerical value, and finally obtains the expected value of software maintainability.

[0134] Example 3

[0135] On the basis of the first or second embodiment, for step S4: merging rule bases based on the fuzzy network, the present invention uses formula (4) to perform the merging of rule bases:

[0136] [(N 11 +N 21 +I 31 +…I n,1 )*(I 12 +N 22 +…+I n-1,2 +I n,2 )*…*(I 1,n-2 +N 2,n-2 +I n,n-2 )*

[0137] (I 1,n-1 +N 2,n-1 )*N 1,n ](x1,…,xm+n |y) (4)

[0138] Among them, '*' indicates horizontal merging and '+' indicates vertical merging.

[0139] Preferably, the rules for horizontal merging and vertical merging are as follows:

[0140] (1) Horizontal Merge(*)

[0141] See also Figure 5 , two nodes RB1 and RB2 are horizontally merged to obtain node RB.

[0142] RB1 has two inputs (x1, x2) and two outputs (z1, z2). Each input variable and output variable is divided into two segments according to the range space. See Table 1. Assume that RB1 consists of the following rule base:

[0143] If x1 is 1 and x2 is 1 then z1 is 1 and z2 is 2;

[0144] If x1 is 1 and x2 is 2 then z1 is 1 and z2 is 2;

[0145] If x1 is 2 and x2 is 1 then z1 is 2 and z2 is 1;

[0146] If x1 is 2 and x2 is 2 then z1 is 2 and z2 is 2.

[0147] Then the node RB1 can be represented by a 4×4 matrix as follows:

[0148]

[0149] Node RB2 has two inputs (x3, x4) and two outputs (z3, z4). Each input variable and output variable is divided into two segments according to the range space. Assume that RB2 consists of the following rule base, as shown in Table 1:

[0150] If x3 is 1 and x4 is 1 then z3 is 1 and z4 is 1;

[0151] If x3 is 1 and x4 is 2 then z3 is 1 and z4 is 2;

[0152] If x3 is 2 and x4 is 1 then z3 is 2 and z4 is 2;

[0153] If x3 is 2 and x4 is 2 then z3 is 2 and z4 is 1.

[0154] Then the node RB2 can be represented by a 4×4 matrix as follows:

[0155]

[0156] Table 1 Horizontal merger of nodes RB1 and RB2

[0157]

[0158] As shown in Table 1, horizontal merging is a matrix multiplication operation, which can be viewed as the dot product of two matrix vectors. The merged RB node has two inputs (x1, x2) and two outputs (z3, z4). The two inputs (x1, x2) are the two inputs of the RB1 node, and the two outputs (z3, z4) are the two outputs of the RB2 node. The two outputs of the RB1 node and the two inputs of RB2 are offset in the merging operation.

[0159] The merged RB node matrix is expressed as follows:

[0160]

[0161] (2) Vertical merger (+)

[0162] See also Figure 6 , the two nodes RB1 and RB2 are vertically merged to obtain the node RB.

[0163] Node RB1 has one input (x1) and one output (z1). Each input variable (x1) and output variable (z1) is divided into three segments according to the range space. See Table 2. Assume that RB1 consists of the following rule base:

[0164] If x1 is 1 then z1 is 2;

[0165] If x1 is 2 then z1 is 1;

[0166] If x1 is 3 then z1 is 3.

[0167] Then the node RB1 can be represented by a 3×3 matrix as follows:

[0168]

[0169] Node RB2 has one input (x2) and one output (z2). Each input variable (x2) and output variable (z2) is divided into three segments according to the range space. See Table 2. Assume that RB2 consists of the following rule base:

[0170] If x2 is 1 then z2 is 1;

[0171] If x2 is 2 then z2 is 3;

[0172] If x2 is 3 then z2 is 2.

[0173] Then the node RB2 can be represented by a 3×3 matrix as follows:

[0174]

[0175] Table 2 Vertical merger of nodes RB1 and RB2

[0176]

[0177] A vertical merge is the outer product of two matrices. The merged RB node has two inputs and two outputs. The two inputs are the two inputs (x1, x2) of the RB1 and RB2 nodes, and the two outputs are the two outputs (z1, z2) of the RB1 and RB2 nodes. Vertical merging uses the inputs of all participating nodes as the merged inputs and the outputs of all participating nodes as the merged outputs.

[0178] The merged RB node matrix is expressed as follows:

[0179]

[0180] The above are only preferred embodiments of the present invention and do not limit the implementation mode and protection scope of the present invention. For those skilled in the art, it should be aware that all solutions obtained by equivalent substitutions and obvious changes made using the contents of the present invention specification should be included in the protection scope of the present invention.

Claims

1. A method for generating a software maintainability prediction model, characterized by: The steps include: S1: Obtain indicators that characterize software maintainability, wherein the indicators include m first-category indicators and n second-category indicators, wherein the first-category indicators are numerical measurement indicators, and the second-category indicators are semantic measurement indicators, and m and n are natural numbers; S2: Obtain historical data as a training set, including obtaining the value of the first type of indicator and obtaining the input variable x i , where 1≤i≤m, and the corresponding software maintainability is used as the output value, where the software maintainability is measured by the number of lines of code changed; Get the semantic metric value of the second type of indicator and get the input variable x j , where m+1≤j≤m+n, preprocess the data; S3: Construct the membership function and convert the input variable x of the first type of indicator obtained in step S2 into i , cluster the m inputs and their corresponding output values into data pairs, where 1≤i≤m; the input variable x of the second type of indicator obtained in step S2 j Classification, where m+1≤j≤m+n; S4: constructing a rule base and merging the rule base based on the fuzzy network; S5: Optimizing the parameter value of the membership function; S6: Constructing a software maintainability prediction model based on the membership function and the rule base.

2. The generation method according to claim 1, wherein: In step S3, the first category of indicators adopts fuzzy C-means clustering, and the second category of indicators adopts expert knowledge or expert system classification. The number of classes of the first category of indicators and the second category of indicators is 2K+1, where K is a natural number.

3. The generation method according to claim 2, characterized in that: In step S3, the first type of indicators adopts fuzzy C-means clustering steps, which specifically include: Step S31: Each input variable of the first category of indicators is spatially divided into 2K+1 categories; Step S32: When the fuzzy C-means clustering algorithm reaches the maximum number of iterations or the objective function improvement between two consecutive iterations is less than the specified minimum improvement, the clustering process stops and the generation of clusters and membership functions is completed.

4. The generation method according to claim 1, wherein: Step S4 specifically includes: Step S41: Input variable x i According to the first and second indicators, it is divided into two parts: variable set 1 and variable set 2. Variable set 1 consists of numerical metrics x i Composition, 1≤i≤m, variable set 2 is composed of semantic metric x i Composition, m+1≤i≤m+n; Step S42: For variable set 1, construct a node N based on the fuzzy clustering algorithm 11 ; Node N 11 The first type of indicator rule base is generated by machine learning algorithm from the input and output data pairs as training set, N 11 The rule base contains 2K+1 rules: Rule j: If x1 is C 1j and x2 is C 2j and…and x j is C mj then z 1j is C zj , where C ij is the i-th indicator and the j-th class, C zj is the jth category of the corresponding software maintainability output value, 1≤i≤m, 1≤j≤2K+1; For variable set 2, the first two indicators in variable set 2 are used as node N 21 Input, N 21 The output z2 and the third index in variable set 2 are used as node N 22 Input, N 22 The output z3 is the next index as N 23 Input, and so on, each time only one indicator is added, thus obtaining n-1 nodes N 21 、N 22 ...N 2,n-1 During the merging and combining process, an identity node is added to adjust the timing and order of the various indicators of variable set 2 as input variables; the identity node is a node with the same input and output; Among them, the rule base node N 21 Generated by expert knowledge, the structure is as follows: If x m+1 is C p1 and x m+2 is C p2 then z2 is C p3 Where p is a positive integer and 1≤p≤(2K+1) 2 , C p1 、C p2 、C p3 Take a value from {1, 2, ..., 2K+1}; Rule Base N 22 Generated by expert knowledge, the structure is as follows: If x m+3 is C q1 and z2 is C q2 then z3 is C q3 Where q is a positive integer and 1≤q≤(2K+1) 2 , C q1 、C q2 、C q3 Take a value from {1, 2, ..., 2K+1}; Step S43: merging rule bases based on the fuzzy network; The rule bases of all nodes are first merged vertically and then merged horizontally to obtain a rule base for the entire software maintainability prediction model. The topological structure of the rule base is formula (4): [(N 11 +N 21 +I 31 +…I n,1 )*(I 12 +N 22 +…+I n-1,2 +I n,2 )*…*(I 1,n-2 +N 2,n-2 +I n,n-2 )* (YO 1,n-1 +N 2,n-1 )*N 1,n ](x1,…,x m+n |y) (4) Among them, the content in "[]" represents the topological expression of a node, '+' represents vertical merging, '*' represents horizontal merging, N ij Represents the node in the i-th row and j-th column; I ij represents the identity node at row i and column j; "()" represents the input and output of the node, x1,…,x m+n represents input and y represents output.

5. The generation method according to claim 1, wherein: Step S3 specifically includes: the first type of indicators use a Gaussian function as their membership function; the second type of indicators use a triangular membership function as their membership function.

6. The generation method according to claim 5, characterized in that: The triangular membership function is: Among them, x ij is the input variable x i The jth value of f ij is the membership degree corresponding to this value, t h mid Is the range R h a The center point, t h-1 mid Is the left value range R h-1 a The center point, t h+1 mid The right value range R h+1 a The symbol ' / ' represents the "division operation" in arithmetic operations. The superscript h represents the range of the h-th class, and the subscript a represents its input variable, m+1≤i≤m+n.

7. A method for predicting software maintainability, characterized by: The model generated by the method for generating a software maintainability prediction model according to any one of claims 1 to 6 is used to calculate the predicted value of software maintainability.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the method for generating a software maintainability prediction model according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for generating a software maintainability prediction model according to any one of claims 1 to 6 is implemented.

Citation Information

Patent Citations

  • Control system maintenance platform based on intelligent decision-making technology

    CN109189053A

  • Shared bicycle position prediction method and device and storage medium

    CN114118182A