You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tn...@apache.org on 2012/04/09 18:55:03 UTC

svn commit: r1311321 - in /commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics: ElitisticListPopulation.java ListPopulation.java

Author: tn
Date: Mon Apr  9 16:55:03 2012
New Revision: 1311321

URL: http://svn.apache.org/viewvc?rev=1311321&view=rev
Log:
[MATH-775] remove getChromosomeList method and change internal list to protected.

Modified:
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/ElitisticListPopulation.java
    commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/ListPopulation.java

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/ElitisticListPopulation.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/ElitisticListPopulation.java?rev=1311321&r1=1311320&r2=1311321&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/ElitisticListPopulation.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/ElitisticListPopulation.java Mon Apr  9 16:55:03 2012
@@ -76,13 +76,13 @@ public class ElitisticListPopulation ext
         ElitisticListPopulation nextGeneration =
                 new ElitisticListPopulation(getPopulationLimit(), getElitismRate());
 
-        final List<Chromosome> oldChromosomes = getChromosomeList();
-        Collections.sort(oldChromosomes);
+        // sort the chromosomes inplace
+        Collections.sort(chromosomes);
 
         // index of the last "not good enough" chromosome
-        int boundIndex = (int) FastMath.ceil((1.0 - getElitismRate()) * oldChromosomes.size());
-        for (int i = boundIndex; i < oldChromosomes.size(); i++) {
-            nextGeneration.addChromosome(oldChromosomes.get(i));
+        int boundIndex = (int) FastMath.ceil((1.0 - getElitismRate()) * chromosomes.size());
+        for (int i = boundIndex; i < chromosomes.size(); i++) {
+            nextGeneration.addChromosome(chromosomes.get(i));
         }
         return nextGeneration;
     }

Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/ListPopulation.java
URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/ListPopulation.java?rev=1311321&r1=1311320&r2=1311321&view=diff
==============================================================================
--- commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/ListPopulation.java (original)
+++ commons/proper/math/trunk/src/main/java/org/apache/commons/math3/genetics/ListPopulation.java Mon Apr  9 16:55:03 2012
@@ -37,7 +37,7 @@ import org.apache.commons.math3.exceptio
 public abstract class ListPopulation implements Population {
 
     /** List of chromosomes */
-    private List<Chromosome> chromosomes;
+    protected List<Chromosome> chromosomes;
 
     /** maximal size of the population */
     private int populationLimit;
@@ -121,14 +121,6 @@ public abstract class ListPopulation imp
     }
 
     /**
-     * Access the list of chromosomes.
-     * @return the list of chromosomes
-     */
-    protected List<Chromosome> getChromosomeList() {
-        return chromosomes;
-    }
-
-    /**
      * Add the given chromosome to the population.
      * @param chromosome the chromosome to add.
      * @throws NumberIsTooLargeException if the population would exceed the {@code populationLimit} after