Class NEATGene
- All Implemented Interfaces:
Prototype,Setup,Serializable,Cloneable
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionbooleanIs the link this gene represent is enable in network activation.booleanIs this gene frozen, a frozen gene's weight cannot get mutated in breeding procedure.The actual in node this gene connect to.intThe id of the in node, this is useful in reading a gene from file, we will use this id to find the actual node after we finish reading the genome file.intThe innovation number of this link.booleanIs the link this gene represent a recurrent link.doubleThe mutation number of this gene, Used to see how much mutation has changed.The actual out node this gene connect to.intThe id of the in node, this is useful in reading a gene from file, we will use this id to find the actual node after we finish reading the genome file.static final StringbooleanTime delay of the link, used in network activation.doubleThe weight of link this gene is represent. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates a new individual cloned from a prototype, and suitable to begin use in its own evolutionary context.Returns the default base for this prototype.booleanUnlike the standard form for Java, this function should return true if this gene is "genetically identical" to the other gene.inthashCode()"Placeholder" method for generating a hashcode.This method is used to output a gene that is same as the format in start genome file.Prints the gene to a string in a human-readable fashion.voidreadGeneFromString(String string, EvolutionState state) This method is used to read a gene in start genome from file.voidreset(double w, int iNodeId, int oNodeId, boolean recur, int innov, double mutNum) Reset the gene with given parameters.voidreset(EvolutionState state, int thread) The reset method randomly reinitializes the gene.voidsetup(EvolutionState state, Parameter base) The setup method initializes a "meaningless" gene that does not specify any connection.toString()This method convert the gene in to human readable format.
-
Field Details
-
P_GENE
- See Also:
-
weight
public double weightThe weight of link this gene is represent. -
inNode
The actual in node this gene connect to. -
outNode
The actual out node this gene connect to. -
inNodeId
public int inNodeIdThe id of the in node, this is useful in reading a gene from file, we will use this id to find the actual node after we finish reading the genome file. -
outNodeId
public int outNodeIdThe id of the in node, this is useful in reading a gene from file, we will use this id to find the actual node after we finish reading the genome file. -
isRecurrent
public boolean isRecurrentIs the link this gene represent a recurrent link. -
timeDelay
public boolean timeDelayTime delay of the link, used in network activation. -
innovationNumber
public int innovationNumberThe innovation number of this link. -
mutationNumber
public double mutationNumberThe mutation number of this gene, Used to see how much mutation has changed. -
enable
public boolean enableIs the link this gene represent is enable in network activation. -
frozen
public boolean frozenIs this gene frozen, a frozen gene's weight cannot get mutated in breeding procedure.
-
-
Constructor Details
-
NEATGene
public NEATGene()
-
-
Method Details
-
setup
The setup method initializes a "meaningless" gene that does not specify any connection. -
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 classGene
-
reset
Description copied from class:GeneThe reset method randomly reinitializes the gene. -
reset
public void reset(double w, int iNodeId, int oNodeId, boolean recur, int innov, double mutNum) Reset the gene with given parameters. -
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; }
-
printGeneToStringForHumans
Description copied from class:GenePrints the gene to a string in a human-readable fashion. The default simply calls toString().- Overrides:
printGeneToStringForHumansin classGene
-
toString
This method convert the gene in to human readable format. It can be useful in debugging. -
printGeneToString
This method is used to output a gene that is same as the format in start genome file.- Overrides:
printGeneToStringin classGene
-
readGeneFromString
This method is used to read a gene in start genome from file. Example : i1|i4|d0|0.0|Fi1|d0|0.0|T have these parts : i1 i4 d0|0.0 F i1 d0|0.0 T which are: inNode outNode weight isRecurrent innovationNumber mutationNumber enable- Overrides:
readGeneFromStringin classGene
-
hashCode
public int hashCode()"Placeholder" method for generating a hashcode. The algorithm is stolen from GPIndividual and modified a bit to use NEATGene's variables. It is by no means "good" and is subject for improvement. -
equals
Description copied from class:GeneUnlike the standard form for Java, this function should return true if this gene is "genetically identical" to the other gene.
-