Package org.jppf.ga

Class AbstractChromosome

java.lang.Object
org.jppf.ga.AbstractChromosome
All Implemented Interfaces:
Serializable, Comparable<Chromosome>, Chromosome

public abstract class AbstractChromosome extends Object implements Chromosome
Common abstract super class for chromosme implementations.
Author:
Laurent Cohen
See Also:
  • Field Details

    • fitness

      protected double fitness
      The fitness of this chromosme.
    • genes

      protected Gene[] genes
      The genes of this chromosome.
    • size

      protected int size
      The size (number of genes) of this chromosome.
    • random

      protected Random random
      A random number generator.
  • Constructor Details

    • AbstractChromosome

      public AbstractChromosome()
  • Method Details

    • getFitness

      public double getFitness()
      Description copied from interface: Chromosome
      Get the fitness of this chromosome.
      Specified by:
      getFitness in interface Chromosome
      Returns:
      the fitness as a double value.
    • setFitness

      public void setFitness(double fitness)
      Description copied from interface: Chromosome
      Set the fitness of this chromosome.
      Specified by:
      setFitness in interface Chromosome
      Parameters:
      fitness - the fitness as a double value.
    • getGenes

      public Gene[] getGenes()
      Description copied from interface: Chromosome
      Get the genes of this chromosome.
      Specified by:
      getGenes in interface Chromosome
      Returns:
      an array of Gene instances.
    • setGenes

      public void setGenes(Gene[] genes)
      Set the genes of this chromosome.
      Parameters:
      genes - the array of genes to set.
    • getSize

      public int getSize()
      Description copied from interface: Chromosome
      Get the number of genes.
      Specified by:
      getSize in interface Chromosome
      Returns:
      the number of genes as an int.
    • compareTo

      public int compareTo(Chromosome other)
      Specified by:
      compareTo in interface Comparable<Chromosome>
    • isValid

      public boolean isValid()
      Specified by:
      isValid in interface Chromosome
      Returns:
      whether this chromosome is valid.