Test case generation method based on genetic algorithm and reinforcement learning local search

By combining program structure information and reinforcement learning local search, the test case generation method is optimized, which solves the problem of low search efficiency of genetic algorithms in complex program path coverage and realizes efficient path coverage testing.

CN122262008APending Publication Date: 2026-06-23CHINA UNIV OF MINING & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
CHINA UNIV OF MINING & TECH
Filing Date
2026-04-23
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

Existing test case generation methods based on genetic algorithms rely on random crossover and mutation during the search process, lack proactive optimization capabilities, and are difficult to effectively utilize program structure information, resulting in low search efficiency and poor path coverage efficiency.

Method used

By combining program structure information to construct a path dimension matrix, a global search is performed using a genetic algorithm, and a local search mechanism is introduced using reinforcement learning. Path-related input variables are then used for fine-tuning to optimize the test case generation process.

Benefits of technology

It improves the efficiency and success rate of complex program path coverage testing, and significantly enhances the efficiency and quality of test case generation through global and local collaborative search.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122262008A_ABST
    Figure CN122262008A_ABST
Patent Text Reader

Abstract

The application discloses a test case generation method based on a genetic algorithm and local search of reinforcement learning, and comprises the following steps: performing static analysis on a program to be tested, and constructing a control flow graph and a data flow graph; enumerating executable paths, analyzing the dependency relationship between the paths and input variables, and constructing a path dimension matrix; randomly generating an initial population, and calculating fitness based on branch distance; performing selection, crossover and mutation operations of the genetic algorithm under the constraint of the path dimension matrix; selecting elite individuals, introducing local search of reinforcement learning, and adjusting variables on relevant dimensions through the local search of reinforcement learning to reduce branch distance; and outputting test cases covering target paths when a termination condition is met. The application identifies key variables through the path dimension matrix, focuses on a search space, finely adjusts elite individuals through local search of reinforcement learning, overcomes the problem of slow convergence in the later stage of the genetic algorithm, realizes the cooperation of global exploration and local optimization, and improves the efficiency and success rate of path coverage testing of a complex program.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of software testing and intelligent optimization technology, specifically a test case generation method based on genetic algorithms and reinforcement learning local search. Background Technology

[0002] In software testing, path coverage testing verifies the internal logic of a program by constructing input data that triggers specific execution paths. It is a crucial method in structured testing. For software systems with complex branching structures, different execution paths are typically determined by multiple conditional judgments, and these conditions often have data dependencies, resulting in complex nonlinear characteristics in path constraints. As the scale of software and the dimensionality of input variables continue to increase, the difficulty of manually designing test cases that satisfy specific path constraints increases significantly. Therefore, researching automated test case generation methods is of great importance.

[0003] Currently, search-based software testing methods typically transform the test case generation problem into an optimization problem, and use intelligent optimization algorithms to search for test data that satisfies path constraints in the input space. Among these, genetic algorithms are widely used in the field of automated test case generation due to their good global search capabilities and strong adaptability.

[0004] However, existing genetic algorithm-based methods still have certain limitations in practical applications. For example, the search process mainly relies on random crossover and mutation operations, and individuals lack the ability to actively optimize. Furthermore, the algorithms typically perform a uniform search on all input variables, making it difficult to utilize program structure information to narrow the search space, thus affecting search efficiency. In addition, when the algorithm approaches the target path constraints, it lacks an effective local optimization mechanism, making it difficult to fine-tune test cases, thereby reducing path coverage efficiency.

[0005] Therefore, there is an urgent need for an automated test case generation method that can perform efficient searches by combining program structure information and has local optimization capabilities, in order to improve the efficiency of complex program path coverage testing. Summary of the Invention

[0006] The purpose of this invention is to overcome the defects and shortcomings of existing technologies and provide a test case generation method based on genetic algorithms and reinforcement learning local search. This method aims to solve the following technical problems: Traditional genetic algorithm-based test case generation methods mainly rely on random crossover and mutation for searching, and individuals lack active optimization capabilities, leading to a slowdown or stagnation in convergence speed in the later stages of the search. Furthermore, these methods typically perform a uniform search on all input variables, making it difficult to effectively utilize program structure information to identify key variables related to the target path, resulting in invalid searches on a large number of irrelevant variables and reducing search efficiency. In addition, when the search results approach the solution region satisfying the path constraints, there is a lack of effective local optimization mechanisms, making it difficult to fine-tune the test cases and affecting path coverage efficiency. Therefore, it is necessary to propose an automated test case generation method that can combine program structure information for guided searching and use reinforcement learning mechanisms to locally optimize candidate test cases, thereby improving the efficiency and quality of path coverage testing for complex programs.

