Class NEATNode
- All Implemented Interfaces:
Prototype,Setup,Serializable,Cloneable
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe activation function is used in for hidden node.static enumThe place this node could be.static enumThe type of a node. -
Field Summary
FieldsModifier and TypeFieldDescriptiondoubleThe total activation entering the node.intKeeps track of which activation the node is currently in.booleanTo make sure outputs are active.doubleThe incoming activity before being processed.booleanWhen it's true, the node cannot be mutated.The activation function, use sigmoid for default, but can use some other choice, like ReLU.Distinguish the input node, hidden or output node.A list of incoming links, it is used to get activation status of the nodes on the other ends.intThe depth of current node in current network, this field is used in counting max depth in a network.booleanIndicate if this node has been traversed in max depth counting.doubleHolds the previous step's activation for recurrence.intNode id for this node.booleanIndicates if the value of current node has been override by method other than network's activation.doubleContains the activation value that will override this node's activation.static final StringdoubleHolds the activation BEFORE the previous step's This is necessary for a special recurrent case when the inNode of a recurrent link is one time step ahead of the outNode.Distinguish the Sensor node or other neuron node. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidSet activation to the override value and turn off override.voidClear in incomgin links of this node, this is useful in create a new network from current genotype.clone()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.intdepth(int d, NEATNetwork network, int maxDepth) Return the depth of this node in the network.Return a clone of this node, but with a empty incomingGenes list.booleanvoidflush()Put all the field into initial status, this is useful in flushing the whole network.voidOld flush code, used in C++ version.doubleReturn the activation status of this node.doubleReturn the last step activation if this node is active at last step.inthashCode()voidoverrideOutput(double newOutput) Force an output value on the node.This method is used to output a gene that is same as the format in start genome file.voidreadNode(EvolutionState state, LineNumberReader reader) Reads a Node printed by printNode(...).voidreadNodeFromString(String string, EvolutionState state) This method is used to read a node in start genome from file.voidreset(NEATNode.NodeType nodeType, int id, NEATNode.NodePlace placement) Reset the node to initial status.booleansensorLoad(double val) If this node is a sensor node, load this node with the given inputvoidsetup(EvolutionState state, Parameter base) Sets up the object by reading it from the parameters stored in state, built off of the parameter base base.voidsigmoid(double slope) The Sigmoid function.toString()This method convert the gene in to human readable format.
-
Field Details
-
P_NODE
- See Also:
-
activationCount
public int activationCountKeeps track of which activation the node is currently in. -
lastActivation
public double lastActivationHolds the previous step's activation for recurrence. -
previousLastActivation
public double previousLastActivationHolds the activation BEFORE the previous step's This is necessary for a special recurrent case when the inNode of a recurrent link is one time step ahead of the outNode. The innode then needs to send from TWO time steps ago. -
override
public boolean overrideIndicates if the value of current node has been override by method other than network's activation. -
overrideValue
public double overrideValueContains the activation value that will override this node's activation. -
frozen
public boolean frozenWhen it's true, the node cannot be mutated. -
functionType
The activation function, use sigmoid for default, but can use some other choice, like ReLU. -
type
Distinguish the Sensor node or other neuron node. -
geneticNodeLabel
Distinguish the input node, hidden or output node. -
activeSum
public double activeSumThe incoming activity before being processed. -
activation
public double activationThe total activation entering the node. -
activeFlag
public boolean activeFlagTo make sure outputs are active. -
incomingGenes
A list of incoming links, it is used to get activation status of the nodes on the other ends. -
nodeId
public int nodeIdNode id for this node. -
innerLevel
public int innerLevelThe depth of current node in current network, this field is used in counting max depth in a network. -
isTraversed
public boolean isTraversedIndicate if this node has been traversed in max depth counting.
-
-
Constructor Details
-
NEATNode
public NEATNode()
-
-
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.
-
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
-
reset
Reset the node to initial status. -
emptyClone
Return a clone of this node, but with a empty incomingGenes 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; }
-
equals
-
hashCode
public int hashCode() -
flushBack
public void flushBack()Old flush code, used in C++ version. Put all the field into initial status, this is useful in flushing the whole network. -
flush
public void flush()Put all the field into initial status, this is useful in flushing the whole network. -
getActivation
public double getActivation()Return the activation status of this node. -
getTimeDelayActivation
public double getTimeDelayActivation()Return the last step activation if this node is active at last step. -
activateWithOverride
public void activateWithOverride()Set activation to the override value and turn off override. -
overrideOutput
public void overrideOutput(double newOutput) Force an output value on the node. -
clearIncoming
public void clearIncoming()Clear in incomgin links of this node, this is useful in create a new network from current genotype. -
depth
Return the depth of this node in the network. -
readNode
Reads a Node printed by printNode(...). The default form simply reads a line into a string, and then calls readNodeFromString() on that line.- Throws:
IOException
-
readNodeFromString
This method is used to read a node in start genome from file. -
toString
This method convert the gene in to human readable format. It can be useful in debugging. -
printNodeToString
This method is used to output a gene that is same as the format in start genome file. -
sigmoid
public void sigmoid(double slope) The Sigmoid function. -
sensorLoad
public boolean sensorLoad(double val) If this node is a sensor node, load this node with the given input
-