From e7d7e8506a511d78f9e323ac09587f79ad503f42 Mon Sep 17 00:00:00 2001 From: Eduardo Pedroni Date: Sun, 13 Apr 2014 10:41:25 +0100 Subject: Performance suddenly decreased, looking into why --- src/jcgp/backend/population/Population.java | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/jcgp/backend/population') diff --git a/src/jcgp/backend/population/Population.java b/src/jcgp/backend/population/Population.java index fdeec82..a850595 100644 --- a/src/jcgp/backend/population/Population.java +++ b/src/jcgp/backend/population/Population.java @@ -6,6 +6,7 @@ public class Population { private Chromosome[] chromosomes; private final Resources resources; + private int fittest = 0; /** * Initialise a random population according to the parameters specified @@ -76,5 +77,26 @@ public class Population { chromosomes[c].reinitialiseConnections(); } } + + public void setFittest(int fittest) { + this.fittest = fittest; + } + + public void setFittest(Chromosome fittest) { + for (int i = 0; i < chromosomes.length; i++) { + if (chromosomes[i] == fittest) { + this.fittest = i; + return; + } + } + } + + public Chromosome getFittest() { + return chromosomes[fittest]; + } + + public int getFittestIndex() { + return fittest; + } } -- cgit v1.2.3