[0007] To achieve the above objectives, the present invention provides the following technical solution:

[0008] A test case generation method based on genetic algorithms and reinforcement learning local search includes the following steps:

[0009] S1. Perform static analysis on the source code of the program under test, construct the abstract syntax tree, control flow graph and data flow graph of the program, and enumerate the program path set based on the control flow graph;

[0010] S2. For each target path in the program path set, use a data flow graph to perform dependency analysis on the branch condition expressions in the path, determine the set of input variables that affect the reachability of the path, and construct a path dimension matrix to describe the correlation between the program path and the input variables.

[0011] S3. Under the constraints of the path dimension matrix, a genetic algorithm is used to perform a global search in the input space. Candidate solutions for test cases are generated through population initialization, fitness evaluation, selection, crossover and mutation operations. The fitness function is calculated based on the branch distance of the target path.

[0012] S4. Select the elite individual with the best fitness from the current population of the genetic algorithm, and use the elite individual as the initial state of the local search in reinforcement learning, and perform local optimization search in the path-related input dimension subspace identified by the path dimension matrix;

[0013] S5. The local search process is modeled as a Markov decision process. The reinforcement learning policy network outputs continuous actions to adjust the values ​​of elite individuals in the path-related dimension one dimension at a time, and the reward signal is calculated based on the change of branch distance.

[0014] S6. When the reinforcement learning local search is completed or the target path is successfully covered, the optimized test cases are added back to the genetic algorithm population to continue participating in the subsequent evolution process until the termination condition is met, and the set of test cases covering the target path is output.

[0015] The path dimension matrix in step S2 is a binary matrix, where the rows represent each path in the program path set and the columns represent the program input variable set. When an input variable has a data dependency relationship with the corresponding path, the matrix element takes the value of 1, otherwise it takes the value of 0.

[0016] The process of constructing the path dimension matrix includes enumerating executable paths of the program on the control flow graph, extracting branch decision nodes in the path, performing reverse slicing analysis on the branch condition expressions on the data flow graph to obtain the set of input variables that each branch condition depends on, and performing a union operation on the set of dependent variables of all branch conditions in the path to determine the set of input variables corresponding to the path.

[0017] The fitness function of the genetic algorithm in step S3 is calculated based on the branch distance of the target path. The branch distance is used to characterize the degree to which the test case satisfies the condition constraints of the target path. The smaller the value, the closer the test case is to the target path.

[0018] The selection operation of the genetic algorithm adopts a probabilistic selection mechanism based on roulette wheel. The selection probability is calculated based on the individual fitness, and parent individuals are randomly selected from the current population for subsequent genetic operations.

[0019] The crossover operation is a crossover operator based on path dimension matrix constraints. The method is as follows: randomly select crossover points within the path-related input dimensions identified by the path dimension matrix, so that the crossover operation acts on at least one path-related input variable, thereby generating new child test cases.

[0020] The mutation operation is a mutation operator based on path dimension matrix constraints. The method is as follows: randomly select an input dimension from the set of path-related input variables as the mutation position, and apply Gaussian random perturbation to that dimension to generate new test case individuals.

[0021] The reinforcement learning local search mechanism in step S4 uses a proximal policy optimization algorithm to construct a policy network and a value network. The policy network outputs continuous actions to control the update step size of test cases on the path-related input dimension.

[0022] The state vector in the reinforcement learning local search in step S5 is composed of the normalized position of the current input variable in its value range, the action step size corresponding to the previous search step, the fitness value of the current test case, and the local optimization trend calculated based on the moving average.

[0023] The reward function for the reinforcement learning local search is calculated based on the change in branch distance between the current test case and the previous state. When a test case successfully covers the target path, an additional reward is given to guide the policy network to learn the optimal search strategy.

