<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>nbproject/private/profiler/configurations.xml</filename>
    </added>
    <added>
      <filename>nbproject/profiler-build-impl.xml</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -10,7 +10,8 @@
 &lt;project name=&quot;GeneticDrawing&quot; default=&quot;default&quot; basedir=&quot;.&quot;&gt;
     &lt;description&gt;Builds, tests, and runs the project GeneticDrawing.&lt;/description&gt;
     &lt;import file=&quot;nbproject/build-impl.xml&quot;/&gt;
-    &lt;!--
+
+    &lt;import file=&quot;nbproject/profiler-build-impl.xml&quot;/&gt;    &lt;!--
 
     There exist several targets which are by default empty and which can be 
     used for execution of your tasks. These targets are usually executed </diff>
      <filename>build.xml</filename>
    </modified>
    <modified>
      <diff>@@ -6,3 +6,6 @@ build.xml.stylesheet.CRC32=958a1d3e
 nbproject/build-impl.xml.data.CRC32=82e3b9fd
 nbproject/build-impl.xml.script.CRC32=ba378ae5
 nbproject/build-impl.xml.stylesheet.CRC32=e55b27f5
+nbproject/profiler-build-impl.xml.data.CRC32=82e3b9fd
+nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
+nbproject/profiler-build-impl.xml.stylesheet.CRC32=42cb6bcf</diff>
      <filename>nbproject/genfiles.properties</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
 &lt;project-private xmlns=&quot;http://www.netbeans.org/ns/project-private/1&quot;&gt;
+    &lt;data xmlns=&quot;http://www.netbeans.org/ns/profiler/1&quot; version=&quot;0.9.1&quot;/&gt;
     &lt;editor-bookmarks xmlns=&quot;http://www.netbeans.org/ns/editor-bookmarks/1&quot;/&gt;
 &lt;/project-private&gt;</diff>
      <filename>nbproject/private/private.xml</filename>
    </modified>
    <modified>
      <diff>@@ -71,7 +71,7 @@ run.classpath=\
 # Space-separated list of JVM arguments used when running the project
 # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
 # or test-sys-prop.name=value to set system properties for unit tests):
-run.jvmargs=
+run.jvmargs=-server
 run.test.classpath=\
     ${javac.test.classpath}:\
     ${build.test.classes.dir}</diff>
      <filename>nbproject/project.properties</filename>
    </modified>
    <modified>
      <diff>@@ -26,14 +26,11 @@ public class DrawingGPConfiguration
         this.setFitnessFunction(new LMSFitnessFunction(this));
         this.setPopulationSize(5);
         this.setStrictProgramCreation(false);
-        this.setCrossoverProb(0.4f);
-        this.setReproductionProb(0.6f);
-        this.setNewChromsPercent(0.3f);
-        this.setReproductionProb(1.0f / 50);
-
-        this.setMinInitDepth(50);
-        this.setMaxInitDepth(300);
-        this.setMaxCrossoverDepth(300);
+        this.setCrossoverProb(0.3f);
+        this.setReproductionProb(0.7f);
+        this.setNewChromsPercent(0.1f);
+        this.setMutationProb(0.9f);
+        this.setMaxCrossoverDepth(100);
     }
 
     /**</diff>
      <filename>src/gd/core/DrawingGPConfiguration.java</filename>
    </modified>
    <modified>
      <diff>@@ -52,8 +52,8 @@ public class DrawingProblem
                 new Terminal(conf, CommandGene.FloatClass, 0.0d, 1.0d),
                 new Terminal(conf, CommandGene.IntegerClass, 0, conf.getTarget().getWidth(), true, TerminalType.WIDTH.intValue()),
                 new Terminal(conf, CommandGene.IntegerClass, 0, conf.getTarget().getHeight(), true, TerminalType.HEIGHT.intValue()),}};
-        int[] minDepth = new int[]{40};
-        int[] maxDepth = new int[]{50};
+        int[] minDepth = new int[]{5};
+        int[] maxDepth = null;
         int maxNodes = 5000;
         boolean[] fullMode = new boolean[]{false};
 </diff>
      <filename>src/gd/core/DrawingProblem.java</filename>
    </modified>
    <modified>
      <diff>@@ -4,8 +4,10 @@
  */
 package gd.core;
 
-import java.awt.Color;
 import java.awt.image.BufferedImage;
+import java.awt.image.PixelGrabber;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 import org.jgap.gp.GPFitnessFunction;
 import org.jgap.gp.IGPProgram;
 
