Index: /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj
===================================================================
--- /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj	(revision 18094)
+++ /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj	(revision 18095)
@@ -267,4 +267,8 @@
       <Private>False</Private>
     </ProjectReference>
+    <ProjectReference Include="..\..\HeuristicLab.Random\3.3\HeuristicLab.Random-3.3.csproj">
+      <Project>{f4539fb6-4708-40c9-be64-0a1390aea197}</Project>
+      <Name>HeuristicLab.Random-3.3</Name>
+    </ProjectReference>
   </ItemGroup>
   <ItemGroup>
Index: /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/ISymbolicRegressionSingleObjectiveEvaluator.cs
===================================================================
--- /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/ISymbolicRegressionSingleObjectiveEvaluator.cs	(revision 18094)
+++ /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/ISymbolicRegressionSingleObjectiveEvaluator.cs	(revision 18095)
@@ -1,3 +1,6 @@
-﻿using HEAL.Attic;
+﻿using System.Collections.Generic;
+using System.Linq;
+using HEAL.Attic;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 #region License Information
 /* HeuristicLab
@@ -24,4 +27,12 @@
   [StorableType("5dd2601a-b884-48c0-85bc-bc1f437187a3")]
   public interface ISymbolicRegressionSingleObjectiveEvaluator : ISymbolicRegressionEvaluator, ISymbolicDataAnalysisSingleObjectiveEvaluator<IRegressionProblemData> {
+    double Evaluate(
+      IRegressionProblemData problemData, 
+      ISymbolicExpressionTree tree, 
+      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, 
+      IEnumerable<int> rows = null,
+      bool applyLinearScaling = true,
+      double lowerEstimationLimit = double.MinValue, 
+      double upperEstimationLimit = double.MaxValue);
   }
 }
Index: /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/NMSESingleObjectiveConstraintsEvaluator.cs
===================================================================
--- /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/NMSESingleObjectiveConstraintsEvaluator.cs	(revision 18094)
+++ /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/NMSESingleObjectiveConstraintsEvaluator.cs	(revision 18095)
@@ -233,4 +233,68 @@
       return nmse;
     }
+
+    public override double Evaluate(IRegressionProblemData problemData,
+      ISymbolicExpressionTree solution,
+      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+      IEnumerable<int> rows = null,
+      bool applyLinearScaling = true,
+      double lowerEstimationLimit = double.MinValue,
+      double upperEstimationLimit = double.MaxValue) {
+
+      if (OptimizeParameters) {
+        SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(
+          interpreter, 
+          solution, 
+          problemData, 
+          rows,
+          false, 
+          ConstantOptimizationIterations, 
+          true,
+          lowerEstimationLimit, 
+          upperEstimationLimit);
+      } else {
+        if (applyLinearScaling) {
+          var rootNode = new ProgramRootSymbol().CreateTreeNode();
+          var startNode = new StartSymbol().CreateTreeNode();
+          var offset = solution.Root.GetSubtree(0) //Start
+                                    .GetSubtree(0); //Offset
+          var scaling = offset.GetSubtree(0);
+
+          //Check if tree contains offset and scaling nodes
+          if (!(offset.Symbol is Addition) || !(scaling.Symbol is Multiplication))
+            throw new ArgumentException($"{ItemName} can only be used with LinearScalingGrammar.");
+
+          var t = (ISymbolicExpressionTreeNode)scaling.GetSubtree(0).Clone();
+          rootNode.AddSubtree(startNode);
+          startNode.AddSubtree(t);
+          var newTree = new SymbolicExpressionTree(rootNode);
+
+          //calculate alpha and beta for scaling
+          var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(newTree, problemData.Dataset, rows);
+
+          var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
+          OnlineLinearScalingParameterCalculator.Calculate(estimatedValues, targetValues, out var alpha, out var beta,
+            out var errorState);
+
+          if (errorState == OnlineCalculatorError.None) {
+            //Set alpha and beta to the scaling nodes from ia grammar
+            var offsetParameter = offset.GetSubtree(1) as ConstantTreeNode;
+            offsetParameter.Value = alpha;
+            var scalingParameter = scaling.GetSubtree(1) as ConstantTreeNode;
+            scalingParameter.Value = beta;
+          }
+        } // else: alpha and beta are evolved
+      }
+      return Calculate(
+        interpreter, 
+        solution, 
+        lowerEstimationLimit, 
+        upperEstimationLimit, 
+        problemData, 
+        rows ?? problemData.TrainingIndices,
+        BoundsEstimator,
+        UseSoftConstraints,
+        PenalityFactor);
+    }
   }
 }
Index: /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs
===================================================================
--- /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs	(revision 18094)
+++ /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs	(revision 18095)
@@ -30,4 +30,5 @@
 using HeuristicLab.Optimization;
 using HeuristicLab.Parameters;
+using HeuristicLab.Random;
 
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
@@ -175,4 +176,58 @@
 
       return base.InstrumentedApply();
+    }
+
+    public override double Evaluate(IRegressionProblemData problemData,
+      ISymbolicExpressionTree solution,
+      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+      IEnumerable<int> rows = null,
+      bool applyLinearScaling = true,
+      double lowerEstimationLimit = double.MinValue,
+      double upperEstimationLimit = double.MaxValue) {
+
+
+      var random = RandomParameter?.Value ?? new MersenneTwister((uint)DateTime.Now.Millisecond);
+      double quality;
+
+      var propability = random.NextDouble();
+      if (propability < ConstantOptimizationProbability.Value) {
+        var counter = new EvaluationsCounter();
+        quality = OptimizeConstants(
+          interpreter, 
+          solution, 
+          problemData,
+          rows ?? problemData.TrainingIndices, 
+          applyLinearScaling, 
+          ConstantOptimizationIterations.Value, 
+          updateVariableWeights: UpdateVariableWeights, 
+          lowerEstimationLimit: lowerEstimationLimit, 
+          upperEstimationLimit: upperEstimationLimit, 
+          updateConstantsInTree: UpdateConstantsInTree, 
+          counter: counter);
+
+        if (ConstantOptimizationRowsPercentage.Value != RelativeNumberOfEvaluatedSamplesParameter.ActualValue.Value) {
+          var evaluationRows = GenerateRowsToEvaluate();
+          quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
+            interpreter, 
+            solution, 
+            lowerEstimationLimit, 
+            upperEstimationLimit, 
+            problemData, 
+            evaluationRows, 
+            applyLinearScaling);
+        }
+
+      } else {
+        var evaluationRows = GenerateRowsToEvaluate();
+        quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(
+          interpreter, 
+          solution,
+          lowerEstimationLimit,
+          upperEstimationLimit,
+          problemData,
+          evaluationRows,
+          applyLinearScaling);
+      }
+      return quality;
     }
 
@@ -311,5 +366,5 @@
         FactorVariableTreeNode factorVarTreeNode = node as FactorVariableTreeNode;
         if (constantTreeNode != null) {
-          if (constantTreeNode.Parent.Symbol is Power 
+          if (constantTreeNode.Parent.Symbol is Power
               && constantTreeNode.Parent.GetSubtree(1) == constantTreeNode) continue; // exponents in powers are not optimizated (see TreeToAutoDiffTermConverter)
           constantTreeNode.Value = constants[i++];
Index: /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionLogResidualEvaluator.cs
===================================================================
--- /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionLogResidualEvaluator.cs	(revision 18094)
+++ /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionLogResidualEvaluator.cs	(revision 18095)
@@ -90,4 +90,14 @@
       return mlr;
     }
+
+    public override double Evaluate(IRegressionProblemData problemData,
+      ISymbolicExpressionTree solution,
+      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+      IEnumerable<int> rows = null,
+      bool applyLinearScaling = true,
+      double lowerEstimationLimit = double.MinValue,
+      double upperEstimationLimit = double.MaxValue) {
+      return Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows ?? problemData.TrainingIndices);
+    }
   }
 }
Index: /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionMeanRelativeErrorEvaluator.cs
===================================================================
--- /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionMeanRelativeErrorEvaluator.cs	(revision 18094)
+++ /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionMeanRelativeErrorEvaluator.cs	(revision 18095)
@@ -83,4 +83,14 @@
       return mre;
     }
+
+    public override double Evaluate(IRegressionProblemData problemData,
+      ISymbolicExpressionTree solution,
+      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+      IEnumerable<int> rows = null,
+      bool applyLinearScaling = true,
+      double lowerEstimationLimit = double.MinValue,
+      double upperEstimationLimit = double.MaxValue) {
+      return Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows ?? problemData.TrainingIndices);
+    }
   }
 }
Index: /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveEvaluator.cs
===================================================================
--- /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveEvaluator.cs	(revision 18094)
+++ /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveEvaluator.cs	(revision 18095)
@@ -22,4 +22,7 @@
 using HeuristicLab.Common;
 using HEAL.Attic;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using System.Collections.Generic;
+
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
   [StorableType("7EB90F03-4385-474F-BDE7-3B133E8FEAAB")]
@@ -28,5 +31,13 @@
     protected SymbolicRegressionSingleObjectiveEvaluator(StorableConstructorFlag _) : base(_) { }
     protected SymbolicRegressionSingleObjectiveEvaluator(SymbolicRegressionSingleObjectiveEvaluator original, Cloner cloner) : base(original, cloner) { }
-    protected SymbolicRegressionSingleObjectiveEvaluator(): base() {}    
+    protected SymbolicRegressionSingleObjectiveEvaluator(): base() {}
+    public abstract double Evaluate(
+      IRegressionProblemData problemData,
+      ISymbolicExpressionTree tree,
+      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+      IEnumerable<int> rows = null,
+      bool applyLinearScaling = true,
+      double lowerEstimationLimit = double.MinValue,
+      double upperEstimationLimit = double.MaxValue);
   }
 }
Index: /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator.cs
===================================================================
--- /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator.cs	(revision 18094)
+++ /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator.cs	(revision 18095)
@@ -84,4 +84,14 @@
       return mse;
     }
+
+    public override double Evaluate(IRegressionProblemData problemData,
+      ISymbolicExpressionTree solution,
+      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+      IEnumerable<int> rows = null,
+      bool applyLinearScaling = true,
+      double lowerEstimationLimit = double.MinValue,
+      double upperEstimationLimit = double.MaxValue) {
+      return Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows ?? problemData.TrainingIndices, applyLinearScaling);
+    }
   }
 }
Index: /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator.cs
===================================================================
--- /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator.cs	(revision 18094)
+++ /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator.cs	(revision 18095)
@@ -84,4 +84,14 @@
       return mse;
     }
+
+    public override double Evaluate(IRegressionProblemData problemData,
+      ISymbolicExpressionTree solution,
+      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+      IEnumerable<int> rows = null,
+      bool applyLinearScaling = true,
+      double lowerEstimationLimit = double.MinValue,
+      double upperEstimationLimit = double.MaxValue) {
+      return Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows ?? problemData.TrainingIndices, applyLinearScaling);
+    }
   }
 }
Index: /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.cs
===================================================================
--- /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.cs	(revision 18094)
+++ /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.cs	(revision 18095)
@@ -84,4 +84,14 @@
       return mse;
     }
+
+    public override double Evaluate(IRegressionProblemData problemData,
+      ISymbolicExpressionTree solution,
+      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+      IEnumerable<int> rows = null,
+      bool applyLinearScaling = true,
+      double lowerEstimationLimit = double.MinValue,
+      double upperEstimationLimit = double.MaxValue) {
+      return Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows ?? problemData.TrainingIndices, applyLinearScaling);
+    }
   }
 }
Index: /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs
===================================================================
--- /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs	(revision 18094)
+++ /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs	(revision 18095)
@@ -86,4 +86,14 @@
       return r2;
     }
+
+    public override double Evaluate(IRegressionProblemData problemData,
+      ISymbolicExpressionTree solution,
+      ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+      IEnumerable<int> rows = null,
+      bool applyLinearScaling = true,
+      double lowerEstimationLimit = double.MinValue,
+      double upperEstimationLimit = double.MaxValue) {
+      return Calculate(interpreter, solution, lowerEstimationLimit, upperEstimationLimit, problemData, rows ?? problemData.TrainingIndices, applyLinearScaling);
+    }
   }
 }
Index: /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/StructuredSymbolicRegressionSingleObjectiveProblem.cs
===================================================================
--- /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/StructuredSymbolicRegressionSingleObjectiveProblem.cs	(revision 18094)
+++ /branches/3136_Structural_GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/StructuredSymbolicRegressionSingleObjectiveProblem.cs	(revision 18095)
@@ -31,4 +31,5 @@
 
     private const string SymbolicExpressionTreeName = "SymbolicExpressionTree";
+    private const string VariableName = "Variable";
 
     private const string StructureTemplateDescriptionText =
@@ -94,5 +95,5 @@
 
       Parameters.Add(new ConstrainedValueParameter<SymbolicRegressionSingleObjectiveEvaluator>(
-        TreeEvaluatorParameterName, 
+        TreeEvaluatorParameterName,
         evaluators,
         evaluators.First()));
@@ -114,14 +115,10 @@
       Parameters.Add(new FixedValueParameter<DoubleLimit>(
         EstimationLimitsParameterName,
-        new DoubleLimit(targetInterval.LowerBound - estimationWidth, targetInterval.UpperBound + estimationWidth)));
-      EstimationLimitsParameter.Hidden = true;
-
-      Parameters.Add(new ResultParameter<ISymbolicRegressionSolution>(BestTrainingSolutionParameterName, ""));
-      this.BestTrainingSolutionParameter.Hidden = true;
+        new DoubleLimit(targetInterval.LowerBound - estimationWidth, targetInterval.UpperBound + estimationWidth)) { Hidden = true });
+
+      Parameters.Add(new ResultParameter<ISymbolicRegressionSolution>(BestTrainingSolutionParameterName, "") { Hidden = true });
 
       this.EvaluatorParameter.Hidden = true;
-
-     
-
+      
       Operators.Add(new SymbolicDataAnalysisVariableFrequencyAnalyzer());
       Operators.Add(new MinAverageMaxSymbolicExpressionTreeLengthAnalyzer());
@@ -175,6 +172,5 @@
       base.Analyze(individuals, qualities, results, random);
 
-      var orderedIndividuals = individuals.Zip(qualities, (i, q) => new { Individual = i, Quality = q }).OrderBy(z => z.Quality);
-      var best = Maximization ? orderedIndividuals.Last().Individual : orderedIndividuals.First().Individual;
+      var best = GetBestIndividual(individuals, qualities).Item1;
 
       if (!results.ContainsKey(BestTrainingSolutionParameter.ActualName)) {
@@ -199,45 +195,12 @@
       individual[SymbolicExpressionTreeName] = tree;
 
-      //TreeEvaluatorParameter.Value.EstimationLimitsParameter.ActualValue = EstimationLimits;
-      //TreeEvaluatorParameter.Value.EstimationLimitsParameter.Value = EstimationLimits;
-      //var quality = TreeEvaluatorParameter.Value.Evaluate(new ExecutionContext(null, this, new Scope("Test")), tree, ProblemData, ProblemData.TrainingIndices);
-
-      var quality = double.MaxValue;
-      var evaluatorGUID = TreeEvaluatorParameter.Value.GetType().GUID;
-
-      // TODO: use Evaluate method instead of static Calculate -> a fake ExecutionContext is needed
-      if (evaluatorGUID == typeof(NMSESingleObjectiveConstraintsEvaluator).GUID) {
-        quality = NMSESingleObjectiveConstraintsEvaluator.Calculate(
-        Interpreter, tree,
-        EstimationLimits.Lower, EstimationLimits.Upper,
-        ProblemData, ProblemData.TrainingIndices, new IntervalArithBoundsEstimator());
-      } else if (evaluatorGUID == typeof(SymbolicRegressionLogResidualEvaluator).GUID) {
-        quality = SymbolicRegressionLogResidualEvaluator.Calculate(
-        Interpreter, tree,
-        EstimationLimits.Lower, EstimationLimits.Upper,
-        ProblemData, ProblemData.TrainingIndices);
-      } else if (evaluatorGUID == typeof(SymbolicRegressionMeanRelativeErrorEvaluator).GUID) {
-        quality = SymbolicRegressionMeanRelativeErrorEvaluator.Calculate(
-        Interpreter, tree,
-        EstimationLimits.Lower, EstimationLimits.Upper,
-        ProblemData, ProblemData.TrainingIndices);
-      } else if (evaluatorGUID == typeof(SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator).GUID) {
-        quality = SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator.Calculate(
-        Interpreter, tree,
-        EstimationLimits.Lower, EstimationLimits.Upper,
-        ProblemData, ProblemData.TrainingIndices, false);
-      } else if (evaluatorGUID == typeof(SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator).GUID) {
-        quality = SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator.Calculate(
-        Interpreter, tree,
-        EstimationLimits.Lower, EstimationLimits.Upper,
-        ProblemData, ProblemData.TrainingIndices, false);
-      } else { // SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator
-        quality = SymbolicRegressionSingleObjectiveMeanSquaredErrorEvaluator.Calculate(
-        Interpreter, tree,
-        EstimationLimits.Lower, EstimationLimits.Upper,
-        ProblemData, ProblemData.TrainingIndices, false);
-      }
-    
-      return quality;
+      return TreeEvaluatorParameter.Value.Evaluate(
+        ProblemData, 
+        tree, 
+        Interpreter,
+        ProblemData.TrainingIndices,
+        StructureTemplate.ApplyLinearScaling,
+        EstimationLimits.Lower, 
+        EstimationLimits.Upper);
     }
 
@@ -280,5 +243,5 @@
 
     private void SetupVariables(SubFunction subFunction) {
-      var varSym = (Variable)subFunction.Grammar.GetSymbol("Variable");
+      var varSym = (Variable)subFunction.Grammar.GetSymbol(VariableName);
       if (varSym == null) {
         varSym = new Variable();