[0024] In step S6, when the reinforcement learning local search meets the preset convergence condition on a certain input dimension, the search for that dimension is stopped and the search is switched to the next path-related input dimension until all path-related dimensions are searched or the target path is successfully covered.

[0025] The termination condition is to satisfy at least one of the following conditions: the genetic algorithm reaches the preset maximum number of iterations, successfully generates test cases that cover the target path, or the set of generated test cases reaches the preset path coverage requirement.

[0026] Compared with the prior art, the beneficial effects of the present invention are:

[0027] This invention constructs control flow graphs and data flow graphs by performing static analysis on the program under test, and establishes a path dimension matrix on this basis to characterize the data dependency relationship between the program execution path and input variables. This enables the test case search process to focus on the input variable dimension related to the target path, thereby effectively reducing search interference caused by irrelevant variables and reducing the complexity of the search space.

[0028] During the global search process of the genetic algorithm, the crossover and mutation operations are constrained by the path dimension matrix, so that the evolution operation is preferentially applied to the input dimensions related to the target path, thereby improving the targeting and convergence efficiency of the search process. At the same time, after the genetic algorithm generates elite individuals, a reinforcement learning local search mechanism based on proximal policy optimization is introduced. The test case optimization process is modeled as a Markov decision process in a continuous state-action space, and the path-related input variables are continuously and finely adjusted through the policy network. This enables the algorithm to maintain its global search capability while having effective local optimization capability, thereby overcoming the problem of the slow convergence speed of traditional genetic algorithms in the later stages of the search.

[0029] Furthermore, by directly constructing the branch distance change as a reinforcement learning reward function, the local search process can dynamically adjust the optimization strategy based on search feedback, thereby improving the efficiency of test cases in approximating the target path constraints.

[0030] In summary, this invention integrates program structure analysis, global search using genetic algorithms, and local optimization mechanisms using reinforcement learning to form a test case generation method that combines global exploration with local fine-grained search. This method can significantly improve the efficiency and success rate of test case generation in complex program path coverage testing. Attached Figure Description

[0031] Figure 1 This is the overall flowchart of the present invention.

[0032] Figure 2 This is a flowchart of the multi-condition branch decision-making program logic in this invention. Detailed Implementation

[0033] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0034] See appendix Figure 1-2 A test case generation method based on genetic algorithms and reinforcement learning local search, such as... Figure 1 As shown, the method of the present invention mainly includes the following steps:

[0035] Step 1: Perform static analysis on the source code of the program under test, construct the abstract syntax tree, control flow graph and data flow graph of the program, and enumerate the program path set based on the control flow graph;

[0036] First, the program source code is parsed to construct an abstract syntax tree. The multi-condition branching procedure used in this embodiment is as follows: Figure 2 As shown. Based on the abstract syntax tree, each basic statement block in the program is mapped to a control flow node, and a control flow graph is constructed according to sequential execution relationships, conditional jump relationships, and loop back edge relationships:

[0037]

[0038] in For the set of basic block nodes, This represents a control transfer edge. Simultaneously, a Data Flow Graph (DFG) is constructed through variable definition and usage relationships:

[0039]

[0040] in This represents a set of nodes, where each node represents a variable definition or usage point in the program. This represents a set of edges, where each directed edge represents a data dependency from the definition point to the usage point;

[0041] The definition and usage points of a variable, if the variable The value of the variable is used in the calculation. Then there are data-dependent edges:

[0042]

[0043] Step 2: For each target path in the path set, perform dependency analysis on the branch condition expressions in the path using a data flow graph to determine the set of input variables affecting the reachability of the path, and construct a path dimension matrix to describe the correlation between the program path and the input variables. The construction process of the path dimension matrix includes enumerating executable paths on the control flow graph, extracting branch decision nodes in the path, performing reverse slicing analysis on the branch condition expressions on the data flow graph to obtain the set of input variables that each branch condition depends on, and performing a union operation on the dependency variable sets of all branch conditions in the path to determine the set of input variables corresponding to that path. Specifically:

[0044] Enumerate the program paths on the control flow graph to obtain the set of executable paths:

[0045]

[0046]

[0047] in, It is a set Each element in the file represents a different executable path. Indicates the total number of executable paths; paths This can be represented as a sequence of nodes from the program's entry point to its exit point.

