package jcgp.population; import jcgp.CGP.Utilities; import jcgp.function.Function; public class Node implements MutableElement, Connection { private Function function; private Connection[] connections; @Override public int evaluate() { 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 >= Utilities.getMaxArity()) { connections = newConnections; } else { throw new InsufficientConnectionsException(); } } }