Akiira / Comp-524-program

A genetic algorithm to create test suites that cover every branch of a program
2 stars 0 forks source link

Fitness Function #5

Closed Akiira closed 9 years ago

Akiira commented 9 years ago

We need to decide on a fitness function to use. We have a couple of general ideas, like punishing for covering multiple edges, but deciding the best way to bring them all together will take some more thought. Now that we have a concrete implementation it may be advantageous to discuss this with Dr. Bui and Dr. El Ariss again.

ambarket commented 9 years ago

Here's an idea based on some of the things we talked about

  1. sum <- 0
  2. Foreach index in duplicateEdgesCoverage
    • sum += baseReward * (duplicateEdgesCoverage[index] / populationEdgeCoverage[index]) //This should give a fitness boost to organisms who cover edges not covered elsewhere while punishing those that cover that same edges covered elsewhere in the population
  3. Do same for predicateCoverage

//(Sum of testSuite to population coverage ratios) – max is numOfEdges+numOfPredicates (Only test suite to cover anything and it covers everything), min is 0 (Covered nothing).

// sum – max is (numOfEdges+numOfPredicates)^2 * baseReward, min is 0

  1. fitness <- sum / testSuiteSize
Akiira commented 9 years ago

So heres a question, when an Organism covers an edge two or more times, do we want to give more fitness then if it covered it once, or less? If we give it more then that Organism would have a higher fitness then it really deserves. The fitness value might not be a good indicator of its actual quality.

Thats why I was thinking we give it some standard fitness value for covering an edge once, and for each time it covers it more then once we subtract a number from it.

For example if the base fitness is 1, and it covers the edge 3 times, then we take 1 - (1/2) - (1/4), to get its fitness. We could actually use the harmonic numbers to do this; the reason i suggest them is because it will still always give us a positive fitness if we start with a base of 1.

To take into account the populationEdgeCoverage we can still just divide the fitness by that. Though i just relized; if fitness depends on this meta data it will need to be recalculated for everyone if the meta data ever changes. So even if we are just replacing one organism with another we may need to recalculate fitness for everyone.