Index: branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Grammar.cs
===================================================================
--- branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Grammar.cs	(revision 15723)
+++ branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Grammar.cs	(revision 15724)
@@ -155,5 +155,5 @@
     #endregion
     */
-    
+
     #region Hashing
     public int CalcHashCode(SymbolString sentence) {
@@ -282,4 +282,29 @@
     }
     #endregion
+
+    #region Parse to Infix string
+
+    public SymbolString PostfixToInfixParser(SymbolString phrase) {
+      Stack<Symbol> parseStack = new Stack<Symbol>(phrase);
+
+      return PostfixToInfixSubtreeParser(parseStack);
+    }
+
+    private SymbolString PostfixToInfixSubtreeParser(Stack<Symbol> parseStack) {
+      Symbol head = parseStack.Pop();
+
+      SymbolString result = new SymbolString();
+
+      if (ReferenceEquals(head, Addition) || ReferenceEquals(head, Multiplication)) {
+        result.AddRange(PostfixToInfixSubtreeParser(parseStack));
+        result.Add(head);
+        result.AddRange(PostfixToInfixSubtreeParser(parseStack));
+      } else {
+        result.Add(head);
+      }
+      return result;
+    }
+
+    #endregion
   }
 }
Index: branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs
===================================================================
--- branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs	(revision 15723)
+++ branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs	(revision 15724)
@@ -20,8 +20,6 @@
   public class GrammarEnumerationAlgorithm : FixedDataAnalysisAlgorithm<IRegressionProblem> {
     private readonly string BestTrainingSolution = "Best solution (training)";
-    private readonly string BestTrainingSolutionString = "Best solution string (training)";
     private readonly string BestTrainingSolutionQuality = "Best solution quality (training)";
     private readonly string BestTestSolution = "Best solution (test)";
-    private readonly string BestTestSolutionString = "Best solution string (test)";
     private readonly string BestTestSolutionQuality = "Best solution quality (test)";
 
@@ -56,7 +54,10 @@
     }
 
+    public SymbolString BestTrainingSentence;
+    public SymbolString BestTestSentence;
+
     #endregion
 
