public class NEATNode extends java.lang.Object implements Prototype
Modifier and Type | Class and Description |
---|---|
static class |
NEATNode.FunctionType
The activation function is used in for hidden node.
|
static class |
NEATNode.NodePlace
The place this node could be.
|
static class |
NEATNode.NodeType
The type of a node.
|
Modifier and Type | Field and Description |
---|---|
double |
activation
The total activation entering the node.
|
int |
activationCount
Keeps track of which activation the node is currently in.
|
boolean |
activeFlag
To make sure outputs are active.
|
double |
activeSum
The incoming activity before being processed.
|
boolean |
frozen
When it's true, the node cannot be mutated.
|
NEATNode.FunctionType |
functionType
The activation function, use sigmoid for default, but can use some other
choice, like ReLU.
|
NEATNode.NodePlace |
geneticNodeLabel
Distinguish the input node, hidden or output node.
|
java.util.ArrayList<NEATGene> |
incomingGenes
A list of incoming links, it is used to get activation status of the
nodes on the other ends.
|
int |
innerLevel
The depth of current node in current network, this field is used in
counting max depth in a network.
|
boolean |
isTraversed
Indicate if this node has been traversed in max depth counting.
|
double |
lastActivation
Holds the previous step's activation for recurrence.
|
int |
nodeId
Node id for this node.
|
boolean |
override
Indicates if the value of current node has been override by method other
than network's activation.
|
double |
overrideValue
Contains the activation value that will override this node's activation.
|
static java.lang.String |
P_NODE |
double |
previousLastActivation
Holds 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.
|
NEATNode.NodeType |
type
Distinguish the Sensor node or other neuron node.
|
Constructor and Description |
---|
NEATNode() |
Modifier and Type | Method and Description |
---|---|
void |
activateWithOverride()
Set activation to the override value and turn off override.
|
void |
clearIncoming()
Clear in incomgin links of this node, this is useful in create a new
network from current genotype.
|
java.lang.Object |
clone()
Creates a new individual cloned from a prototype,
and suitable to begin use in its own evolutionary
context.
|
Parameter |
defaultBase()
Returns the default base for this prototype.
|
int |
depth(int d,
NEATNetwork network,
int maxDepth)
Return the depth of this node in the network.
|
java.lang.Object |
emptyClone()
Return a clone of this node, but with a empty incomingGenes list.
|
boolean |
equals(java.lang.Object obj) |
void |
flush()
Put all the field into initial status, this is useful in flushing the
whole network.
|
void |
flushBack()
Old flush code, used in C++ version.
|
double |
getActivation()
Return the activation status of this node.
|
double |
getTimeDelayActivation()
Return the last step activation if this node is active at last step.
|
int |
hashCode() |
void |
overrideOutput(double newOutput)
Force an output value on the node.
|
java.lang.String |
printNodeToString()
This method is used to output a gene that is same as the format in start
genome file.
|
void |
readNode(EvolutionState state,
java.io.LineNumberReader reader)
Reads a Node printed by printNode(...).
|
void |
readNodeFromString(java.lang.String string,
EvolutionState state)
This method is used to read a node in start genome from file.
|
void |
reset(NEATNode.NodeType nodeType,
int id,
NEATNode.NodePlace placement)
Reset the node to initial status.
|
boolean |
sensorLoad(double val)
If this node is a sensor node, load this node with the given input
|
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 |
sigmoid(double slope)
The Sigmoid function.
|
java.lang.String |
toString()
This method convert the gene in to human readable format.
|
public static final java.lang.String P_NODE
public int activationCount
public double lastActivation
public double previousLastActivation
public boolean override
public double overrideValue
public boolean frozen
public NEATNode.FunctionType functionType
public NEATNode.NodeType type
public NEATNode.NodePlace geneticNodeLabel
public double activeSum
public double activation
public boolean activeFlag
public java.util.ArrayList<NEATGene> incomingGenes
public int nodeId
public int innerLevel
public boolean isTraversed
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 Parameter defaultBase()
Prototype
defaultBase
in interface Prototype
public void reset(NEATNode.NodeType nodeType, int id, NEATNode.NodePlace placement)
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 boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public void flushBack()
public void flush()
public double getActivation()
public double getTimeDelayActivation()
public void activateWithOverride()
public void overrideOutput(double newOutput)
public void clearIncoming()
public int depth(int d, NEATNetwork network, int maxDepth)
public void readNode(EvolutionState state, java.io.LineNumberReader reader) throws java.io.IOException
java.io.IOException
public void readNodeFromString(java.lang.String string, EvolutionState state)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String printNodeToString()
public void sigmoid(double slope)
public boolean sensorLoad(double val)