Documentation of 'org.jgap.util.ChromosomeFitnessComparator' Java class
ChromosomeFitnessComparator
org.jgap.util

Class ChromosomeFitnessComparator

  • All Implemented Interfaces:
    java.util.Comparator


    public class ChromosomeFitnessComparator
    extends java.lang.Object
    implements java.util.Comparator
    Simple comparator to allow the sorting of Chromosome lists with the highest fitness value in first place of the list. Usage example: Collections.sort( population.getChromosomes(), new ChromosomeFitnessComparator() );
    Since:
    2.4
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method and Description
      int compare(java.lang.Object a_chromosome1, java.lang.Object a_chromosome2)
      Compares two chromosomes by using a FitnessEvaluator.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Constructor Detail

      • ChromosomeFitnessComparator

        public ChromosomeFitnessComparator()
        Constructs the comparator using the DefaultFitnessEvaluator
        Since:
        2.6
      • ChromosomeFitnessComparator

        public ChromosomeFitnessComparator(FitnessEvaluator a_evaluator)
        Parameters:
        a_evaluator - the fitness evaluator to use
        Since:
        2.6
    • Method Detail

      • compare

        public int compare(java.lang.Object a_chromosome1,
                           java.lang.Object a_chromosome2)
        Compares two chromosomes by using a FitnessEvaluator.
        Specified by:
        compare in interface java.util.Comparator
        Parameters:
        a_chromosome1 - the first chromosome to compare
        a_chromosome2 - the second chromosome to compare
        Returns:
        -1 if a_chromosome1 is fitter than a_chromosome2, 1 if it is the other way round and 0 if both are equal
        Since:
        2.6

DMelt 3.0 © DataMelt by jWork.ORG

You see the box below because you did not login.