package jcgp.population; import jcgp.Parameters; import jcgp.Utilities; import jcgp.function.Function; public class Node implements MutableElement, Connection { private Function function; private Connection[] connections; private int column, row; public Node(int row, int column) { this.column = column; this.row = row; } @Override public int getValue() { return function.run(connections); } public void setFunction(Function newFunction) { function = newFunction; } @Override public void setConnection(Connection newConnection) { connections[Utilities.getRandomInt(connections.length)] = newConnection; } public void initialise(Function newFunction, Connection ... newConnections) throws InsufficientConnectionsException { function = newFunction; if (newConnections.length >= Parameters.getMaxArity()) { connections = newConnections; } else { throw new InsufficientConnectionsException(); } } @Override public int getColumn() { return column; } @Override public int getRow() { return row; } }