1 10 package org.jgap; 11 12 import org.jgap.util.*; 13 14 21 public class DeltaFitnessEvaluator 22 implements FitnessEvaluator, ICloneable, Comparable { 23 24 private final static String CVS_REVISION = "$Revision: 1.10 $"; 25 26 35 public boolean isFitter(final double a_fitness_value1, 36 final double a_fitness_value2) { 37 if (Double.isNaN(a_fitness_value1)) { 38 return false; 39 } 40 else if (!Double.isNaN(a_fitness_value1) && 41 !Double.isNaN(a_fitness_value2)) { 42 if (a_fitness_value1 < 0) { 43 return false; 44 } 45 if (a_fitness_value2 < 0) { 46 return true; 47 } 48 return a_fitness_value1 < a_fitness_value2; 49 } 50 return true; 51 } 52 53 public boolean isFitter(IChromosome a_chrom1, IChromosome a_chrom2) { 54 return isFitter(a_chrom1.getFitnessValue(), a_chrom2.getFitnessValue()); 55 } 56 57 63 public Object clone() { 64 return new DeltaFitnessEvaluator(); 65 } 66 67 74 public int compareTo(Object a_other) { 75 if (a_other.getClass().equals(getClass())) { 76 return 0; 77 } 78 else { 79 return getClass().getName().compareTo(a_other.getClass().getName()); 80 } 81 } 82 } 83 | Popular Tags |