[0048]

[0049] satisfy:

[0050]

[0051] in: It is the entry point of the program, that is, the starting point of program execution; These are intermediate nodes in the path, representing various states or operation points encountered during program execution. It is the exit node of the program, marking the end of program execution. and yes Two adjacent nodes in the middle.

[0052] A depth-first search algorithm is used, starting from the program entry node and traversing along the control transfer edges until the exit node is reached, recording the node sequence traversed by each path. The target path is then determined. For example, the condition combination corresponding to this path is: x≤5, z>5, w>5, and the output is 3; the parameters x, z, and w are three independent numerical variables used to determine whether the branch conditions are true.

[0053] By performing reverse dependency analysis on path branch conditions on the data flow graph, the set of input variables affecting path execution is identified, and the path dimension matrix (PDM) is constructed, defined as follows:

[0054]

[0055] Where L represents the number of paths and D represents the number of input variables; the path dimension matrix is ​​a binary matrix, whose rows represent each path in the program path set and whose columns represent the program input variable set. When an input variable has a data dependency relationship with the corresponding path, the matrix element takes the value of 1, otherwise it takes the value of 0.

[0056] For path For each branch condition, trace back along the control flow to determine the input variables that affect the value of that branch condition: branch condition x≤5 is affected by variable x, branch condition z>5 is affected by variable z, and branch condition w>5 is affected by variable w. Therefore, the path... The set of input variable dependencies:

[0057]

[0058] Similarly, the dependency sets of other paths can be analyzed:

[0059] , , , .

[0060] Construct a path dimension matrix based on the dependencies between paths and input variables. Where 5 represents the number of paths and 4 represents the number of input variables (x, y, z, w). The matrix elements are defined as follows:

[0061]

[0062] in Represents a path The input variables depend on the set, and the constructed dimension matrix is ​​shown below:

[0063]

[0064] This matrix clearly depicts the dependency relationship between each path and the input variables. Based on the path dimension matrix, the variable y and the target path... Irrelevant.

[0065] Step 3: Under the constraints of the path dimension matrix, a genetic algorithm is used to perform a global search in the input space. Candidate solutions for test cases are generated through population initialization, fitness evaluation, selection, crossover and mutation operations. The fitness function is calculated based on the branch distance of the target path.

[0066] First, initialize the population and evaluate fitness. Randomly generate an initial test case population of size N within the range of input variable values:

[0067]

[0068] in To represent a set, it is usually used to represent an initial state or an initial set. The superscript indicates the total number of elements in the set. This usually indicates that it is the value at the initial time or under the initial conditions;

[0069] Each individual is represented as an input variable vector:

[0070]

[0071] It is usually represented as a vector. Representing vectors The first component, This represents the total number of dimensions of the vector;

[0072] The branch distance of the test cases is calculated based on the branch conditions of the target path and used as the fitness function.

[0073]

[0074] in Indicates the object of measurement The value indicating the degree of superiority or inferiority; BD(·) represents the branch distance between the test case and the branch condition; Positive integers, representing quantities; Indicates the object to be evaluated; Indicates and The first in the relevant set of reference objects One element;

[0075] Therefore, the target path The fitness function is:

[0076]

[0077] A global search using a genetic algorithm based on PDM constraints is employed. The fitness function of this genetic algorithm is calculated based on the branch distance of the target path. The branch distance characterizes the degree to which test cases satisfy the constraints of the target path; the smaller the value, the closer the test cases are to the target path.

[0078] In terms of selection operations, a probabilistic selection mechanism based on roulette wheel is adopted. The selection probability is calculated based on the individual fitness, and parent individuals are randomly selected from the current population for subsequent genetic operations.

[0079] Regarding the cross operation, the cross operator based on the path dimension matrix constraint works as follows: randomly select the cross point within the path-related input dimension range identified by the path dimension matrix, so that the cross operation acts on at least one path-related input variable, thereby generating new child test cases.

[0080] Regarding mutation operations, the mutation operator based on path dimension matrix constraints works as follows: randomly select an input dimension from the set of path-related input variables as the mutation location, and apply Gaussian random perturbation to that dimension to generate new test case individuals;

