Class BinaryChromosome

All Implemented Interfaces:
Comparable<Chromosome>, Fitness

public abstract class BinaryChromosome extends AbstractListChromosome<Integer>
Chromosome represented by a vector of 0s and 1s.
Since:
2.0
  • Constructor Details

  • Method Details

    • checkValidity

      protected void checkValidity(List<Integer> chromosomeRepresentation) throws InvalidRepresentationException
      Asserts that representation can represent a valid chromosome.
      Specified by:
      checkValidity in class AbstractListChromosome<Integer>
      Parameters:
      chromosomeRepresentation - representation of the chromosome
      Throws:
      InvalidRepresentationException - iff the representation can not represent a valid chromosome
    • randomBinaryRepresentation

      public static List<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