Test case generation method based on RBF neural network and Adam algorithm

By using a test case generation method based on RBF neural network and Adam algorithm, the number of neurons and optimization parameters are dynamically adjusted, which solves the problem of low test case generation efficiency in the existing technology and achieves efficient and accurate test case generation.

CN118964185APending Publication Date: 2024-11-15CHANGZHOU UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410979404.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-22
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

Existing technologies suffer from high operating costs, time consumption, and increased code complexity when calculating the fitness value of individual test cases, resulting in low efficiency in test case generation.

Method used

A test case generation method based on RBF neural network and Adam algorithm is adopted. The fitness function is simulated by training and optimizing the RBF neural network, which replaces program instrumentation. The number of neurons in the hidden layer is dynamically adjusted, and the center, width and connection weights of the radial basis function are optimized.

Benefits of technology

It improves the efficiency and accuracy of test case generation, reduces time costs, and enhances the generalization ability and prediction accuracy of neural networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118964185A_ABST
    Figure CN118964185A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of machine learning, and particularly relates to a test case generation method based on an RBF neural network and an Adam algorithm, and the method comprises the steps: S1, designing a training sample of the RBF neural network, generating a test case and a fitness value of the test case through a genetic algorithm, and enabling the test case to serve as input data of the neural network; s2, establishing an RBF neural network; s3, adjusting parameters of the RBF neural network by using an Adam algorithm; s4, training the RBF neural network by using the training sample, calculating a root-mean-square error, and dynamically adjusting the number of neurons in a hidden layer; and S5, after training is completed, generating a test case by using a genetic algorithm, and predicting an individual fitness value through an RBF neural network. According to the method, the fitness function is simulated through the trained and optimized RBF neural network model, the fitness value of the test case individual is predicted, program instrumentation is replaced, and the problem of time loss caused by program instrumentation through a test case generation algorithm is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of machine learning, and in particular relates to a test case generation method based on RBF neural network and Adam algorithm. Background Art

[0002] In the field of software testing, the generation of test cases using heuristic search algorithms has become a hot topic among scholars. However, how to quickly and accurately calculate the individual fitness values ​​of test cases has always been the key and focus of research on test case generation based on optimization algorithms.

[0003] At present, the existing methods for calculating the fitness value of test cases all rely on using the plug-in function to plug the program and calculate the fitness value of each test case. However, due to the high running cost, time-consuming, and increased code complexity, the existing test case generation methods are generally inefficient. Using RBF neural network to simulate the fitness function and predict individual fitness values ​​can not only replace the plug-in function to reduce the time loss, but also expand the scale of processing data and adapt to the changes of programs and test cases. However, how to optimize the RBF neural network, improve the generalization and prediction accuracy, and introduce it into test case generation is still a severe challenge. Summary of the invention

[0004] The purpose of the present invention is to provide a test case generation method based on RBF neural network and Adam algorithm to solve the technical problems existing in the background technology. In order to solve the above technical problems, the present invention provides a test case generation method based on RBF neural network and Adam algorithm, which simulates the fitness function by training the optimized RBF neural network model and predicts the fitness value of the individual test case, thereby replacing the program instrumentation and solving the time loss caused by the program instrumentation of the test case generation algorithm.

[0005] The present invention provides a test case generation method based on RBF neural network and Adam algorithm, comprising the following steps:

[0006] S1. Design training samples for RBF neural network: Generate test cases and their fitness values ​​through genetic algorithm, and use these test cases as training samples for RBF neural network. Each test case is represented by {X m |m=1,2,...,M}, where M represents the number of samples required for training the network and N represents the number of variables of the program under test.

[0007] S2. Establish RBF neural network: RBF neural network includes input layer, hidden layer and output layer. The number of input layer nodes is N, the hidden layer has H neurons, and the output layer has only one node. The output of the hidden layer node is Indicates that ch Represents the radial basis function center of the hidden layer node h, which is an N-dimensional vector; σ h represents the width of the hidden layer node h; ||X m -c h || represents X m to c h The Euclidean distance of .

[0008]

[0009] S3. Use the Adam algorithm to adjust the parameters of the RBF neural network: including the center c and width of the radial basis function

[0010] σ and the connection weights ω between the hidden layer and the output layer nodes. The parameter update rule of the Adam algorithm is as follows:

[0011]

[0012] Among them, α is the learning rate, which is usually set to 0.001; ∈ is a decimal to prevent the denominator from being 0, which is usually set to 10 -8 ; and are the bias-corrected estimates of the first and second moments, respectively.

[0013] S4. Training RBF neural network: Train the training samples and calculate the root mean square error L θ The number of neurons in the hidden layer is adjusted dynamically. If the contribution of a hidden layer neuron is low, it will be deleted; if the error of the training sample in the current group is large, the number of neurons in the hidden layer will be increased.

