From dd3b6446671f31d716eb07e546c6150b4d080abd Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Tue, 11 Feb 2014 16:50:27 +0000 Subject: Implemented more tests, refactored chromosome more, added the beginnings of active node detection --- src/jcgp/population/Node.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/jcgp/population/Node.java') 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]; + } } -- cgit v1.2.3