Intelligent equipment software testing method fusing clustering and convolutional neural network
By combining fuzzy clustering and convolutional neural networks, adaptive clustering and optimization model construction are performed on mutated branch paths, solving the problem of low efficiency in generating test cases for equipment software and achieving the ability to generate test cases efficiently and detect software defects.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XUZHOU UNIV OF TECH
- Filing Date
- 2026-02-25
- Publication Date
- 2026-05-05
AI Technical Summary
Existing technologies have low efficiency in generating test cases for equipment software, making it difficult to efficiently detect software defects. In particular, when processing multimodal data, the efficiency bottleneck of evolutionary algorithms is obvious.
Fuzzy clustering is used to adaptively cluster mutated branch paths. A convolutional neural network model is constructed based on the coverage difficulty and similarity of mutated branch paths. Test cases covering the paths are generated by combining particle swarm optimization. The model is optimized by adaptive fuzzy clustering and convolutional neural network to reduce model construction costs and improve test case generation efficiency.
It significantly improves the efficiency of test case generation. By combining fuzzy clustering and convolutional neural networks, it breaks through the limitations of traditional hard clustering, improves the ability to retain overlapping information between path categories and the construction efficiency of convolutional neural networks, and achieves efficient test case generation.
Smart Images

Figure CN121979800A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer software testing, specifically to a method for testing intelligent equipment software that integrates clustering and convolutional neural networks. Background Technology
[0002] Equipment software is a core product of the deep integration of equipment manufacturing and software technology. It serves as the "digital nerve center" for various industrial equipment (such as machine tools, construction machinery, aerospace equipment, ships, and military equipment) to achieve "intelligent, automated, and precise" operation. It is directly embedded in or controls equipment hardware, determining the equipment's performance ceiling, operating efficiency, reliability, and level of intelligence. It is a key support for the transformation of modern equipment from "mechanically driven" to "software-defined."
[0003] Software testing is a crucial means of ensuring software quality. In recent years, software testing has received increasing attention, and the requirements for its efficiency have also risen. Equipment software testing is a core component in ensuring the reliable operation of equipment throughout its entire lifecycle, mitigating major risks, and realizing the performance value of equipment. Its importance is multi-dimensional and irreplaceable. Once a failure is caused by software defects, it may lead to catastrophic consequences such as loss of life, production paralysis, and damage to national security. Testing is the "last line of defense" for early detection of hidden dangers and prevention of security risks. Testing can accurately verify core indicators such as functional logic, resource consumption, and anti-interference capabilities, ensuring that equipment can stably perform according to design specifications. As equipment upgrades towards intelligence and networking, the proportion of software continues to increase. High-quality testing is not only a key support for ensuring the independent controllability of equipment, but also an important foundation for enhancing the core competitiveness of domestically produced equipment and promoting the transformation of the equipment manufacturing industry towards high-end development.
[0004] Mutation testing, as a defect-oriented software testing method, has significant advantages such as strong debugging capabilities, convenience and flexibility, and a high degree of automation. In mutation testing, small, controlled modifications are introduced into the source program. A syntax change to a statement is called a mutation, and the mutated statement is called a mutated statement. Weak mutation testing only requires meeting reachability and necessity conditions. A mutation branch is a branch statement constructed based on the necessary conditions of a mutation test; it consists of the original statement and the mutated statement. Each mutated statement corresponds to a mutation branch, representing a potential software defect.
[0005] The core idea of fuzzy clustering is to break the traditional rigid classification logic of "either / or". Based on the concept of "partial attribution" in fuzzy mathematics, it believes that the category boundaries of most things in the real world are not absolutely clear. Samples can be classified into multiple categories to different degrees at the same time, thus more realistically depicting the fuzzy relationships and complex structures between data.
[0006] Convolutional neural networks (CNNs), as a deep learning model, possess excellent feature learning capabilities. In software testing, the variety and complexity of input data are often high, especially when dealing with multimodal data. CNNs can effectively handle such complex data, automatically extracting key information from the data for analysis through feature learning and abstraction, thereby improving the accuracy and reliability of testing.
[0007] Evolutionary algorithms require individuals to execute the program multiple times when calculating fitness values, increasing the execution cost and reducing efficiency. Therefore, to address this bottleneck, this invention leverages the advantages of convolutional neural network models to improve the performance of evolutionary methods. Summary of the Invention
[0008] To address the problem of low efficiency in generating test cases for detecting software defects in existing technologies, this invention proposes a software testing method for intelligent equipment that integrates clustering and convolutional neural networks. This method differs from existing methods in that it adaptively fuzzy clustering paths based on the similarity of mutated branch paths; constructs a convolutional neural network model for each cluster center path; and combines convolutional neural networks and particle swarm optimization to generate test cases covering the paths.
[0009] The technical solution adopted in this invention is: a method for testing intelligent equipment software that integrates clustering and convolutional neural networks, the method comprising the following steps:
[0010] S1: Adaptive fuzzy clustering path based on the difficulty and similarity of mutated branch path coverage;
[0011] Let the program under test be ,insert The set of mutation branches is , It is a variant branch. Let be the number of mutated branches; let be the set of executable paths formed by the mutated branches. ;
[0012] S1.1: Determine the difficulty of the mutated branch path and the similarity between paths;
[0013] A mutated branch path is defined as a path in which nodes contain only mutated branches. Therefore, the complexity of the mutated branch determines the difficulty of covering the path. The operators used in the mutated branch, such as arithmetic operators, logical operators, bitwise operators, and the number of operands, can also be used as an indicator of the difficulty of the mutated branch. In addition, the more operators and operands there are, the greater the computational complexity and difficulty of understanding the mutated branch may be.
[0014] Based on the above, four principles are designed to determine the difficulty of the mutation branch path: (1) the number of mutation branches contained in the path; (2) the number of operators and operands contained in the path; (3) the density of operators in the path, the more complex it is when multiple operators are in the same expression; (4) special operators in the path, such as ternary operators, lambda, regular expression metacharacters, etc., will increase the difficulty of understanding the path.
[0015] Then, the mutated branch paths are sorted according to the difficulty of path coverage, resulting in an ordered set of paths, denoted as . , Represented as the number of paths. Set The first path in The path that is most difficult to cover;
[0016] The following calculates the similarity between paths: Suppose there are two different paths. , , , These represent the lengths of the two paths, which are the number of mutated branches. , The similarity between them is denoted as , can be represented as:
[0017] (1)
[0018] From the above formula, we can see that ;in Represented as and The number of identical mutated branch nodes in the middle. This is represented as the maximum path length;
[0019] The same method can be used to calculate All paths The similarity between them;
[0020] The similarity matrix between the paths is constructed and denoted as follows: , can be represented as:
[0021]
[0022] Based on the matrix above, calculate the average similarity of all paths, denoted as . ;
[0023] S1.2: Based on the difficulty of path coverage and similarity, fuzzy cluster the paths to form path classes;
[0024] Input: an ordered set of paths Path similarity matrix Threshold ;
[0025] Output: Cluster set after clustering , The number of clusters.
[0026] S1.2.1: Initialize each cluster , Let variables be defined. ;
[0027] S1.2.2: From In the process, the first mutated branch node is selected as... The cluster center path, denoted as Update cluster ;
[0028] S1.2.3: Scan ,if Any path in Similarity greater than threshold Then these paths are placed into a cluster;
[0029] S1.2.4: From Delete cluster Included paths; Update ;
[0030] S1.2.5: If , Otherwise, proceed to S1.2.7;
[0031] S1.2.6: Repeat S1.2.2 to S1.2.5 until the set is complete. If the set is empty, then the clustering ends;
[0032] S1.2.7: Output all clusters, denoted as ,in The path to the cluster center;
[0033] S2: Each of the path classes constitutes a cluster, and for each cluster... Optimize the model for generating test cases that cover the paths;
[0034] Cluster center path For example, construct an optimized model for generating test cases covering the path; let... For the target path, test cases cover If the objective is to achieve the desired result, then the objective function is denoted as: The objective function is defined as the similarity between the target path and the traversal path;
[0035] When a test case Executing the program under test yields the following traversal path: Therefore, based on equation (1), the target path and The similarity can be expressed as:
[0036] (2)
[0037] As can be seen from the above formula, when the traversal path is the same as the target path, That is Take the maximum value; therefore, the optimized model for generating test cases that cover the target path can be expressed as:
[0038] (3)
[0039] in To optimize the decision variables of the model, yes The range of values;
[0040] Based on equations (2) and (3), the fitness function is defined as follows:
[0041] (4)
[0042] S3: Convolutional neural network model for constructing cluster center paths based on optimization model;
[0043] In general, there are many paths in the same cluster, and it would be too costly to build a convolutional neural network model for each path. Therefore, this invention builds a convolutional neural network model based on the optimization model of the central path of each cluster.
[0044] S3.1: Constructing a sample set based on the optimization model:
[0045] For cluster center path The decision variables of its optimization model As the input feature vector of a convolutional neural network, Include One sample input data;
[0046] Executing the program under test yields the set of traversal paths. To improve the accuracy and stability of convolutional neural network models, in addition to the input features of traditional convolutional neural networks... It also added As an auxiliary feature of convolutional neural networks, it adds more feature information to the convolutional neural network model.
[0047] remember Indicates the path of crossing In the middle, the first one is related to the target path The same node The position value in the index starts from 0; similarly, Indicates in In the middle, the last one with The same node The position value in the data; normalize the position value:
[0048] (5)
[0049] (6)
[0050] in, For the target path The number of nodes in the middle.
[0051] according to and Based on equation (4), the fitness value can be obtained. ;
[0052] In convolutional neural networks, The corresponding output feature value is represented as Therefore, for the input feature vector The corresponding output feature vector is represented as The sample set is represented as ;
[0053] sample set Divided into training set and test set .
[0054] S3.2: Training a convolutional neural network model based on a sample set;
[0055] Define the convolutional layer, pooling layer, and output layer of a convolutional neural network; define the input features of the model as... The output features are ;
[0056] Compile the model, specify the loss function as mean squared error, and set the metric for evaluating model performance as accuracy;
[0057] Building a Convolutional Neural Network Model: Using a Training Set The model is trained based on a convolutional neural network, and the parameters of training epochs and batch size are set.
[0058] Evaluation model: using the test set Evaluate the model and output the accuracy on the test set;
[0059] S4: Test case generation for particle swarm optimization algorithm enhanced by convolutional neural network model;
[0060] S4.1: Selecting the initial population of the particle swarm based on a convolutional neural network model;
[0061] To reduce the cost of building separate convolutional neural network models for other paths within a cluster, and considering the high similarity among multiple paths within the same cluster, all paths within the cluster can be reused. The convolutional neural network model, that is, other paths within a cluster can also predict excellent initial particles as the initial population of their respective particle groups based on the convolutional neural network model of the cluster center path.
[0062] Cluster Includes path , for The number of paths included.
[0063] For cluster paths Based on cluster center path The specific strategy for selecting excellent particles in a convolutional neural network model is as follows:
[0064] Define path Path to cluster center Similarity is ,in for and The fitness function corresponding to similarity;
[0065] based on The predicted value obtained by the convolutional neural network model is denoted as . ;
[0066] Let the predicted value be With target output value The absolute error is expressed as :
[0067] (7)
[0068] The input is evaluated using the absolute error method described above. Is it Corresponding superior particles; when using particle swarm optimization to generate coverage paths At that time, the superior particles are used as the initial particle swarm; let the initial particle swarm be . , The number of particles;
[0069] S4.2: Combining convolutional neural networks and particle swarm optimization to generate test cases;
[0070] Input: Randomly generated test cases; Path set ;
[0071] Output: A set of test cases covering the path set.
[0072] S4.2.1: Set the various parameter values for the particle swarm algorithm;
[0073] S4.2.2: For cluster center paths Based on a convolutional neural network model, an excellent particle swarm is predicted and used as the initial particles for the particle swarm optimization algorithm. ;
[0074] S4.2.3: Execute the program under test, if One of the particles is the coverage path ( Stop particle swarm optimization when the test cases or iterations reach the maximum number of iterations. The evolution of the system, saving test cases;
[0075] judge Do neutron particles cover clusters? The path in; if Each particle can cover the cluster. Paths, among which Save the k particles as test cases corresponding to the path; from the cluster Delete the path where the test cases have been found, and update the cluster. ; ; ;
[0076] If no particle is covered ( And the maximum number of iterations has not been reached; proceed to step S4.2.6; if Proceed to step S4.2.7;
[0077] S4.2.4: For paths where no test cases were found The calculation process involves the particle's traversal path and the path itself. The similarity is determined by the threshold. Save these particles as paths The excellent initial particles are accumulated, and the number of particles is denoted as . ;
[0078] S4.2.5: In Select path Based on cluster center path The convolutional neural network model, selected of One excellent particle; compared with the excellent particles saved in step 4.2.5 Together Corresponding initial population Proceed to step S4.2.3;
[0079] S4.2.6: Calculate the particle fitness values of the initial population in step 4.2.5; update the particle velocity and position, update the local optimum and global optimum values; proceed to step S4.2.3;
[0080] S4.2.7: Iteration terminates, output test case set.
[0081] The beneficial effects of this invention are:
[0082] (1) In the field of software testing, fuzzy clustering is used to adaptively cluster variable branch paths. This method quantifies the similarity between paths and divides highly similar paths into the same fuzzy cluster. At the same time, it allows the same path to belong to multiple categories with different membership degrees. This feature is more in line with the actual situation in real-world testing where the boundaries of path similarity are fuzzy and categories overlap. The method breaks the limitation of the traditional hard clustering "either / or" through the flexible division of fuzzy membership degrees. It not only preserves the overlapping information between path categories, but also reduces the number of models through cluster compression. While improving the rationality of test data classification, it also takes into account the construction efficiency and prediction performance of convolutional neural network models.
[0083] (2) When constructing the convolutional neural network model, this invention only needs to construct the central path convolutional neural network model for each cluster, without having to model all paths within the cluster one by one, thus significantly reducing the construction cost of the convolutional neural network model. In addition, this invention improves the traditional convolutional neural network: at the input feature level, in addition to the program input in the traditional method, a traversal path is added as an auxiliary feature to inject richer contextual information into the model and enhance the feature expression ability; at the output feature level, the output is designed as a ternary structure. In addition to retaining the fitness value corresponding to the input feature in the traditional method, two additional feature points are introduced to label the traversal path and the target path. This design enables the model to output differentiated prediction results through the added feature points when different paths have the same fitness value, avoiding the "single value confusion" problem of the traditional model and improving the discrimination and practical value of the prediction results.
[0084] (3) In the process of test case generation based on convolutional neural network models to enhance particle swarm optimization, the prediction accuracy of multi-path reuse of convolutional neural network models is crucial. During the prediction phase, multiple paths within the same cluster can repeatedly call the already constructed central path convolutional neural network model. Through the mechanism of "modeling once and reusing multiple times," the efficiency of model usage is significantly improved, avoiding the computational overhead caused by repeated modeling. In addition, when executing the particle swarm optimization algorithm, if the particles generated during the iteration process have no optimization value for the current target path, it can be determined whether they are valid test cases or excellent particles for other paths within the cluster. This strategy can reduce the number of repeated predictions of the convolutional neural network model and reduce the computational cost of other paths in the particle swarm evolution process. Through cross-path particle sharing and resource reuse, the overall efficiency of test case generation is optimized. This method significantly improves the efficiency of test case generation while ensuring prediction accuracy through the efficient reuse of convolutional neural network models and cross-path collaboration of particle swarm iteration. Attached Figure Description
[0085] Figure 1 This is a flowchart illustrating the overall process of a software testing method for intelligent equipment that integrates clustering and convolutional neural networks, as described in this invention.
[0086] Figure 2 This is an example program for implementing the present invention;
[0087] Figure 3 A heatmap of the similarity matrix between paths generated by the mutated branches of the example program;
[0088] Figure 4 This is a diagram illustrating the improved convolutional neural network framework of the present invention. Detailed Implementation
[0089] The technical solution studied in this invention is a software testing method for intelligent equipment that integrates clustering and convolutional neural networks. This method includes the following steps:
[0090] S1: Adaptive fuzzy clustering path based on the difficulty and similarity of mutated branch path coverage;
[0091] Let the program under test be ,insert The set of mutation branches is , It is a variant branch. Let be the number of mutated branches; let be the set of executable paths formed by the mutated branches. ;
[0092] S1.1: Determine the difficulty of the mutated branch path and the similarity between paths;
[0093] A mutated branch path is defined as a path in which nodes contain only mutated branches. Therefore, the complexity of the mutated branch determines the difficulty of covering the path. The operators used in the mutated branch, such as arithmetic operators, logical operators, bitwise operators, and the number of operands, can also be used as an indicator of the difficulty of the mutated branch. In addition, the more operators and operands there are, the greater the computational complexity and difficulty of understanding the mutated branch may be.
[0094] Based on the above, four principles are designed to determine the difficulty of the mutation branch path: (1) the number of mutation branches contained in the path; (2) the number of operators and operands contained in the path; (3) the density of operators in the path, the more complex it is when multiple operators are in the same expression; (4) special operators in the path, such as ternary operators, lambda, regular expression metacharacters, etc., will increase the difficulty of understanding the path.
[0095] Then, the mutated branch paths are sorted according to the difficulty of path coverage, resulting in an ordered set of paths, denoted as . , Represented as the number of paths. Set The first path in The path that is most difficult to cover;
[0096] The following calculates the similarity between paths: Suppose there are two different paths. , , , These represent the lengths of the two paths, which are the number of mutated branches. , The similarity between them is denoted as , can be represented as:
[0097] (1)
[0098] From the above formula, we can see that ;in Represented as and The number of identical mutated branch nodes in the middle. This is represented as the maximum path length;
[0099] Based on equation (1), it is possible to calculate All paths The similarity between them;
[0100] The similarity matrix between the paths is constructed and denoted as follows: , can be represented as:
[0101]
[0102] Based on the matrix above, calculate the average similarity of all paths, denoted as . .
[0103] S1.2: Based on the difficulty of path coverage and similarity, fuzzy cluster the paths to form path classes;
[0104] Input: an ordered set of paths Path similarity matrix Threshold ;
[0105] Output: Cluster set after clustering , The number of clusters.
[0106] S1.2.1: Initialize each cluster , Let variables be defined. ;
[0107] S1.2.2: From In the process, the first mutated branch node is selected as... The cluster center path, denoted as Update cluster ;
[0108] S1.2.3: Scan ,if Any path in Similarity greater than threshold Then these paths are placed into a cluster;
[0109] S1.2.4: From Delete cluster Included paths; Update ;
[0110] S1.2.5: If , Otherwise, proceed to S1.2.7;
[0111] S1.2.6: Repeat S1.2.2 to S1.2.5 until the set is complete. If the set is empty, then the clustering ends;
[0112] S1.2.7: Output all clusters, denoted as ,in The path to the cluster center;
[0113] Step S2: Each of the path classes constitutes a cluster, and for each cluster... Optimize the model for generating test cases that cover the paths;
[0114] Cluster center path For example, construct an optimized model for generating test cases covering the path; let... For the target path, test cases cover If the objective is to achieve the desired result, then the objective function is denoted as: The objective function is defined as the similarity between the target path and the traversal path;
[0115] When a test case Executing the program under test yields the following traversal path: Therefore, based on equation (1), the target path and The similarity can be expressed as:
[0116] (2)
[0117] As can be seen from the above formula, when the traversal path is the same as the target path, That is Take the maximum value; therefore, the optimized model for generating test cases that cover the target path can be expressed as:
[0118] (3)
[0119] in To optimize the decision variables of the model, yes The range of values;
[0120] Based on equations (2) and (3), the fitness function is defined as follows:
[0121] (4)
[0122] S3: Convolutional neural network model for constructing cluster center paths based on optimization model;
[0123] In general, there are many paths in the same cluster, and it would be too costly to build a convolutional neural network model for each path. Therefore, this invention builds a convolutional neural network model based on the optimization model of the central path of each cluster.
[0124] S3.1: Construct a sample set based on the optimization model;
[0125] For cluster center path The decision variables of its optimization model As the input feature vector of a convolutional neural network, Include One sample input data;
[0126] Executing the program under test yields the set of traversal paths. To improve the accuracy and stability of convolutional neural network models, in addition to the input features of traditional convolutional neural networks... and increase As an auxiliary feature of convolutional neural networks, it adds more feature information to the convolutional neural network model.
[0127] remember Indicates in Corresponding traversal path In the middle, the first one is related to the target path The same node The position value in the index starts from 0; similarly, Indicates in In the middle, the last one with The same node The position value in the data; normalize the position value:
[0128] (5)
[0129] (6)
[0130] in, For the target path The number of nodes in the middle.
[0131] according to and Based on equation (4), the fitness value can be obtained. ;
[0132] In convolutional neural networks, The corresponding representation is Therefore, for the input feature vector The corresponding output features are represented as The sample set is represented as ;
[0133] sample set Divided into training set and test set .
[0134] S3.2: Training a convolutional neural network model based on a sample set.
[0135] Define the convolutional layer, pooling layer, and output layer of a convolutional neural network; define the input features of the model as... The output features are ;
[0136] Compile the model, specify the loss function as mean squared error, and set the metric for evaluating model performance as accuracy;
[0137] Building a Convolutional Neural Network Model: Using a Training Set The model is trained based on a convolutional neural network, and the parameters of training epochs and batch size are set.
[0138] Evaluation model: using the test set Evaluate the model and output the accuracy on the test set;
[0139] S4: Test case generation for particle swarm optimization algorithm enhanced by convolutional neural network model;
[0140] S4.1: Selecting the initial population of the particle swarm based on a convolutional neural network model;
[0141] To reduce the cost of building separate convolutional neural network models for other paths within a cluster, and considering the high similarity among multiple paths within the same cluster, all paths within the cluster can be reused. The convolutional neural network model, that is, other paths within a cluster can also predict excellent initial particles as the initial population of their respective particle groups based on the convolutional neural network model of the cluster center path.
[0142] Cluster Includes path , for The number of paths included.
[0143] For cluster paths Based on cluster center path The specific strategy for selecting excellent particles in a convolutional neural network model is as follows:
[0144] Define path Path to cluster center Similarity is ,in for and The fitness function corresponding to similarity;
[0145] based on The predicted value obtained by the convolutional neural network model is denoted as . ;
[0146] Let the predicted value be With target output value The absolute error is expressed as :
[0147] (7)
[0148] The input is evaluated using the absolute error method described above. Is it Corresponding superior particles; when using particle swarm optimization to generate coverage paths At that time, the superior particles are used as the initial particle swarm; let the initial particle swarm be . , The number of particles;
[0149] S4.2: Combining convolutional neural networks and particle swarm optimization to generate test cases;
[0150] Input: Randomly generated test cases; Path set ;
[0151] Output: A set of test cases covering the path set.
[0152] S4.2.1: Set the various parameter values for the particle swarm algorithm;
[0153] S4.2.2: For cluster center paths Based on a convolutional neural network model, an excellent particle swarm is predicted and used as the initial particles for the particle swarm optimization algorithm. ;
[0154] S4.2.3: Execute the program under test, if One of the particles is the coverage path ( Stop particle swarm optimization when the test cases or iterations reach the maximum number of iterations. The evolution of the system, saving test cases;
[0155] judge Do neutron particles cover clusters? The path in; if k particles can cover the cluster Paths, among which Save the k particles as test cases corresponding to the path; from the cluster Delete the path where the test cases have been found, and update the cluster. ; ; ;
[0156] If no particle is covered ( And the maximum number of iterations has not been reached; proceed to step S4.2.6; if Proceed to step S4.2.7;
[0157] S4.2.4: For the path where no test case was found in step 4.2.3 The calculation process involves the particle's traversal path and the path itself. The similarity is determined by the threshold. Particles with a threshold greater than U are saved as paths. The excellent initial particles are accumulated, and the number of particles is denoted as . ;
[0158] S4.2.5: In Select path Based on cluster center path The convolutional neural network model, selected of One excellent particle; compared with the excellent particles saved in step 4.2.4 Together Corresponding initial population Proceed to step S4.2.3:
[0159] S4.2.6: Calculate the particle fitness values of the initial population in step 4.2.5; update the particle velocity and position, update the local optimum and global optimum values; proceed to step S4.2.3;
[0160] S4.2.7: Iteration terminates, output test case set. The implementation process of this invention is illustrated below through example programs.
[0161] Figure 2 (a) in the text represents the source code of the program under test; Figure 2 (b) in the diagram represents the new program after inserting the mutated branch.
[0162] 1. Adaptive Fuzzy Clustering Path Based on Path Similarity
[0163] Figure 2 The set of mutation branch paths obtained from the 62 mutation branches is as follows .
[0164]
[0165] Based on four principles, static analysis is used to determine the coverage difficulty of the paths, resulting in the sorted set of paths. .
[0166] Next, the similarity between paths is calculated.
[0167] path and There are 32 identical variant branch nodes. According to equation (1), calculate... and The similarity is = .
[0168] Similarly, the similarity between all paths can be calculated, and a similarity matrix can be constructed. ,
[0169]
[0170] Calculate the average similarity of all paths. .
[0171] Path similarity matrix heatmap as follows Figure 3 As shown, because it is a symmetric matrix, only the upper triangle of the matrix is displayed.
[0172] The following section performs fuzzy clustering on the six paths.
[0173] exist Select the first path As a cluster The central path.
[0174] Then, set the threshold to Based on the similarity matrix Filter out those that are related to Similarity greater than threshold The paths are respectively Put them into clusters In the middle. The first cluster is obtained:
[0175]
[0176] Next, from In the middle, delete cluster Included paths The updated ordered set of paths
[0177] Next, select In As a cluster The central path. Repeat the above process until... .
[0178] Finally, two path clusters were obtained:
[0179]
[0180]
[0181]
[0182] 2. Optimize the test case generation model based on the cluster center path.
[0183] Cluster central path For the target path, cluster central path For the target path, cluster central path For the target path, we can build three path coverage test cases to generate an optimization model:
[0184]
[0185] 3. Constructing a proxy model based on a convolutional neural network based on an optimization model.
[0186] It is the cluster center path of the first cluster, and it is built using a surrogate model based on a convolutional neural network model.
[0187] Assumption Given an input data set, its traversal path is: According to equation (2), the path and The similarity is Calculate according to equations (5) and (6) , This outputs the eigenvalues. Therefore, the sample value input The corresponding sample output is .
[0188] Following the method described above, establish a convolutional neural network sample set. and construct such Figure 4 As shown, this is a proxy model based on a convolutional neural network.
[0189] by For example, this illustrates how intra-cluster paths are based on the central path. The proxy model selects the initial population process for each particle swarm.
[0190] First, select the central path based on the agent model. The initial population of the corresponding particle swarm.
[0191] From equation (4), we can calculate The fitness corresponding to its similarity to itself is: ;
[0192] From equations (5) and (6), we can calculate respectively. With its own , Therefore, the path The target output vector value when using this proxy model is .
[0193] right Assuming its sample input test case set is ,
[0194] according to The output values predicted by the constructed proxy model are as follows:
[0195]
[0196]
[0197] Next, the absolute error is calculated according to equation (7), with For example:
[0198]
[0199] Using the same method, , , ,
[0200] Suppose we need 2 excellent particles, and we choose from 5 particles. , As the initial population for the particle swarm optimization algorithm, because of their absolute error values , The minimum error is selected by choosing the two input data points with the smallest error. , As The initial population for the corresponding particle swarm optimization algorithm.
[0201] Based on the above method, The constructed proxy model can be used for clusters Other paths in the algorithm predict excellent particles. For example... Figure 1 As shown.
[0202] exist In the middle, path and With the target path The similarity scores are the same, both at 0.74. Therefore, based on... and To illustrate, although they have the same path similarity to the cluster center, the method of this invention can be used to screen out their respective superior particles.
[0203] For path
[0204] The following can be calculated from equation (1): and The fitness corresponding to the similarity is From equations (5) and (6), we can calculate the results respectively. and of and value: , So, the path and Similar target output vector values are: .
[0205] Input data For example, based on The predicted value is The absolute error value is calculated according to equation (7):
[0206]
[0207] Similarly, calculate the absolute error values for the other outputs. See the table below:
[0208] The corresponding absolute error values are shown in Table 1 below: Table 1
[0209]
[0210] According to the table above, because , Corresponding absolute error , Minimum, therefore choose , As an excellent particle.
[0211] Similarly, it can be calculated that The target feature value when using this proxy model is .
[0212] The error analysis table is shown in Table 2 below: Table 2
[0213]
[0214] According to the table above, because , Corresponding absolute error , Minimum, therefore choose , As an excellent particle.
[0215] As can be seen from the examples above, and respectively with The similarity is the same, and and It is for paths and It's the same input, but because of the path... and Different node compositions result in different absolute errors based on the proxy model. Therefore, the method of this invention... It can be and Selected as the representative particle, and Only can be Choose representative particles, and not be... Selected.
[0216] cluster Other paths The model was used sequentially to screen for superior particles.
[0217] When the particle swarm optimization algorithm generates new particles, they are integrated into the sample set as new test cases, enabling the model to continuously learn.
[0218] When using the particle swarm optimization algorithm to generate test cases, individuals with high similarity generated by the convolutional neural network model are used as the initial population for the particle swarm optimization algorithm.
[0219] The particle swarm optimization algorithm is set with a particle swarm size of 30, a particle dimension of 3, and a maximum number of iterations of 10,000. Finally, based on step 4.2, the test cases covering 9 paths are obtained as follows:
[0220]
[0221] In summary, the method of this invention, in the field of software testing, employs fuzzy clustering to adaptively cluster variable branch paths. By quantifying the similarity between paths, it groups highly similar paths into the same fuzzy cluster. Simultaneously, it allows the same path to belong to multiple categories with different membership degrees, a characteristic that better reflects the real-world testing situation where path similarity boundaries are blurred and categories overlap. Through the flexible division of fuzzy membership degrees, the method breaks the "either / or" limitation of traditional hard clustering, preserving overlapping information between path categories while reducing the number of models through cluster compression. This improves the rationality of test data classification while balancing the construction efficiency and predictive performance of convolutional neural network models.
Claims
1. A method for testing intelligent equipment software that integrates clustering and convolutional neural networks, characterized in that, Includes the following steps: S1: Adaptive fuzzy clustering path by utilizing the difficulty and similarity of the mutated branch path coverage; S1.1: Determine the difficulty of covering the mutated branch path and the similarity between paths; S1.2: Based on path coverage difficulty and similarity, fuzzy clustering of paths is performed to form multiple path classes; S2: Each of the path classes constitutes a cluster, and an optimized model covering the generation of path test cases is constructed for each cluster; S3: Convolutional neural network model for constructing cluster center paths based on optimization model; S4: Test case generation based on the enhanced particle swarm algorithm using a convolutional neural network model.
2. The method according to claim 1, characterized in that, Step S1.2 specifically includes: Input data: a set of ordered mutation branch paths Path similarity matrix Threshold ; Output data: Cluster set after clustering , The number of clusters; S1.2.1: Initialize each cluster , ; Let variables ; S1.2.2: From In the process, the first mutated branch node is selected as... The cluster center path, denoted as Update cluster ; S1.2.3: Scan ,if Any path in Similarity greater than threshold Then these paths are placed into a cluster; S1.2.4: From Delete cluster Included paths; Update ; S1.2.5: If , Otherwise, proceed to S1.2.7; S1.2.6: Repeat S1.2.2 to S1.2.5 until the set is complete. If the set is empty, then the clustering ends; S1.2.7: Output all clusters, denoted as ,in This is the path to the cluster center.
3. The method according to claim 2, characterized in that, Step S3 specifically involves: S3.1: Construct a sample set based on the optimization model; S3.2: Training a convolutional neural network model based on a sample set.
4. The method according to claim 3, characterized in that, Step S3.1 is performed as follows: cluster central path The corresponding input feature vector of the convolutional neural network is... ,Include One sample input data; Executing the program under test yields the set of traversal paths. ; and increase As an auxiliary feature of convolutional neural networks; remember Indicates the path traversed In the middle, the first one is related to the target path The same node The position value in the index starts from 0; similarly, Indicates in In the middle, the last one with The same node The position value in the middle; Normalize the position values: in, For the target path The number of nodes in the middle; according to and Calculate the fitness value .
5. The method according to claim 4, characterized in that, In convolutional neural networks, The corresponding output feature value is Therefore, for the input feature vector The corresponding output feature vector is represented as The sample set is .
6. The method according to claim 1, characterized in that, Step S4 specifically involves: S4.1: Selecting the initial population of the particle swarm based on a convolutional neural network model; S4.2: Test cases are generated using the particle swarm optimization algorithm based on the initial population.
7. The method according to claim 6, characterized in that, The specific steps in S4.2 are as follows: Input data: randomly generated test cases; path set ; Output data: A set of test cases covering the path set; S4.2.1: Set the parameter values for the particle swarm optimization algorithm; S4.2.2: For cluster center paths Based on a convolutional neural network model, a superior particle swarm is predicted and used as the initial particles for the particle swarm optimization algorithm. Let the initial particle swarm be... , The number of particles; S4.2.3: Execute the program under test, if A certain particle coverage path ( If the test cases are not found or the maximum number of iterations is reached, then the particle swarm optimization should be stopped. The evolution of the system, saving test cases; If no particle is covered ( And it has not reached the maximum number of iterations; Proceed to step S4.2.6; if Proceed to step S4.2.7; S4.2.4: The path to the test case was not found in step 4.2.
3. At that time, the calculation process involves the particle's traversal path and the path... The similarity is determined by the threshold. Particles with a threshold greater than U are saved as paths. The excellent initial particles are accumulated, and the number of particles is denoted as . ; S4.2.5: In Select path Based on cluster center path The convolutional neural network model, selected of One excellent particle; The excellent ones saved in step 4.2.4 Together Corresponding initial population ; Proceed to step S4.2.3: S4.2.6: Calculate the particle fitness values of the initial population in step 4.2.5; update the particle velocity and position, update the local optimum and global optimum values; proceed to step S4.2.3; S4.2.7: Iteration terminates, output test case set.
8. The method according to claim 7, characterized in that, In step S4.2.3, determine Do neutron particles cover clusters? If k particles can cover the path in the cluster, then... Paths, among which Save the k particles as test cases corresponding to the path; From cluster Delete the path where test cases have been found, and update the cluster. ; ; .