Index: branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Grammar.cs
===================================================================
--- branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Grammar.cs	(revision 15746)
+++ branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Grammar.cs	(revision 15772)
@@ -20,7 +20,20 @@
     public NonterminalSymbol Term;
     public NonterminalSymbol Factor;
+    public NonterminalSymbol LogFactor;
+    public NonterminalSymbol ExpFactor;
+    public NonterminalSymbol SinFactor;
+
+    public NonterminalSymbol SimpleExpr;
+    public NonterminalSymbol SimpleTerm;
 
     public TerminalSymbol Addition;
     public TerminalSymbol Multiplication;
+    public TerminalSymbol Log;
+    public TerminalSymbol Exp;
+    public TerminalSymbol Sin;
+
+    // For infix notation
+    public TerminalSymbol OpeningBracket;
+    public TerminalSymbol ClosingBracket;
 
     #endregion
@@ -39,4 +52,5 @@
     private ISymbol expSy;
     private ISymbol divSy;
+    private ISymbol sinSy;
 
     private ISymbol rootSy;
@@ -52,7 +66,19 @@
       Term = new NonterminalSymbol("Term");
       Factor = new NonterminalSymbol("Factor");
+      LogFactor = new NonterminalSymbol("LogFactor");
+      ExpFactor = new NonterminalSymbol("ExpFactor");
+      SinFactor = new NonterminalSymbol("SinFactor");
+
+      SimpleExpr = new NonterminalSymbol("SimpleExpr");
+      SimpleTerm = new NonterminalSymbol("SimpleTerm");
 
       Addition = new TerminalSymbol("+");
       Multiplication = new TerminalSymbol("*");
+      Log = new TerminalSymbol("log");
+      Exp = new TerminalSymbol("exp");
+      Sin = new TerminalSymbol("sin");
+
+      OpeningBracket = new TerminalSymbol("(");
+      ClosingBracket = new TerminalSymbol(")");
       #endregion
 
@@ -70,4 +96,17 @@
 
       Factor.AddProduction(Var);
+      Factor.AddProduction(LogFactor);
+      Factor.AddProduction(ExpFactor);
+      Factor.AddProduction(SinFactor);
+
+      LogFactor.AddProduction(SimpleExpr, Log);
+      ExpFactor.AddProduction(SimpleTerm, Exp);
+      SinFactor.AddProduction(SimpleExpr, Sin);
+
+      SimpleExpr.AddProduction(SimpleTerm, SimpleExpr, Addition);
+      SimpleExpr.AddProduction(SimpleTerm);
+
+      SimpleTerm.AddProduction(Var, SimpleTerm, Multiplication);
+      SimpleTerm.AddProduction(Var);
       #endregion
 
@@ -78,12 +117,13 @@
       constSy = symbolicExpressionGrammar.Symbols.OfType<Constant>().First();
       varSy = symbolicExpressionGrammar.Symbols.OfType<Variable>().First();
-      addSy = symbolicExpressionGrammar.AllowedSymbols.OfType<Addition>().First();
-      mulSy = symbolicExpressionGrammar.AllowedSymbols.OfType<Multiplication>().First();
-      logSy = symbolicExpressionGrammar.AllowedSymbols.OfType<Logarithm>().First();
-      expSy = symbolicExpressionGrammar.AllowedSymbols.OfType<Exponential>().First();
-      divSy = symbolicExpressionGrammar.AllowedSymbols.OfType<Division>().First();
-
-      rootSy = symbolicExpressionGrammar.AllowedSymbols.OfType<ProgramRootSymbol>().First();
-      startSy = symbolicExpressionGrammar.AllowedSymbols.OfType<StartSymbol>().First();
+      addSy = symbolicExpressionGrammar.Symbols.OfType<Addition>().First();
+      mulSy = symbolicExpressionGrammar.Symbols.OfType<Multiplication>().First();
+      logSy = symbolicExpressionGrammar.Symbols.OfType<Logarithm>().First();
+      expSy = symbolicExpressionGrammar.Symbols.OfType<Exponential>().First();
+      divSy = symbolicExpressionGrammar.Symbols.OfType<Division>().First();
+      sinSy = symbolicExpressionGrammar.Symbols.OfType<Sine>().First();
+
+      rootSy = symbolicExpressionGrammar.Symbols.OfType<ProgramRootSymbol>().First();
+      startSy = symbolicExpressionGrammar.Symbols.OfType<StartSymbol>().First();
 
       #endregion
@@ -104,9 +144,4 @@
     private int[] GetSubtreeHashes(Stack<Symbol> parseStack) {
       Symbol currentSymbol = parseStack.Pop();
-
-      // VARIABLE
-      // if (Var.VariableTerminalSymbols.Contains(currentSymbol)) {
-      //   return currentSymbol.StringRepresentation.GetHashCode().ToEnumerable().ToArray();
-      // }
 
       // MULTIPLICATION
@@ -156,4 +191,10 @@
       }
 
+      // LOG, EXP, SIN
+      if (ReferenceEquals(currentSymbol, Log) || ReferenceEquals(currentSymbol, Exp) ||
+          ReferenceEquals(currentSymbol, Sin)) {
+        return AggregateHashes(parseStack.Peek(), GetSubtreeHashes(parseStack)).ToEnumerable().ToArray();
+      }
+
       // var or nonterminal symbol
       return currentSymbol.StringRepresentation.GetHashCode().ToEnumerable().ToArray();
@@ -161,7 +202,13 @@
 
     private int AggregateHashes(Symbol operatorSym, IEnumerable<int> hashes) {
-      // If multiple subtrees are "merged" (e.g. added, multiplied, etc.), consider the executed operation
       var hashesArray = hashes.ToArray();
-      int start = hashesArray.Length > 1 ? operatorSym.StringRepresentation.GetHashCode() : 0;
+
+      int start;
+      if (ReferenceEquals(operatorSym, Addition) && hashesArray.Count() <= 1) {
+        start = 0;
+      } else {
+        start = operatorSym.StringRepresentation.GetHashCode();
+      }
+
       return hashesArray.Aggregate(start, (result, ti) => ((result << 5) + result) ^ ti.GetHashCode());
     }
@@ -199,4 +246,16 @@
         parsedSubTree.AddSubtree(ParseSymbolicExpressionTree(parseStack)); // left part
         parsedSubTree.AddSubtree(ParseSymbolicExpressionTree(parseStack)); // right part
+
+      } else if (ReferenceEquals(currentSymbol, Log)) {
+        parsedSubTree = logSy.CreateTreeNode();
+        parsedSubTree.AddSubtree(ParseSymbolicExpressionTree(parseStack));
+
+      } else if (ReferenceEquals(currentSymbol, Exp)) {
+        parsedSubTree = expSy.CreateTreeNode();
+        parsedSubTree.AddSubtree(ParseSymbolicExpressionTree(parseStack));
+
+      } else if (ReferenceEquals(currentSymbol, Sin)) {
+        parsedSubTree = sinSy.CreateTreeNode();
+        parsedSubTree.AddSubtree(ParseSymbolicExpressionTree(parseStack));
 
       } else if (Var.VariableTerminalSymbols.Contains(currentSymbol)) {
@@ -233,4 +292,11 @@
         result.Add(head);
         result.AddRange(rightPart);
+
+      } else if (ReferenceEquals(head, Log) || ReferenceEquals(head, Exp) || ReferenceEquals(head, Sin)) {
+        result.Add(head);
+        result.Add(OpeningBracket);
+        result.AddRange(PostfixToInfixSubtreeParser(parseStack));
+        result.Add(ClosingBracket);
+
       } else {
         result.Add(head);
