dimanche 1 mai 2016

Finding the perfect fitness function for path testing using Genetic Algorithm

I recently started working with genetic algorithm, and to understand it better, I decided to use it to solve a problem. I'm working on using genetic algorithm to generate test cases for a path testing question. I have everything figured out, except for how to choose the best fitness function. So, I could use some help :)

Here is an overview of my problem: In each generation, 100 test cases are being generated. Each path in the CFG has been assigned a weight, depending on how rare the test cases for that path are. For example, take the following CFG:

enter image description here

There are 4 independent paths. Let's say the weights of the path are as follows-

Path 1: 10

Path 2: 5

Path 3: 4

Path 4: 5

Right now, for each test case in the generation, I'm considering the avg fitness the entire generation can have.

(10*100 - 4*100)/2 = 300 [Since there are 100 test cases]

So, I'm diving the weight of that test case (the weight of the path which it covers) by 300. Although the result is satisfactory, the logic for this is extremely flawed. I think a better fitness function, so that the fitness of the test case is directly proportional to the weight of the path it covers, would be the weight divided by the sum of the weights of all paths. So for this problem,

w/(10+5+5+4) = w/24

What do you think would be a better approach to calculate the fitness of each test case?

  1. w/300

  2. w/24

Or would you suggest a completely different approach? Can a better fitness function be generated for this problem?

I would be grateful for your help :)

Aucun commentaire:

Enregistrer un commentaire