diff options
author | Eduardo Pedroni <ep625@york.ac.uk> | 2014-02-13 17:43:59 +0000 |
---|---|---|
committer | Eduardo Pedroni <ep625@york.ac.uk> | 2014-02-13 17:43:59 +0000 |
commit | 3326c58f4d2d7e8c77738277dcd093aa864ad2a5 (patch) | |
tree | 407f574c88254b8327f41a24f4660ae808420311 /src/jcgp/population | |
parent | 727801ab8002481fd2d213b45c3b43225b0f73bb (diff) |
Finished population tests, now thinking about methods to compare chromosomes
Diffstat (limited to 'src/jcgp/population')
-rw-r--r-- | src/jcgp/population/Population.java | 23 |
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."); } - }; } } |