[0014] S5. Generate test cases using genetic algorithms: After training, initialize the genetic algorithm population, use the RBF neural network instead of the plug-in function to calculate the fitness value of the test case individual, and determine whether the output conditions are met. If so, output the optimal individual. If not, perform the genetic operation again until the output conditions are met.

[0015] The test case generation method based on RBF neural network and Adam algorithm of the present invention improves the RBF neural network, optimizes the parameters of the neural network by using Adam algorithm, and dynamically adjusts the number of hidden layer neurons, thereby improving the efficiency and accuracy of test case generation. In the training process of the neural network, the center, width and connection weight of the radial basis function are optimized by Adam algorithm, thereby enhancing the generalization ability and prediction accuracy of the neural network.

[0016] In the parameter optimization process of RBF neural network, the Adam algorithm is used for gradient descent to dynamically adjust the learning rate, which improves the convergence speed and stability of the training process. The Adam algorithm can effectively use the estimated values ​​of the first-order moment and the second-order moment to update the parameters, thereby improving the prediction ability of the model while ensuring the training speed.

[0017] By dynamically adjusting the number of neurons in the hidden layer, the problem of the neural network structure being too complex or too simple is avoided, and the generalization ability of the neural network is improved. During the training process, according to the activation state of the neurons in the hidden layer, neurons with low contribution are deleted, and new neurons are added when needed, so that the neural network can adaptively adjust its structure, thereby improving the training effect.

[0018] In summary, the present invention improves the training and optimization process of the RBF neural network, combines the Adam algorithm and the method of dynamically adjusting the number of neurons, effectively improves the efficiency and quality of test case generation, reduces time cost, and improves the search efficiency of the algorithm and the quality of the solution.

[0019] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0021] Figure 1 A flow chart of a test case generation method based on RBF neural network and Adam algorithm of the present invention;

[0022] Figure 2 It is a basic principle diagram of the RBF neural network of an embodiment of the present invention;

[0023] Figure 3 It is a basic flow chart of RBF neural network simulation fitness value function training based on an embodiment of the present invention;

[0024] Figure 4 The present invention is a flowchart of introducing the RBF neural network simulation fitness function into the genetic algorithm to generate test cases. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0026] like Figures 1 to 4 As shown, the embodiment of the present invention mainly includes the design of RBF neural network samples, the design of neural network and the use of Adam algorithm to adjust the neural network parameters.

[0027] First, before establishing the RBF neural network, it is necessary to find suitable test cases and their fitness values ​​as training samples, and then obtain some parameters of the RBF neural network through the training samples. Here, the method of generating test cases using genetic algorithms is used to generate test cases and their fitness values ​​as training samples of the neural network. The test case set is used as the input data of the neural network. Each test case is represented by {X m |m=1,2,...,M}, where M represents the number of samples required for training the network. m =[x m1 , x m2 , ..., x mN ] T is an N-dimensional vector, representing the N variables of the program under test. m is the expected output data of the neural network training, then the output data of sample i is {d m |m=1,2,...,M}.

[0028] The basic structure of RBF neural network is input layer, hidden layer and output layer. The number of input nodes is N, the hidden layer has H neurons, and the output layer has only 1 node. The output of node h is represented by φ h (X m ) indicates that c h Represents the radial basis function center of the hidden layer node h, which is an N-dimensional vector; σ h represents the width of the hidden layer node h; ||X m -c h || represents X m to c h The Euclidean distance of .

[0029]

[0030] The actual output of the training sample m after the network is y m Indicates that, where ω hand ω0 represent the connection weight and bias between a node h in the hidden layer and the node in the output layer respectively.

[0031]

[0032] Train the test case samples of the current group and calculate the root mean square error L of all samples in the group at this time θ , d i is the true value of the sample data, y i is the predicted value of RBF neural network;

[0033]

[0034] Calculate the normalized output r of each hidden node h , that is, the training sample (x i , d i )For the normalized output of hidden node h, θ is a given threshold. If multiple consecutive samples satisfy r h <θ, it indicates that the contribution of the neuron is low and multiple samples have failed to activate the neuron. In this case, the neuron can be deleted. The activation state of the hidden node is determined according to the hidden node activation condition;

[0035]

[0036] When the predetermined step length is reached, if the error of the training samples in the current group is large and meets the addition conditions, the number of hidden nodes will be increased according to a certain rule. If the contribution of a hidden node is low under multiple samples, it will be deleted. Check whether the hidden nodes in the current network are redundant. If there is redundancy, merge them;

