Intelligent equipment software testing method based on combination of convolutional neural network and genetic algorithm

Through the combination of convolutional neural networks and genetic algorithms, efficient test cases are generated, which solves the problem of inefficient detection of defects of complex intelligent equipment software and realizes efficient software testing.

CN119988236AActive Publication Date: 2025-05-13XUZHOU UNIV OF TECH
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202510451127.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-11
Publication Date
2025-05-13
Estimated Expiration
2045-04-11

AI Technical Summary

Technical Problem

The generation efficiency of test cases for detecting software defects in complex intelligent equipment in the prior art is inefficient, resulting in a large amount of computing resources and time spent in the software testing process.

Method used

The method of convolutional neural network combined with genetic algorithm is adopted to generate mutated branches representing defects through variation tests, generate paths based on coverage difficulty and correlation, and build an incremental learning convolutional neural network model to optimize test case generation.

Benefits of technology

It improves the efficiency of test case generation, reduces time and resource consumption during the test process, and ensures the reliability and stability of the software system under limited resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119988236A_ABST
    Figure CN119988236A_ABST
Patent Text Reader

Abstract

The invention discloses an intelligent equipment software testing method by combining a convolutional neural network with a genetic algorithm, and aims to convert a variation test problem into a traditional coverage path test problem and generate an effective test case. Firstly, variation branch coverage difficulty is calculated, a relevancy matrix is constructed, a variation branch correlation graph is generated, and then an executable path set is generated; constructing a multi-task test case aiming at multiple paths to generate a mathematical model; then, a convolutional neural network model based on incremental learning is constructed, then high-fitness individuals are predicted to serve as an initial population of the multi-population genetic method, and finally, by means of the multi-population genetic method enhanced based on the convolutional neural network based on incremental learning, test cases with defect detection capacity are efficiently generated. According to the method, the test case with high defect detection capability is generated, and the software test efficiency and quality of the intelligent equipment are effectively improved.
Need to check novelty before this filing date? Find Prior Art

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 the key to giving it intelligence and realizing automation and accurate decision-making. Comprehensive and rigorous software testing can accurately locate and repair software defects before the equipment is activated, preventing serious problems such as instability, reduced efficiency, and even safety accidents caused by software failures. Software testing is an important means to ensure software quality. By discovering and repairing defects in the program, the reliability of the software can be effectively improved. Among them, mutation testing can evaluate the quality of test cases, improve the testing process and improve software quality. Mutation testing first generates a new program by selecting a mutation operator and making a grammatically correct minor modification to a statement in the program. This newly generated program is called a mutant. However, in reality, mutation testing requires the generation of a large number of mutants. Use the same test case to execute the original program and the mutant respectively. If the outputs of the two are different, the test case kills the mutant. This criterion is called strong mutation testing. Obviously, executing the test case for each mutant will consume a lot of computing resources and time, which makes the execution cost of strong mutation testing very high, which may become unbearable for large and complex software systems. To solve this problem, weak mutation testing was proposed.

[0003] Recently, more and more researchers have integrated machine learning and deep learning techniques into software testing. Convolutional neural networks are deep learning models that extract features from input data through convolution operations to achieve tasks such as classification and recognition. Convolutional neural networks can process large-scale data sets without significantly increasing computational complexity. In addition, convolutional neural networks reduce the need for extensive feature engineering and enhance the robustness of data processing.

[0004] Genetic methods can perform global searches in a broad search space and avoid falling into local optimal solutions. In test case generation, operations such as selection, crossover, and mutation are used to continuously optimize solutions, which means that a wider range of input combinations can be found to cover different program paths and states, improving the comprehensiveness of the test. Although evolutionary methods perform well in test case generation, the fitness value of each individual needs to be calculated by executing the tested program. As the complexity of the optimization problem increases, this process will lead to a significant increase in execution time, which in turn increases the cost of testing and becomes a bottleneck for the in-depth application of evolutionary methods. In order to solve this problem, machine learning methods and predictive models in deep learning are applied. The process of predictive model optimization evolutionary methods mainly includes data collection and analysis, establishing a predictive model, guiding the evolutionary process, and model updating and optimization. Summary of the invention

