From 05aae985d9d0e26cf278cdd6f69672ebe3f8ed92 Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Sun, 15 Dec 2013 10:56:49 +0000 Subject: [PATCH] Small improvement. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1551014 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/commons/math3/genetics/NPointCrossover.java | 4 ++-- .../org/apache/commons/math3/genetics/OnePointCrossover.java | 4 ++-- .../org/apache/commons/math3/genetics/UniformCrossover.java | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) 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();