public class Node extends java.lang.Object implements Mutable, Connection
Mutable
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.
mutate()
.
Alternatively, you may also perform a specific mutation using
setConnection(...)
and setFunction(...)
.Constructor and Description |
---|
Node(Chromosome chromosome,
int row,
int column)
Constructs a new instance of
Node with the
specified parameters. |
Modifier and Type | Method and Description |
---|---|
boolean |
copyOf(Mutable 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 |
mutate()
This method performs an arbitrary mutation on the
Mutable . |
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)
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.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 void setFunction(Function newFunction)
newFunction
- the new function to set.public Connection getConnection(int index)
index
- the connection to return.public void setConnection(int index, Connection newConnection)
index
- the connection index to set.newConnection
- the Connection
to connect to.public boolean copyOf(Mutable element)
Mutable
public java.lang.Object getValue()
Connection
getValue
in interface Connection
public void mutate()
Mutable
Mutable
.
public java.lang.String toString()
toString
in class java.lang.Object