[0005] In order to solve the problem of low efficiency in generating test cases for detecting numerous defects of complex intelligent equipment software in the prior art, the present invention proposes a testing method combining a convolutional neural network with a genetic method for defects in intelligent equipment software. The characteristics of this method that are different from the original method are as follows: first, a mutation testing method is adopted to generate mutation branches representing defects, and then an executable path is generated based on the coverage difficulty of the mutation branches and the correlation between the mutation 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 adopted to enhance the genetic method to generate test cases with high defect detection capabilities.

[0006] The technical solution adopted by the present invention is as follows: A method for testing intelligent equipment software by combining a convolutional neural network with a genetic algorithm comprises the following steps: S1: Generate a path set based on the variation branch correlation graph; S2: Build a test case generation optimization model based on the generated path set; S3: Using the optimization model to construct an incremental learning convolutional neural network model according to preset rules; S4: Combining the incremental learning convolutional neural network and the multi-population genetic method to generate test cases.

[0007] Preferably, the preset rule in step S3 is implemented as follows: S3.1: Optimizing the initial sample set , is the initial data set, is the initial sample size; P(X 0 ) is a corresponding set of crossing paths obtained based on the initial data set; For X 0 The corresponding fitness value set; S3.1.1: For the initial traversal path set Each path in , get the hashed path , the set of hash-encoded paths is ;set up is an input feature value, which is converted into a hash feature value ; S3.1.2: Push In; outside the stack Can it be pushed into the stack? , one of the following two conditions is met: (I) will With the stack For comparison, if and If the hash codes are different, just Put in middle; (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; In the same way, the stack with stack Compare with the existing hash path in the 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; Get the optimized sample set ; S3.2: The optimized sample set Divide into training set and test set ; S3.3: When new data continues to arrive, return to step S3.2, re-optimize the sample set, and the model continues to learn.

[0008] A method for testing intelligent equipment software by combining a convolutional neural network with a genetic algorithm comprises the following steps: S1: Generate a path set based on the variation branch correlation graph; S2: Build a test case generation optimization model based on the generated path set; S3: constructing an incremental learning convolutional neural network model using the model; S3.1: Optimizing the initial sample set , is the initial data set, is the initial sample size; P(X 0 ) is a corresponding set of crossing paths obtained based on the initial data set; For X 0 The corresponding fitness value set; S3.1.1: For the initial traversal path set Each path in , get the hashed path , the set of hash-encoded paths is ;set up is an input feature value, which is converted into a hash feature value ; S3.1.2: Push In; outside the stack Can it be pushed into the stack? , one of the following two conditions is met: (I) will With the stack For comparison, if and If the hash codes are different, just Put in middle; (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; In the same way, the stack with stack Compare with the existing hash path in the 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; Get the optimized sample set ; S3.2: The optimized sample set Divide into training set and test set ; 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: Combining the incremental learning convolutional neural network and the multi-population genetic method to generate test cases.

[0009] 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:

[0010] S1: Generate path set based on variant branch correlation graph

[0011] Assume that the program under test is ,insert The set of mutation branches is , is the variation branch, is the number of mutation branches; the set of executable paths formed by the mutation branches is set to ;

[0012] S1.1: Calculate the correlation between variant branches

[0013] 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 ;

[0014] Set mutation branch The correlation between ; Based on simultaneous coverage variant branches The ratio of the number of samples to the total number of samples is used to estimate the correlation between the variant 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;

[0015] if The correlation between , then set is a pair of conflicting variant branches, marked as .

[0016] S1.2: Generate a variant branch correlation graph based on variant branch correlation

[0017] Suppose the variation branch correlation graph 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;

[0018] First, traverse the correlation matrix A. When the mutation branch The correlation between When Add to diagram The vertex set In , 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 .

[0019] S1.3: Generate path sets based on variant branch correlation graph

[0020] From the variant branch collection In the above example, 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;

[0021] S1.3.1: Set mutation branch For the picture The current node in the graph Up along Traverse the successor direction to find the The most relevant successor node , and Add to the path, now the path ;set up For the current node, continue from Search in the subsequent direction The most relevant node , 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;

[0022] 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;

[0023] S1.3.2: Assume For the picture The current node in the graph Up along Traverse in the predecessor direction to find the node that is closest to the current 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 variant branches, then It cannot be added to the path node; then, continue to look for The next node with high relevance;

[0024] According to the above method, continue to traverse in the forward direction until all predecessor nodes are traversed and the path is obtained. ; From the variant branch set Delete The variant branches contained in Add to the executable path collection In ;

[0025] 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 to generate ; Finally, generate an executable path set , is the number of paths in the path set, is the executable path.

[0026] S2: Build a test case generation optimization model based on the generated path set;

[0027] For each target path , establish a test case generation optimization model based on path coverage, which can be expressed as:

[0028]

[0029] in for The value domain formed; is the objective function, which can be defined as the similarity between the paths;

[0030]

[0031] in, is the number of nodes contained in the target path, For test cases The number of nodes included in the traversal path; To cross the path and the target path The number of consecutive identical nodes between them;

[0032] S3: Use the generated optimized model to build an incremental learning convolutional neural network model;

[0033] S3.1: Use the generated optimization model to construct 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;

[0034] Incremental learning convolutional neural network initialization:

[0035] Define the convolutional layer, pooling layer and output layer of the incremental learning convolutional neural network; assume that the input features of the model are , is the auxiliary feature; the output feature is ;

[0036] Compile the model:

[0037] Specify the loss function as cross entropy loss and set the indicator for evaluating the model performance as accuracy;

[0038] S3.2: Optimizing the initial sample set

[0039] S3.2.1: For the initial traversal path set Each path in , using hash function, obtain hash encoding path , the set of hash-encoded paths is ;set up is an input feature value, which is converted into a hash feature value , thus obtaining the hash feature set ;

[0040] 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:

[0041] (I) With the stack For comparison, if and If the hash codes are different, just Put in middle;

[0042] (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;

[0043] Then, follow the same method to add with stack If one of the above two conditions is met, the hash path in the 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;

[0044] Finally, we get the optimized sample set ,in To optimize the number of samples, is the optimized input eigenvalue, for The corresponding fitness value;

[0045] S3.3: The optimized sample set Divide into training set and test set ;

[0046] Training set Used to train the neural network model, assuming the input features of the model are , the auxiliary feature is The output features are ;

[0047] 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.

[0048] 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 is the present invention's improvement of the traditional convolutional neural network, optimization of the sample set and addition of auxiliary features ; The outer frame diagram continuously updates the model to form an incremental learning convolutional neural network model.

[0049] S4: Combining the incremental learning convolutional neural network and the multi-population genetic method to generate test cases.

[0050] The specific steps are:

[0051] 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;

[0052] S4.2: Using the incremental learning convolutional neural network model, estimate the individuals with high fitness as The initial population of

[0053] S4.3: Determine whether the method meets the termination condition. If so, go to S4.7;

[0054] S4.4: Execute the program under test and calculate The fitness value of the evolving individuals in ;

[0055] 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;

[0056] 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;

[0057] S4.7: Stop evolution and output the test case set.

[0058] There are two termination conditions in S4.3 above: one is to generate the expected test cases; the other is that the population evolves to the maximum number of iterations;

[0059] The fitness value in S4.4 is given by the function Determined by the objective function of formula (2):

[0060]

[0061] Beneficial effects of the present invention:

[0062] (1) Using graph theory methods to bidirectionally traverse the mutation branch correlation graph to generate paths, this method ensures that the generated path set is kept to a minimum while achieving coverage of the mutation branches in the program. By corresponding to a compact test case set, the time and resource consumption in the testing process is greatly reduced, thereby improving the efficiency of mutation testing. Without increasing hardware costs, comprehensive and efficient testing of the software system can be achieved, ensuring the reliability and stability of the software under limited resources.

[0063] (2) The present invention 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 and ensures that the test case set is continuously improved throughout the process.

[0064] (3) When the incremental learning convolutional neural network and the multi-population genetic method are combined to generate test cases, the incremental learning convolutional neural network can quickly evaluate the fitness value of the evolving individuals, thereby improving the evolutionary efficiency of the multi-population genetic method. In addition, the real-time update supported by the incremental learning convolutional neural network allows 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, providing a robust solution for large-scale testing of intelligent equipment software. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] 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;

[0066] Figure 2 This is a framework diagram of the incremental learning convolutional neural network proposed in the present invention;

[0067] Figure 3 Example procedures for implementing the present invention;

[0068] Figure 4 A radar chart showing the difficulty of covering variant branches for the example program.

[0069] Figure 5 This is a heat map of the correlation matrix before the example program mutates the branch;

[0070] Figure 6 This is the branch correlation diagram for the example program mutation;

[0071] Figure 7 Optimizing process graph for sample set DETAILED DESCRIPTION

[0072] Figure 1 A general flow chart of a method for testing intelligent equipment software using a convolutional neural network combined with a genetic algorithm is provided for 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 comprises the following steps:

[0073] S1: Generate path set based on variant branch correlation graph

[0074] Assume that the program under test is ,insert The set of mutation branches is , is the variation branch, is the number of mutation branches; the set of executable paths formed by the mutation branches is set to ;

[0075] S1.1: Calculate the correlation between variant branches

[0076] 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 ;

[0077] Set mutation branch The correlation between ; Based on simultaneous coverage variant branches The ratio of the number of samples to the total number of samples is used to estimate the correlation between the variant 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;

[0078] if The correlation between , then set is a pair of conflicting variant branches, marked as .

[0079] S1.2: Generate a variant branch correlation graph based on variant branch correlation

[0080] Suppose the variation branch correlation graph is ,in is a set of vertices, is the set of edges, is the weight set of edges, and the initial values ​​of these sets are empty sets;

[0081] First, traverse the correlation matrix A. When the mutation branch The correlation between When Add to diagram The vertex set In , 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 .

[0082] S1.3: Generate path sets based on variant branch correlation graph

[0083] From the variant branch collection In the above example, 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;

[0084] S1.3.1: Set mutation branch For the picture The current node in the graph Up along Traverse the subsequent direction and find the The most relevant successor node , and Add to the path, now the path ;set up For the current node, continue from Search in the subsequent direction The most relevant node , 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;

[0085] 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;

[0086] S1.3.2: Assume For the picture The current node in the graph Up along Traverse in the predecessor direction to find the node that is closest to the current 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 variant branches, then It cannot be added to the path node; then, continue to look for The next node with high relevance;

[0087] According to the above method, continue to traverse in the forward direction until all predecessor nodes are traversed and the path is obtained. ; From the variant branch set Delete The variant branches contained in Add to the executable path collection In ;

[0088] 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 to generate ; Finally, generate an executable path set , is the number of paths in the path set, is the executable path.

[0089] S2: Build a test case generation optimization model based on the generated path set;

[0090] For each target path , establish a test case generation optimization model based on path coverage, which can be expressed as:

[0091] (1)

[0092] in for The value domain formed; is the objective function, which can be defined as the similarity between the paths;

[0093] (2)

[0094] in, is the number of nodes contained in the target path, For test cases The number of nodes included in the traversal path; To cross the path and the target path The number of consecutive identical nodes between them;

[0095] S3: Use the generated optimized model to build an incremental learning convolutional neural network model;

[0096] S3.1: Use the generated optimization model to construct 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;

[0097] Incremental learning convolutional neural network initialization:

[0098] Define the convolutional layer, pooling layer and output layer of the incremental learning convolutional neural network; assume that the input features of the model are , is the auxiliary feature; the output feature is ;

[0099] Compile the model:

[0100] Specify the loss function as cross entropy loss and set the indicator for evaluating the model performance as accuracy;

[0101] S3.2: Optimizing the initial sample set

[0102] S3.2.1: For the initial traversal path set Each path in , using hash function, obtain hash encoding path , the set of hash-encoded paths is ;set up is an input feature value, which is converted into a hash feature value , thus obtaining the hash feature set ;

[0103] 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:

[0104] (I) With the stack For comparison, if and If the hash codes are different, just Put in middle;

[0105] (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;

[0106] Then, follow the same method to add with stack If one of the above two conditions is met, the hash path in the 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;

[0107] Finally, we get the optimized sample set ,in To optimize the number of samples, is the optimized input eigenvalue, for The corresponding fitness value;

[0108] S3.3: The optimized sample set Divide into training set and test set ;

[0109] Training set Used to train the neural network model, assuming the input features of the model are , the auxiliary feature is The output features are ;

[0110] 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.

[0111] 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 is the present invention's improvement of the traditional convolutional neural network, optimization of the sample set and addition of auxiliary features ; The outer frame diagram continuously updates the model to form an incremental learning convolutional neural network model.

[0112] S4: Combining the incremental learning convolutional neural network and the multi-population genetic method to generate test cases.

[0113] The specific steps are:

[0114] 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;

[0115] S4.2: Using the incremental learning convolutional neural network model, estimate the individuals with high fitness as The initial population of

[0116] S4.3: Determine whether the method meets the termination condition. If so, go to S4.7;

[0117] S4.4: Execute the program under test and calculate The fitness value of the evolving individuals in ;

[0118] 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;

[0119] 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;

[0120] S4.7: Stop evolution and output the test case set.

[0121] There are two termination conditions in S4.3 above: one is to generate the expected test cases; the other is that the population evolves to the maximum number of iterations;

[0122] The fitness value in S4.4 is given by the function Determined by the objective function of formula (2):

[0123] (3)

[0124] 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.

[0125] The following is an example of the implementation process of the present invention.

[0126] 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.

[0127] 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 mutations;

[0128] Next, using the method described in S1.2, a variation branch correlation graph was constructed, such as Figure 6 shown.

[0129] Next, generate a set of paths based on the variant 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 the predecessor and successor directions respectively.

[0130] when When traversing in the successor 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. .

[0131] Next, traverse The predecessor direction of In the related predecessor nodes, and Therefore, the update path Next, repeat the process, starting with Traverse forward, from Traverse backwards.

[0132] It should be noted that from When traversing backwards, 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.

[0133] 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.

[0134] 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 set of mutation branches, where,

[0135] Finally, we can get the path collection .

[0136] Then, based on these two paths, a multi-task optimization model covering them is established as follows:

[0137] (4)

[0138] Then, convolutional neural networks need to be built for the two paths respectively.

[0139] like Figure 7 As shown, the specific process of optimizing the sample set is described below with examples.

[0140] Assume that the input feature set of the initial dataset is , which contains:

[0141]

[0142] Then, by executing the program under test, the traversal path set corresponding to the initial data set is obtained. , which contains:

[0143]

[0144] When the target path The initial data set can be obtained when The corresponding fitness value set , which contains:

[0145] , , , ;

[0146] Next, hash code each path in the traversal path set to obtain the hash code path set , which contains:

[0147]

[0148] Thus, we get the hash feature set .

[0149] Further construction and initialization Then, the hash feature value There are three situations when the next hash feature value is pushed into the stack:

[0150] Case 1: In judgment When deciding whether to push into the stack, first The hash value already exists in the stack Compare the path hash codes and find Then we need to continue to compare the Euclidean distance of the initial data in the search space

[0151] Due to setting the threshold ,and Greater than ,therefore Accessible .

[0152] Case 2: When determining whether to When pushing into the stack, the path hash code is compared again. With the existing and Therefore, Push to stack.

[0153] Situation 3: When deciding whether to When entering the stack, it is found With the existing The same. By calculation and Euclidean distance in the search space ,Right now:

[0154] Since this distance is less than the threshold 6, Cannot push onto the stack.

[0155] 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 .

[0156] 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.

[0157] 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.

[0158] The multi-population genetic method sets the number of sub-populations to 3 and the sub-population size to 5. The evolutionary generations of the multi-population genetic method are set to 4000. The genetic operation uses roulette selection, single-point crossover and single-point mutation, and the crossover probability and mutation probability are 0.9 and 0.3 respectively. Finally, the test case set that kills the mutant branch is obtained as follows: .

[0159] It should be noted that the sequence of the embodiments of the present invention described above is for description only and does not represent the advantages and disadvantages of the embodiments. The above describes specific embodiments of this specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded 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 drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0160] The above description is intended to be illustrative and not limiting. Upon reading the above description, many embodiments and many applications beyond the examples provided will be apparent to those skilled in the art. Therefore, the scope of the present teachings should not be determined with reference to the above description, but should be determined with reference to the appended claims and the full scope of equivalents to which such claims are entitled. For the purpose of comprehensiveness, 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 in the preceding claims is not intended to be a waiver of such subject matter, nor should it be considered 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 by combining convolutional neural network with genetic algorithm, characterized in that: The following steps are involved: S1: Generate a path set based on the variation branch correlation graph; S2: Build a test case generation optimization model based on the generated path set; S3: Using the optimization model to construct an incremental learning convolutional neural network model according to preset rules; S4: Combining the incremental learning convolutional neural network and the multi-population genetic method to generate test cases.

2. The intelligent equipment software testing method combining convolutional neural network with genetic algorithm according to claim 1 is characterized in that: The preset rule in step S3 is implemented as follows: S3.1: Optimizing the initial sample set , is the initial data set, is the initial sample size; P(X 0 ) is a corresponding set of crossing paths obtained based on the initial data set; For X 0 The corresponding fitness value set; S3.1.1: For the initial traversal path set Each path in , get the hashed path , the set of hash-encoded paths is ;set up is an input feature value, which is converted into a hash feature value ; S3.1.2: Push In; outside the stack Can it be pushed into the stack? , one of the following two conditions is met: (I) will With the stack For comparison, if and If the hash codes are different, just Put in middle; (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; In the same way, the stack with stack Compare with the existing hash path in the Put it in 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; Get the optimized sample set ; S3.2: The optimized sample set Divide into training set and test set ; S3.3: When new data continues to arrive, return to step S3.2, re-optimize the sample set, and the model continues to learn.

3. The intelligent equipment software testing method combining convolutional neural network with genetic algorithm according to claim 1 or 2, 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 ,insert The set of mutation branches is , is the variation branch, 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 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 ; Set mutation branch The correlation between ; Based on simultaneous coverage variant branches The ratio of the number of samples to the total number of samples is used to estimate the correlation between the variant branches. ; The same method can get all the variant branches The correlation between them and construct the mutation branch correlation matrix ; if The correlation between , then set is a pair of conflicting variant branches, marked as ; S1.2: Generate a variant branch correlation graph based on variant branch correlation Suppose the variation branch correlation graph is ,in is a set of vertices, is the set of edges, is the weight set of edges, and the initial values ​​of these sets are empty sets; First, traverse the correlation matrix A. When the mutation branch The correlation between When Add to diagram The vertex set In , gather at the edge Add a line by point to The real edge , edge set ;side Set the weight to The correlation between , weight set ; According to the above method, generate the variation branch correlation diagram ; S1.3: Generate path sets based on variant branch correlation graph From the variant branch collection In the above example, 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.

4. The intelligent equipment software testing method combining convolutional neural network with genetic algorithm according to claim 3 is 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: Set mutation branch is the variation branch correlation diagram The current node in the mutation branch related graph Up along Traverse the successor direction to find the The most relevant successor node , and Add to the path, now the path ;set up For the current node, continue from Search in the subsequent direction The most relevant node , 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; 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 variant branch; S1.3.2: Assume is the variation branch correlation diagram The current node in the mutation branch related graph Up along Traverse in the predecessor direction to find the node that is closest to the current node The predecessor node with the highest correlation , and Add to the current path, then ; Then will 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 variant branches, then It cannot be added to the path node; then, continue to look for The next node with high relevance; According to the above method, continue to traverse in the forward direction until all predecessor nodes are traversed and the path is obtained. ; From the variant branch set Delete The variant branches contained in Add to the executable path collection In ; 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 to generate ; Finally, generate an executable path set , is the number of paths in the path set, is the executable path.

5. The intelligent equipment software testing method combining convolutional neural network with genetic algorithm according to claim 2, characterized in that: The specific steps of step S4 combining incremental learning convolutional neural network and multi-population genetic method to generate test cases are as follows: S4.1: Let the population be , is the number of subpopulations, For subpopulations, subpopulations Responsible for generating coverage paths Test cases; set the values ​​of various parameters required by the method; S4.2: Using the incremental learning convolutional neural network model, estimate the individuals with high fitness as 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 The fitness value of the evolving individuals in ; 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; 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; S4.7: Stop evolution and output the test case set.

Citation Information

Patent Citations

  • System and method for structure learning for graph neural networks

    CA3131843A1

  • Software test case generation method based on multi-population genetic algorithm

    CN112699045A

  • Test case generation method, system and equipment based on genetic algorithm and medium

    CN114185800A

  • Fuzzy test case generation and selection method and device, equipment and medium

    CN117194219A

  • Variation score guided deep neural network test case generation method

    CN117472781A