[0081] Specifically, during the evolutionary process of the genetic algorithm, a probabilistic selection mechanism is used to select individuals from the population based on their fitness values, calculating the probability of each individual being selected:

[0082]

[0083] Where parameters For the first During the nth iteration, the 1st Normalized weights (probabilities) of each element; For the first In the nth iteration, the 1st The original weights of each element; For the first In the next iteration, all The sum of the original weights of each element. The total number of elements;

[0084] in and:

[0085]

[0086] Where parameters for In a specific context The updated vector below; for In the context Some related input feature or original representation; This represents a small perturbation term.

[0087] In the crossover operation, first in the set Offspring individuals are generated by randomly selecting crossover points. This embodiment uses a single-point crossover method: two parent individuals are randomly selected. and Randomly select an intersection point Generate offspring individuals, whose first c dimensions come from The latter 4-c dimension comes from The intersection point 'c' refers to its position within the overall series, but since selection is only allowed within R, the crossover operation is guaranteed to be performed only on the relevant dimensions.

[0088] In the mutation operation, from the set of path-related input dimensions... Randomly select variables and perform Gaussian perturbation mutation, and use boundary constraints to ensure that the mutated variable values ​​are still within the legal range:

[0089]

[0090] in: This represents the new value of the j-th input variable after the mutation operation; δ represents the original value of the j-th input variable before the mutation operation; δ represents the value from a mean of 0 and a variance of 0. Gaussian perturbation values ​​obtained by random sampling from a normal distribution; The variance parameter represents the Gaussian distribution and is used to control the magnitude of the variation disturbance. In practical applications, variance... The value is usually set based on the domain of variable j, for example, taking... ,in and These are the upper and lower bounds of the j-th input variable, respectively, to ensure that the disturbance magnitude is adapted to the variable scale.

[0091] Step 4: Select the elite individual with the best fitness from the current population of the genetic algorithm, and use the elite individual as the initial state of the reinforcement learning local search. Perform local optimization search in the path-related input dimension subspace identified by the path dimension matrix. The reinforcement learning local search mechanism uses the proximal policy optimization algorithm to construct a policy network and a value network. The policy network outputs continuous actions to control the update step size of the test cases in the path-related input dimension.

[0092] Step 5: Reinforcement Learning Local Search. Select the individual with the best fitness from the current population as the initial state for the reinforcement learning local search, and model the test case optimization process as a Markov decision process:

[0093]

[0094] Among them, the state space Used to describe the search state information of the current test case during the local search process; action space Used to control continuous perturbations of input variables in the path-dependent dimension; state transition probability. Represents the transition relationship between states given an action; reward function Used to measure the optimization effect of the current action on the distance of the target path branches; This represents the discount factor. During the local search process in reinforcement learning, adjustments are only allowed to the input dimensions marked as relevant in the path dimension matrix.

[0095] The reinforcement learning state vector consists of four consecutive features:

[0096]

[0097] in Indicates the normalized position of the current dimension value within the boundary interval. ; This indicates the search step size at the previous moment, used to reflect the current search direction and magnitude; This is the normalized value of the current fitness. The local improvement trend is obtained based on the moving average calculation:

[0098]

[0099] in This represents the local improvement trend moving average at time t-1, which is the historical cumulative trend; Represents the solution vector at time t The corresponding fitness function value; This represents the absolute value of the search step size at time t-1; It is a very small positive number (e.g., ϵ=10−8) used to avoid the denominator being 0 and to ensure numerical stability.

[0100] This state design simultaneously encodes the current position, historical search direction, fitness level, and local optimization trend, enabling the policy network to perceive the dynamic geometry of the search process.

[0101] The action space of reinforcement learning is a one-dimensional continuous variable. The output of the policy network is mapped to the actual update step size of the input variables:

[0102]

[0103] in This represents the new value of the d-th dimension decision variable after the policy update; This represents the current value of the d-th dimension decision variable before the policy update. This represents the continuous actions output by the reinforcement learning policy network; and This represents the upper and lower bounds of the d-th dimension variable.

[0104] Furthermore, the reward function is composed of changes in branch distance:

[0105]

[0106] in This represents the single-step reward value at the current moment, used to guide policy gradient optimization; This represents the fitness function corresponding to the current state.

