diff options
Diffstat (limited to 'src/jcgp/backend/population')
-rw-r--r-- | src/jcgp/backend/population/Node.java | 8 | ||||
-rw-r--r-- | src/jcgp/backend/population/Population.java | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/jcgp/backend/population/Node.java b/src/jcgp/backend/population/Node.java index 6a558a4..b716ff8 100644 --- a/src/jcgp/backend/population/Node.java +++ b/src/jcgp/backend/population/Node.java @@ -31,8 +31,12 @@ public class Node extends Gene implements MutableElement, Connection { @Override public void setConnection(int index, Connection newConnection) { - connections[index] = newConnection; - chromosome.recomputeActiveNodes(); + if (newConnection instanceof Node) { + if (((Node) newConnection).getColumn() < column) { + connections[index] = newConnection; + chromosome.recomputeActiveNodes(); + } + } } public void initialise(Function newFunction, Connection ... newConnections) throws InsufficientConnectionsException { diff --git a/src/jcgp/backend/population/Population.java b/src/jcgp/backend/population/Population.java index 1bbdc54..b6dd055 100644 --- a/src/jcgp/backend/population/Population.java +++ b/src/jcgp/backend/population/Population.java @@ -4,7 +4,7 @@ import jcgp.backend.resources.Resources; public class Population { - private Chromosome[] chromosomes; + private final Chromosome[] chromosomes; private final Resources resources; private int fittest = 0; |