Class GeneticAlgorithm<Data,​T>

  • Type Parameters:
    Data - The data that the organisms use
    T - The type of the target the organisms will be tested against

    public class GeneticAlgorithm<Data,​T>
    extends java.lang.Object
    A simulation of natural selection using a genetic algorithm The Genetic Algorithm class houses the interactions of all the different organisms within an "Environment". When a generation is run, a parent pool is generated, and a new population is created based on that parent pool
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Organism getBest()
      returns the most fit organism out of the population
      Organism getBest​(T target)
      returns the most fit organism out of the population based on a target
      void runGeneration()
      The runGeneration will simulate one generation of Natural Selection on the given population and produce a new population
      void setReproduction​(Reproduce r)
      Specify the way the organisms produce offspring
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • GeneticAlgorithm

        public GeneticAlgorithm​(int populationSize,
                                Generator<Organism<Data>> generator,
                                T target)
        Create a new Genetic Algorithm Simulation
        Parameters:
        populationSize - Number of members in each generation
        generator - On object that dictates how the organisms produce offspring
        target - The goal of the organisms. (used in determining fitness)
    • Method Detail

      • getBest

        public Organism getBest​(T target)
        returns the most fit organism out of the population based on a target
      • getBest

        public Organism getBest()
        returns the most fit organism out of the population
      • runGeneration

        public void runGeneration()
        The runGeneration will simulate one generation of Natural Selection on the given population and produce a new population
      • setReproduction

        public void setReproduction​(Reproduce r)
        Specify the way the organisms produce offspring