[0107] A termination reward is given when a test case successfully covers the target path:

[0108]

[0109] In this embodiment This is a preset positive reward constant, such as 2.0.

[0110] The reinforcement learning policy network adopts an Actor-Critic architecture and is updated using the Proximal Policy Optimization (PPO) algorithm; the policy function is modeled as a Gaussian distribution.

[0111]

[0112] in It is a stochastic policy function with θ as a parameter, representing the probability density of taking action a in state s; This represents the continuous actions output by the policy network, corresponding to the step size of the variable update; This represents the current state vector of the algorithm; Represents a Gaussian probability distribution; This represents the mean of a Gaussian distribution fitted to the policy network with state s as input. The standard deviation represents the Gaussian distribution and is used to control the intensity of action exploration. In this paper, the standard deviation adopts a learnable mode, which is adaptively optimized by a neural network, and the positive value is guaranteed by Softplus activation.

[0113] The value function is used to estimate the expected cumulative return in the current state:

[0114]

[0115] The discount reward is as follows:

[0116]

[0117] Where γ is the discount factor, taking the value (0,1), used to balance immediate rewards and long-term returns; k represents the time step offset; This represents the k-th power of the discount factor, where the weight of the long-term reward decays over time. This represents the instantaneous reward value obtained at time s+k.

[0118] Furthermore, the policy network parameters are updated using a proximal policy optimization algorithm, the objective function of which is:

[0119]

[0120] in:

[0121]

[0122]

[0123] The dominance function Cumulative rewards from discounts With value network estimates The difference is obtained and used to evaluate the relative value of actions. The shear coefficient ϵ is the range for control strategy updates. The ratio of the probabilities of the new and old policies is used to effectively avoid excessive policy updates and improve the stability of algorithm training through pruning operations.

[0124] Furthermore, during the reinforcement learning local search process, the current dimension satisfies the one-dimensional convergence condition:

[0125]

[0126] If this is the case, then the search is considered to have reached a local optimum in that dimension, and the strategy automatically switches to the next path-related dimension to continue the search. This is the preset step size for small perturbations, typically set to 1; For the perturbation of the d-th dimension variable of x The resulting branch distance value

[0127] Assuming the elite individuals in this embodiment are (3, 8, 6, 5), optimization is performed according to the relevant dimensions. Variable x=3 already satisfies x≤5, and variable z=6 already satisfies z>5, therefore only variable w needs optimization. Currently, w=5, and needs to be adjusted to w>5. During the reinforcement learning local search process, the policy network attempts to adjust the value of w through multiple explorations. After several exploration steps, when the action output by the policy network causes w to be adjusted to 6, the fitness value of the new individual (3,8,6,6) is 0, successfully covering the target path. Upon receiving the termination reward, the partial search ends.

[0128] Step 6: Result Feedback and Iterative Loop. When test cases covering the target path are successfully generated, the reinforcement learning local search process ends. The optimized best individual (3,8,6,6) is returned to the genetic algorithm population, replacing the worst individual in the population, completing one "global-local" collaborative optimization loop.

[0129] Through the above steps, this method uses the path dimension matrix to identify the relationship between the variable y and the target path. This significantly reduces the complexity of the search space and greatly improves the efficiency of test case generation.

[0130] Although this specification describes embodiments, not every embodiment contains only one independent technical solution. This way of describing the specification is only for clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.

[0131] Therefore, the above description is only a preferred embodiment of this application and is not intended to limit the scope of this application; that is, all equivalent modifications made in accordance with the scope of the claims of this application shall be within the protection scope of the claims of this application.

Claims

