Intelligent Equipment Software Testing Method Combining Convolutional Neural Network and Genetic Algorithm
Through the method of combining convolutional neural networks and genetic algorithms, a mutant branch-related graph is generated and an incremental learning model is constructed, which solves the problem of inefficient generation of software test cases for complex intelligent equipment, and realizes efficient and reliable software testing.
Patent Information
- Application Number
- CN202510451127.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-11
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2045-04-11
AI Technical Summary
In the prior art, the generation efficiency of test cases for detecting defects in complex intelligent equipment software is low, resulting in excessive consumption of computing resources and time, making it difficult to effectively apply in large and complex software systems.
The method of convolutional neural network combined with genetic algorithm is adopted to generate mutated branch-related graphs, build a mathematical model for multi-task test cases, and optimize the genetic method using incremental learning convolutional neural network to generate test cases with high defect detection capabilities.
It improves the efficiency and quality of test case generation, reduces resource consumption, ensures the reliability and stability of the software system under limited resources, and adapts to the expansion needs of complex software systems.
Smart Images

Figure CN119988236B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer complex software defect detection, and in particular to a method for testing intelligent equipment software by combining a convolutional neural network with a genetic algorithm. Background Art
[0002] Intelligent equipment integrates complex mechanical structures, precision sensors, and advanced communication modules. Software is key to imbuing it with intelligence and enabling automation and precise decision-making. Comprehensive and rigorous software testing can accurately identify and correct software defects before equipment is put into operation, preventing serious problems such as instability, reduced efficiency, and even safety incidents caused by software failures. Software testing is a key means of ensuring software quality. By discovering and correcting program defects, it can effectively improve software reliability. Mutation testing, among other things, can evaluate the quality of test cases, improve the testing process, and ultimately enhance software quality. Mutation testing first selects a mutation operator and makes a minor, grammatically correct modification to a program statement to generate a new program, called a variant. However, in reality, mutation testing requires generating a large number of variants. Using the same test case, the original program and the variant are executed separately. If the outputs differ, the test case kills the variant. This principle is called strong mutation testing. Obviously, executing the test case for each variant consumes a large amount of computing resources and time, making strong mutation testing very expensive to execute, which can be prohibitive for large and complex software systems. To address this problem, weak mutation testing has been proposed.
[0003] Recently, an increasing number of researchers have been integrating machine learning and deep learning techniques into software testing. Convolutional neural networks (CNNs) are deep learning models that extract features from input data through convolution operations, enabling tasks such as classification and recognition. CNNs can process large datasets without significantly increasing computational complexity. Furthermore, CNNs reduce the need for extensive feature engineering and enhance data processing robustness.
[0004] Genetic methods can perform global searches across a vast search space, avoiding being trapped in local optimal solutions. In test case generation, operations such as selection, crossover, and mutation are used to continuously optimize solutions. This means that a wider range of input combinations can be found to cover different program paths and states, improving the comprehensiveness of testing. While evolutionary methods perform well in test case generation, evaluating each individual requires calculating the fitness value by executing the program under test. As the complexity of the optimization problem increases, this process significantly increases execution time, further increasing testing costs and becoming a bottleneck for the further application of evolutionary methods. To address this issue, machine learning methods and predictive models from deep learning have been applied. The process of predictive model optimization evolutionary methods primarily involves data collection and analysis, establishing a predictive model, guiding the evolutionary process, and updating and optimizing the model. Summary of the Invention
[0005] In order to solve the problem of low efficiency in generating test cases for detecting numerous defects in complex intelligent equipment software in the prior art, the present invention proposes a testing method for intelligent equipment software defects that combines convolutional neural networks with genetic methods. The characteristics of this method that distinguish it from the original method are as follows: first, a mutation testing method is adopted to generate variant branches representing defects, and then executable paths are generated based on the coverage difficulty of the variant branches and the correlation between the variant branches; secondly, a multi-task test case generation mathematical model is constructed for multiple paths, and then a convolutional neural network model based on incremental learning is constructed; finally, an incremental learning convolutional neural network is used to enhance the genetic method to generate test cases with high defect detection capabilities.
[0006] The technical solution adopted in the present invention is as follows:
[0007] A method for testing intelligent equipment software using a convolutional neural network combined with a genetic algorithm comprises the following steps:
[0008] S1: Generate a path set based on the variation branch correlation graph;
[0009] S2: Build a test case generation optimization model based on the generated path set;
[0010] S3: Using the optimization model to construct an incremental learning convolutional neural network model according to preset rules;
[0011] S4: Combine the incremental learning convolutional neural network and the multi-population genetic method to generate test cases.
[0012] Preferably, the preset rule in step S3 is implemented as follows:
[0013] S3.1: Optimize the initial sample set , is the initial data set, is the initial sample size; P(X0 ) is the corresponding traversal path set obtained based on the initial data set; For X 0 The corresponding fitness value set;
[0014] S3.1.1: For the initial traversal path set Each path in , get the hashed path , the set of hash-coded paths is ;set up An input feature value is converted into a hash feature value ;
[0015] S3.1.2: Push In; outside the stack Can it be pushed into the stack? , satisfying one of the following two conditions:
[0016] (I) will With the stack For comparison, if and If the hash codes are different, just Put in middle;
[0017] (II) If and If the hash codes are the same, continue comparing and ,if and The Euclidean distance between Greater than threshold , then Put in middle;
[0018] In the same way, the stack with stack Compare with the existing hash path in the , if one of the above two conditions is met, Put it into the stack; pop the elements in the stack and convert the hash feature value into the input feature vector of the corresponding convolutional neural network model;
[0019] Get the optimized sample set ;
[0020] S3.2: The optimized sample set Divide into training set and test set ;
[0021] S3.3: When new data continues to arrive, return to step S3.2, re-optimize the sample set, and the model continues to learn.
[0022] A method for testing intelligent equipment software using a convolutional neural network combined with a genetic algorithm comprises the following steps:
[0023] S1: Generate a path set based on the variation branch correlation graph;
[0024] S2: Build a test case generation optimization model based on the generated path set;
[0025] S3: Using the model to construct an incremental learning convolutional neural network model;
[0026] S3.1: Optimize the initial sample set , is the initial data set, is the initial sample size; P(X 0 ) is the corresponding traversal path set obtained based on the initial data set; For X 0 The corresponding fitness value set;
[0027] S3.1.1: For the initial traversal path set Each path in , get the hash code path , the set of hash-coded paths is ;set up An input feature value is converted into a hash feature value ;
[0028] S3.1.2: Push In; outside the stack Can it be pushed into the stack? , satisfying one of the following two conditions:
[0029] (I) will With the stack For comparison, if and If the hash codes are different, just Put in middle;
[0030] (II) If and If the hash codes are the same, continue comparing and ,if and The Euclidean distance between Greater than threshold , then Put in middle;
[0031] In the same way, the stack with stack Compare with the existing hash path in the , if one of the above two conditions is met, Put it into the stack; pop the elements in the stack and convert the hash feature value into the input feature vector of the corresponding convolutional neural network model;
[0032] Get the optimized sample set ;
[0033] S3.2: The optimized sample set Divide into training set and test set ;
[0034] S3.3: When new data continues to arrive, return to step S3.2, re-optimize the sample set, and the model continues to learn;
[0035] S4: Combine the incremental learning convolutional neural network and the multi-population genetic method to generate test cases.
[0036] Also included is a method for testing intelligent equipment software using a convolutional neural network combined with a genetic algorithm, the method comprising the following steps:
[0037] S1: Generate path sets based on mutation branch correlation graph
[0038] Assume that the program under test is ,insert The set of mutation branches is , is a variation branch, is the number of mutation branches; the set of executable paths formed by the mutation branches is set to ;
[0039] S1.1: Calculate the correlation between variant branches
[0040] Based on the relationship between the number of samples covering the variant branch and the total number of samples, the variant branch can be calculated Difficulty of coverage ;
[0041] Set mutation branch The correlation between ; Based on simultaneous coverage variation branches The ratio of the number of samples to the total number of samples is used to estimate the correlation between the mutation branches. ; The same method can get all the variant branches The correlation between them is calculated and the mutation branch correlation matrix A is constructed;
[0042] if The correlation between , then set is a pair of conflicting mutation branches, marked as .
[0043] S1.2: Generate a variant branch correlation graph based on variant branch correlation
[0044] Assume that the variation branch correlation diagram is ,in is a set of vertices, is the set of edges, is the weight set of edges, and the initial value of these sets is an empty set;
[0045] First, traverse the correlation matrix A. When the mutation branch The correlation between When Add to Graph The vertex set In, that is , gather at the edge Add a line by point to The real edge ,gather .side Set the weight to The correlation between , weight set ; According to the above method, generate the variation branch correlation diagram .
[0046] S1.3: Generate path sets based on variant branch correlation graph
[0047] From the mutation branch collection In the above example, we select the variant branch with the highest coverage difficulty. , as the build path The benchmark node and Positioning on the variant branch correlation graph middle;
[0048] S1.3.1: Set mutation branch For the picture The current node in the graph Along the upper Traverse the subsequent direction and find the The successor node with the highest correlation , and Add to the path, now the path ;set up For the current node, continue from Search in the subsequent direction The node with the highest correlation , if the node All nodes in the current path are not conflicting mutation branches. Add to the current path, then ;if and a mutation branch node in the current path is the conflict mutation branch, that is ,but Cannot be added to the path, then continue to search for the node that matches the current node The next node with high relevance;
[0049] According to the above method, continue to traverse in the successor direction until all successor nodes are traversed and the path is obtained. ,in is a variation branch; at the same time, from the variation branch set Delete The variant branches included above;
[0050] S1.3.2: Set For the picture The current node in the graph Along the upper Traverse the predecessor direction to find the node The predecessor node with the highest correlation , and Add to the current path, then ; then As the current node, continue to search for the next node in the forward direction ; If the node All nodes in the current path are not conflicting mutation branches. Add to the current path, ; If the node and a node in the current path are a pair of conflicting mutation branches, then Cannot be added to the path node; then, continue to look for The next node with high relevance;
[0051] According to the above method, continue to traverse in the forward direction until all the predecessor nodes are traversed and the path is obtained. ; From the mutation branch set Delete The variant branches included in Add to the executable path collection In, that is ;
[0052] S1.3.3: From the updated variant branch set In the above example, we select the variant branch with the highest coverage difficulty as the path Repeat steps S1.3.1 to S1.3.2 above for the reference node to generate ;Finally, generate an executable path set , is the number of paths in the path set, is the executable path.
[0053] S2: Build a test case generation optimization model based on the generated path set;
[0054] For each target path , establish a test case generation optimization model based on path coverage, which can be expressed as:
[0055]
[0056] in for The value range formed; is the objective function, which can be defined as the similarity between the paths;
[0057]
[0058] in, is the number of nodes included in the target path, For test cases The number of nodes included in the traversal path; To cross the path and target path The number of consecutive identical nodes between them;
[0059] S3: Use the generated optimized model to build an incremental learning convolutional neural network model;
[0060] S3.1: Use the generated optimization model to build the initial sample set of the neural network model , where is the initial data set, is the initial sample size, is the initial data; is the corresponding traversal path set obtained based on the initial data set; for The corresponding fitness value set; define the convolution layer, pooling layer and output layer of the incremental learning convolutional neural network; specify the loss function as cross entropy loss, and set the indicator for evaluating model performance as accuracy;
[0061] Initialization of incremental learning convolutional neural network:
[0062] Define the convolution layer, pooling layer and output layer of the incremental learning convolutional neural network; let the input features of the model be , is the auxiliary feature; the output feature is ;
[0063] Compile the model:
[0064] Specify the loss function as cross entropy loss and set the indicator for evaluating model performance as accuracy;
[0065] S3.2: Optimize the initial sample set
[0066] S3.2.1: For the initial traversal path set Each path in , using hash function to obtain hash coding path , the set of hash-coded paths is ;set up An input feature value is converted into a hash feature value , thus obtaining the hash feature set ;
[0067] S3.2.2: Initialize the stack , hash the feature value Push In; outside the stack Can it be pushed into the stack? , one of the following two conditions must be met:
[0068] (I) With the stack For comparison, if and If the hash codes are different, just Put in middle;
[0069] (II) If and If the hash codes are the same, then continue comparing and ,if and The Euclidean distance between Greater than threshold , then, Put in middle;
[0070] Then, follow the same method to remove the with stack Compare with the existing hash path in the , if one of the above two conditions is met, Put it into the stack; finally, pop the elements in the stack and convert the hash feature value into the input feature vector of the corresponding convolutional neural network model;
[0071] Finally, the optimized sample set is obtained ,in To optimize the number of samples, is the optimized input eigenvalue, for The corresponding fitness value;
[0072] S3.3: The optimized sample set Divide into training set and test set ;
[0073] training set Used to train the neural network model, the input features of the model are , the auxiliary feature is ; The output features are ;
[0074] S3.4: When new data continues to arrive, return to step S3.2, re-optimize the sample set, and the model continues to learn without the need to retrain the entire model.
[0075] Figure 2 This is a framework diagram of the incremental learning convolutional neural network model constructed by the present invention, in which the inner frame diagram shows the improvement of the traditional convolutional neural network by the present invention, optimizing the sample set and adding auxiliary features. ; The outer frame diagram continuously updates the model to form an incremental learning convolutional neural network model.
[0076] S4: Combine the incremental learning convolutional neural network and the multi-population genetic method to generate test cases.
[0077] The specific steps are:
[0078] S4.1: Let the population be , is the number of subpopulations, Responsible for generating coverage paths Test cases; set the values of various parameters required by the method;
[0079] S4.2: Use the incremental learning convolutional neural network model to estimate the individuals with high fitness as The initial population of
[0080] S4.3: Determine whether the method meets the termination condition. If so, go to S4.7;
[0081] S4.4: Execute the program under test and calculate The fitness value of the evolving individuals in ;
[0082] S4.5: Comparison The performance of different evolving individuals is used to perform genetic operations such as selection, crossover, and mutation to generate and preserve new individuals;
[0083] S4.6: The new individual is used as new data to continue to input the incremental learning convolutional neural network sample set, and go to S4.2;
[0084] S4.7: Stop evolution and output the test case set.
[0085] There are two termination conditions in S4.3 above: one is the generation of the desired test cases; the other is the population evolution to the maximum number of iterations;
[0086] The fitness value in S4.4 is determined by the function Determined by the objective function of formula (2):
[0087]
[0088] Beneficial effects of the present invention:
[0089] (1) Using graph theory methods, we bidirectionally traverse the mutation branch correlation graph to generate paths. This method ensures that the generated path set remains minimal while achieving coverage of the mutation branches in the program. By corresponding to a compact set of test cases, the time and resource consumption during the testing process are greatly reduced, thereby improving the efficiency of mutation testing. Without increasing hardware costs, we can achieve comprehensive and efficient testing of the software system, ensuring the reliability and stability of the software under limited resources.
[0090] (2) This paper proposes an incremental learning convolutional neural network, adds an auxiliary input feature, and a hash function to optimize the sample set. In addition, by adopting an incremental learning method, the training set is dynamically updated in real time during the test case generation process. This incremental learning optimization improves the accuracy and effectiveness of the model, ensuring that the test case set is continuously improved throughout the process.
[0091] (3) When incremental learning convolutional neural networks and multi-population genetic methods are combined to generate test cases, the incremental learning convolutional neural network can quickly evaluate the fitness values of evolving individuals, thereby improving the evolutionary efficiency of the multi-population genetic method. In addition, the real-time updates supported by the incremental learning convolutional neural network allow continuous improvement, obtaining higher-quality test cases over time. This method can effectively generate multi-path test cases through parallel evolution of sub-populations. This method can also effectively scale increasingly complex software systems and provide a robust solution for large-scale testing of intelligent equipment software. BRIEF DESCRIPTION OF THE DRAWINGS
[0092] Figure 1 This is a general flow chart of a method for testing intelligent equipment software using a convolutional neural network combined with a genetic algorithm according to the present invention;
[0093] Figure 2 This is the framework diagram of the incremental learning convolutional neural network proposed in the present invention;
[0094] Figure 3 Example procedures for implementing the present invention;
[0095] Figure 4 A radar chart showing the difficulty of covering variant branches for the example program.
[0096] Figure 5 This is a heat map of the correlation matrix before the example program mutated the branch;
[0097] Figure 6 This is the branch correlation diagram of the example program mutation;
[0098] Figure 7 Optimizing process graphs for sample sets DETAILED DESCRIPTION
[0099] Figure 1 This is a general flow chart of a method for testing intelligent equipment software using a convolutional neural network combined with a genetic algorithm, provided in one embodiment of the present invention. In this embodiment, the method for testing intelligent equipment software using a convolutional neural network combined with a genetic algorithm includes the following steps:
[0100] S1: Generate path sets based on mutation branch correlation graph
[0101] Assume that the program under test is ,insert The set of mutation branches is , is a variation branch, is the number of mutation branches; the set of executable paths formed by the mutation branches is set to ;
[0102] S1.1: Calculate the correlation between variant branches
[0103] Based on the relationship between the number of samples covering the variant branch and the total number of samples, the variant branch can be calculated Difficulty of coverage ;
[0104] Set mutation branch The correlation between ; Based on simultaneous coverage variation branches The ratio of the number of samples to the total number of samples is used to estimate the correlation between the mutation branches. ; The same method can get all the variant branches The correlation between them is calculated and the mutation branch correlation matrix A is constructed;
[0105] if The correlation between , then set is a pair of conflicting mutation branches, marked as .
[0106] S1.2: Generate a variant branch correlation graph based on variant branch correlation
[0107] Assume that the variation branch correlation diagram is ,in is a set of vertices, is the set of edges, is the weight set of edges, and the initial value of these sets is an empty set;
[0108] First, traverse the correlation matrix A. When the mutation branch The correlation between When Add to Graph The vertex set In, that is , gather at the edge Add a line by point to The real edge ,gather .side Set the weight to The correlation between , weight set ; According to the above method, generate the variation branch correlation diagram .
[0109] S1.3: Generate path sets based on variant branch correlation graph
[0110] From the mutation branch collection In the above example, we select the variant branch with the highest coverage difficulty. , as the build path The benchmark node and Positioning on the variant branch correlation graph middle;
[0111] S1.3.1: Set mutation branch For the picture The current node in the graph Along the upper Traverse the subsequent direction and find the The successor node with the highest correlation , and Add to the path, now the path ;set up For the current node, continue from Search in the subsequent direction The node with the highest correlation , if the node All nodes in the current path are not conflicting mutation branches. Add to the current path, then ;if and a mutation branch node in the current path is the conflict mutation branch, that is ,but Cannot be added to the path, then continue to search for the node that matches the current node The next node with high relevance;
[0112] According to the above method, continue to traverse in the successor direction until all successor nodes are traversed and the path is obtained. ,in is a variation branch; at the same time, from the variation branch set Delete The variant branches included above;
[0113] S1.3.2: Set For the picture The current node in the graph Along the upper Traverse the predecessor direction to find the node The predecessor node with the highest correlation , and Add to the current path, then ; then As the current node, continue to search for the next node in the forward direction ; If the node All nodes in the current path are not conflicting mutation branches. Add to the current path, ; If the node and a node in the current path are a pair of conflicting mutation branches, then Cannot be added to the path node; then, continue to look for The next node with high relevance;
[0114] According to the above method, continue to traverse in the forward direction until all the predecessor nodes are traversed and the path is obtained. ; From the mutation branch set Delete The variant branches included in Add to the executable path collection In, that is ;
[0115] S1.3.3: From the updated variant branch set In the above example, we select the variant branch with the highest coverage difficulty as the path Repeat steps S1.3.1 to S1.3.2 above for the reference node to generate ;Finally, generate an executable path set , is the number of paths in the path set, is the executable path.
[0116] S2: Build a test case generation optimization model based on the generated path set;
[0117] For each target path , establish a test case generation optimization model based on path coverage, which can be expressed as:
[0118] (1)
[0119] in for The value range formed; is the objective function, which can be defined as the similarity between the paths;
[0120] (2)
[0121] in, is the number of nodes included in the target path, For test cases The number of nodes included in the traversal path; To cross the path and target path The number of consecutive identical nodes between them;
[0122] S3: Use the generated optimized model to build an incremental learning convolutional neural network model;
[0123] S3.1: Use the generated optimization model to build the initial sample set of the neural network model , where is the initial data set, is the initial sample size, is the initial data; is the corresponding traversal path set obtained based on the initial data set; for The corresponding fitness value set; define the convolution layer, pooling layer and output layer of the incremental learning convolutional neural network; specify the loss function as cross entropy loss, and set the indicator for evaluating model performance as accuracy;
[0124] Initialization of incremental learning convolutional neural network:
[0125] Define the convolution layer, pooling layer and output layer of the incremental learning convolutional neural network; let the input features of the model be , is the auxiliary feature; the output feature is ;
[0126] Compile the model:
[0127] Specify the loss function as cross entropy loss and set the indicator for evaluating model performance as accuracy;
[0128] S3.2: Optimize the initial sample set
[0129] S3.2.1: For the initial traversal path set Each path in , using hash function to obtain hash code path , the set of hash-coded paths is ;set up An input feature value is converted into a hash feature value , thus obtaining the hash feature set ;
[0130] S3.2.2: Initialize the stack , the hash feature value Push In; outside the stack Can it be pushed into the stack? , one of the following two conditions must be met:
[0131] (I) With the stack For comparison, if and If the hash codes are different, just Put in middle;
[0132] (II) If and If the hash codes are the same, then continue comparing and ,if and The Euclidean distance between Greater than threshold , then, Put in middle;
[0133] Then, follow the same method to remove the with stack Compare with the existing hash path in the , if one of the above two conditions is met, Put it into the stack; finally, pop the elements in the stack and convert the hash feature value into the input feature vector of the corresponding convolutional neural network model;
[0134] Finally, the optimized sample set is obtained ,in To optimize the number of samples, is the optimized input eigenvalue, for The corresponding fitness value;
[0135] S3.3: The optimized sample set Divide into training set and test set ;
[0136] training set Used to train the neural network model, the input features of the model are , the auxiliary feature is ; The output features are ;
[0137] S3.4: When new data continues to arrive, return to step S3.2, re-optimize the sample set, and the model continues to learn without the need to retrain the entire model.
[0138] Figure 2 This is a framework diagram of the incremental learning convolutional neural network model constructed by the present invention, in which the inner frame diagram shows the improvement of the traditional convolutional neural network by the present invention, optimizing the sample set and adding auxiliary features. ; The outer frame diagram continuously updates the model to form an incremental learning convolutional neural network model.
[0139] S4: Combine the incremental learning convolutional neural network and the multi-population genetic method to generate test cases.
[0140] The specific steps are:
[0141] S4.1: Let the population be , is the number of subpopulations, Responsible for generating coverage paths Test cases; set the values of various parameters required by the method;
[0142] S4.2: Use the incremental learning convolutional neural network model to estimate the individuals with high fitness as The initial population of
[0143] S4.3: Determine whether the method meets the termination condition. If so, go to S4.7;
[0144] S4.4: Execute the program under test and calculate The fitness value of the evolving individuals in ;
[0145] S4.5: Comparison The performance of different evolving individuals is used to perform genetic operations such as selection, crossover, and mutation to generate and preserve new individuals;
[0146] S4.6: The new individual is used as new data to continue to input the incremental learning convolutional neural network sample set, and go to S4.2;
[0147] S4.7: Stop evolution and output the test case set.
[0148] There are two termination conditions in S4.3 above: one is the generation of the desired test cases; the other is the population evolution to the maximum number of iterations;
[0149] The fitness value in S4.4 is determined by the function Determined by the objective function of formula (2):
[0150] (3)
[0151] Figure 3 This is an example program of the present invention. Figure 3 (a) is the source statement of the program, Figure 3 (b) is a variant, Figure 3 (c) is the new program under test with the mutation branch inserted.
[0152] The following example program illustrates the implementation process of the present invention.
[0153] Assume that there are 4000 samples in the test case set, of which 1962 can cover the variant branches. ,So The coverage difficulty is Similarly, the coverage difficulty of all variant branches can be calculated, such as Figure 4 This is a radar chart of the coverage difficulty of all variant branches in the example program. The farther the data point is from the center, the larger the value of the indicator.
[0154] Furthermore, according to the number of test cases that kill the variant branches together, the correlation between the variant branches can be estimated, thereby obtaining the variant branch correlation matrix, such as Figure 5 Shown is a heat map of the branch correlation matrix of the example program mutation;
[0155] Next, using the method described in S1.2, a variation branch correlation diagram was constructed, such as Figure 6 shown.
[0156] Next, a path set is generated based on the variation branch correlation graph. First, select the most difficult variant branch to cover in the variant branch set. ( ).use As the base node of the path, Positioning in the figure In , the mutation branch correlation graph is traversed in both the predecessor and successor directions.
[0157] when When traversing in the subsequent direction, the 5th row of the mutation branch correlation matrix is traversed. The relevant successor nodes include and .in, and Therefore, Add to the path, i.e. .
[0158] Next, traverse The predecessor direction, that is, traversing the mutation branch correlation graph, is in the In the related predecessor nodes, and Therefore, the update path Next, repeat the process, starting with Traverse forward, from Traverse backwards.
[0159] It should be noted that, from When traversing backward, the current path .Although and The highest correlation is between and Constitute a pair of conflicting mutation branches So don't Add to the path.
[0160] Finally, based on the benchmark node , traverse the mutation branch correlation graph and generate paths , ,like Figure 6 The dark lines shown connect the variant branches.
[0161] Next, remove the path from the set of mutation branches Then select the node with the highest coverage difficulty from the remaining mutation branches , and generate the path in the same way , until there are no remaining mutation branches in the initial mutation branch set, where,
[0162] Finally, we can get the path collection .
[0163] Then, based on these two paths, a multi-task optimization model covering them is established as follows:
[0164] (4)
[0165] Then, convolutional neural networks need to be built for the two paths respectively.
[0166] like Figure 7 As shown, the specific process of optimizing the sample set is described below with an example.
[0167] Assume that the input feature set of the initial dataset is , which contains:
[0168]
[0169] Then, by executing the program under test, the traversal path set corresponding to the initial data set is obtained. , which contains:
[0170]
[0171] When the target path When the initial data set is obtained Corresponding fitness value set , which contains:
[0172] , , , ;
[0173] Next, hash code each path in the traversal path set to obtain the hash code path set , which contains:
[0174]
[0175] Thus, the hash feature set is obtained .
[0176] Further construction and initialization Then, the hash feature value There are three situations when the next hash feature value is pushed into the stack:
[0177] Case 1: In judgment When deciding whether to push into the stack, first and the hash feature value already in the stack Comparing the path hash codes, we found Then we need to continue to compare the Euclidean distance of the initial data in the search space
[0178] Due to setting the threshold ,and Greater than ,therefore Can enter .
[0179] Case 2: When determining whether to When pushing into the stack, the path hash code is compared again. With the existing and Therefore, Push onto the stack.
[0180] Situation 3: When deciding whether to When pushing into the stack, it is found With the existing The same. By calculation and Euclidean distance in the search space ,Right now:
[0181] Since this distance is less than the threshold 6, Cannot be pushed onto the stack.
[0182] Then, hash the feature value from the stack are sequentially removed from the stack Take it out and get the optimized data set . and The input feature vector that constitutes the convolutional neural network, As output, we finally get the optimized sample set .
[0183] Afterwards, Divide into training set and test set and use Train a convolutional neural network model, Evaluate the accuracy of the convolutional neural network model. When the evolutionary method generates new individuals, return to step S3.2 as new data, re-optimize the sample set, and continue learning the model.
[0184] When using the multi-population genetic method to generate test cases, the convolutional neural network model is first used to generate individuals with high fitness as the initial population of the multi-population genetic method.
[0185] The multi-population genetic method sets the number of subpopulations to 3 and the subpopulation size to 5. The evolutionary generations of the multi-population genetic method are set to 4000. The genetic operation uses roulette wheel selection, single-point crossover and single-point mutation, with crossover probability and mutation probability of 0.9 and 0.3 respectively. Finally, the test case set that kills the mutant branch is obtained as follows: .
[0186] It should be noted that the order in which the embodiments of the present invention are described above is for illustrative purposes only and does not represent the superiority or inferiority of the embodiments. The above description is of specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps described in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0187] The above description is intended to be illustrative and not limiting. Many embodiments and applications beyond the examples provided will be apparent to those skilled in the art upon reading the above description. Therefore, the scope of the present teachings should not be determined with reference to the above description, but rather with reference to the appended claims and the full scope of equivalents to which such claims are entitled. For the purpose of completeness, all articles and references, including disclosures of patent applications and publications, are incorporated herein by reference. The omission of any aspect of the subject matter disclosed herein from the foregoing claims is not a disclaimer of such subject matter, nor should it be assumed that the inventors did not consider such subject matter to be part of the disclosed inventive subject matter.
Claims
1. A method for testing intelligent equipment software using a convolutional neural network combined with a genetic algorithm, characterized in that: The following steps are involved: S1: Generate a path set based on the variant branch correlation graph to achieve coverage of the variant branches in the program; S2: Build a test case generation optimization model based on the generated path set; S3: Using the optimization model to build an incremental learning convolutional neural network model according to preset rules, optimize the sample set and add auxiliary features; S3.1: Optimize the initial sample set N 0 ={X 0 ,P(X 0 ),Fit(X 0 )}, is the initial data set, n′ is the number of initial samples; P(X 0 ) is the corresponding crossing path set obtained based on the initial data set; Fit(X 0 ) is X 0 The corresponding fitness value set; S3.1.1: For the initial traversal path set P(X 0 ) for each path Get the hash code path h1, h2...h n′ , the hash code path set is H = {h1, h2…h n′ };set up An input feature value is converted into a hash feature value S3.1.2: Push into the stack Sta; outside the stack Whether Sta can be pushed into the stack depends on whether one of the following two conditions is met: (I) Compare h2 with h1 in the stack. If the hash codes of h2 and h1 are different, directly put NH2 into Sta; (II) If the hash codes of h2 and h1 are the same, continue comparing and if and The Euclidean distance D between 1,2 Greater than the threshold Th D , then put NH2 into Sta; In the same way, h outside the stack is i (i=3,…n′) is compared with the hash path already existing in the stack Sta. If one of the above two conditions is met, Put it into the stack; Pop the elements from the stack and convert the hash feature value into the input feature vector of the corresponding convolutional neural network model; Get the optimized sample set N; S3.2: Divide the optimized sample set N into a training set N1 and a test set N2; S3.3: When new data continues to arrive, return to step S3.2, re-optimize the sample set, and the model continues to learn; S4: Combine the incremental learning convolutional neural network and the multi-population genetic method to generate test cases.
2. The intelligent equipment software testing method combining a convolutional neural network and a genetic algorithm according to claim 1, characterized in that: The generation of a path set based on the variation branch correlation graph in step S1 is implemented as follows: Assume that the program under test is P, and the set of mutation branches inserted into P is M = {M1, M2, ..., M m }, M1, M2, …, M m is the mutation branch, m is the number of mutation branches; the set of executable paths formed by the mutation branches is set to S1.1: Calculate the correlation between variant branches According to the relationship between the number of samples covering the mutation branch and the total number of samples, the mutation branch M is calculated. i The coverage difficulty dif(M i ); Suppose mutation branch M i , M j The correlation between them is t i,j ; According to the simultaneous coverage variation branch M i ,M j The ratio of the number of samples to the total number of samples is used to estimate the correlation between the mutation branches t i,j ; In the same way, all variant branches M1, M2, ...M are obtained m The correlation between them and construct the mutation branch correlation matrix ∧; If M i ,M j The correlation between i,j =0, then set M i , M j is a pair of conflicting mutation branches, marked as S1.2: Generate a variant branch correlation graph based on variant branch correlation Suppose the mutation branch correlation graph is G = {V, E, W}, where V is the vertex set, E is the edge set, and W is the edge-to-edge weight set. The initial values of these sets are empty sets. First, traverse the correlation matrix A. When the mutation branch M i , M j The correlation between i,j >0, M i , M j Add to the vertex set V of graph G, that is, V=V∪{M i ,M j }, add an edge from M to the edge set E i Pointing to M j The real edge <M i ,M j >, the edge set E=E∪{ <M i ,M j >}; side <M i ,M j Set the weight to M i ,M j The correlation between i,j , weight set W=W∪{t j,j According to the above method, a variation branch correlation graph G = {V, E, W} is generated; S1.3: Generate path sets based on variant branch correlation graph From the mutation branch set M={M1,M2,…M m }, select the variant branch M with the highest coverage difficulty i , as the construction path S l The reference node, and M i Positioned in the variation branch correlation graph G.
3. The intelligent equipment software testing method combining a convolutional neural network and a genetic algorithm according to claim 2, characterized in that: The generation of a path set based on the variation branch correlation graph in step S1.3 is implemented as follows: S1.3.1: Let the mutation branch M i is the current node in the variation branch correlation graph G, along M on the variation branch correlation graph G i Traverse the subsequent direction and find the i The successor node M with the highest correlation j , and M j Added to the path, now the path S l =M i ,M j ; Set M j For the current node, continue from M j Search in the subsequent direction with M j The node M with the highest correlation p , if node M p All nodes in the current path are not conflicting mutation branches, and M p Add to the current path, then S l =M i , M j , M p ; If M p and a mutation branch node M in the current path i is the conflict mutation branch, that is Then M p Cannot be added to the path, then continue to look for the node that matches the current node M j The next node with high relevance; According to the above method, continue to traverse in the successor direction until all successor nodes are traversed and the path S is obtained. l =M i , M j , M p ,…, where M i , M j , M p is a variation branch; S1.3.2: Let M i is the current node in the variation branch correlation graph G, along M on the variation branch correlation graph G i Traverse the predecessor direction and find the node M i The predecessor node M with the highest correlation j′ , and M j′ Add to the current path, then S l =M j′ ,M i ,M j ,M p ,…; then M j′ As the current node, continue to search for the next node M in the forward direction p′ ; If node M p′ All nodes in the current path are not conflicting mutation branches, and M p′ Add to the current path, S l =M p′ ,M j′ ,M i ,M j ,M p ,…; if node M p′ and a node in the current path are a pair of conflicting mutation branches, then M o′ It cannot be added to the path node; then, continue to look for the node with M j′ The next node with high relevance; According to the above method, continue to traverse in the forward direction until all the predecessor nodes are traversed and the path S is obtained. l =…,M p′ ,M j′ ,M i ,M j ,M p ,…; delete S from the mutation branch set M l The variant branches included in S l Add to the executable path set S, that is, S=S∪{S l }; S1.3.3: From the updated variant branch set M, select the variant branch with the highest coverage difficulty again as path S l+1 Repeat the above steps S1.3.1 to S1.3.2 for the reference node to generate S l+1 ; Finally, generate the executable path set S = {S1, S2, ..., S |s| }, |S| is the number of paths in the path set, S1, S2, ..., S |S| is the executable path.
4. The intelligent equipment software testing method combining a convolutional neural network and a genetic algorithm according to claim 2, characterized in that: The specific steps of step S4 for combining incremental learning of convolutional neural networks and multi-population genetic methods to generate test cases are as follows: S4.1: Let the population be G = {G1, G2, ..., G q }, q is the number of subpopulations, G1, G2, ..., G q is the subpopulation, subpopulation G l Responsible for generating coverage path S l Test cases; set the values of various parameters required by the method; S4.2: Use the incremental learning convolutional neural network model to estimate the individuals with high fitness as G l The initial population of S4.3: Determine whether the method meets the termination condition. If so, go to step S4.7; S4.4: Execute the program under test and calculate G l The fitness value of the evolving individuals in ; S4.5: Comparison G l The performance of different evolving individuals is used to perform genetic operations such as selection, crossover, and mutation to generate and preserve new individuals; S4.6: The new individual is used as new data to continue to input the incremental learning convolutional neural network sample set, and go to Step S4.2; S4.7: Stop evolution and output the test case set; There are two termination conditions in step S4.3: one is to generate the expected test case; The other is that the population evolves to the maximum number of iterations.
Citation Information
Patent Citations
Software test case generation method based on multi-population genetic algorithm
CN112699045A
Fuzzy test case generation and selection method and device, equipment and medium
CN117194219A