diff --git a/examples/pom.xml b/examples/pom.xml
index 773b7d2d..0f95981d 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -22,7 +22,7 @@
org.uncommons.watchmakerwatchmaker
- 0.7.2
+ 0.7.2-qumulwatchmaker-examples
diff --git a/framework/pom.xml b/framework/pom.xml
index 51ecd7bd..fd550306 100644
--- a/framework/pom.xml
+++ b/framework/pom.xml
@@ -22,7 +22,7 @@
org.uncommons.watchmakerwatchmaker
- 0.7.2
+ 0.7.2-qumulwatchmaker-framework
@@ -30,7 +30,7 @@
org.uncommons.mathsuncommons-maths
- 1.2.2
+ 1.2.2acom.google.collections
diff --git a/framework/src/java/main/org/uncommons/watchmaker/framework/EvolutionUtils.java b/framework/src/java/main/org/uncommons/watchmaker/framework/EvolutionUtils.java
index 2838e318..67c6de79 100644
--- a/framework/src/java/main/org/uncommons/watchmaker/framework/EvolutionUtils.java
+++ b/framework/src/java/main/org/uncommons/watchmaker/framework/EvolutionUtils.java
@@ -111,17 +111,8 @@ public static PopulationData getPopulationData(List
int iterationNumber,
long startTime)
{
- DataSet stats = new DataSet(evaluatedPopulation.size());
- for (EvaluatedCandidate candidate : evaluatedPopulation)
- {
- stats.addValue(candidate.getFitness());
- }
- return new PopulationData(evaluatedPopulation.get(0).getCandidate(),
- evaluatedPopulation.get(0).getFitness(),
- stats.getArithmeticMean(),
- stats.getStandardDeviation(),
+ return new PopulationData(evaluatedPopulation,
naturalFitness,
- stats.getSize(),
eliteCount,
iterationNumber,
System.currentTimeMillis() - startTime);
diff --git a/framework/src/java/main/org/uncommons/watchmaker/framework/PopulationData.java b/framework/src/java/main/org/uncommons/watchmaker/framework/PopulationData.java
index a04f5bbb..77b68e5e 100644
--- a/framework/src/java/main/org/uncommons/watchmaker/framework/PopulationData.java
+++ b/framework/src/java/main/org/uncommons/watchmaker/framework/PopulationData.java
@@ -15,6 +15,10 @@
//=============================================================================
package org.uncommons.watchmaker.framework;
+import org.uncommons.maths.statistics.DataSet;
+
+import java.util.List;
+
/**
* Immutable data object containing statistics about the state of
* an evolved population and a reference to the fittest candidate
@@ -26,6 +30,7 @@
*/
public final class PopulationData
{
+ private final List> evaluatedPopulation;
private final T bestCandidate;
private final double bestCandidateFitness;
private final double meanFitness;
@@ -37,6 +42,8 @@ public final class PopulationData
private final long elapsedTime;
/**
+ * Constructor only
+ * @param evaluatedPopulation List of all candidates
* @param bestCandidate The fittest candidate present in the population.
* @param bestCandidateFitness The fitness score for the fittest candidate
* in the population.
@@ -45,23 +52,25 @@ public final class PopulationData
* @param fitnessStandardDeviation A measure of the variation in fitness
* scores.
* @param naturalFitness True if higher fitness scores are better, false
- * otherwise.
+ * otherwise.
* @param populationSize The number of individuals in the population.
* @param eliteCount The number of candidates preserved via elitism.
* @param generationNumber The (zero-based) number of the last generation
* that was processed.
* @param elapsedTime The number of milliseconds since the start of the
*/
- public PopulationData(T bestCandidate,
- double bestCandidateFitness,
- double meanFitness,
- double fitnessStandardDeviation,
- boolean naturalFitness,
- int populationSize,
- int eliteCount,
- int generationNumber,
- long elapsedTime)
+ public PopulationData(
+ List> evaluatedPopulation, T bestCandidate,
+ double bestCandidateFitness,
+ double meanFitness,
+ double fitnessStandardDeviation,
+ boolean naturalFitness,
+ int populationSize,
+ int eliteCount,
+ int generationNumber,
+ long elapsedTime)
{
+ this.evaluatedPopulation = evaluatedPopulation;
this.bestCandidate = bestCandidate;
this.bestCandidateFitness = bestCandidateFitness;
this.meanFitness = meanFitness;
@@ -72,7 +81,48 @@ public PopulationData(T bestCandidate,
this.generationNumber = generationNumber;
this.elapsedTime = elapsedTime;
}
+ /**
+ * @param evaluatedPopulation List of all candidates, the list should be
+ * ordered by fitness for the the best candidate to be meaningfull.
+ * Otherwise consider making your own statistics and use the other
+ * constructor
+ * @param naturalFitness True if higher fitness scores are better, false otherwise.
+ * @param eliteCount The number of candidates preserved via elitism.
+ * @param generationNumber The (zero-based) number of the last generation that was processed.
+ * @param elapsedTime The number of milliseconds since the start of the
+ */
+ public PopulationData(List> evaluatedPopulation,
+ boolean naturalFitness,
+ int eliteCount,
+ int generationNumber,
+ long elapsedTime)
+ {
+ DataSet stats = new DataSet(evaluatedPopulation.size());
+ for (EvaluatedCandidate candidate : evaluatedPopulation)
+ {
+ stats.addValue(candidate.getFitness());
+ }
+
+ this.bestCandidate = evaluatedPopulation.get(0).getCandidate();
+ this.bestCandidateFitness = evaluatedPopulation.get(0).getFitness();
+ this.meanFitness = stats.getArithmeticMean();
+ this.fitnessStandardDeviation = stats.getStandardDeviation();
+ this.naturalFitness = naturalFitness;
+ this.populationSize = stats.getSize();
+ this.eliteCount = eliteCount;
+ this.generationNumber = generationNumber;
+ this.elapsedTime = elapsedTime;
+ this.evaluatedPopulation = evaluatedPopulation;
+ }
+ /**
+ * @return The list of all candidates in the population at this stage,
+ * be carefull in the references you hold of this and don't assume this
+ * list to remain unchanged over generations.
+ */
+ public List> getEvaluatedPopulation() {
+ return evaluatedPopulation;
+ }
/**
* @return The fittest candidate present in the population.
diff --git a/framework/src/java/test/org/uncommons/watchmaker/framework/termination/ElapsedTimeTest.java b/framework/src/java/test/org/uncommons/watchmaker/framework/termination/ElapsedTimeTest.java
index ea268765..3a62858c 100644
--- a/framework/src/java/test/org/uncommons/watchmaker/framework/termination/ElapsedTimeTest.java
+++ b/framework/src/java/test/org/uncommons/watchmaker/framework/termination/ElapsedTimeTest.java
@@ -19,6 +19,8 @@
import org.uncommons.watchmaker.framework.PopulationData;
import org.uncommons.watchmaker.framework.TerminationCondition;
+import java.util.ArrayList;
+
/**
* Unit test for termination condition that checks the time taken so far by the
* evolutionary algorithm.
@@ -30,9 +32,9 @@ public class ElapsedTimeTest
public void testElapsedTimes()
{
TerminationCondition condition = new ElapsedTime(1000);
- PopulationData