aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/population/Population.java
diff options
context:
space:
mode:
authorEduardo Pedroni <ep625@york.ac.uk>2014-02-13 17:43:59 +0000
committerEduardo Pedroni <ep625@york.ac.uk>2014-02-13 17:43:59 +0000
commit3326c58f4d2d7e8c77738277dcd093aa864ad2a5 (patch)
tree407f574c88254b8327f41a24f4660ae808420311 /src/jcgp/population/Population.java
parent727801ab8002481fd2d213b45c3b43225b0f73bb (diff)
Finished population tests, now thinking about methods to compare chromosomes
Diffstat (limited to 'src/jcgp/population/Population.java')
-rw-r--r--src/jcgp/population/Population.java23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/jcgp/population/Population.java b/src/jcgp/population/Population.java
index 56f1b50..4153e0f 100644
--- a/src/jcgp/population/Population.java
+++ b/src/jcgp/population/Population.java
@@ -8,14 +8,17 @@ public class Population implements Iterable<Chromosome> {
private Chromosome[] population;
- public Population(Chromosome ... chromosomes) {
- if (chromosomes.length > 0) {
- population = chromosomes;
- } else {
- population = new Chromosome[Parameters.getPopulationSize()];
- for (int c = 0; c < population.length; c++) {
- population[c] = new Chromosome();
- }
+ public Population(Chromosome chromosome) {
+ population = new Chromosome[Parameters.getPopulationSize()];
+ for (int c = 0; c < population.length; c++) {
+ population[c] = new Chromosome(chromosome);
+ }
+ }
+
+ public Population() {
+ population = new Chromosome[Parameters.getPopulationSize()];
+ for (int c = 0; c < population.length; c++) {
+ population[c] = new Chromosome();
}
}
@@ -44,10 +47,8 @@ public class Population implements Iterable<Chromosome> {
@Override
public void remove() {
// not allowed
- // since this would shift everything back one position, increment index
- // index++;
+ throw new UnsupportedOperationException("Removing chromosomes from the population is not allowed. Instead, re-instantiate the chromosome.");
}
-
};
}
}