/home/ooechs/ECJ_Tutorial/src/ac/essex/ecj/fitness/FitnessCalculator.java
|
package ac.essex.ecj.fitness;
/**
* @author Olly Oechsle, University of Essex, Date: 18-Aug-2006
* @version 1.0
*/
public class FitnessCalculator {
public static float ALPHA = 1;
public static float BETA = 1;
public static float getKozaFitness(int TP, int FP, int totalTruePixels) {
// use our biased formula to calculate the fitness
return (ALPHA * (float) TP) / ((ALPHA * totalTruePixels) + (BETA * (float) FP));
}
public static float createKozaFitness(float fitness) {
// dont allow fitness to be 0 - otherwise we get divide by 0 errors
if (fitness < 0.00000000001f) fitness = 0.00000000001f;
// invert fitness - Koza Fitness assumes low numbers to be the best
// this way when we return 0, we know it is the absolute best and we
// can stop now.
return 1.0f / fitness;
}
}