aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/population
diff options
context:
space:
mode:
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;
+ }
}