A method for generating extreme test cases based on genetic algorithm
Through the extreme test case generation method based on genetic algorithm, the problem of inefficiency in writing extreme test cases is solved, and the ability to automatically generate extreme test cases is realized.
Patent Information
- Application Number
- CN202110426746.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-20
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2041-04-20
AI Technical Summary
Writing extreme test cases requires guidance from hardware designers, and usually requires manual ordering of instruction sequences, which are inefficient.
The extreme test case generation method based on genetic algorithm is adopted, individual attributes and evolution settings are defined through configuration files, and the cross and mutation results are calculated in the iteration process using the genetic algorithm core, and the instruction sequence is generated that is useful for generating extreme test cases, and embedded in the assembly code.
It automatically generates specific extreme test cases without manual dispatch, improving the efficiency of writing extreme test cases.
Smart Images

Figure CN114218064B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a method for generating extreme test cases based on a genetic algorithm, and belongs to the technical field of reliability testing. Background Art
[0002] Genetic algorithm is a computational model of biological evolution that simulates the natural selection and genetic mechanism of Darwin's theory of biological evolution. It is a method of searching for the optimal solution by simulating the natural evolution process. Genetic coding is designed for the problem to be solved. After the first generation of population is generated, the fitness value is calculated for each individual. According to the principle of survival of the fittest and survival of the fittest, the evolution of each generation produces approximate solutions that are closer and closer to the target. The best individual in the last generation of population can be used as the approximate optimal solution to the problem.
[0003] Extreme test cases are essential in processor verification, because some corner design errors can only be exposed under extreme conditions, and extreme testing is crucial in post-silicon electrical characteristics testing, which can not only test the frequency and voltage boundaries, but also test the stability of various components. Writing extreme test cases requires guidance from hardware designers, and often requires manual sorting of instruction sequences, which is inefficient. Summary of the invention
[0004] The purpose of the present invention is to provide a method for generating extreme test cases based on a genetic algorithm to solve the problem of difficulty in writing extreme test cases.
[0005] To achieve the above object, the technical solution adopted by the present invention is: to provide a method for generating extreme test cases based on a genetic algorithm, based on the following configuration:
[0006] Configuration file, which is used to define individual attributes and evolution settings in XML format, where the evolution settings include the fitness value to be reached;
[0007] The core of the genetic algorithm is used to calculate the results of crossover and mutation according to the fitness value in the iteration process according to the basic rule of survival of the fittest, and find the instruction sequence that is useful for generating extreme test cases. This instruction sequence will be embedded in the assembly code to generate an extreme test program;
[0008] A population generator, used to generate the next generation population according to the crossover and mutation results of the genetic algorithm core, wherein the population is an assembly program generated after the instruction sequence is embedded in the assembly code;
[0009] The fitness value calculator is used to calculate the fitness value of individuals in the population. There can be multiple fitness values at the same time. The fitness value can be various indicators obtained during the program running process;
[0010] The fitness value collection module is used to collect the fitness value of the population and feed it back to the genetic algorithm core;
[0011] The generation method comprises the following steps:
[0012] S1. The population generator reads the evolution configuration file, individual attribute file and constraint file in XML format to generate the initial population;
[0013] S2, a fitness value calculator calculates the fitness value of each individual in the initial population obtained in S1;
[0014] S3, the fitness value collection module collects the fitness values of all individuals and feeds them back to the genetic algorithm core;
[0015] S4, the genetic algorithm core determines whether a near-optimal solution is obtained according to the fitness value fed back in S3 and the fitness value set in the evolution configuration file. When the individual fitness value in the population reaches the set fitness value after multiple evolutions, a near-optimal solution is obtained and jumps to S5. If a near-optimal solution has not been obtained, the genetic algorithm core generates multiple groups of instruction sequences based on the fitness value results of the previous generation, crossover and mutation, and the population generator embeds the assembly code to generate the next generation population and jump to S2;
[0016] S5. Obtain near-optimal assembly code.
[0017] Due to the application of the above technical solution, the present invention has the following advantages compared with the prior art:
[0018] The extreme test case generation method based on genetic algorithm of the present invention does not need manual arrangement of instructions to write extreme test cases. It only needs to set the evolution configuration file, individual attribute file and constraint file to automatically generate specific extreme test cases. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Attached Figure 1 Schematic diagram of the extreme test case generation method based on genetic algorithm. DETAILED DESCRIPTION
[0020] Embodiment: The present invention provides a method for generating extreme test cases based on a genetic algorithm, based on the following configuration:
[0021] Configuration file, which is used to define individual attributes and evolution settings in XML format, where the evolution settings include the fitness value to be reached;
[0022] The core of the genetic algorithm is used to calculate the results of crossover and mutation according to the fitness value in the iteration process according to the basic rule of survival of the fittest, and find the instruction sequence that is useful for generating extreme test cases. This instruction sequence will be embedded in the assembly code to generate an extreme test program;
[0023] A population generator, used to generate the next generation population according to the crossover and mutation results of the genetic algorithm core, wherein the population is an assembly program generated after the instruction sequence is embedded in the assembly code;
[0024] The fitness value calculator is used to calculate the fitness value of individuals in the population. There can be multiple fitness values at the same time. The fitness value can be various indicators obtained during the program running process, such as power consumption, throughput, etc.
[0025] The fitness value collection module is used to collect the fitness value of the population and feed it back to the genetic algorithm core;
[0026] The generation method comprises the following steps:
[0027] S1. The population generator reads the evolution configuration file, individual attribute file and constraint file in XML format to generate the initial population;
[0028] S2, a fitness value calculator calculates the fitness value of each individual in the initial population obtained in S1;
[0029] S3, the fitness value collection module collects the fitness values of all individuals and feeds them back to the genetic algorithm core;
[0030] S4, the genetic algorithm core determines whether a near-optimal solution is obtained based on the fitness value fed back in S3 and the fitness value to be reached set in the evolution configuration file. When the individual fitness value in the population reaches the set fitness value after multiple evolutions, a near-optimal solution is obtained and jumps to S5. If a near-optimal solution has not been obtained, the genetic algorithm core generates multiple groups of instruction sequences based on the fitness value results of the previous generation, crossover and mutation, and the population generator embeds the assembly code to generate the next generation population and jump to S2;
[0031] S5. Obtain near-optimal assembly code.
[0032] The further explanation of the above embodiment is as follows:
[0033] The present invention utilizes the evolution function of the genetic algorithm and combines various fitness value calculators to automatically evolve and generate various extreme test cases.
[0034] The present invention is mainly composed of a genetic algorithm core, a population generator, a fitness value calculator, and a fitness value collection. The input of the present invention is an evolution configuration file, an individual attribute file, and a constraint file in XML format. The output of the present invention is an optimal assembly code.
[0035] The composition of the present invention is as follows Figure 1 As shown, the process is as follows:
[0036] 1. The population generator reads the constraint file and individual attribute file to generate the initial population;
[0037] 2. Calculate the fitness value of each individual in the population;
[0038] 3. Collect the fitness values of all individuals and feed them back to the genetic algorithm core;
[0039] 4. The genetic algorithm core determines whether a near-optimal solution is obtained based on the feedback fitness value and evolution profile. If so, it jumps to 5. If a near-optimal solution is not obtained, a new generation of population is generated through crossover and mutation, and it jumps to 2.
[0040] 5. Get the near-optimal assembly code.
[0041] When using the above-mentioned extreme test case generation method based on genetic algorithm, it does not need to manually arrange instructions to write extreme test cases. It only needs to set the evolution configuration file, individual attribute file and constraint file to automatically generate specific extreme test cases.
[0042] In order to facilitate a better understanding of the present invention, the terms used in this article are briefly explained below:
[0043] The above embodiments are only for illustrating the technical concept and features of the present invention, and their purpose is to enable people familiar with the technology to understand the content of the present invention and implement it accordingly, and they cannot be used to limit the protection scope of the present invention. Any equivalent changes or modifications made according to the spirit of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for generating extreme test cases based on genetic algorithm, characterized in that: Based on the following configuration: Configuration file, which is used to define individual attributes and evolution settings in XML format, where the evolution settings include the fitness value to be reached; The core of the genetic algorithm is used to calculate the results of crossover and mutation according to the fitness value in the iterative process according to the rule of survival of the fittest, and find the instruction sequence that is useful for generating extreme test cases. This instruction sequence will be embedded in the assembly code to generate an extreme test program; A population generator, used to generate the next generation population according to the crossover and mutation results of the genetic algorithm core, wherein the population is an assembly program generated after the instruction sequence is embedded in the assembly code; The fitness value calculator is used to calculate the fitness value of individuals in the population. There are multiple fitness values at the same time. The fitness value is various indicators obtained during the program running process; The fitness value collection module is used to collect the fitness value of the population and feed it back to the genetic algorithm core; The generation method comprises the following steps: S1. The population generator reads the evolution configuration file, individual attribute file and constraint file in XML format to generate the initial population; S2, a fitness value calculator calculates the fitness value of each individual in the initial population obtained in S1; S3, the fitness value collection module collects the fitness values of all individuals and feeds them back to the genetic algorithm core; S4, the genetic algorithm core determines whether a near-optimal solution is obtained based on the fitness value fed back in S3 and the fitness value to be reached set in the evolution configuration file. When the individual fitness value in the population reaches the set fitness value to be reached after multiple evolutions, a near-optimal solution is obtained and jumps to S5. If a near-optimal solution has not been obtained, the genetic algorithm core generates multiple groups of instruction sequences based on the fitness value results of the previous generation, crossover and mutation, and the population generator embeds the assembly code to generate the next generation population, and jumps to S2; S5. Obtain near-optimal assembly code.
Citation Information
Patent Citations
Genetic algorithm based software repair method
CN103294595A
Testing case priority ranking method for white-box testing
CN106528433A