[0037] The three parameters in the RBF neural network: the center, width and connection weight of the radial basis function are adjusted using the Adam algorithm. Using the parameter update rule of the Adam algorithm, the center c, width σ of the hidden layer radial basis function in the RBF neural network, and the connection weight ω between the hidden layer and the output layer nodes are updated. In the formula, α is the learning rate, which is generally set to 0.001. ∈ is a very small number to prevent the denominator from being 0, which is generally set to 10 -8 , and are the bias-corrected moment estimates for the first and second moments, respectively.

[0038]

[0039] The first and second moment estimates are updated using the formula of the Adam algorithm; β1 and β2 are the decay terms of the momentum term, which are generally set to 0.9 and 0.999. The initial values ​​of the first and second moment estimates are both 0.

[0040]

[0041] Compute bias-corrected moment estimates of first- and second-order moments;

[0042]

[0043] After calculating the bias-corrected moment estimates of the first-order and second-order moments, the update formula Δ k+1 Update the three parameters and calculate the network output y i ;

[0044] If the number of training samples reaches M and the maximum number of iterations is reached, the algorithm exits and training stops. If the number of training samples has not reached the preset number, go to the training group sample step and train the next group of samples.

[0045] After the training is completed, enter the genetic algorithm module, initialize the genetic algorithm population, use the RBF neural network instead of the plug-in function to calculate the fitness value of the test case individual, and judge whether the output condition is met, that is, the genetic algorithm reaches the maximum number of iterations or the branch coverage of the individual reaches the preset threshold. If it is met, the optimal individual is output. If not, the genetic operation is performed again until the output condition is met.

[0046] By using RBF neural network to predict individual fitness values ​​instead of program instrumentation, the efficiency of genetic algorithm in generating test cases is improved and time cost is saved.

[0047] In summary, the present invention improves and optimizes the RBF neural network and introduces it into the heuristic search algorithm to generate test cases instead of program instrumentation to predict the individual fitness values ​​of test cases, thereby improving the test case generation efficiency and shortening the test time.

[0048] In the optimization of RBF neural network, Adam algorithm is used to optimize the parameters of neural network and dynamically adjust the number of neurons in hidden layer, which improves the generalization ability of neural network, enhances the prediction ability and accuracy of neural network and reduces time cost.

[0049] The various devices selected in this application are all universal standard parts or parts known to those skilled in the art, and their structures and principles can be known to those skilled in the art through technical manuals or conventional experimental methods.

[0050] In the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or a connection; it can be a direct connection or an indirect connection through an intermediate medium, or it can be the internal communication of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.

[0051] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.

[0052] Based on the above ideal embodiments of the present invention, the relevant staff can make various changes and modifications without departing from the technical concept of the present invention through the above description. The technical scope of the present invention is not limited to the contents of the specification, and its technical scope must be determined according to the scope of the claims.

Claims

1. A test case generation method based on RBF neural network and Adam algorithm, characterized in that: The following steps are involved: S1. Design training samples for RBF neural network, generate test cases and their fitness values ​​through genetic algorithm, and use the test cases as input data for neural network; S2. Establish an RBF neural network, which includes an input layer, a hidden layer and an output layer. The number of nodes in the input layer is N, the number of nodes in the hidden layer is H, and the number of nodes in the output layer is 1; S3, use the Adam algorithm to adjust the parameters of the RBF neural network, including the center, width and connection weight of the radial basis function; S4, using the training samples to train the RBF neural network, calculate the root mean square error and dynamically adjust the number of neurons in the hidden layer; S5. After training, the genetic algorithm is used to generate test cases and the individual fitness values ​​are predicted through the RBF neural network.

2. The test case generation method based on RBF neural network and Adam algorithm according to claim 1, characterized in that: In step S1, the test case generation step includes: S11, initialize the genetic algorithm population; S12, using RBF neural network to calculate the fitness value of the test case individual; S13. Determine whether the output condition is met. If so, output the optimal individual. If not, perform the genetic operation again until the output condition is met.

3. The test case generation method based on RBF neural network and Adam algorithm according to claim 2, characterized in that: In step S3, the optimization steps of the RBF neural network include: S31, using the Adam algorithm to update the parameters of the radial basis function center, width and connection weight of the neural network; S32. Dynamically adjust the number of neurons in the hidden layer, delete neurons with lower contribution, and increase the number of neurons in the hidden layer when conditions are met.

4. The test case generation method based on RBF neural network and Adam algorithm according to claim 3 is characterized in that: The parameter update rules of the Adam algorithm include: S311, set the learning rate α, the momentum term attenuation coefficients β1 and β2, and the decimal ∈ to prevent the denominator from being 0; S312, calculating the deviation-corrected values ​​of the first-order moment estimate and the second-order moment estimate; S313. Update the three parameters of the RBF neural network simultaneously according to the parameter update formula.

5. A computer system comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the computer program is loaded into the processor, the steps of the test case generation method based on the RBF neural network and the Adam algorithm according to any one of claims 1 to 4 are implemented.