aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/population
diff options
context:
space:
mode:
Diffstat (limited to 'src/jcgp/population')
-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.");
}
-
};
}
}