-    private Grammar grammar;
+    public Grammar Grammar;
 
 
@@ -85,4 +86,7 @@
 
     protected override void Run(CancellationToken cancellationToken) {
+      BestTrainingSentence = null;
+      BestTrainingSentence = null;
+
       List<SymbolString> allGenerated = new List<SymbolString>();
       List<SymbolString> distinctGenerated = new List<SymbolString>();
@@ -92,8 +96,8 @@
       HashSet<int> evaluatedHashes = new HashSet<int>();
 
-      grammar = new Grammar(Problem.ProblemData.AllowedInputVariables.ToArray());
+      Grammar = new Grammar(Problem.ProblemData.AllowedInputVariables.ToArray());
 
       Stack<SymbolString> remainingTrees = new Stack<SymbolString>();
-      remainingTrees.Push(new SymbolString(new[] { grammar.StartSymbol }));
+      remainingTrees.Push(new SymbolString(new[] { Grammar.StartSymbol }));
 
       while (remainingTrees.Any()) {
@@ -103,9 +107,9 @@
 
         if (currSymbolString.IsSentence()) {
-          allGenerated.Add(currSymbolString);
+          allGenerated.Add(Grammar.PostfixToInfixParser(currSymbolString));
 
           //if (evaluatedHashes.Add(grammar.CalcHashCode(currSymbolString))) {
           EvaluateSentence(currSymbolString);
-          //distinctGenerated.Add(currSymbolString);
+          distinctGenerated.Add(Grammar.PostfixToInfixParser(currSymbolString));
           //}
 
@@ -155,5 +159,5 @@
 
     private void EvaluateSentence(SymbolString symbolString) {
-      SymbolicExpressionTree tree = grammar.ParseSymbolicExpressionTree(symbolString);
+      SymbolicExpressionTree tree = Grammar.ParseSymbolicExpressionTree(symbolString);
       SymbolicRegressionModel model = new SymbolicRegressionModel(
         Problem.ProblemData.TargetVariable,
@@ -168,9 +172,10 @@
            || !Results.TryGetValue(BestTestSolution, out currBestTestSolutionResult)) {
 
+        BestTrainingSentence = symbolString;
         Results.Add(new Result(BestTrainingSolution, newSolution));
-        Results.Add(new Result(BestTrainingSolutionString, new StringValue(symbolString.ToString()).AsReadOnly()));
         Results.Add(new Result(BestTrainingSolutionQuality, new DoubleValue(newSolution.TrainingRSquared).AsReadOnly()));
+
+        BestTestSentence = symbolString;
         Results.Add(new Result(BestTestSolution, newSolution));
-        Results.Add(new Result(BestTestSolutionString, new StringValue(symbolString.ToString()).AsReadOnly()));
         Results.Add(new Result(BestTestSolutionQuality, new DoubleValue(newSolution.TestRSquared).AsReadOnly()));
 
@@ -178,6 +183,6 @@
         IRegressionSolution currBestTrainingSolution = (IRegressionSolution)currBestTrainingSolutionResult.Value;
         if (currBestTrainingSolution.TrainingRSquared < newSolution.TrainingRSquared) {
+          BestTrainingSentence = symbolString;
           currBestTrainingSolutionResult.Value = newSolution;
-          Results.AddOrUpdateResult(BestTrainingSolutionString, new StringValue(symbolString.ToString()));
           Results.AddOrUpdateResult(BestTrainingSolutionQuality, new DoubleValue(newSolution.TrainingRSquared).AsReadOnly());
         }
@@ -185,6 +190,6 @@
         IRegressionSolution currBestTestSolution = (IRegressionSolution)currBestTestSolutionResult.Value;
         if (currBestTestSolution.TestRSquared < newSolution.TestRSquared) {
+          BestTestSentence = symbolString;
           currBestTestSolutionResult.Value = newSolution;
-          Results.AddOrUpdateResult(BestTestSolutionString, new StringValue(symbolString.ToString()));
           Results.AddOrUpdateResult(BestTestSolutionQuality, new DoubleValue(newSolution.TestRSquared).AsReadOnly());
         }
Index: branches/2886_SymRegGrammarEnumeration/Test/GrammarEnumerationTest.cs
===================================================================
--- branches/2886_SymRegGrammarEnumeration/Test/GrammarEnumerationTest.cs	(revision 15723)
+++ branches/2886_SymRegGrammarEnumeration/Test/GrammarEnumerationTest.cs	(revision 15724)
@@ -2,6 +2,8 @@
 using System.Linq;
 using HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration;
+using HeuristicLab.Common;
 using HeuristicLab.Core;
 using HeuristicLab.Data;
+using HeuristicLab.Optimization;
 using HeuristicLab.Problems.DataAnalysis;
 using HeuristicLab.Random;
@@ -9,5 +11,5 @@
 
 namespace HeuristicLab.Algorithms.DataAnalysis.MctsSymbolicRegression {
-  [TestClass()]
+  [TestClass]
   public class MctsSymbolicRegressionTest {
     private const int Seed = 1234;
@@ -30,4 +32,14 @@
     }
 
+    [TestCleanup()]
+    public void Cleanup() {
+      if (alg.BestTrainingSentence != null) {
+        Console.WriteLine("Training: " + alg.Grammar.PostfixToInfixParser(alg.BestTrainingSentence));
+      }
+      if (alg.BestTestSentence != null) {
+        Console.WriteLine("Test: " + alg.Grammar.PostfixToInfixParser(alg.BestTestSentence));
+      }
+    }
+
 
     private void TestGrammarEnumeration(IRegressionProblemData problemData) {
@@ -49,6 +61,7 @@
 
       // Check overfitting
-      Assert.AreEqual(alg.Results["Best solution string (training)"].Value.ToString(),
-                      alg.Results["Best solution string (test)"].Value.ToString());
+      Assert.AreEqual(alg.Grammar.CalcHashCode(alg.BestTrainingSentence),
+                    alg.Grammar.CalcHashCode(alg.BestTestSentence),
+                    "Training and Test solution are not equal!");
     }
 
@@ -63,6 +76,4 @@
       var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F1 ")));
       TestGrammarEnumeration(regProblem);
-
-      Console.WriteLine("Nguyen1: " + alg.Results["Best solution string (training)"].Value);
     }
 
@@ -75,6 +86,4 @@
       var regProblem = provider.LoadData(provider.GetDataDescriptors().Single(x => x.Name.Contains("F2 ")));
       TestGrammarEnumeration(regProblem);
-
-      Console.WriteLine("Nguyen2: " + alg.Results["Best solution string (training)"].Value);
     }
 
