diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-02-11 16:50:27 +0000 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-02-11 16:50:27 +0000 |
commit | dd3b6446671f31d716eb07e546c6150b4d080abd (patch) | |
tree | b30c1ac7599bce9a17f1ea621eecc427256e1486 /src/jcgp/population/Node.java | |
parent | 3fc4bf4a2ea7c6cff9810b76964dd3c1388c0b3f (diff) |
Implemented more tests, refactored chromosome more, added the beginnings of active node detection
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]; + } } |