public class Node extends java.lang.Object implements MutableElement, Connection
MutableElement
and Connection
since they can be mutated but also connected to.
Nodes are constructed with a fixed number of connections
(determined by the maximum arity of the function set)
and must be reinstantiated if the experiment arity
changes.Constructor and Description |
---|
Node(Chromosome chromosome,
int row,
int column,
int arity)
Constructs a new instance of
Node with the
specified parameters. |
Modifier and Type | Method and Description |
---|---|
boolean |
copyOf(MutableElement element)
Asserts if the specified element is a copy of the elements
this is called on.
This method returns true if and only if: the elements being compared are not the same instance; the connections of the compared elements are not the same instance; the elements have the same function (in the case of Node); the grid position of the elements themselves are the same; the grid position of all equivalent connections are the same; The relationship computed by this method is: symmetric: a.copyOf(b) == b.copyOf(a); not reflexive: a.copyOf(a) returns false; not transitive: if a.copyOf(b) is true and b.copyOf(c) is true, a.copyOf(c) is not necessarily true since it is possible that a == c. |
int |
getColumn() |
Connection |
getConnection(int index) |
Function |
getFunction() |
int |
getRow() |
java.lang.Object |
getValue()
Compute and return the value of this connection.
|
void |
initialise(Function newFunction,
Connection... newConnections)
Initialises the node with the specified values.
|
void |
setConnection(int index,
Connection newConnection)
This method sets the indexed connection to the specified new connection.
|
void |
setFunction(Function newFunction)
Sets the node function.
|
java.lang.String |
toString() |
public Node(Chromosome chromosome, int row, int column, int arity)
Node
with the
specified parameters. Nodes must contain their
own row and column for ease of copying.chromosome
- the chromosome this node belongs to.row
- the node's row.column
- the node's column.arity
- the maximum arity of the experiment.public void setFunction(Function newFunction)
newFunction
- the new function to set.public void initialise(Function newFunction, Connection... newConnections)
IllegalArgumentException
will be thrown.newFunction
- the node function to set.newConnections
- the node connections to set.public int getColumn()
public int getRow()
public Function getFunction()
public Connection getConnection(int index)
index
- the connection to return.public boolean copyOf(MutableElement element)
MutableElement
copyOf
in interface MutableElement
element
- the mutable element to compare to.element
is a copy of this element.public java.lang.Object getValue()
Connection
getValue
in interface Connection
public void setConnection(int index, Connection newConnection)
MutableElement
setConnection
in interface MutableElement
index
- the connection index to set.newConnection
- the chromosome element to connect to.public java.lang.String toString()
toString
in class java.lang.Object