Author: tdunning
Date: Thu Aug 19 07:26:22 2010
New Revision: 987047

URL: http://svn.apache.org/viewvc?rev=987047&view=rev
Log:
Small changes to test and added toString

Modified:
    
mahout/trunk/core/src/main/java/org/apache/mahout/ep/ThreadedEvolutionaryProcess.java
    
mahout/trunk/core/src/test/java/org/apache/mahout/ep/ThreadedEvolutionaryProcessTest.java

Modified: 
mahout/trunk/core/src/main/java/org/apache/mahout/ep/ThreadedEvolutionaryProcess.java
URL: 
http://svn.apache.org/viewvc/mahout/trunk/core/src/main/java/org/apache/mahout/ep/ThreadedEvolutionaryProcess.java?rev=987047&r1=987046&r2=987047&view=diff
==============================================================================
--- 
mahout/trunk/core/src/main/java/org/apache/mahout/ep/ThreadedEvolutionaryProcess.java
 (original)
+++ 
mahout/trunk/core/src/main/java/org/apache/mahout/ep/ThreadedEvolutionaryProcess.java
 Thu Aug 19 07:26:22 2010
@@ -17,7 +17,9 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
 
 /**
- * Implements threaded evaluation of an objective function for evolutionary 
optimization.
+ * Implements threaded optimization of an objective function.  The evolving 
population
+ * is updated incrementally as results are received.  One useful feature is 
that the
+ * optimization is inherently time-bounded which is useful for some scheduled 
operations.
  */
 public class ThreadedEvolutionaryProcess {
   private volatile int taskCount = 0;
@@ -84,7 +86,6 @@ public class ThreadedEvolutionaryProcess
       }
 
       int k = 0;
-      pending.clear();    // should already be empty (i like belt AND 
suspenders)
       while (pending.size() + working.size() < threadCount) {
         State tmp = parents[(k++) % parentDepth];
         pending.add(tmp.mutate());
@@ -103,6 +104,12 @@ public class ThreadedEvolutionaryProcess
     return resultPopulation.peek();
   }
 
+  
+  @Override
+  public String toString() {
+    return String.format("Launched %d function evaluations\nMaximum threading 
width was %d", processCount, maxTask);
+  }
+
   public class EvalTask implements Callable<State> {
     private Function f;
     private State what;

Modified: 
mahout/trunk/core/src/test/java/org/apache/mahout/ep/ThreadedEvolutionaryProcessTest.java
URL: 
http://svn.apache.org/viewvc/mahout/trunk/core/src/test/java/org/apache/mahout/ep/ThreadedEvolutionaryProcessTest.java?rev=987047&r1=987046&r2=987047&view=diff
==============================================================================
--- 
mahout/trunk/core/src/test/java/org/apache/mahout/ep/ThreadedEvolutionaryProcessTest.java
 (original)
+++ 
mahout/trunk/core/src/test/java/org/apache/mahout/ep/ThreadedEvolutionaryProcessTest.java
 Thu Aug 19 07:26:22 2010
@@ -35,10 +35,12 @@ public class ThreadedEvolutionaryProcess
       }
     }, 5, 200, 2);
 
+    System.out.printf("%s\n", ep);
     double[] r = x.getMappedParams();
     int i = 0;
     for (double v : r) {
-      Assert.assertEquals(i++, v, 1e-2);
+      Assert.assertEquals(String.format("Coordinate %d", i), i, v, 0.02);
+      i++;
     }
   }
 }


Reply via email to