aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/population/Node.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/backend/population/Node.java')
-rw-r--r--src/jcgp/backend/population/Node.java57
1 files changed, 27 insertions, 30 deletions
diff --git a/src/jcgp/backend/population/Node.java b/src/jcgp/backend/population/Node.java
index 7712c50..6696694 100644
--- a/src/jcgp/backend/population/Node.java
+++ b/src/jcgp/backend/population/Node.java
@@ -40,24 +40,14 @@ public class Node implements Mutable, Connection {
* @param chromosome the chromosome this node belongs to.
* @param row the node's row.
* @param column the node's column.
- * @param arity the maximum arity of the experiment.
*/
- public Node(Chromosome chromosome, int row, int column, int arity) {
+ public Node(Chromosome chromosome, int row, int column) {
this.chromosome = chromosome;
this.column = column;
this.row = row;
}
/**
- * Sets the node function.
- *
- * @param newFunction the new function to set.
- */
- public void setFunction(Function newFunction) {
- function = newFunction;
- }
-
- /**
* Initialises the node with the specified values.
* The number of connections passed as argument must
* be exactly the same as the experiment arity, or
@@ -66,7 +56,7 @@ public class Node implements Mutable, Connection {
* @param newFunction the node function to set.
* @param newConnections the node connections to set.
*/
- public void initialise(Function newFunction, Connection ... newConnections) {
+ public void initialise(Function newFunction, Connection... newConnections) {
function = newFunction;
if (newConnections.length == chromosome.getResources().arity()) {
connections = newConnections;
@@ -97,12 +87,37 @@ public class Node implements Mutable, Connection {
}
/**
+ * Sets the node function.
+ *
+ * @param newFunction the new function to set.
+ */
+ public void setFunction(Function newFunction) {
+ function = newFunction;
+ }
+
+ /**
* @param index the connection to return.
* @return the indexed connection.
*/
public Connection getConnection(int index) {
return connections[index];
}
+
+ /**
+ * This method sets the indexed connection to the specified new connection.
+ * If the given connection is null or disrespects levels back, it is discarded
+ * and no connections are changed.
+ *
+ * @param index the connection index to set.
+ * @param newConnection the {@code Connection} to connect to.
+ */
+ public void setConnection(int index, Connection newConnection) {
+ // connection must not be null
+ if (newConnection != null) {
+ connections[index] = newConnection;
+ chromosome.recomputeActiveNodes();
+ }
+ }
/**
* For package use, this is a recursive method
@@ -127,24 +142,6 @@ public class Node implements Mutable, Connection {
}
}
}
-
- /**
- * This method sets the indexed connection to the specified new connection.
- * If the given connection is null or disrespects levels back, it is discarded
- * and no connections are changed.
- *
- * @param index the connection index to set.
- * @param newConnection the {@code Connection} to connect to.
- */
- public void setConnection(int index, Connection newConnection) {
- // connection must not be null
- if (newConnection != null) {
- //if () {
- connections[index] = newConnection;
- chromosome.recomputeActiveNodes();
- //}
- }
- }
@Override
public boolean copyOf(Mutable element) {