1 10 package org.jgap; 11 12 import java.util.*; 13 import org.jgap.data.config.*; 14 15 22 public abstract class NaturalSelector 23 implements INaturalSelector, Configurable { 24 25 private static final String CVS_REVISION = "$Revision: 1.24 $"; 26 27 private Configuration m_config; 28 29 36 public NaturalSelector(Configuration a_config) { 37 m_config = a_config; 38 } 39 40 46 public Configuration getConfiguration() { 47 return m_config; 48 } 49 50 58 protected abstract void add(IChromosome a_chromosomeToAdd); 59 60 67 public class FitnessValueComparator 68 implements Comparator, java.io.Serializable { 69 public int compare(Object first, Object second) { 70 IChromosome chrom1 = (IChromosome) first; 71 IChromosome chrom2 = (IChromosome) second; 72 if (getConfiguration().getFitnessEvaluator().isFitter(chrom2, 73 chrom1)) { 74 return 1; 75 } 76 else if (getConfiguration().getFitnessEvaluator().isFitter( 77 chrom1, chrom2)) { 78 return -1; 79 } 80 else { 81 return 0; 82 } 83 } 84 } 85 } 86 | Popular Tags |