Index: branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/Analysis/RSquaredEvaluator.cs
===================================================================
--- branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/Analysis/RSquaredEvaluator.cs	(revision 15860)
+++ branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/Analysis/RSquaredEvaluator.cs	(revision 15861)
@@ -19,7 +19,11 @@
     private readonly ISymbolicDataAnalysisExpressionTreeInterpreter expressionTreeLinearInterpreter = new SymbolicDataAnalysisExpressionTreeLinearInterpreter();
 
+    public bool OptimizeConstants { get; set; }
+
     public RSquaredEvaluator() { }
 
-    protected RSquaredEvaluator(RSquaredEvaluator original, Cloner cloner) { }
+    protected RSquaredEvaluator(RSquaredEvaluator original, Cloner cloner) {
+      this.OptimizeConstants = original.OptimizeConstants;
+    }
 
     public override IDeepCloneable Clone(Cloner cloner) {
@@ -72,30 +76,36 @@
       // TODO: Restarts
 
-      double r2 = SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(expressionTreeLinearInterpreter,
-        tree,
-        problemData,
-        problemData.TrainingIndices,
-        applyLinearScaling: false,
-        maxIterations: 50,
-        updateVariableWeights: true,
-        updateConstantsInTree: true);
-
-      foreach (var symbolicExpressionTreeNode in tree.IterateNodesPostfix()) {
-        ConstantTreeNode constTreeNode = symbolicExpressionTreeNode as ConstantTreeNode;
-        if (constTreeNode != null && constTreeNode.Value.IsAlmost(0.0)) {
-          constTreeNode.Value = 0.0;
-        }
-      }
+      double r2;
 
       SymbolicRegressionModel model = new SymbolicRegressionModel(
-        problemData.TargetVariable,
-        tree,
-        expressionTreeLinearInterpreter);
+          problemData.TargetVariable,
+          tree,
+          expressionTreeLinearInterpreter);
 
-      //var target = problemData.TargetVariableTrainingValues;
-      //var estVals = model.GetEstimatedValues(problemData.Dataset, problemData.TrainingIndices);
-      //OnlineCalculatorError error;
-      //double r2 = OnlinePearsonsRCalculator.Calculate(target, estVals, out error);
-      //if (error != OnlineCalculatorError.None) r2 = 0.0;
+      if (OptimizeConstants) {
+        r2 = SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(expressionTreeLinearInterpreter,
+          tree,
+          problemData,
+          problemData.TrainingIndices,
+          applyLinearScaling: false,
+          maxIterations: 50,
+          updateVariableWeights: true,
+          updateConstantsInTree: true);
+
+        foreach (var symbolicExpressionTreeNode in tree.IterateNodesPostfix()) {
+          ConstantTreeNode constTreeNode = symbolicExpressionTreeNode as ConstantTreeNode;
+          if (constTreeNode != null && constTreeNode.Value.IsAlmost(0.0)) {
+            constTreeNode.Value = 0.0;
+          }
+        }
+
+
+      } else {
+        var target = problemData.TargetVariableTrainingValues;
+        var estVals = model.GetEstimatedValues(problemData.Dataset, problemData.TrainingIndices);
+        OnlineCalculatorError error;
+        r2 = OnlinePearsonsRCalculator.Calculate(target, estVals, out error);
+        if (error != OnlineCalculatorError.None) r2 = 0.0;
+      }
 
       var bestR2Result = (DoubleValue)algorithm.Results[BestTrainingQualityResultName].Value;
Index: branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Grammar.cs
===================================================================
--- branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Grammar.cs	(revision 15860)
+++ branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/Grammar.cs	(revision 15861)
@@ -165,4 +165,13 @@
     }
 
+    public int GetComplexity(SymbolString s) {
+      int c = 0;
+      int length = s.Count();
+      for (int i = 0; i < length; i++) {
+        if (s[i] is NonterminalSymbol || s[i] is VariableTerminalSymbol) c++;
+      }
+      return c;
+    }
+
     #region Parse to SymbolicExpressionTree
 
