aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/population
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-04-13 10:41:25 +0100
committerEduardo Pedroni <ep625@york.ac.uk>2014-04-13 10:41:25 +0100
commite7d7e8506a511d78f9e323ac09587f79ad503f42 (patch)
tree8d87a718af29470b5bb8e5dfeb0ce18865f185cb /src/jcgp/backend/population
parentdbae5ce2e0765f229e11b692a2aba570286980f4 (diff)
Performance suddenly decreased, looking into why
Diffstat (limited to 'src/jcgp/backend/population')
-rw-r--r--src/jcgp/backend/population/Population.java22
1 files changed, 22 insertions, 0 deletions
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;
+ }
}