From 6769419bea279935c4a3a84616d45ee7d4a6345c Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Tue, 22 Apr 2014 08:48:11 +0100 Subject: Chromosome parser is buggy, need to fix that. --- src/jcgp/backend/population/Node.java | 8 ++++++-- src/jcgp/backend/population/Population.java | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'src/jcgp/backend/population') 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; -- cgit v1.2.3