Class BinaryChromosome

  • All Implemented Interfaces:
    java.lang.Comparable<Chromosome>, Fitness

    public abstract class BinaryChromosome
    extends AbstractListChromosome<java.lang.Integer>
    Chromosome represented by a vector of 0s and 1s.
    Since:
    2.0
    Version:
    $Revision: 811685 $ $Date: 2009-09-05 19:36:48 +0200 (sam. 05 sept. 2009) $
    • Constructor Detail

      • BinaryChromosome

        public BinaryChromosome​(java.util.List<java.lang.Integer> representation)
        Constructor.
        Parameters:
        representation - list of {0,1} values representing the chromosome
      • BinaryChromosome

        public BinaryChromosome​(java.lang.Integer[] representation)
        Constructor.
        Parameters:
        representation - array of {0,1} values representing the chromosome
    • Method Detail

      • randomBinaryRepresentation

        public static java.util.List<java.lang.Integer> randomBinaryRepresentation​(int length)
        Returns a representation of a random binary array of length length.
        Parameters:
        length - length of the array
        Returns:
        a random binary array of length length
      • isSame

        protected boolean isSame​(Chromosome another)
        Returns true iff another has the same representation and therefore the same fitness. By default, it returns false -- override it in your implementation if you need it.
        Overrides:
        isSame in class Chromosome
        Parameters:
        another - chromosome to compare
        Returns:
        true if another is equivalent to this chromosome