Package com.garrettAndPeter.lib
Class Organism<Data>
- java.lang.Object
-
- com.garrettAndPeter.lib.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 Summary
Constructors Constructor Description Organism(Generator<Data> g)
Create a new (First generation) organism based of a generatorOrganism(Organism<Data> a, Organism<Data> b, Reproduce<Organism<Data>> r)
Create a new organism based of its two parents and their specifications for producing offspringOrganism(Data d)
Create a copy of an organism using another organisms data
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract <T> double
calculateFitness(T target)
Calculate how fit (how likely it is for this organism to reproduce) based on a target.<T> void
generateFitness(T target)
calculate and store the fitness of the organismData
getData()
double
getFitness()
-
-
-
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
-
-