@@ -18,30 +20,49 @@ import org.jgap.gp.IGPProgram;
 public class LMSFitnessFunction
         extends GPFitnessFunction {
 
-    private DrawingGPConfiguration m_conf = null;
-    public DrawingGPProgramRunner programRunner = null;
+    private final DrawingGPConfiguration m_conf;
+    private final DrawingGPProgramRunner programRunner;
+    private final int[] targetPixels;
 
     LMSFitnessFunction(DrawingGPConfiguration a_conf) {
         super();
         m_conf = a_conf;
         programRunner = new DrawingGPProgramRunner(m_conf);
+
+        BufferedImage target = m_conf.getTarget();
+        targetPixels = new int[target.getWidth() * target.getHeight()];
+        PixelGrabber pg = new PixelGrabber(target, 0, 0, target.getWidth(),
+                target.getHeight(), targetPixels, 0, target.getWidth());
+        try {
+            pg.grabPixels();
+        } catch (InterruptedException ex) {
+            Logger.getLogger(LMSFitnessFunction.class.getName()).log(Level.SEVERE, null, ex);
+        }
     }
 
     protected double evaluate(final IGPProgram a_subject) {
-        BufferedImage target = m_conf.getTarget();
         BufferedImage generated = programRunner.run(a_subject);
+        final int[] generatedPixels = new int[generated.getWidth() * generated.getHeight()];
+        PixelGrabber pg = new PixelGrabber(generated, 0, 0, generated.getWidth(),
+                generated.getHeight(), generatedPixels, 0, generated.getWidth());
+        try {
+            pg.grabPixels();
+        } catch (InterruptedException ex) {
+            Logger.getLogger(LMSFitnessFunction.class.getName()).log(Level.SEVERE, null, ex);
+        }
+
+        long sum = 0;
+        for (int i = 0; i &lt; generatedPixels.length &amp;&amp; i &lt; targetPixels.length; i++) {
+            int c1 = targetPixels[i];
+            int c2 = generatedPixels[i];
 
-        double lms = 0.0d;
-        for (int i = 0; i &lt; target.getWidth(); i++) {
-            for (int j = 0; j &lt; target.getHeight(); j++) {
-                Color c1 = new Color(target.getRGB(i, j));
-                Color c2 = new Color(generated.getRGB(i, j));
+            int r = ((c1 &gt;&gt; 16) &amp; 0xff) - ((c2 &gt;&gt; 16) &amp; 0xff);
+            int g = ((c1 &gt;&gt; 8) &amp; 0xff) - ((c2 &gt;&gt; 8) &amp; 0xff);
+            int b = (c1 &amp; 0xff) - (c2 &amp; 0xff);
 
-                lms += Math.pow(c1.getRed() - c2.getRed(), 2) +
-                        Math.pow(c1.getGreen() - c2.getGreen(), 2) +
-                        Math.pow(c1.getBlue() - c2.getBlue(), 2);
-            }
+            sum += r * r + g * g + b * b;
         }
-        return Math.sqrt(lms);
+
+        return Math.sqrt((double) sum);
     }
 }</diff>
      <filename>src/gd/core/LMSFitnessFunction.java</filename>
    </modified>
    <modified>
      <diff>@@ -41,6 +41,10 @@ public class EvolutionRunnable implements Runnable {
             final DrawingGPConfiguration conf =
                     new DrawingGPConfiguration(m_view.getTargetImage());
 
+            JFreeChart chart = m_view.getChart();
+            XYSeriesCollection sc = (XYSeriesCollection) chart.getXYPlot().getDataset();
+            XYSeries series = sc.getSeries(0);
+            series.clear();
             IEventManager eventManager = conf.getEventManager();
             eventManager.addEventListener(GeneticEvent.GPGENOTYPE_EVOLVED_EVENT,
                     new GeneticEventListener() {
@@ -53,14 +57,12 @@ public class EvolutionRunnable implements Runnable {
                             GPGenotype genotype = (GPGenotype) a_firedEvent.getSource();
                             int evno = genotype.getGPConfiguration().getGenerationNr();
 
-                            if (evno % 25 == 0 || evno == 1) {
+                            if (evno % 25 == 0) {
                                 double best = genotype.getFittestProgram().getFitnessValue();
                                 JFreeChart chart = m_view.getChart();
                                 XYSeriesCollection sc = (XYSeriesCollection) chart.getXYPlot().getDataset();
                                 XYSeries series = sc.getSeries(0);
-                                if (evno == 1) {
-                                    series.clear();
-                                }
+
                                 series.add(evno, best);
                             }
 
@@ -86,7 +88,7 @@ public class EvolutionRunnable implements Runnable {
 
             GPProblem problem = new DrawingProblem(conf);
             GPGenotype gp = problem.create();
-            gp.setVerboseOutput(false);
+            gp.setVerboseOutput(true);
 
             while (m_view.isEvolutionActivated()) {
                 gp.evolve();</diff>
      <filename>src/gd/gui/EvolutionRunnable.java</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>f67a7803108e731f47cacd9b85cf98125d4bd147</id>
    </parent>
  </parents>
  <author>
    <name>Yann Dauphin</name>
    <email>dhaemon@gmail.com</email>
  </author>
  <url>http://github.com/ynd/genetic-drawing/commit/29b294414a988f41fa82c4ff216da4720e1f7e0d</url>
  <id>29b294414a988f41fa82c4ff216da4720e1f7e0d</id>
  <committed-date>2008-12-20T14:53:17-08:00</committed-date>
  <authored-date>2008-12-20T14:53:17-08:00</authored-date>
  <message>Added profiler. Various optimizations for the fitness function's speed.</message>
  <tree>e13030bcaba3607ed6dbafef54637ecae49280f4</tree>
  <committer>
    <name>Yann Dauphin</name>
    <email>dhaemon@gmail.com</email>
  </committer>
</commit>
