Class Organism<Data>

  • Type Parameters:
    Data - The type of data (DNA) the Organisms contain
    Direct Known Subclasses:
    StringOrganism

    public abstract class Organism<Data>
    extends java.lang.Object
    The main actors within a genetic algorithm Organisms interact and produce offspring with other organisms in order to improve the species
    • Constructor Detail

      • Organism

        public Organism​(Data d)
        Create a copy of an organism using another organisms data
      • Organism

        public Organism​(Generator<Data> g)
        Create a new (First generation) organism based of a generator
    • Method Detail

      • getData

        public Data getData()
        Returns:
        the data or genetic code of the organism
      • calculateFitness

        public abstract <T> double calculateFitness​(T target)
        Calculate how fit (how likely it is for this organism to reproduce) based on a target. organisms closer to a target should have higher fitness values
      • generateFitness

        public <T> void generateFitness​(T target)
        calculate and store the fitness of the organism
      • getFitness

        public double getFitness()
        Returns:
        the fitness (How likely the organism is to reproduce) of the organism