Package com.garrettAndPeter.lib
Class GeneticAlgorithm<Data,T>
- java.lang.Object
-
- com.garrettAndPeter.lib.GeneticAlgorithm<Data,T>
-
- Type Parameters:
Data
- The data that the organisms useT
- 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
-
-
Constructor Summary
Constructors Constructor Description GeneticAlgorithm(int populationSize, Generator<Organism<Data>> generator, T target)
Create a new Genetic Algorithm Simulation
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Organism
getBest()
returns the most fit organism out of the populationOrganism
getBest(T target)
returns the most fit organism out of the population based on a targetvoid
runGeneration()
The runGeneration will simulate one generation of Natural Selection on the given population and produce a new populationvoid
setReproduction(Reproduce r)
Specify the way the organisms produce offspring
-
-
-
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 generationgenerator
- On object that dictates how the organisms produce offspringtarget
- 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
-
-