Clover coverage report - JGAP 3.1
Coverage timestamp: Mo Dez 11 2006 21:16:18 CET
file stats: LOC: 85   Methods: 3
NCLOC: 33   Classes: 2
 
 Source file Conditionals Statements Methods TOTAL
NaturalSelector.java 100% 100% 100% 100%
coverage
 1    /*
 2    * This file is part of JGAP.
 3    *
 4    * JGAP offers a dual license model containing the LGPL as well as the MPL.
 5    *
 6    * For licencing information please see the file license.txt included with JGAP
 7    * or have a look at the top of class org.jgap.Chromosome which representatively
 8    * includes the JGAP license policy applicable for any file delivered with JGAP.
 9    */
 10    package org.jgap;
 11   
 12    import java.util.*;
 13    import org.jgap.data.config.*;
 14   
 15    /**
 16    * Abstract base implementation of interface INaturalSelector.
 17    *
 18    * @author Neil Rotstan
 19    * @author Klaus Meffert
 20    * @since 2.0
 21    */
 22    public abstract class NaturalSelector
 23    implements INaturalSelector, Configurable {
 24    /** String containing the CVS revision. Read out via reflection!*/
 25    private static final String CVS_REVISION = "$Revision: 1.24 $";
 26   
 27    private /*transient*/ Configuration m_config;
 28   
 29    /**
 30    *
 31    * @param a_config the configuration to use
 32    *
 33    * @author Klaus Meffert
 34    * @since 3.0
 35    */
 36  3584 public NaturalSelector(Configuration a_config) {
 37  3584 m_config = a_config;
 38    }
 39   
 40    /**
 41    * @return the (immutable) configuration to use
 42    *
 43    * @author Klaus Meffert
 44    * @since 3.0
 45    */
 46  29232 public Configuration getConfiguration() {
 47  29232 return m_config;
 48    }
 49   
 50    /**
 51    * Add a Chromosome instance to this selector's working pool of Chromosomes.
 52    *
 53    * @param a_chromosomeToAdd the specimen to add to the pool
 54    *
 55    * @author Neil Rotstan
 56    * @since 1.0
 57    */
 58    protected abstract void add(IChromosome a_chromosomeToAdd);
 59   
 60    /**
 61    * Comparator regarding only the fitness value. Best fitness value will
 62    * be on first position of resulting sorted list
 63    *
 64    * @author Klaus Meffert
 65    * @since 1.1
 66    */
 67    public class FitnessValueComparator
 68    implements Comparator, java.io.Serializable {
 69  19636 public int compare(Object first, Object second) {
 70  19636 IChromosome chrom1 = (IChromosome) first;
 71  19636 IChromosome chrom2 = (IChromosome) second;
 72  19636 if (getConfiguration().getFitnessEvaluator().isFitter(chrom2,
 73    chrom1)) {
 74  10405 return 1;
 75    }
 76  9231 else if (getConfiguration().getFitnessEvaluator().isFitter(
 77    chrom1, chrom2)) {
 78  2235 return -1;
 79    }
 80    else {
 81  6996 return 0;
 82    }
 83    }
 84    }
 85    }