Class Chromosome

  • Direct Known Subclasses:
    BinaryChromosome, IntegerChromosome

    public abstract class Chromosome
    extends java.lang.Object
    The chromosome abstraction. Keeps the fitness and the chance to be selected by the roulette. Also has the methods to mutate and cross with another chromosome in an specific point.
    • Constructor Detail

      • Chromosome

        public Chromosome()
    • Method Detail

      • cross

        public abstract Chromosome[] cross​(Chromosome b,
                                           int position)
        Split the genes by position and swap lower portion of this with the lower portion of b and return the new individual
        Parameters:
        b - b
        position - position
        Returns:
        new individual
      • mutate

        public abstract Chromosome mutate​(double pm)
        Change one gene of the chromosome
        Parameters:
        pm - pm
        Returns:
        mutated Chromosome
      • getCopy

        public abstract Chromosome getCopy()
        Copy constructor
        Returns:
        copy of this Chromosome
      • getInstance

        public abstract Chromosome getInstance​(int length,
                                               java.util.Random random)
        Generic constructor
        Parameters:
        length - length
        Returns:
        Chromosome instance
      • getFitness

        public double getFitness()
        Returns:
        the fitness
      • setFitness

        public void setFitness​(double fitness)
        Parameters:
        fitness - The new fitness
      • getChance

        public double getChance()
        Returns:
        the chance to be selected
      • setChance

        public void setChance​(double chance)
        Parameters:
        chance - The new chance.
      • getFitnessReal

        public double getFitnessReal()
        Returns:
        the fitnessReal
      • setFitnessReal

        public void setFitnessReal​(double fitnessReal)
        Parameters:
        fitnessReal - The new fitnessReal.