1. A test case generation method based on genetic algorithm and reinforcement learning local search, characterized in that, Includes the following steps: S1. Perform static analysis on the source code of the program under test, construct the abstract syntax tree, control flow graph and data flow graph of the program, and enumerate the program path set based on the control flow graph; S2. For each target path in the program path set, use a data flow graph to perform dependency analysis on the branch condition expressions in the path, determine the set of input variables that affect the reachability of the path, and construct a path dimension matrix to describe the correlation between the program path and the input variables. S3. Under the constraints of the path dimension matrix, a genetic algorithm is used to perform a global search in the input space. Candidate solutions for test cases are generated through population initialization, fitness evaluation, selection, crossover and mutation operations. The fitness function is calculated based on the branch distance of the target path. S4. Select the elite individual with the best fitness from the current population of the genetic algorithm, and use the elite individual as the initial state of the local search in reinforcement learning, and perform local optimization search in the path-related input dimension subspace identified by the path dimension matrix; S5. The local search process is modeled as a Markov decision process. The reinforcement learning policy network outputs continuous actions to adjust the values ​​of elite individuals in the path-related dimension one dimension at a time, and the reward signal is calculated based on the change of branch distance. S6. When the reinforcement learning local search is completed or the target path is successfully covered, the optimized test cases are added back to the genetic algorithm population to continue participating in the subsequent evolution process until the termination condition is met, and the set of test cases covering the target path is output.

2. The test case generation method based on genetic algorithm and reinforcement learning local search according to claim 1, characterized in that, The path dimension matrix in step S2 is a binary matrix, where the rows represent each path in the program path set and the columns represent the program input variable set. When an input variable has a data dependency relationship with the corresponding path, the matrix element takes the value of 1, otherwise it takes the value of 0.

3. The test case generation method based on genetic algorithm and reinforcement learning local search according to claim 2, characterized in that, The process of constructing the path dimension matrix includes enumerating executable paths of the program on the control flow graph, extracting branch decision nodes in the path, performing reverse slicing analysis on the branch condition expressions on the data flow graph to obtain the set of input variables that each branch condition depends on, and performing a union operation on the set of dependent variables of all branch conditions in the path to determine the set of input variables corresponding to the path.

4. The test case generation method based on genetic algorithm and reinforcement learning local search according to claim 1, characterized in that, The fitness function of the genetic algorithm in step S3 is calculated based on the branch distance of the target path. The branch distance is used to characterize the degree to which the test case satisfies the condition constraints of the target path. The smaller the value, the closer the test case is to the target path.

5. The test case generation method based on genetic algorithm and reinforcement learning local search according to claim 1, characterized in that, The selection operation of the genetic algorithm adopts a probabilistic selection mechanism based on roulette wheel. The selection probability is calculated based on the individual fitness, and parent individuals are randomly selected from the current population for subsequent genetic operations.

6. The test case generation method based on genetic algorithm and reinforcement learning local search according to claim 1, characterized in that, The crossover operation is a crossover operator based on path dimension matrix constraints. The method is as follows: randomly select crossover points within the path-related input dimensions identified by the path dimension matrix, so that the crossover operation acts on at least one path-related input variable, thereby generating new child test cases.

7. The test case generation method based on genetic algorithm and reinforcement learning local search according to claim 1, characterized in that, The mutation operation is a mutation operator based on path dimension matrix constraints. The method is as follows: randomly select an input dimension from the set of path-related input variables as the mutation position, and apply Gaussian random perturbation to that dimension to generate new test case individuals.

8. The test case generation method based on genetic algorithm and reinforcement learning local search according to claim 1, characterized in that, The reinforcement learning local search mechanism in step S4 uses a proximal policy optimization algorithm to construct a policy network and a value network. The policy network outputs continuous actions to control the update step size of test cases on the path-related input dimension.

9. The test case generation method based on genetic algorithm and reinforcement learning local search according to claim 1, characterized in that, The state vector in the reinforcement learning local search in step S5 is composed of the normalized position of the current input variable in its value range, the action step size corresponding to the previous search step, the fitness value of the current test case, and the local optimization trend calculated based on the moving average. The reward function for the reinforcement learning local search is calculated based on the change in branch distance between the current test case and the previous state. When a test case successfully covers the target path, an additional reward is given to guide the policy network to learn the optimal search strategy.

10. The test case generation method based on genetic algorithm and reinforcement learning local search according to claim 1, characterized in that, In step S6, when the reinforcement learning local search meets the preset convergence condition on a certain input dimension, the search for that dimension is stopped and the search is switched to the next path-related input dimension until all path-related dimensions are searched or the target path is successfully covered. The termination condition is to satisfy at least one of the following conditions: the genetic algorithm reaches the preset maximum number of iterations, successfully generates test cases that cover the target path, or the set of generated test cases reaches the preset path coverage requirement.