public class NEATSubspecies extends java.lang.Object implements Prototype
Modifier and Type | Field and Description |
---|---|
int |
age
Age of the current subspecies.
|
int |
ageOfLastImprovement
Record the last time the best fitness improved within the individuals of
this subspecies If this is too long ago, the subspecies will goes extinct
|
int |
expectedOffspring
Expected Offspring for next generation for this subspecies
|
java.util.ArrayList<Individual> |
individuals
The individuals within this species
|
double |
maxFitnessEver
The max fitness the an individual in this subspecies ever achieved.
|
java.util.ArrayList<Individual> |
newGenIndividuals
The next generation individuals within this species
|
static java.lang.String |
P_SUBSPECIES |
Constructor and Description |
---|
NEATSubspecies() |
Modifier and Type | Method and Description |
---|---|
void |
addNewGenIndividual(NEATIndividual neatInd)
Add the individual to the next generation of this subspecies
|
void |
adjustFitness(EvolutionState state,
int dropoffAge,
double ageSignificance)
Adjust the fitness of the individuals within this subspecies.
|
java.lang.Object |
clone()
Creates a new individual cloned from a prototype,
and suitable to begin use in its own evolutionary
context.
|
double |
countOffspring(double skim)
Compute the collective offspring the entire species (the sum of all
individual's offspring) is assigned skim is fractional offspring left
over from a previous subspecies that was counted.
|
Parameter |
defaultBase()
Returns the default base for this prototype.
|
java.lang.Object |
emptyClone()
Return a clone of this subspecies, but with a empty individuals and
newGenIndividuals list.
|
Individual |
first()
Return the first individual in this subspecies
|
boolean |
hasNewGeneration()
Test if newGenIndividuals list is empty.
|
void |
markReproducableIndividuals(double survivalThreshold)
Mark the individual who can reproduce for this generation.
|
Individual |
newGenerationFirst()
Return the first individual in newGenIndividuals list.
|
void |
removePoorFitnessIndividuals()
Remove the individuals from current subspecies who have been mark as
eliminate the remain individuals will be allow to reproduce
|
boolean |
reproduce(EvolutionState state,
int thread,
int subpop,
java.util.ArrayList<NEATSubspecies> sortedSubspecies)
Where the actual reproduce is happening, it will grab the candidate
parents, and calls the crossover or mutation method on these parents
individuals.
|
void |
reset()
Reset the status of the current subspecies.
|
void |
setup(EvolutionState state,
Parameter base)
Sets up the object by reading it from the parameters stored
in state, built off of the parameter base base.
|
void |
sortIndividuals()
Sort the individuals in this subspecies, the one with highest fitness
comes first.
|
int |
timeSinceLastImproved()
Compute generations gap since last improvement
|
void |
toNewGeneration()
After we finish the reproduce, the newGenIndividual list has the all the
individuals that is ready for evalution in next generation.
|
void |
updateSubspeciesMaxFitness()
Update the maxFitnessEver variable.
|
public static final java.lang.String P_SUBSPECIES
public int age
public int ageOfLastImprovement
public double maxFitnessEver
public java.util.ArrayList<Individual> individuals
public java.util.ArrayList<Individual> newGenIndividuals
public int expectedOffspring
public void setup(EvolutionState state, Parameter base)
Prototype
For prototypes, setup(...) is typically called once for the prototype instance; cloned instances do not receive the setup(...) call. setup(...) may be called more than once; the only guarantee is that it will get called at least once on an instance or some "parent" object from which it was ultimately cloned.
public java.lang.Object emptyClone()
public java.lang.Object clone()
Prototype
Typically this should be a full "deep" clone. However, you may share certain elements with other objects rather than clone hem, depending on the situation:
Implementations.
public Object clone()
{
try
{
return super.clone();
}
catch ((CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
}
public Object clone()
{
try
{
MyObject myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
}
catch ((CloneNotSupportedException e)
{ throw new InternalError(); } // never happens
return myobj;
}
public Object clone()
{
MyObject myobj = (MyObject) (super.clone());
// put your deep-cloning code here...
return myobj;
}
public void reset()
public Individual first()
public Individual newGenerationFirst()
public Parameter defaultBase()
Prototype
defaultBase
in interface Prototype
public void adjustFitness(EvolutionState state, int dropoffAge, double ageSignificance)
public void sortIndividuals()
public void updateSubspeciesMaxFitness()
public void markReproducableIndividuals(double survivalThreshold)
public boolean hasNewGeneration()
public double countOffspring(double skim)
public boolean reproduce(EvolutionState state, int thread, int subpop, java.util.ArrayList<NEATSubspecies> sortedSubspecies)
public int timeSinceLastImproved()
public void addNewGenIndividual(NEATIndividual neatInd)
public void removePoorFitnessIndividuals()
public void toNewGeneration()