diff --git a/src/main/java/org/apache/commons/math3/genetics/NPointCrossover.java b/src/main/java/org/apache/commons/math3/genetics/NPointCrossover.java index 436eab767..7d975bc40 100644 --- a/src/main/java/org/apache/commons/math3/genetics/NPointCrossover.java +++ b/src/main/java/org/apache/commons/math3/genetics/NPointCrossover.java @@ -139,8 +139,8 @@ public class NPointCrossover implements CrossoverPolicy { final List parent1Rep = first.getRepresentation(); final List parent2Rep = second.getRepresentation(); // and of the children - final List child1Rep = new ArrayList(first.getLength()); - final List child2Rep = new ArrayList(second.getLength()); + final List child1Rep = new ArrayList(length); + final List child2Rep = new ArrayList(length); final RandomGenerator random = GeneticAlgorithm.getRandomGenerator(); diff --git a/src/main/java/org/apache/commons/math3/genetics/OnePointCrossover.java b/src/main/java/org/apache/commons/math3/genetics/OnePointCrossover.java index 8ac6d1b2a..9dea40d32 100644 --- a/src/main/java/org/apache/commons/math3/genetics/OnePointCrossover.java +++ b/src/main/java/org/apache/commons/math3/genetics/OnePointCrossover.java @@ -105,8 +105,8 @@ public class OnePointCrossover implements CrossoverPolicy { final List parent1Rep = first.getRepresentation(); final List parent2Rep = second.getRepresentation(); // and of the children - final List child1Rep = new ArrayList(first.getLength()); - final List child2Rep = new ArrayList(second.getLength()); + final List child1Rep = new ArrayList(length); + final List child2Rep = new ArrayList(length); // select a crossover point at random (0 and length makes no sense) final int crossoverIndex = 1 + (GeneticAlgorithm.getRandomGenerator().nextInt(length-2)); diff --git a/src/main/java/org/apache/commons/math3/genetics/UniformCrossover.java b/src/main/java/org/apache/commons/math3/genetics/UniformCrossover.java index b135f91d8..cd215324c 100644 --- a/src/main/java/org/apache/commons/math3/genetics/UniformCrossover.java +++ b/src/main/java/org/apache/commons/math3/genetics/UniformCrossover.java @@ -112,8 +112,8 @@ public class UniformCrossover implements CrossoverPolicy { final List parent1Rep = first.getRepresentation(); final List parent2Rep = second.getRepresentation(); // and of the children - final List child1Rep = new ArrayList(first.getLength()); - final List child2Rep = new ArrayList(second.getLength()); + final List child1Rep = new ArrayList(length); + final List child2Rep = new ArrayList(length); final RandomGenerator random = GeneticAlgorithm.getRandomGenerator();