Class NEATIndividual
- All Implemented Interfaces:
Prototype,Setup,Serializable,Cloneable,Comparable<Individual>
Parameters
| base.network Classname, = ec.neat.NEATNetwork |
Class of network in the individual |
Parameter bases
| base.network | network in the individual |
Default Base
neat.individual
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptiondoubleFitness after the adjustment.booleanMarks the subspecies champion, which is the individual who has the highest fitness with the subspecies.booleanMarker for destruction of inferior individual.doubleNumber of children this individual may have for next generation.intTells which generation this individual is from.doubledebug variable, highest fitness of championAll the node of this individual.booleanMarks the best individual in current generation of the population.booleanMarks the duplicate child of a champion (for tracking purposes).The individual's subpeciesintNumber of reserved offspring for a population leader.intWhen playing in real-time allows knowing the maturity of an individualFields inherited from class ec.vector.GeneVectorIndividual
genome, P_GENEVECTORINDIVIDUALFields inherited from class ec.Individual
evaluated, EVALUATED_PREAMBLE, fitness, P_INDIVIDUAL, species -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidWe append new gene(s) to the current genomeclone()Creates a new individual cloned from a prototype, and suitable to begin use in its own evolutionary context.voidcreateNodeCopyIfMissing(ArrayList<NEATNode> nodeList, NEATNode node) Create the node if the nodeList do not have that node.The nodes in the nodeList is guarantee in ascending order according to node's nodeId.crossover(EvolutionState state, int thread, NEATIndividual secondParent) Crossover function.Returns the default base for this prototype.voiddefaultMutate(EvolutionState state, int thread) Mutation function, determine which mutation is going to proceed with certain probabilities parameters.booleanReturns true if I am genetically "equal" to ind.This method is used to output a individual that is same as the format in start genome file.intGet the upperbound for the innovation number, used in Initializer.intGet the upperbound for the node id, used in Initializer.booleanTest if a genome has certain gene.inthashCode()Returns a hashcode for the individual, such that individuals which are equals(...) each other always return the same hash code.mateMultipoint(EvolutionState state, int thread, NEATIndividual secondParent, boolean averageFlag) Doing crossover from two parent at multiple points in the genome.mateSinglepoint(EvolutionState state, int thread, NEATIndividual secondParent) Deprecated.voidmutateAddLink(EvolutionState state, int thread) Try to add a new gene (link) into the current genome.voidmutateAddNode(EvolutionState state, int thread) Add a new node into this individual.voidReenable a gene if it's disabled.voidmutateLinkWeights(EvolutionState state, int thread, NEATSpecies species, double power, double rate, NEATSpecies.MutationType mutationType) Mutate the weights of the genesvoidmutateToggleEnable(EvolutionState state, int thread, int times) Randomly enable or disable a gene.protected voidparseGenotype(EvolutionState state, LineNumberReader reader) This method is used to read a gene in start genome from file.voidparseNodes(EvolutionState state, LineNumberReader reader) Create the nodes from the reader, and calls readNode method on each node.voidreset(EvolutionState state, int thread) Initializes an individual with minimal structure.voidReset the individual with given nodes and genomevoidsetGeneration(EvolutionState state) Set the born generation of this individual.voidsetup(EvolutionState state, Parameter base) This should be used to set up only those things which you share in common with all other individuals in your species; individual-specific items which make you you should be filled in by Species.newIndividual(...), and modified by breeders.toString()This method convert the individual in to human readable format.Methods inherited from class ec.vector.GeneVectorIndividual
cloneGenes, defaultCrossover, genomeLength, genotypeToStringForHumans, getGenome, join, readGenotype, setGenome, setGenomeLength, split, writeGenotypeMethods inherited from class ec.vector.VectorIndividual
reset, sizeMethods inherited from class ec.Individual
compareTo, distanceTo, merge, printIndividual, printIndividual, printIndividual, printIndividualForHumans, printIndividualForHumans, readIndividual, readIndividual, writeIndividual
-
Field Details
-
adjustedFitness
public double adjustedFitnessFitness after the adjustment. -
subspecies
The individual's subpecies -
expectedOffspring
public double expectedOffspringNumber of children this individual may have for next generation. -
generation
public int generationTells which generation this individual is from. -
eliminate
public boolean eliminateMarker for destruction of inferior individual. -
champion
public boolean championMarks the subspecies champion, which is the individual who has the highest fitness with the subspecies. -
superChampionOffspring
public int superChampionOffspringNumber of reserved offspring for a population leader. This is used for delta coding. -
popChampion
public boolean popChampionMarks the best individual in current generation of the population. -
popChampionChild
public boolean popChampionChildMarks the duplicate child of a champion (for tracking purposes). -
highFit
public double highFitdebug variable, highest fitness of champion -
timeAlive
public int timeAliveWhen playing in real-time allows knowing the maturity of an individual -
nodes
All the node of this individual. Nodes are arranged so that the first part of the nodes are SENSOR nodes.
-
-
Constructor Details
-
NEATIndividual
public NEATIndividual()
-
-
Method Details
-
setup
Description copied from class:IndividualThis should be used to set up only those things which you share in common with all other individuals in your species; individual-specific items which make you you should be filled in by Species.newIndividual(...), and modified by breeders. -
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- Overrides:
defaultBasein classGeneVectorIndividual
-
reset
Initializes an individual with minimal structure.- Overrides:
resetin classGeneVectorIndividual
-
reset
Reset the individual with given nodes and genome -
hashCode
public int hashCode()Description copied from class:IndividualReturns a hashcode for the individual, such that individuals which are equals(...) each other always return the same hash code.- Overrides:
hashCodein classGeneVectorIndividual
-
equals
Description copied from class:IndividualReturns true if I am genetically "equal" to ind. This should mostly be interpreted as saying that we are of the same class and that we hold the same data. It should NOT be a pointer comparison.- Overrides:
equalsin classGeneVectorIndividual
-
setGeneration
Set the born generation of this individual. -
getNodeIdSup
public int getNodeIdSup()Get the upperbound for the node id, used in Initializer. -
getGeneInnovationNumberSup
public int getGeneInnovationNumberSup()Get the upperbound for the innovation number, used in Initializer. -
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; }
- Specified by:
clonein interfacePrototype- Overrides:
clonein classGeneVectorIndividual
-
genotypeToString
This method is used to output a individual that is same as the format in start genome file.- Overrides:
genotypeToStringin classGeneVectorIndividual
-
parseGenotype
This method is used to read a gene in start genome from file. It will then calls the corresponding methods to parse genome and nodes respectively.- Overrides:
parseGenotypein classGeneVectorIndividual- Throws:
IOException
-
parseNodes
Create the nodes from the reader, and calls readNode method on each node.- Throws:
IOException
-
addGene
We append new gene(s) to the current genome -
mutateLinkWeights
public void mutateLinkWeights(EvolutionState state, int thread, NEATSpecies species, double power, double rate, NEATSpecies.MutationType mutationType) Mutate the weights of the genes -
mutateAddLink
Try to add a new gene (link) into the current genome. -
mutateAddNode
Add a new node into this individual. -
mutateToggleEnable
Randomly enable or disable a gene. -
mutateGeneReenable
public void mutateGeneReenable()Reenable a gene if it's disabled. -
defaultMutate
Mutation function, determine which mutation is going to proceed with certain probabilities parameters.- Overrides:
defaultMutatein classGeneVectorIndividual
-
crossover
Crossover function. Unlike defaultCrossover, this does not do destructive crossover. It will create a new individual as the crossover of the new parents. -
mateSinglepoint
@Deprecated public NEATIndividual mateSinglepoint(EvolutionState state, int thread, NEATIndividual secondParent) Deprecated. -
hasGene
Test if a genome has certain gene. -
createNodeCopyIfMissing
Create the node if the nodeList do not have that node.The nodes in the nodeList is guarantee in ascending order according to node's nodeId. -
mateMultipoint
public NEATIndividual mateMultipoint(EvolutionState state, int thread, NEATIndividual secondParent, boolean averageFlag) Doing crossover from two parent at multiple points in the genome. -
createNetwork
-
toString
This method convert the individual in to human readable format. It can be useful in debugging.- Overrides:
toStringin classIndividual
-