Index: branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs
===================================================================
--- branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs	(revision 15860)
+++ branches/2886_SymRegGrammarEnumeration/HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration/GrammarEnumeration/GrammarEnumerationAlgorithm.cs	(revision 15861)
@@ -2,4 +2,5 @@
 using System.Collections.Generic;
 using System.Linq;
+using System.Security.Cryptography;
 using System.Threading;
 using HeuristicLab.Algorithms.DataAnalysis.SymRegGrammarEnumeration.GrammarEnumeration;
@@ -30,4 +31,5 @@
 
 
+    private readonly string OptimizeConstantsParameterName = "Optimize Constants";
     private readonly string SearchDataStructureParameterName = "Search Data Structure";
     private readonly string MaxComplexityParameterName = "Max. Complexity";
@@ -35,4 +37,13 @@
 
     public override bool SupportsPause { get { return false; } }
+
+    protected IValueParameter<BoolValue> OptimizeConstantsParameter {
+      get { return (IValueParameter<BoolValue>)Parameters[OptimizeConstantsParameterName]; }
+    }
+
+    public bool OptimizeConstants {
+      get { return OptimizeConstantsParameter.Value.Value; }
+      set { OptimizeConstantsParameter.Value.Value = value; }
+    }
 
     protected IValueParameter<IntValue> MaxComplexityParameter {
@@ -97,4 +108,5 @@
       };
 
+      Parameters.Add(new ValueParameter<BoolValue>(OptimizeConstantsParameterName, "Run constant optimization in sentence evaluation.", new BoolValue(true)));
       Parameters.Add(new ValueParameter<IntValue>(MaxComplexityParameterName, "The maximum number of variable symbols in a sentence.", new IntValue(5)));
       Parameters.Add(new ValueParameter<IntValue>(GuiUpdateIntervalParameterName, "Number of generated sentences, until GUI is refreshed.", new IntValue(100000)));
@@ -124,4 +136,6 @@
       #region init
       InitResults();
+
+      Analyzers.OfType<RSquaredEvaluator>().First().OptimizeConstants = OptimizeConstants;
 
       ArchivedPhrases = new HashSet<int>();
Index: branches/2886_SymRegGrammarEnumeration/Test/GrammarEnumerationTest.cs
===================================================================
--- branches/2886_SymRegGrammarEnumeration/Test/GrammarEnumerationTest.cs	(revision 15860)
+++ branches/2886_SymRegGrammarEnumeration/Test/GrammarEnumerationTest.cs	(revision 15861)
@@ -60,4 +60,5 @@
     public void NoConstants_Nguyen1() {
       // x³ + x² + x
+      alg.OptimizeConstants = false;
       alg.MaxComplexity = 6;
       alg.Problem.ProblemData = new NguyenFunctionOne(Seed).GenerateRegressionData();
@@ -117,4 +118,5 @@
     public void NoConstants_Nguyen6() {
       // sin(x) + sin(x + x²)
+      alg.OptimizeConstants = false;
       alg.MaxComplexity = 4;
       alg.Problem.ProblemData = new NguyenFunctionSix(Seed).GenerateRegressionData();
@@ -147,5 +149,6 @@
     [TestProperty("Goal", "structure search")]
     public void NoConstants_Nguyen9() {
-      // sin(x) + sin(y²)
+      // sin(x) + sin(y²)    
+      alg.OptimizeConstants = false;
       alg.MaxComplexity = 3;
       alg.Problem.ProblemData = new NguyenFunctionNine(Seed).GenerateRegressionData();
@@ -190,5 +193,6 @@
     [TestProperty("Goal", "structure search")]
     public void NoConstants_Inverse() {
-      // x / (log(x)*x + x)
+      // x / (log(x)*x + x) 
+      alg.OptimizeConstants = false;
       alg.MaxComplexity = 4;
 
