diff options
Diffstat (limited to 'src/jcgp/population/Node.java')
-rw-r--r-- | src/jcgp/population/Node.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/jcgp/population/Node.java b/src/jcgp/population/Node.java index 3dbabb2..40ffa52 100644 --- a/src/jcgp/population/Node.java +++ b/src/jcgp/population/Node.java @@ -10,8 +10,10 @@ public class Node implements MutableElement, Connection { private Function function; private Connection[] connections; private int column, row; + private Chromosome chromosome; - public Node(int row, int column) { + public Node(Chromosome chromosome, int row, int column) { + this.chromosome = chromosome; this.column = column; this.row = row; } @@ -23,11 +25,13 @@ public class Node implements MutableElement, Connection { public void setFunction(Function newFunction) { function = newFunction; + chromosome.recomputeActiveNodes(); } @Override public void setConnection(Connection newConnection) { connections[Utilities.getRandomInt(connections.length)] = newConnection; + chromosome.recomputeActiveNodes(); } public void initialise(Function newFunction, Connection ... newConnections) throws InsufficientConnectionsException { @@ -41,14 +45,20 @@ public class Node implements MutableElement, Connection { } } - @Override public int getColumn() { return column; } - @Override public int getRow() { return row; } + + public Function getFunction() { + return function; + } + + public Connection getConnections(int index) { + return connections[index]; + } } |