Index: branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs
===================================================================
--- branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs	(revision 15821)
+++ branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs	(revision 15824)
@@ -8,11 +8,8 @@
 using HeuristicLab.Core;
 using HeuristicLab.Data;
-using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 using HeuristicLab.Optimization;
 using HeuristicLab.Parameters;
 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
 using HeuristicLab.Problems.DataAnalysis;
-using HeuristicLab.Problems.DataAnalysis.Symbolic;
-using HeuristicLab.Problems.DataAnalysis.Symbolic.Regression;
 
 namespace HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration {
@@ -22,6 +19,4 @@
   public class GrammarEnumerationAlgorithm : FixedDataAnalysisAlgorithm<IRegressionProblem> {
     #region properties and result names
-    private readonly string BestTrainingQualityName = "Best R² (Training)";
-    private readonly string BestTrainingSolutionName = "Best solution (Training)";
     private readonly string SearchStructureSizeName = "Search Structure Size";
     private readonly string GeneratedPhrasesName = "Generated/Archived Phrases";
@@ -32,4 +27,5 @@
     private readonly string OverwrittenSentencesName = "Sentences overwritten";
     private readonly string AnalyzersParameterName = "Analyzers";
+    private readonly string ExpansionsPerSecondName = "Expansions per second";
 
 
@@ -72,6 +68,5 @@
     }
 
-    public SymbolString BestTrainingSentence;
-
+    public SymbolString BestTrainingSentence { get; set; }     // Currently set in RSquaredEvaluator: quite hacky, but makes testing much easier for now...
     #endregion
 
@@ -91,5 +86,4 @@
     public Grammar Grammar { get; private set; }
 
-    private readonly ISymbolicDataAnalysisExpressionTreeInterpreter expressionTreeLinearInterpreter = new SymbolicDataAnalysisExpressionTreeLinearInterpreter();
 
     #region ctors
@@ -109,5 +103,6 @@
       var availableAnalyzers = new IGrammarEnumerationAnalyzer[] {
         new SearchGraphVisualizer(),
-        new SentenceLogger()
+        new SentenceLogger(),
+        new RSquaredEvaluator()
       };
       Parameters.Add(new FixedValueParameter<ReadOnlyCheckedItemCollection<IGrammarEnumerationAnalyzer>>(
@@ -119,4 +114,5 @@
       }
       Analyzers.CheckedItemsChanged += AnalyzersOnCheckedItemsChanged;
+      Analyzers.SetItemCheckedState(Analyzers.First(analyzer => analyzer is RSquaredEvaluator), true);
     }
 
@@ -179,6 +175,4 @@
 
                 DistinctSentencesLength[phraseHash] = newPhrase.Count;
-                EvaluateSentence(newPhrase);
-
                 OnDistinctSentenceGenerated(fetchedPhrase.Hash, fetchedPhrase.SymbolString, phraseHash, newPhrase, expandedSymbol, productionAlternative);
               }
@@ -191,42 +185,10 @@
         }
       }
-
       UpdateView(force: true);
-      UpdateFinalResults();
-    }
-
-    #region Evaluation of generated models.
-
-    // Evaluate sentence within an algorithm run.
-    private void EvaluateSentence(SymbolString symbolString) {
-      SymbolicExpressionTree tree = Grammar.ParseSymbolicExpressionTree(symbolString);
-      SymbolicRegressionModel model = new SymbolicRegressionModel(
-        Problem.ProblemData.TargetVariable,
-        tree,
-        expressionTreeLinearInterpreter);
-
-      var probData = Problem.ProblemData;
-      var target = probData.TargetVariableTrainingValues;
-      var estVals = model.GetEstimatedValues(probData.Dataset, probData.TrainingIndices);
-      OnlineCalculatorError error;
-      var r2 = OnlinePearsonsRSquaredCalculator.Calculate(target, estVals, out error);
-      if (error != OnlineCalculatorError.None) r2 = 0.0;
-
-      var bestR2 = ((DoubleValue)Results[BestTrainingQualityName].Value).Value;
-      if (r2 > bestR2) {
-        ((DoubleValue)Results[BestTrainingQualityName].Value).Value = r2;
-        BestTrainingSentence = symbolString;
-      }
-    }
-
-    #endregion
+    }
 
     #region Visualization in HL
     // Initialize entries in result set.
     private void InitResults() {
-      BestTrainingSentence = null;
-
-      Results.Add(new Result(BestTrainingQualityName, new DoubleValue(-1.0)));
-
       Results.Add(new Result(GeneratedPhrasesName, new IntValue(0)));
       Results.Add(new Result(SearchStructureSizeName, new IntValue(0)));
@@ -236,4 +198,5 @@
       Results.Add(new Result(OverwrittenSentencesName, new IntValue(0)));
       Results.Add(new Result(AverageSentenceLengthName, new DoubleValue(1.0)));
+      Results.Add(new Result(ExpansionsPerSecondName, "In Thousand expansions per second", new IntValue(0)));
     }
 
@@ -251,17 +214,7 @@
         ((DoubleValue)Results[AverageSentenceLengthName].Value).Value = DistinctSentencesLength.Select(pair => pair.Value).Average();
         ((IntValue)Results[OverwrittenSentencesName].Value).Value = OverwrittenSentencesCount;
-      }
-    }
-
-    // Generate all Results after an algorithm run.
-    private void UpdateFinalResults() {
-      SymbolicExpressionTree tree = Grammar.ParseSymbolicExpressionTree(BestTrainingSentence);
-      SymbolicRegressionModel model = new SymbolicRegressionModel(
-        Problem.ProblemData.TargetVariable,
-        tree,
-        new SymbolicDataAnalysisExpressionTreeLinearInterpreter());
-
-      IRegressionSolution bestTrainingSolution = new RegressionSolution(model, Problem.ProblemData);
-      Results.AddOrUpdateResult(BestTrainingSolutionName, bestTrainingSolution);
+        ((IntValue)Results[ExpansionsPerSecondName].Value).Value = (int)((PhraseExpansionCount /
+                                                                          ExecutionTime.TotalSeconds) / 1000.0);
+      }
     }
     #endregion
