Class NEATSubspecies
- All Implemented Interfaces:
Prototype,Setup,Serializable,Cloneable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionintAge of the current subspecies.intRecord the last time the best fitness improved within the individuals of this subspecies If this is too long ago, the subspecies will goes extinctintExpected Offspring for next generation for this subspeciesThe individuals within this speciesdoubleThe max fitness the an individual in this subspecies ever achieved.The next generation individuals within this speciesstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNewGenIndividual(NEATIndividual neatInd) Add the individual to the next generation of this subspeciesvoidadjustFitness(EvolutionState state, int dropoffAge, double ageSignificance) Adjust the fitness of the individuals within this subspecies.clone()Creates a new individual cloned from a prototype, and suitable to begin use in its own evolutionary context.doublecountOffspring(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.Returns the default base for this prototype.Return a clone of this subspecies, but with a empty individuals and newGenIndividuals list.first()Return the first individual in this subspeciesbooleanTest if newGenIndividuals list is empty.voidmarkReproducableIndividuals(double survivalThreshold) Mark the individual who can reproduce for this generation.Return the first individual in newGenIndividuals list.voidRemove the individuals from current subspecies who have been mark as eliminate the remain individuals will be allow to reproducebooleanreproduce(EvolutionState state, int thread, int subpop, 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.voidreset()Reset the status of the current subspecies.voidsetup(EvolutionState state, Parameter base) Sets up the object by reading it from the parameters stored in state, built off of the parameter base base.voidSort the individuals in this subspecies, the one with highest fitness comes first.intCompute generations gap since last improvementvoidAfter we finish the reproduce, the newGenIndividual list has the all the individuals that is ready for evalution in next generation.voidUpdate the maxFitnessEver variable.
-
Field Details
-
P_SUBSPECIES
- See Also:
-
age
public int ageAge of the current subspecies. -
ageOfLastImprovement
public int ageOfLastImprovementRecord the last time the best fitness improved within the individuals of this subspecies If this is too long ago, the subspecies will goes extinct -
maxFitnessEver
public double maxFitnessEverThe max fitness the an individual in this subspecies ever achieved. -
individuals
The individuals within this species -
newGenIndividuals
The next generation individuals within this species -
expectedOffspring
public int expectedOffspringExpected Offspring for next generation for this subspecies
-
-
Constructor Details
-
NEATSubspecies
public NEATSubspecies()
-
-
Method Details
-
setup
Description copied from interface:PrototypeSets up the object by reading it from the parameters stored in state, built off of the parameter base base. If an ancestor implements this method, be sure to call super.setup(state,base); before you do anything else.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.
-
emptyClone
Return a clone of this subspecies, but with a empty individuals and newGenIndividuals list. -
clone
Description copied from interface:PrototypeCreates a new individual cloned from a prototype, and suitable to begin use in its own evolutionary context.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:
- If you hold objects which are shared with other instances, don't clone them.
- If you hold objects which must be unique, clone them.
- If you hold objects which were given to you as a gesture of kindness, and aren't owned by you, you probably shouldn't clone them.
- DON'T attempt to clone: Singletons, Cliques, or Populations, or Subpopulation.
- Arrays are not cloned automatically; you may need to clone an array if you're not sharing it with other instances. Arrays have the nice feature of being copyable by calling clone() on them.
Implementations.
- If no ancestor of yours implements clone(), and you have no need to do clone deeply, and you are abstract, then you should not declare clone().
- If no ancestor of yours implements clone(),
and you have no need to do clone deeply,
and you are not abstract, then you should implement
it as follows:
public Object clone() { try { return super.clone(); } catch ((CloneNotSupportedException e) { throw new InternalError(); } // never happens } - If no ancestor of yours implements clone(), but you
need to deep-clone some things, then you should implement it
as follows:
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; } - If an ancestor has implemented clone(), and you also need
to deep clone some things, then you should implement it as follows:
public Object clone() { MyObject myobj = (MyObject) (super.clone()); // put your deep-cloning code here... return myobj; }
-
reset
public void reset()Reset the status of the current subspecies. -
first
Return the first individual in this subspecies -
newGenerationFirst
Return the first individual in newGenIndividuals list. -
defaultBase
Description copied from interface:PrototypeReturns the default base for this prototype. This should generally be implemented by building off of the static base() method on the DefaultsForm object for the prototype's package. This should be callable during setup(...).- Specified by:
defaultBasein interfacePrototype
-
adjustFitness
Adjust the fitness of the individuals within this subspecies. We will use the adjusted fitness to determine the expected offsprings within each subspecies. -
sortIndividuals
public void sortIndividuals()Sort the individuals in this subspecies, the one with highest fitness comes first. -
updateSubspeciesMaxFitness
public void updateSubspeciesMaxFitness()Update the maxFitnessEver variable. -
markReproducableIndividuals
public void markReproducableIndividuals(double survivalThreshold) Mark the individual who can reproduce for this generation. -
hasNewGeneration
public boolean hasNewGeneration()Test if newGenIndividuals list is empty. -
countOffspring
public 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. These fractional parts are kept until they add up to 1 -
reproduce
public boolean reproduce(EvolutionState state, int thread, int subpop, 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. -
timeSinceLastImproved
public int timeSinceLastImproved()Compute generations gap since last improvement -
addNewGenIndividual
Add the individual to the next generation of this subspecies -
removePoorFitnessIndividuals
public void removePoorFitnessIndividuals()Remove the individuals from current subspecies who have been mark as eliminate the remain individuals will be allow to reproduce -
toNewGeneration
public void toNewGeneration()After we finish the reproduce, the newGenIndividual list has the all the individuals that is ready for evalution in next generation. Let's switch to it.
-