Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj	(revision 18078)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj	(revision 18180)
@@ -129,5 +129,5 @@
     <Compile Include="Plugin.cs" />
     <Compile Include="ShapeConstraintsAnalyzer.cs" />
-    <Compile Include="SingleObjective\ConstantOptimizationAnalyzer.cs" />
+    <Compile Include="SingleObjective\ParameterOptimizationAnalyzer.cs" />
     <Compile Include="SingleObjective\Evaluators\NMSESingleObjectiveConstraintsEvaluator.cs" />
     <Compile Include="SingleObjective\Evaluators\SymbolicRegressionMeanRelativeErrorEvaluator.cs" />
@@ -142,5 +142,5 @@
     <Compile Include="SingleObjective\Evaluators\SymbolicRegressionSingleObjectiveMaxAbsoluteErrorEvaluator.cs" />
     <Compile Include="SingleObjective\Evaluators\SymbolicRegressionSingleObjectiveMeanAbsoluteErrorEvaluator.cs" />
-    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionConstantOptimizationEvaluator.cs" />
+    <Compile Include="SingleObjective\Evaluators\SymbolicRegressionParameterOptimizationEvaluator.cs" />
     <Compile Include="SingleObjective\SymbolicRegressionSingleObjectiveOverfittingAnalyzer.cs" />
     <Compile Include="SymbolicRegressionModel.cs" />
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/IMultiObjectiveConstraintsEvaluator.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/IMultiObjectiveConstraintsEvaluator.cs	(revision 18078)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/Interfaces/IMultiObjectiveConstraintsEvaluator.cs	(revision 18180)
@@ -27,5 +27,4 @@
   [StorableType("F96C5253-5A78-491C-95AE-78F64BD1F3B1")]
   public interface IMultiObjectiveConstraintsEvaluator : ISymbolicRegressionMultiObjectiveEvaluator {
-
     IFixedValueParameter<IntValue> NumConstraintsParameter { get; }
   }
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/NMSEMultiObjectiveConstraintsEvaluator.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/NMSEMultiObjectiveConstraintsEvaluator.cs	(revision 18078)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/NMSEMultiObjectiveConstraintsEvaluator.cs	(revision 18180)
@@ -90,9 +90,9 @@
       var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
 
-      if (UseConstantOptimization) {
-        SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, tree, problemData, rows,
+      if (UseParameterOptimization) {
+        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, tree, problemData, rows,
           false,
-          ConstantOptimizationIterations,
-          ConstantOptimizationUpdateVariableWeights,
+          ParameterOptimizationIterations,
+          ParameterOptimizationUpdateVariableWeights,
           estimationLimits.Lower,
           estimationLimits.Upper);
@@ -105,5 +105,5 @@
           var scaling = offset.GetSubtree(0);
 
-          //Check if tree contains offset and scaling nodes
+          // 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.");
@@ -115,5 +115,5 @@
           var newTree = new SymbolicExpressionTree(rootNode);
 
-          //calculate alpha and beta for scaling
+          // calculate alpha and beta for scaling
           var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(newTree, problemData.Dataset, rows);
 
@@ -122,8 +122,8 @@
             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;
+            // Set alpha and beta to the scaling nodes from linear scaling grammar
+            var offsetParameter = offset.GetSubtree(1) as NumberTreeNode;
             offsetParameter.Value = alpha;
-            var scalingParameter = scaling.GetSubtree(1) as ConstantTreeNode;
+            var scalingParameter = scaling.GetSubtree(1) as NumberTreeNode;
             scalingParameter.Value = beta;
           }
@@ -162,5 +162,4 @@
       double upperEstimationLimit,
       IRegressionProblemData problemData, IEnumerable<int> rows, IBoundsEstimator estimator, int decimalPlaces) {
-      OnlineCalculatorError errorState;
       var estimatedValues = interpreter.GetSymbolicExpressionTreeValues(solution, problemData.Dataset, rows);
       var targetValues = problemData.Dataset.GetDoubleValues(problemData.TargetVariable, rows);
@@ -174,5 +173,5 @@
 
       var boundedEstimatedValues = estimatedValues.LimitToRange(lowerEstimationLimit, upperEstimationLimit);
-      nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out errorState);
+      nmse = OnlineNormalizedMeanSquaredErrorCalculator.Calculate(targetValues, boundedEstimatedValues, out OnlineCalculatorError errorState);
 
       if (errorState != OnlineCalculatorError.None) nmse = 1.0;
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredAverageSimilarityEvaluator.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredAverageSimilarityEvaluator.cs	(revision 18078)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredAverageSimilarityEvaluator.cs	(revision 18180)
@@ -76,6 +76,6 @@
       var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
 
-      if (UseConstantOptimization) {
-        SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
+      if (UseParameterOptimization) {
+        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, solution, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
       }
 
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNestedTreeSizeEvaluator.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNestedTreeSizeEvaluator.cs	(revision 18078)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNestedTreeSizeEvaluator.cs	(revision 18180)
@@ -54,6 +54,6 @@
       var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
 
-      if (UseConstantOptimization) {
-        SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights,lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
+      if (UseParameterOptimization) {
+        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, solution, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights,lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
       }
 
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNumberOfVariablesEvaluator.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNumberOfVariablesEvaluator.cs	(revision 18078)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredNumberOfVariablesEvaluator.cs	(revision 18180)
@@ -54,6 +54,6 @@
       var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
 
-      if (UseConstantOptimization) {
-        SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
+      if (UseParameterOptimization) {
+        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, solution, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
       }
       double[] qualities = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces);
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredTreeComplexityEvaluator.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredTreeComplexityEvaluator.cs	(revision 18078)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/PearsonRSquaredTreeComplexityEvaluator.cs	(revision 18180)
@@ -53,6 +53,6 @@
       var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
 
-      if (UseConstantOptimization) {
-        SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
+      if (UseParameterOptimization) {
+        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, solution, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
       }
       double[] qualities = Calculate(interpreter, solution, estimationLimits.Lower, estimationLimits.Upper, problemData, rows, applyLinearScaling, DecimalPlaces);
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveEvaluator.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveEvaluator.cs	(revision 18078)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveEvaluator.cs	(revision 18180)
@@ -31,23 +31,23 @@
   public abstract class SymbolicRegressionMultiObjectiveEvaluator : SymbolicDataAnalysisMultiObjectiveEvaluator<IRegressionProblemData>, ISymbolicRegressionMultiObjectiveEvaluator {
     private const string DecimalPlacesParameterName = "Decimal Places";
-    private const string UseConstantOptimizationParameterName = "Use constant optimization";
-    private const string ConstantOptimizationIterationsParameterName = "Constant optimization iterations";
+    private const string UseParameterOptimizationParameterName = "Use parameter optimization";
+    private const string ParameterOptimizationIterationsParameterName = "Parameter optimization iterations";
 
-    private const string ConstantOptimizationUpdateVariableWeightsParameterName =
-      "Constant optimization update variable weights";
+    private const string ParameterOptimizationUpdateVariableWeightsParameterName =
+      "Parameter optimization update variable weights";
 
     public IFixedValueParameter<IntValue> DecimalPlacesParameter {
       get { return (IFixedValueParameter<IntValue>)Parameters[DecimalPlacesParameterName]; }
     }
-    public IFixedValueParameter<BoolValue> UseConstantOptimizationParameter {
-      get { return (IFixedValueParameter<BoolValue>)Parameters[UseConstantOptimizationParameterName]; }
+    public IFixedValueParameter<BoolValue> UseParameterOptimizationParameter {
+      get { return (IFixedValueParameter<BoolValue>)Parameters[UseParameterOptimizationParameterName]; }
     }
 
-    public IFixedValueParameter<IntValue> ConstantOptimizationIterationsParameter {
-      get { return (IFixedValueParameter<IntValue>)Parameters[ConstantOptimizationIterationsParameterName]; }
+    public IFixedValueParameter<IntValue> ParameterOptimizationIterationsParameter {
+      get { return (IFixedValueParameter<IntValue>)Parameters[ParameterOptimizationIterationsParameterName]; }
     }
 
-    public IFixedValueParameter<BoolValue> ConstantOptimizationUpdateVariableWeightsParameter {
-      get { return (IFixedValueParameter<BoolValue>)Parameters[ConstantOptimizationUpdateVariableWeightsParameterName]; }
+    public IFixedValueParameter<BoolValue> ParameterOptimizationUpdateVariableWeightsParameter {
+      get { return (IFixedValueParameter<BoolValue>)Parameters[ParameterOptimizationUpdateVariableWeightsParameterName]; }
     }
 
@@ -56,15 +56,15 @@
       set { DecimalPlacesParameter.Value.Value = value; }
     }
-    public bool UseConstantOptimization {
-      get { return UseConstantOptimizationParameter.Value.Value; }
-      set { UseConstantOptimizationParameter.Value.Value = value; }
+    public bool UseParameterOptimization {
+      get { return UseParameterOptimizationParameter.Value.Value; }
+      set { UseParameterOptimizationParameter.Value.Value = value; }
     }
-    public int ConstantOptimizationIterations {
-      get { return ConstantOptimizationIterationsParameter.Value.Value; }
-      set { ConstantOptimizationIterationsParameter.Value.Value = value; }
+    public int ParameterOptimizationIterations {
+      get { return ParameterOptimizationIterationsParameter.Value.Value; }
+      set { ParameterOptimizationIterationsParameter.Value.Value = value; }
     }
-    public bool ConstantOptimizationUpdateVariableWeights {
-      get { return ConstantOptimizationUpdateVariableWeightsParameter.Value.Value; }
-      set { ConstantOptimizationUpdateVariableWeightsParameter.Value.Value = value; }
+    public bool ParameterOptimizationUpdateVariableWeights {
+      get { return ParameterOptimizationUpdateVariableWeightsParameter.Value.Value; }
+      set { ParameterOptimizationUpdateVariableWeightsParameter.Value.Value = value; }
     }
 
@@ -78,22 +78,39 @@
       : base() {
       Parameters.Add(new FixedValueParameter<IntValue>(DecimalPlacesParameterName, "The number of decimal places used for rounding the quality values.", new IntValue(5)) { Hidden = true });
-      Parameters.Add(new FixedValueParameter<BoolValue>(UseConstantOptimizationParameterName, "", new BoolValue(false)));
-      Parameters.Add(new FixedValueParameter<IntValue>(ConstantOptimizationIterationsParameterName, "The number of iterations constant optimization should be applied.", new IntValue(5)));
-      Parameters.Add(new FixedValueParameter<BoolValue>(ConstantOptimizationUpdateVariableWeightsParameterName, "Determines if the variable weights in the tree should be optimized during constant optimization.", new BoolValue(true)) { Hidden = true });
+      Parameters.Add(new FixedValueParameter<BoolValue>(UseParameterOptimizationParameterName, "", new BoolValue(false)));
+      Parameters.Add(new FixedValueParameter<IntValue>(ParameterOptimizationIterationsParameterName, "The number of iterations parameter optimization should be applied.", new IntValue(5)));
+      Parameters.Add(new FixedValueParameter<BoolValue>(ParameterOptimizationUpdateVariableWeightsParameterName, "Determines if the variable weights in the tree should be optimized during parameter optimization.", new BoolValue(true)) { Hidden = true });
     }
 
     [StorableHook(HookType.AfterDeserialization)]
     private void AfterDeserialization() {
-      if (!Parameters.ContainsKey(UseConstantOptimizationParameterName)) {
-        Parameters.Add(new FixedValueParameter<BoolValue>(UseConstantOptimizationParameterName, "", new BoolValue(false)));
+      if (!Parameters.ContainsKey(UseParameterOptimizationParameterName)) {
+        if (Parameters.ContainsKey("Use constant optimization")) {
+          Parameters.Add(new FixedValueParameter<BoolValue>(UseParameterOptimizationParameterName, "", (BoolValue)Parameters["Use constant optimization"].ActualValue));
+          Parameters.Remove("Use constant optimization");
+        } else {
+          Parameters.Add(new FixedValueParameter<BoolValue>(UseParameterOptimizationParameterName, "", new BoolValue(false)));
+        }
       }
+
       if (!Parameters.ContainsKey(DecimalPlacesParameterName)) {
         Parameters.Add(new FixedValueParameter<IntValue>(DecimalPlacesParameterName, "The number of decimal places used for rounding the quality values.", new IntValue(-1)) { Hidden = true });
       }
-      if (!Parameters.ContainsKey(ConstantOptimizationIterationsParameterName)) {
-        Parameters.Add(new FixedValueParameter<IntValue>(ConstantOptimizationIterationsParameterName, "The number of iterations constant optimization should be applied.", new IntValue(5)));
+      if (!Parameters.ContainsKey(ParameterOptimizationIterationsParameterName)) {
+        if (Parameters.ContainsKey("Constant optimization iterations")) {
+          Parameters.Add(new FixedValueParameter<IntValue>(ParameterOptimizationIterationsParameterName, "The number of iterations parameter optimization should be applied.", (IntValue)Parameters["Constant optimization iterations"].ActualValue));
+          Parameters.Remove("Constant optimization iterations");
+        } else {
+          Parameters.Add(new FixedValueParameter<IntValue>(ParameterOptimizationIterationsParameterName, "The number of iterations parameter optimization should be applied.", new IntValue(5)));
+        }
       }
-      if (!Parameters.ContainsKey(ConstantOptimizationUpdateVariableWeightsParameterName)) {
-        Parameters.Add(new FixedValueParameter<BoolValue>(ConstantOptimizationUpdateVariableWeightsParameterName, "Determines if the variable weights in the tree should be optimized during constant optimization.", new BoolValue(true)));
+      if (!Parameters.ContainsKey(ParameterOptimizationUpdateVariableWeightsParameterName)) {
+        if (Parameters.ContainsKey("Constant optimization update variable weights")) {
+          Parameters.Add(new FixedValueParameter<BoolValue>(ParameterOptimizationUpdateVariableWeightsParameterName, "Determines if the variable weights in the tree should be optimized during parameter optimization.",
+            (BoolValue)Parameters["Constant optimization update variable weights"].ActualValue));
+          Parameters.Remove("Constant optimization update variable weights");
+        } else {
+          Parameters.Add(new FixedValueParameter<BoolValue>(ParameterOptimizationUpdateVariableWeightsParameterName, "Determines if the variable weights in the tree should be optimized during parameter optimization.", new BoolValue(true)));
+        }
       }
     }
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs	(revision 18078)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectiveMeanSquaredErrorTreeSizeEvaluator.cs	(revision 18180)
@@ -53,6 +53,6 @@
       var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
 
-      if (UseConstantOptimization) {
-        SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
+      if (UseParameterOptimization) {
+        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, solution, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
       }
 
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs	(revision 18078)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/MultiObjective/SymbolicRegressionMultiObjectivePearsonRSquaredTreeSizeEvaluator.cs	(revision 18180)
@@ -53,6 +53,6 @@
       var applyLinearScaling = ApplyLinearScalingParameter.ActualValue.Value;
 
-      if (UseConstantOptimization) {
-        SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, solution, problemData, rows, applyLinearScaling, ConstantOptimizationIterations, updateVariableWeights: ConstantOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
+      if (UseParameterOptimization) {
+        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, solution, problemData, rows, applyLinearScaling, ParameterOptimizationIterations, updateVariableWeights: ParameterOptimizationUpdateVariableWeights, lowerEstimationLimit: estimationLimits.Lower, upperEstimationLimit: estimationLimits.Upper);
       }
       double[] qualities = Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, rows, ApplyLinearScalingParameter.ActualValue.Value, DecimalPlaces);
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/ConstantOptimizationAnalyzer.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/ConstantOptimizationAnalyzer.cs	(revision 18078)
+++ 	(revision )
@@ -1,175 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Linq;
-using HeuristicLab.Analysis;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Optimization;
-using HeuristicLab.Parameters;
-using HEAL.Attic;
-
-namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
-  /// <summary>
-  /// An operator that optimizes the constants for the best symbolic expression tress in the current generation.
-  /// </summary>
-  [Item("ConstantOptimizationAnalyzer", "An operator that performs a constant optimization on the best symbolic expression trees.")]
-  [StorableType("9FB87E7B-A9E2-49DD-A92A-78BD9FC17916")]
-  public sealed class ConstantOptimizationAnalyzer : SymbolicDataAnalysisSingleObjectiveAnalyzer, IStatefulItem {
-    private const string PercentageOfBestSolutionsParameterName = "PercentageOfBestSolutions";
-    private const string ConstantOptimizationEvaluatorParameterName = "ConstantOptimizationOperator";
-
-    private const string DataTableNameConstantOptimizationImprovement = "Constant Optimization Improvement";
-    private const string DataRowNameMinimumImprovement = "Minimum improvement";
-    private const string DataRowNameMedianImprovement = "Median improvement";
-    private const string DataRowNameAverageImprovement = "Average improvement";
-    private const string DataRowNameMaximumImprovement = "Maximum improvement";
-
-    #region parameter properties
-    public IFixedValueParameter<PercentValue> PercentageOfBestSolutionsParameter {
-      get { return (IFixedValueParameter<PercentValue>)Parameters[PercentageOfBestSolutionsParameterName]; }
-    }
-
-    public IFixedValueParameter<SymbolicRegressionConstantOptimizationEvaluator> ConstantOptimizationEvaluatorParameter {
-      get { return (IFixedValueParameter<SymbolicRegressionConstantOptimizationEvaluator>)Parameters[ConstantOptimizationEvaluatorParameterName]; }
-    }
-    #endregion
-
-    #region properties
-    public SymbolicRegressionConstantOptimizationEvaluator ConstantOptimizationEvaluator {
-      get { return ConstantOptimizationEvaluatorParameter.Value; }
-    }
-    public double PercentageOfBestSolutions {
-      get { return PercentageOfBestSolutionsParameter.Value.Value; }
-    }
-
-    private DataTable ConstantOptimizationImprovementDataTable {
-      get {
-        IResult result;
-        ResultCollection.TryGetValue(DataTableNameConstantOptimizationImprovement, out result);
-        if (result == null) return null;
-        return (DataTable)result.Value;
-      }
-    }
-    private DataRow MinimumImprovement {
-      get { return ConstantOptimizationImprovementDataTable.Rows[DataRowNameMinimumImprovement]; }
-    }
-    private DataRow MedianImprovement {
-      get { return ConstantOptimizationImprovementDataTable.Rows[DataRowNameMedianImprovement]; }
-    }
-    private DataRow AverageImprovement {
-      get { return ConstantOptimizationImprovementDataTable.Rows[DataRowNameAverageImprovement]; }
-    }
-    private DataRow MaximumImprovement {
-      get { return ConstantOptimizationImprovementDataTable.Rows[DataRowNameMaximumImprovement]; }
-    }
-    #endregion
-
-    [StorableConstructor]
-    private ConstantOptimizationAnalyzer(StorableConstructorFlag _) : base(_) { }
-    private ConstantOptimizationAnalyzer(ConstantOptimizationAnalyzer original, Cloner cloner) : base(original, cloner) { }
-    public override IDeepCloneable Clone(Cloner cloner) { return new ConstantOptimizationAnalyzer(this, cloner); }
-    public ConstantOptimizationAnalyzer()
-      : base() {
-      Parameters.Add(new FixedValueParameter<PercentValue>(PercentageOfBestSolutionsParameterName, "The percentage of the top solutions which should be analyzed.", new PercentValue(0.1)));
-      Parameters.Add(new FixedValueParameter<SymbolicRegressionConstantOptimizationEvaluator>(ConstantOptimizationEvaluatorParameterName, "The operator used to perform the constant optimization"));
-
-      //Changed the ActualName of the EvaluationPartitionParameter so that it matches the parameter name of symbolic regression problems.
-      ConstantOptimizationEvaluator.EvaluationPartitionParameter.ActualName = "FitnessCalculationPartition";
-    }
-
-
-    private double[] qualitiesBeforeCoOp = null;
-    private int[] scopeIndexes = null;
-    void IStatefulItem.InitializeState() {
-      qualitiesBeforeCoOp = null;
-      scopeIndexes = null;
-    }
-    void IStatefulItem.ClearState() {
-      qualitiesBeforeCoOp = null;
-      scopeIndexes = null;
-    }
-
-    public override IOperation Apply() {
-      //code executed in the first call of analyzer
-      if (qualitiesBeforeCoOp == null) {
-        double[] trainingQuality;
-        // sort is ascending and we take the first n% => order so that best solutions are smallest
-        // sort order is determined by maximization parameter
-        if (Maximization.Value) {
-          // largest values must be sorted first
-          trainingQuality = Quality.Select(x => -x.Value).ToArray();
-        } else {
-          // smallest values must be sorted first
-          trainingQuality = Quality.Select(x => x.Value).ToArray();
-        }
-        // sort trees by training qualities
-        int topN = (int)Math.Max(trainingQuality.Length * PercentageOfBestSolutions, 1);
-        scopeIndexes = Enumerable.Range(0, trainingQuality.Length).ToArray();
-        Array.Sort(trainingQuality, scopeIndexes);
-        scopeIndexes = scopeIndexes.Take(topN).ToArray();
-        qualitiesBeforeCoOp = scopeIndexes.Select(x => Quality[x].Value).ToArray();
-
-        OperationCollection operationCollection = new OperationCollection();
-        operationCollection.Parallel = true;
-        foreach (var scopeIndex in scopeIndexes) {
-          var childOperation = ExecutionContext.CreateChildOperation(ConstantOptimizationEvaluator, ExecutionContext.Scope.SubScopes[scopeIndex]);
-          operationCollection.Add(childOperation);
-        }
-
-        return new OperationCollection { operationCollection, ExecutionContext.CreateOperation(this) };
-      }
-
-      //code executed to analyze results of constant optimization
-      double[] qualitiesAfterCoOp = scopeIndexes.Select(x => Quality[x].Value).ToArray();
-      var qualityImprovement = qualitiesBeforeCoOp.Zip(qualitiesAfterCoOp, (b, a) => a - b).ToArray();
-
-      if (!ResultCollection.ContainsKey(DataTableNameConstantOptimizationImprovement)) {
-        var dataTable = new DataTable(DataTableNameConstantOptimizationImprovement);
-        ResultCollection.Add(new Result(DataTableNameConstantOptimizationImprovement, dataTable));
-        dataTable.VisualProperties.YAxisTitle = "R²";
-
-        dataTable.Rows.Add(new DataRow(DataRowNameMinimumImprovement));
-        MinimumImprovement.VisualProperties.StartIndexZero = true;
-
-        dataTable.Rows.Add(new DataRow(DataRowNameMedianImprovement));
-        MedianImprovement.VisualProperties.StartIndexZero = true;
-
-        dataTable.Rows.Add(new DataRow(DataRowNameAverageImprovement));
-        AverageImprovement.VisualProperties.StartIndexZero = true;
-
-        dataTable.Rows.Add(new DataRow(DataRowNameMaximumImprovement));
-        MaximumImprovement.VisualProperties.StartIndexZero = true;
-      }
-
-      MinimumImprovement.Values.Add(qualityImprovement.Min());
-      MedianImprovement.Values.Add(qualityImprovement.Median());
-      AverageImprovement.Values.Add(qualityImprovement.Average());
-      MaximumImprovement.Values.Add(qualityImprovement.Max());
-
-      qualitiesBeforeCoOp = null;
-      scopeIndexes = null;
-      return base.Apply();
-    }
-  }
-}
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/NMSESingleObjectiveConstraintsEvaluator.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/NMSESingleObjectiveConstraintsEvaluator.cs	(revision 18078)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/NMSESingleObjectiveConstraintsEvaluator.cs	(revision 18180)
@@ -46,5 +46,5 @@
       (IFixedValueParameter<BoolValue>)Parameters[OptimizeParametersParameterName];
 
-    public IFixedValueParameter<IntValue> ConstantOptimizationIterationsParameter =>
+    public IFixedValueParameter<IntValue> ParameterOptimizationIterationsParameter =>
       (IFixedValueParameter<IntValue>)Parameters[ParameterOptimizationIterationsParameterName];
 
@@ -62,7 +62,7 @@
     }
 
-    public int ConstantOptimizationIterations {
-      get => ConstantOptimizationIterationsParameter.Value.Value;
-      set => ConstantOptimizationIterationsParameter.Value.Value = value;
+    public int ParameterOptimizationIterations {
+      get => ParameterOptimizationIterationsParameter.Value.Value;
+      set => ParameterOptimizationIterationsParameter.Value.Value = value;
     }
 
@@ -97,5 +97,5 @@
     public NMSESingleObjectiveConstraintsEvaluator() {
       Parameters.Add(new FixedValueParameter<BoolValue>(OptimizeParametersParameterName,
-        "Define whether optimization of numeric parameters is active or not (default: false).", new BoolValue(false)));
+        "Define whether optimization of parameters is active or not (default: false).", new BoolValue(false)));
       Parameters.Add(new FixedValueParameter<IntValue>(ParameterOptimizationIterationsParameterName,
         "Define how many parameter optimization steps should be performed (default: 10).", new IntValue(10)));
@@ -126,6 +126,6 @@
 
       if (OptimizeParameters) {
-        SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(interpreter, tree, problemData, rows,
-          false, ConstantOptimizationIterations, true,
+        SymbolicRegressionParameterOptimizationEvaluator.OptimizeParameters(interpreter, tree, problemData, rows,
+          false, ParameterOptimizationIterations, true,
           estimationLimits.Lower, estimationLimits.Upper);
       } else {
@@ -155,7 +155,7 @@
           if (errorState == OnlineCalculatorError.None) {
             //Set alpha and beta to the scaling nodes from ia grammar
-            var offsetParameter = offset.GetSubtree(1) as ConstantTreeNode;
+            var offsetParameter = offset.GetSubtree(1) as NumberTreeNode;
             offsetParameter.Value = alpha;
-            var scalingParameter = scaling.GetSubtree(1) as ConstantTreeNode;
+            var scalingParameter = scaling.GetSubtree(1) as NumberTreeNode;
             scalingParameter.Value = beta;
           }
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionConstantOptimizationEvaluator.cs	(revision 18078)
+++ 	(revision )
@@ -1,346 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
- *
- * This file is part of HeuristicLab.
- *
- * HeuristicLab is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * HeuristicLab is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
- */
-#endregion
-
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using HEAL.Attic;
-using HeuristicLab.Common;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
-using HeuristicLab.Optimization;
-using HeuristicLab.Parameters;
-
-namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
-  [Item("Constant Optimization Evaluator", "Calculates Pearson R² of a symbolic regression solution and optimizes the constant used.")]
-  [StorableType("24B68851-036D-4446-BD6F-3823E9028FF4")]
-  public class SymbolicRegressionConstantOptimizationEvaluator : SymbolicRegressionSingleObjectiveEvaluator {
-    private const string ConstantOptimizationIterationsParameterName = "ConstantOptimizationIterations";
-    private const string ConstantOptimizationImprovementParameterName = "ConstantOptimizationImprovement";
-    private const string ConstantOptimizationProbabilityParameterName = "ConstantOptimizationProbability";
-    private const string ConstantOptimizationRowsPercentageParameterName = "ConstantOptimizationRowsPercentage";
-    private const string UpdateConstantsInTreeParameterName = "UpdateConstantsInSymbolicExpressionTree";
-    private const string UpdateVariableWeightsParameterName = "Update Variable Weights";
-
-    private const string FunctionEvaluationsResultParameterName = "Constants Optimization Function Evaluations";
-    private const string GradientEvaluationsResultParameterName = "Constants Optimization Gradient Evaluations";
-    private const string CountEvaluationsParameterName = "Count Function and Gradient Evaluations";
-
-    public IFixedValueParameter<IntValue> ConstantOptimizationIterationsParameter {
-      get { return (IFixedValueParameter<IntValue>)Parameters[ConstantOptimizationIterationsParameterName]; }
-    }
-    public IFixedValueParameter<DoubleValue> ConstantOptimizationImprovementParameter {
-      get { return (IFixedValueParameter<DoubleValue>)Parameters[ConstantOptimizationImprovementParameterName]; }
-    }
-    public IFixedValueParameter<PercentValue> ConstantOptimizationProbabilityParameter {
-      get { return (IFixedValueParameter<PercentValue>)Parameters[ConstantOptimizationProbabilityParameterName]; }
-    }
-    public IFixedValueParameter<PercentValue> ConstantOptimizationRowsPercentageParameter {
-      get { return (IFixedValueParameter<PercentValue>)Parameters[ConstantOptimizationRowsPercentageParameterName]; }
-    }
-    public IFixedValueParameter<BoolValue> UpdateConstantsInTreeParameter {
-      get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateConstantsInTreeParameterName]; }
-    }
-    public IFixedValueParameter<BoolValue> UpdateVariableWeightsParameter {
-      get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateVariableWeightsParameterName]; }
-    }
-
-    public IResultParameter<IntValue> FunctionEvaluationsResultParameter {
-      get { return (IResultParameter<IntValue>)Parameters[FunctionEvaluationsResultParameterName]; }
-    }
-    public IResultParameter<IntValue> GradientEvaluationsResultParameter {
-      get { return (IResultParameter<IntValue>)Parameters[GradientEvaluationsResultParameterName]; }
-    }
-    public IFixedValueParameter<BoolValue> CountEvaluationsParameter {
-      get { return (IFixedValueParameter<BoolValue>)Parameters[CountEvaluationsParameterName]; }
-    }
-
-
-    public IntValue ConstantOptimizationIterations {
-      get { return ConstantOptimizationIterationsParameter.Value; }
-    }
-    public DoubleValue ConstantOptimizationImprovement {
-      get { return ConstantOptimizationImprovementParameter.Value; }
-    }
-    public PercentValue ConstantOptimizationProbability {
-      get { return ConstantOptimizationProbabilityParameter.Value; }
-    }
-    public PercentValue ConstantOptimizationRowsPercentage {
-      get { return ConstantOptimizationRowsPercentageParameter.Value; }
-    }
-    public bool UpdateConstantsInTree {
-      get { return UpdateConstantsInTreeParameter.Value.Value; }
-      set { UpdateConstantsInTreeParameter.Value.Value = value; }
-    }
-
-    public bool UpdateVariableWeights {
-      get { return UpdateVariableWeightsParameter.Value.Value; }
-      set { UpdateVariableWeightsParameter.Value.Value = value; }
-    }
-
-    public bool CountEvaluations {
-      get { return CountEvaluationsParameter.Value.Value; }
-      set { CountEvaluationsParameter.Value.Value = value; }
-    }
-
-    public override bool Maximization {
-      get { return true; }
-    }
-
-    [StorableConstructor]
-    protected SymbolicRegressionConstantOptimizationEvaluator(StorableConstructorFlag _) : base(_) { }
-    protected SymbolicRegressionConstantOptimizationEvaluator(SymbolicRegressionConstantOptimizationEvaluator original, Cloner cloner)
-      : base(original, cloner) {
-    }
-    public SymbolicRegressionConstantOptimizationEvaluator()
-      : base() {
-      Parameters.Add(new FixedValueParameter<IntValue>(ConstantOptimizationIterationsParameterName, "Determines how many iterations should be calculated while optimizing the constant of a symbolic expression tree (0 indicates other or default stopping criterion).", new IntValue(10)));
-      Parameters.Add(new FixedValueParameter<DoubleValue>(ConstantOptimizationImprovementParameterName, "Determines the relative improvement which must be achieved in the constant optimization to continue with it (0 indicates other or default stopping criterion).", new DoubleValue(0)) { Hidden = true });
-      Parameters.Add(new FixedValueParameter<PercentValue>(ConstantOptimizationProbabilityParameterName, "Determines the probability that the constants are optimized", new PercentValue(1)));
-      Parameters.Add(new FixedValueParameter<PercentValue>(ConstantOptimizationRowsPercentageParameterName, "Determines the percentage of the rows which should be used for constant optimization", new PercentValue(1)));
-      Parameters.Add(new FixedValueParameter<BoolValue>(UpdateConstantsInTreeParameterName, "Determines if the constants in the tree should be overwritten by the optimized constants.", new BoolValue(true)) { Hidden = true });
-      Parameters.Add(new FixedValueParameter<BoolValue>(UpdateVariableWeightsParameterName, "Determines if the variable weights in the tree should be  optimized.", new BoolValue(true)) { Hidden = true });
-
-      Parameters.Add(new FixedValueParameter<BoolValue>(CountEvaluationsParameterName, "Determines if function and gradient evaluation should be counted.", new BoolValue(false)));
-      Parameters.Add(new ResultParameter<IntValue>(FunctionEvaluationsResultParameterName, "The number of function evaluations performed by the constants optimization evaluator", "Results", new IntValue()));
-      Parameters.Add(new ResultParameter<IntValue>(GradientEvaluationsResultParameterName, "The number of gradient evaluations performed by the constants optimization evaluator", "Results", new IntValue()));
-    }
-
-    public override IDeepCloneable Clone(Cloner cloner) {
-      return new SymbolicRegressionConstantOptimizationEvaluator(this, cloner);
-    }
-
-    [StorableHook(HookType.AfterDeserialization)]
-    private void AfterDeserialization() {
-      if (!Parameters.ContainsKey(UpdateConstantsInTreeParameterName))
-        Parameters.Add(new FixedValueParameter<BoolValue>(UpdateConstantsInTreeParameterName, "Determines if the constants in the tree should be overwritten by the optimized constants.", new BoolValue(true)));
-      if (!Parameters.ContainsKey(UpdateVariableWeightsParameterName))
-        Parameters.Add(new FixedValueParameter<BoolValue>(UpdateVariableWeightsParameterName, "Determines if the variable weights in the tree should be  optimized.", new BoolValue(true)));
-
-      if (!Parameters.ContainsKey(CountEvaluationsParameterName))
-        Parameters.Add(new FixedValueParameter<BoolValue>(CountEvaluationsParameterName, "Determines if function and gradient evaluation should be counted.", new BoolValue(false)));
-
-      if (!Parameters.ContainsKey(FunctionEvaluationsResultParameterName))
-        Parameters.Add(new ResultParameter<IntValue>(FunctionEvaluationsResultParameterName, "The number of function evaluations performed by the constants optimization evaluator", "Results", new IntValue()));
-      if (!Parameters.ContainsKey(GradientEvaluationsResultParameterName))
-        Parameters.Add(new ResultParameter<IntValue>(GradientEvaluationsResultParameterName, "The number of gradient evaluations performed by the constants optimization evaluator", "Results", new IntValue()));
-    }
-
-    private static readonly object locker = new object();
-    public override IOperation InstrumentedApply() {
-      var solution = SymbolicExpressionTreeParameter.ActualValue;
-      double quality;
-      if (RandomParameter.ActualValue.NextDouble() < ConstantOptimizationProbability.Value) {
-        IEnumerable<int> constantOptimizationRows = GenerateRowsToEvaluate(ConstantOptimizationRowsPercentage.Value);
-        var counter = new EvaluationsCounter();
-        quality = OptimizeConstants(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, ProblemDataParameter.ActualValue,
-           constantOptimizationRows, ApplyLinearScalingParameter.ActualValue.Value, ConstantOptimizationIterations.Value, updateVariableWeights: UpdateVariableWeights, lowerEstimationLimit: EstimationLimitsParameter.ActualValue.Lower, upperEstimationLimit: EstimationLimitsParameter.ActualValue.Upper, updateConstantsInTree: UpdateConstantsInTree, counter: counter);
-
-        if (ConstantOptimizationRowsPercentage.Value != RelativeNumberOfEvaluatedSamplesParameter.ActualValue.Value) {
-          var evaluationRows = GenerateRowsToEvaluate();
-          quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, evaluationRows, ApplyLinearScalingParameter.ActualValue.Value);
-        }
-
-        if (CountEvaluations) {
-          lock (locker) {
-            FunctionEvaluationsResultParameter.ActualValue.Value += counter.FunctionEvaluations;
-            GradientEvaluationsResultParameter.ActualValue.Value += counter.GradientEvaluations;
-          }
-        }
-
-      } else {
-        var evaluationRows = GenerateRowsToEvaluate();
-        quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, evaluationRows, ApplyLinearScalingParameter.ActualValue.Value);
-      }
-      QualityParameter.ActualValue = new DoubleValue(quality);
-
-      return base.InstrumentedApply();
-    }
-
-    public override double Evaluate(IExecutionContext context, ISymbolicExpressionTree tree, IRegressionProblemData problemData, IEnumerable<int> rows) {
-      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = context;
-      EstimationLimitsParameter.ExecutionContext = context;
-      ApplyLinearScalingParameter.ExecutionContext = context;
-      FunctionEvaluationsResultParameter.ExecutionContext = context;
-      GradientEvaluationsResultParameter.ExecutionContext = context;
-
-      // Pearson R² evaluator is used on purpose instead of the const-opt evaluator, 
-      // because Evaluate() is used to get the quality of evolved models on 
-      // different partitions of the dataset (e.g., best validation model)
-      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value);
-
-      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
-      EstimationLimitsParameter.ExecutionContext = null;
-      ApplyLinearScalingParameter.ExecutionContext = null;
-      FunctionEvaluationsResultParameter.ExecutionContext = null;
-      GradientEvaluationsResultParameter.ExecutionContext = null;
-
-      return r2;
-    }
-
-    public class EvaluationsCounter {
-      public int FunctionEvaluations = 0;
-      public int GradientEvaluations = 0;
-    }
-
-    public static double OptimizeConstants(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
-      ISymbolicExpressionTree tree, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling,
-      int maxIterations, bool updateVariableWeights = true,
-      double lowerEstimationLimit = double.MinValue, double upperEstimationLimit = double.MaxValue,
-      bool updateConstantsInTree = true, Action<double[], double, object> iterationCallback = null, EvaluationsCounter counter = null) {
-
-      // Numeric constants in the tree become variables for parameter optimization.
-      // Variables in the tree become parameters (fixed values) for parameter optimization.
-      // For each parameter (variable in the original tree) we store the 
-      // variable name, variable value (for factor vars) and lag as a DataForVariable object.
-      // A dictionary is used to find parameters
-      double[] initialConstants;
-      var parameters = new List<TreeToAutoDiffTermConverter.DataForVariable>();
-
-      TreeToAutoDiffTermConverter.ParametricFunction func;
-      TreeToAutoDiffTermConverter.ParametricFunctionGradient func_grad;
-      if (!TreeToAutoDiffTermConverter.TryConvertToAutoDiff(tree, updateVariableWeights, applyLinearScaling, out parameters, out initialConstants, out func, out func_grad))
-        throw new NotSupportedException("Could not optimize constants of symbolic expression tree due to not supported symbols used in the tree.");
-      if (parameters.Count == 0) return 0.0; // constant expressions always have a R² of 0.0 
-      var parameterEntries = parameters.ToArray(); // order of entries must be the same for x
-
-      // extract inital constants
-      double[] c;
-      if (applyLinearScaling) {
-        c = new double[initialConstants.Length + 2];
-        c[0] = 0.0;
-        c[1] = 1.0;
-        Array.Copy(initialConstants, 0, c, 2, initialConstants.Length);
-      } else {
-        c = (double[])initialConstants.Clone();
-      }
-
-      double originalQuality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, tree, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling);
-
-      if (counter == null) counter = new EvaluationsCounter();
-      var rowEvaluationsCounter = new EvaluationsCounter();
-
-      alglib.lsfitstate state;
-      alglib.lsfitreport rep;
-      int retVal;
-
-      IDataset ds = problemData.Dataset;
-      double[,] x = new double[rows.Count(), parameters.Count];
-      int row = 0;
-      foreach (var r in rows) {
-        int col = 0;
-        foreach (var info in parameterEntries) {
-          if (ds.VariableHasType<double>(info.variableName)) {
-            x[row, col] = ds.GetDoubleValue(info.variableName, r + info.lag);
-          } else if (ds.VariableHasType<string>(info.variableName)) {
-            x[row, col] = ds.GetStringValue(info.variableName, r) == info.variableValue ? 1 : 0;
-          } else throw new InvalidProgramException("found a variable of unknown type");
-          col++;
-        }
-        row++;
-      }
-      double[] y = ds.GetDoubleValues(problemData.TargetVariable, rows).ToArray();
-      int n = x.GetLength(0);
-      int m = x.GetLength(1);
-      int k = c.Length;
-
-      alglib.ndimensional_pfunc function_cx_1_func = CreatePFunc(func);
-      alglib.ndimensional_pgrad function_cx_1_grad = CreatePGrad(func_grad);
-      alglib.ndimensional_rep xrep = (p, f, obj) => iterationCallback(p, f, obj);
-
-      try {
-        alglib.lsfitcreatefg(x, y, c, n, m, k, false, out state);
-        alglib.lsfitsetcond(state, 0.0, maxIterations);
-        alglib.lsfitsetxrep(state, iterationCallback != null);
-        alglib.lsfitfit(state, function_cx_1_func, function_cx_1_grad, xrep, rowEvaluationsCounter);
-        alglib.lsfitresults(state, out retVal, out c, out rep);
-      } catch (ArithmeticException) {
-        return originalQuality;
-      } catch (alglib.alglibexception) {
-        return originalQuality;
-      }
-
-      counter.FunctionEvaluations += rowEvaluationsCounter.FunctionEvaluations / n;
-      counter.GradientEvaluations += rowEvaluationsCounter.GradientEvaluations / n;
-
-      //retVal == -7  => constant optimization failed due to wrong gradient
-      //          -8  => optimizer detected  NAN / INF  in  the target
-      //                 function and/ or gradient
-      if (retVal != -7 && retVal != -8) {
-        if (applyLinearScaling) {
-          var tmp = new double[c.Length - 2];
-          Array.Copy(c, 2, tmp, 0, tmp.Length);
-          UpdateConstants(tree, tmp, updateVariableWeights);
-        } else UpdateConstants(tree, c, updateVariableWeights);
-      }
-      var quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, tree, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling);
-
-      if (!updateConstantsInTree) UpdateConstants(tree, initialConstants, updateVariableWeights);
-
-      if (originalQuality - quality > 0.001 || double.IsNaN(quality)) {
-        UpdateConstants(tree, initialConstants, updateVariableWeights);
-        return originalQuality;
-      }
-      return quality;
-    }
-
-    private static void UpdateConstants(ISymbolicExpressionTree tree, double[] constants, bool updateVariableWeights) {
-      int i = 0;
-      foreach (var node in tree.Root.IterateNodesPrefix().OfType<SymbolicExpressionTreeTerminalNode>()) {
-        ConstantTreeNode constantTreeNode = node as ConstantTreeNode;
-        VariableTreeNodeBase variableTreeNodeBase = node as VariableTreeNodeBase;
-        FactorVariableTreeNode factorVarTreeNode = node as FactorVariableTreeNode;
-        if (constantTreeNode != null) {
-          if (constantTreeNode.Parent.Symbol is Power 
-              && constantTreeNode.Parent.GetSubtree(1) == constantTreeNode) continue; // exponents in powers are not optimizated (see TreeToAutoDiffTermConverter)
-          constantTreeNode.Value = constants[i++];
-        } else if (updateVariableWeights && variableTreeNodeBase != null)
-          variableTreeNodeBase.Weight = constants[i++];
-        else if (factorVarTreeNode != null) {
-          for (int j = 0; j < factorVarTreeNode.Weights.Length; j++)
-            factorVarTreeNode.Weights[j] = constants[i++];
-        }
-      }
-    }
-
-    private static alglib.ndimensional_pfunc CreatePFunc(TreeToAutoDiffTermConverter.ParametricFunction func) {
-      return (double[] c, double[] x, ref double fx, object o) => {
-        fx = func(c, x);
-        var counter = (EvaluationsCounter)o;
-        counter.FunctionEvaluations++;
-      };
-    }
-
-    private static alglib.ndimensional_pgrad CreatePGrad(TreeToAutoDiffTermConverter.ParametricFunctionGradient func_grad) {
-      return (double[] c, double[] x, ref double fx, double[] grad, object o) => {
-        var tuple = func_grad(c, x);
-        fx = tuple.Item2;
-        Array.Copy(tuple.Item1, grad, grad.Length);
-        var counter = (EvaluationsCounter)o;
-        counter.GradientEvaluations++;
-      };
-    }
-    public static bool CanOptimizeConstants(ISymbolicExpressionTree tree) {
-      return TreeToAutoDiffTermConverter.IsCompatible(tree);
-    }
-  }
-}
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionParameterOptimizationEvaluator.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionParameterOptimizationEvaluator.cs	(revision 18180)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/Evaluators/SymbolicRegressionParameterOptimizationEvaluator.cs	(revision 18180)
@@ -0,0 +1,401 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using HEAL.Attic;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
+  [Item("Parameter Optimization Evaluator", "Calculates Pearson R² of a symbolic regression solution and optimizes the parameters used.")]
+  [StorableType("24B68851-036D-4446-BD6F-3823E9028FF4")]
+  public class SymbolicRegressionParameterOptimizationEvaluator : SymbolicRegressionSingleObjectiveEvaluator {
+    private const string ParameterOptimizationIterationsParameterName = "ParameterOptimizationIterations";
+    private const string ParameterOptimizationImprovementParameterName = "ParameterOptimizationImprovement";
+    private const string ParameterOptimizationProbabilityParameterName = "ParameterOptimizationProbability";
+    private const string ParameterOptimizationRowsPercentageParameterName = "ParameterOptimizationRowsPercentage";
+    private const string UpdateParametersInTreeParameterName = "UpdateParametersInSymbolicExpressionTree";
+    private const string UpdateVariableWeightsParameterName = "Update Variable Weights";
+
+    private const string FunctionEvaluationsResultParameterName = "Parameters Optimization Function Evaluations";
+    private const string GradientEvaluationsResultParameterName = "Parameters Optimization Gradient Evaluations";
+    private const string CountEvaluationsParameterName = "Count Function and Gradient Evaluations";
+
+    public IFixedValueParameter<IntValue> ParameterOptimizationIterationsParameter {
+      get { return (IFixedValueParameter<IntValue>)Parameters[ParameterOptimizationIterationsParameterName]; }
+    }
+    public IFixedValueParameter<DoubleValue> ParameterOptimizationImprovementParameter {
+      get { return (IFixedValueParameter<DoubleValue>)Parameters[ParameterOptimizationImprovementParameterName]; }
+    }
+    public IFixedValueParameter<PercentValue> ParameterOptimizationProbabilityParameter {
+      get { return (IFixedValueParameter<PercentValue>)Parameters[ParameterOptimizationProbabilityParameterName]; }
+    }
+    public IFixedValueParameter<PercentValue> ParameterOptimizationRowsPercentageParameter {
+      get { return (IFixedValueParameter<PercentValue>)Parameters[ParameterOptimizationRowsPercentageParameterName]; }
+    }
+    public IFixedValueParameter<BoolValue> UpdateParametersInTreeParameter {
+      get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateParametersInTreeParameterName]; }
+    }
+    public IFixedValueParameter<BoolValue> UpdateVariableWeightsParameter {
+      get { return (IFixedValueParameter<BoolValue>)Parameters[UpdateVariableWeightsParameterName]; }
+    }
+
+    public IResultParameter<IntValue> FunctionEvaluationsResultParameter {
+      get { return (IResultParameter<IntValue>)Parameters[FunctionEvaluationsResultParameterName]; }
+    }
+    public IResultParameter<IntValue> GradientEvaluationsResultParameter {
+      get { return (IResultParameter<IntValue>)Parameters[GradientEvaluationsResultParameterName]; }
+    }
+    public IFixedValueParameter<BoolValue> CountEvaluationsParameter {
+      get { return (IFixedValueParameter<BoolValue>)Parameters[CountEvaluationsParameterName]; }
+    }
+
+
+    public IntValue ParameterOptimizationIterations {
+      get { return ParameterOptimizationIterationsParameter.Value; }
+    }
+    public DoubleValue ParameterOptimizationImprovement {
+      get { return ParameterOptimizationImprovementParameter.Value; }
+    }
+    public PercentValue ParameterOptimizationProbability {
+      get { return ParameterOptimizationProbabilityParameter.Value; }
+    }
+    public PercentValue ParameterOptimizationRowsPercentage {
+      get { return ParameterOptimizationRowsPercentageParameter.Value; }
+    }
+    public bool UpdateParametersInTree {
+      get { return UpdateParametersInTreeParameter.Value.Value; }
+      set { UpdateParametersInTreeParameter.Value.Value = value; }
+    }
+
+    public bool UpdateVariableWeights {
+      get { return UpdateVariableWeightsParameter.Value.Value; }
+      set { UpdateVariableWeightsParameter.Value.Value = value; }
+    }
+
+    public bool CountEvaluations {
+      get { return CountEvaluationsParameter.Value.Value; }
+      set { CountEvaluationsParameter.Value.Value = value; }
+    }
+
+    public override bool Maximization {
+      get { return true; }
+    }
+
+    [StorableConstructor]
+    protected SymbolicRegressionParameterOptimizationEvaluator(StorableConstructorFlag _) : base(_) { }
+    protected SymbolicRegressionParameterOptimizationEvaluator(SymbolicRegressionParameterOptimizationEvaluator original, Cloner cloner)
+      : base(original, cloner) {
+    }
+    public SymbolicRegressionParameterOptimizationEvaluator()
+      : base() {
+      Parameters.Add(new FixedValueParameter<IntValue>(ParameterOptimizationIterationsParameterName, "Determines how many iterations should be calculated while optimizing the parameter of a symbolic expression tree (0 indicates other or default stopping criterion).", new IntValue(10)));
+      Parameters.Add(new FixedValueParameter<DoubleValue>(ParameterOptimizationImprovementParameterName, "Determines the relative improvement which must be achieved in the parameter optimization to continue with it (0 indicates other or default stopping criterion).", new DoubleValue(0)) { Hidden = true });
+      Parameters.Add(new FixedValueParameter<PercentValue>(ParameterOptimizationProbabilityParameterName, "Determines the probability that the parameters are optimized", new PercentValue(1)));
+      Parameters.Add(new FixedValueParameter<PercentValue>(ParameterOptimizationRowsPercentageParameterName, "Determines the percentage of the rows which should be used for parameter optimization", new PercentValue(1)));
+      Parameters.Add(new FixedValueParameter<BoolValue>(UpdateParametersInTreeParameterName, "Determines if the parameters in the tree should be overwritten by the optimized parameters.", new BoolValue(true)) { Hidden = true });
+      Parameters.Add(new FixedValueParameter<BoolValue>(UpdateVariableWeightsParameterName, "Determines if the variable weights in the tree should be  optimized.", new BoolValue(true)) { Hidden = true });
+
+      Parameters.Add(new FixedValueParameter<BoolValue>(CountEvaluationsParameterName, "Determines if function and gradient evaluation should be counted.", new BoolValue(false)));
+      Parameters.Add(new ResultParameter<IntValue>(FunctionEvaluationsResultParameterName, "The number of function evaluations performed by the parameters optimization evaluator", "Results", new IntValue()));
+      Parameters.Add(new ResultParameter<IntValue>(GradientEvaluationsResultParameterName, "The number of gradient evaluations performed by the parameters optimization evaluator", "Results", new IntValue()));
+    }
+
+    public override IDeepCloneable Clone(Cloner cloner) {
+      return new SymbolicRegressionParameterOptimizationEvaluator(this, cloner);
+    }
+
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      if (!Parameters.ContainsKey(UpdateParametersInTreeParameterName)) {
+        if (Parameters.ContainsKey("UpdateConstantsInSymbolicExpressionTree")) {
+          Parameters.Add(new FixedValueParameter<BoolValue>(UpdateParametersInTreeParameterName, "Determines if the parameters in the tree should be overwritten by the optimized parameters.", (BoolValue)Parameters["UpdateConstantsInSymbolicExpressionTree"].ActualValue));
+          Parameters.Remove("UpdateConstantsInSymbolicExpressionTree");
+        } else {
+          Parameters.Add(new FixedValueParameter<BoolValue>(UpdateParametersInTreeParameterName, "Determines if the parameters in the tree should be overwritten by the optimized parameters.", new BoolValue(true)));
+        }
+      }
+
+      if (!Parameters.ContainsKey(UpdateVariableWeightsParameterName))
+        Parameters.Add(new FixedValueParameter<BoolValue>(UpdateVariableWeightsParameterName, "Determines if the variable weights in the tree should be  optimized.", new BoolValue(true)));
+
+      if (!Parameters.ContainsKey(CountEvaluationsParameterName))
+        Parameters.Add(new FixedValueParameter<BoolValue>(CountEvaluationsParameterName, "Determines if function and gradient evaluation should be counted.", new BoolValue(false)));
+
+      if (!Parameters.ContainsKey(FunctionEvaluationsResultParameterName)) {
+        if (Parameters.ContainsKey("Constants Optimization Function Evaluations")) {
+          Parameters.Remove("Constants Optimization Function Evaluations");
+        }
+        Parameters.Add(new ResultParameter<IntValue>(FunctionEvaluationsResultParameterName, "The number of function evaluations performed by the parameters optimization evaluator", "Results", new IntValue()));
+      }
+
+      if (!Parameters.ContainsKey(GradientEvaluationsResultParameterName)) {
+        if (Parameters.ContainsKey("Constants Optimization Gradient Evaluations")) {
+          Parameters.Remove("Constants Optimization Gradient Evaluations");
+        }
+        Parameters.Add(new ResultParameter<IntValue>(GradientEvaluationsResultParameterName, "The number of gradient evaluations performed by the parameters optimization evaluator", "Results", new IntValue()));
+      }
+
+      if (!Parameters.ContainsKey(ParameterOptimizationIterationsParameterName)) {
+        if (Parameters.ContainsKey("ConstantOptimizationIterations")) {
+          Parameters.Add(new FixedValueParameter<IntValue>(ParameterOptimizationIterationsParameterName, "Determines how many iterations should be calculated while optimizing the parameter of a symbolic expression tree (0 indicates other or default stopping criterion).", (IntValue)Parameters["ConstantOptimizationIterations"].ActualValue));
+          Parameters.Remove("ConstantOptimizationIterations");
+        } else {
+          Parameters.Add(new FixedValueParameter<IntValue>(ParameterOptimizationIterationsParameterName, "Determines how many iterations should be calculated while optimizing the parameter of a symbolic expression tree (0 indicates other or default stopping criterion).", new IntValue(10)));
+        }
+      }
+
+      if (!Parameters.ContainsKey(ParameterOptimizationImprovementParameterName)) {
+        if (Parameters.ContainsKey("CosntantOptimizationImprovement")) {
+          Parameters.Add(new FixedValueParameter<DoubleValue>(ParameterOptimizationImprovementParameterName, "Determines the relative improvement which must be achieved in the parameter optimization to continue with it (0 indicates other or default stopping criterion).",
+            (DoubleValue)Parameters["CosntantOptimizationImprovement"].ActualValue) { Hidden = true });
+          Parameters.Remove("CosntantOptimizationImprovement");
+        } else {
+          Parameters.Add(new FixedValueParameter<DoubleValue>(ParameterOptimizationImprovementParameterName, "Determines the relative improvement which must be achieved in the parameter optimization to continue with it (0 indicates other or default stopping criterion).", new DoubleValue(0)) { Hidden = true });
+        }
+      }
+
+      if (!Parameters.ContainsKey(ParameterOptimizationProbabilityParameterName)) {
+        if (Parameters.ContainsKey("ConstantOptimizationProbability")) {
+          Parameters.Add(new FixedValueParameter<PercentValue>(ParameterOptimizationProbabilityParameterName, "Determines the probability that the parameters are optimized",
+            (PercentValue)Parameters["ConstantOptimizationProbability"].ActualValue));
+          Parameters.Remove("ConstantOptimizationProbability");
+        } else {
+          Parameters.Add(new FixedValueParameter<PercentValue>(ParameterOptimizationProbabilityParameterName, "Determines the probability that the parameters are optimized", new PercentValue(1)));
+        }
+      }
+
+      if (!Parameters.ContainsKey(ParameterOptimizationRowsPercentageParameterName)) {
+        if (Parameters.ContainsKey("ConstantOptimizationRowsPercentage")) {
+          Parameters.Add(new FixedValueParameter<PercentValue>(ParameterOptimizationRowsPercentageParameterName, "Determines the percentage of the rows which should be used for parameter optimization", (PercentValue)Parameters["ConstantOptimizationRowsPercentage"].ActualValue));
+          Parameters.Remove("ConstantOptimizationRowsPercentage");
+        } else {
+          Parameters.Add(new FixedValueParameter<PercentValue>(ParameterOptimizationRowsPercentageParameterName, "Determines the percentage of the rows which should be used for parameter optimization", new PercentValue(1)));
+        }
+        
+      }
+    }
+
+    private static readonly object locker = new object();
+    public override IOperation InstrumentedApply() {
+      var solution = SymbolicExpressionTreeParameter.ActualValue;
+      double quality;
+      if (RandomParameter.ActualValue.NextDouble() < ParameterOptimizationProbability.Value) {
+        IEnumerable<int> parameterOptimizationRows = GenerateRowsToEvaluate(ParameterOptimizationRowsPercentage.Value);
+        var counter = new EvaluationsCounter();
+        quality = OptimizeParameters(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, ProblemDataParameter.ActualValue,
+           parameterOptimizationRows, ApplyLinearScalingParameter.ActualValue.Value, ParameterOptimizationIterations.Value, updateVariableWeights: UpdateVariableWeights, lowerEstimationLimit: EstimationLimitsParameter.ActualValue.Lower, upperEstimationLimit: EstimationLimitsParameter.ActualValue.Upper, updateParametersInTree: UpdateParametersInTree, counter: counter);
+
+        if (ParameterOptimizationRowsPercentage.Value != RelativeNumberOfEvaluatedSamplesParameter.ActualValue.Value) {
+          var evaluationRows = GenerateRowsToEvaluate();
+          quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, evaluationRows, ApplyLinearScalingParameter.ActualValue.Value);
+        }
+
+        if (CountEvaluations) {
+          lock (locker) {
+            FunctionEvaluationsResultParameter.ActualValue.Value += counter.FunctionEvaluations;
+            GradientEvaluationsResultParameter.ActualValue.Value += counter.GradientEvaluations;
+          }
+        }
+
+      } else {
+        var evaluationRows = GenerateRowsToEvaluate();
+        quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, solution, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, ProblemDataParameter.ActualValue, evaluationRows, ApplyLinearScalingParameter.ActualValue.Value);
+      }
+      QualityParameter.ActualValue = new DoubleValue(quality);
+
+      return base.InstrumentedApply();
+    }
+
+    public override double Evaluate(IExecutionContext context, ISymbolicExpressionTree tree, IRegressionProblemData problemData, IEnumerable<int> rows) {
+      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = context;
+      EstimationLimitsParameter.ExecutionContext = context;
+      ApplyLinearScalingParameter.ExecutionContext = context;
+      FunctionEvaluationsResultParameter.ExecutionContext = context;
+      GradientEvaluationsResultParameter.ExecutionContext = context;
+
+      // Pearson R² evaluator is used on purpose instead of the const-opt evaluator, 
+      // because Evaluate() is used to get the quality of evolved models on 
+      // different partitions of the dataset (e.g., best validation model)
+      double r2 = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(SymbolicDataAnalysisTreeInterpreterParameter.ActualValue, tree, EstimationLimitsParameter.ActualValue.Lower, EstimationLimitsParameter.ActualValue.Upper, problemData, rows, ApplyLinearScalingParameter.ActualValue.Value);
+
+      SymbolicDataAnalysisTreeInterpreterParameter.ExecutionContext = null;
+      EstimationLimitsParameter.ExecutionContext = null;
+      ApplyLinearScalingParameter.ExecutionContext = null;
+      FunctionEvaluationsResultParameter.ExecutionContext = null;
+      GradientEvaluationsResultParameter.ExecutionContext = null;
+
+      return r2;
+    }
+
+    public class EvaluationsCounter {
+      public int FunctionEvaluations = 0;
+      public int GradientEvaluations = 0;
+    }
+
+    public static double OptimizeParameters(ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+      ISymbolicExpressionTree tree, IRegressionProblemData problemData, IEnumerable<int> rows, bool applyLinearScaling,
+      int maxIterations, bool updateVariableWeights = true,
+      double lowerEstimationLimit = double.MinValue, double upperEstimationLimit = double.MaxValue,
+      bool updateParametersInTree = true, Action<double[], double, object> iterationCallback = null, EvaluationsCounter counter = null) {
+
+      // Numeric parameters in the tree become variables for parameter optimization.
+      // Variables in the tree become parameters (fixed values) for parameter optimization.
+      // For each parameter (variable in the original tree) we store the 
+      // variable name, variable value (for factor vars) and lag as a DataForVariable object.
+      // A dictionary is used to find parameters
+      double[] initialParameters;
+      var parameters = new List<TreeToAutoDiffTermConverter.DataForVariable>();
+
+      TreeToAutoDiffTermConverter.ParametricFunction func;
+      TreeToAutoDiffTermConverter.ParametricFunctionGradient func_grad;
+      if (!TreeToAutoDiffTermConverter.TryConvertToAutoDiff(tree, updateVariableWeights, applyLinearScaling, out parameters, out initialParameters, out func, out func_grad))
+        throw new NotSupportedException("Could not optimize parameters of symbolic expression tree due to not supported symbols used in the tree.");
+      if (parameters.Count == 0) return 0.0; // constant expressions always have a R² of 0.0 
+      var parameterEntries = parameters.ToArray(); // order of entries must be the same for x
+
+      // extract inital parameters
+      double[] c;
+      if (applyLinearScaling) {
+        c = new double[initialParameters.Length + 2];
+        c[0] = 0.0;
+        c[1] = 1.0;
+        Array.Copy(initialParameters, 0, c, 2, initialParameters.Length);
+      } else {
+        c = (double[])initialParameters.Clone();
+      }
+
+      double originalQuality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, tree, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling);
+
+      if (counter == null) counter = new EvaluationsCounter();
+      var rowEvaluationsCounter = new EvaluationsCounter();
+
+      alglib.lsfitstate state;
+      alglib.lsfitreport rep;
+      int retVal;
+
+      IDataset ds = problemData.Dataset;
+      double[,] x = new double[rows.Count(), parameters.Count];
+      int row = 0;
+      foreach (var r in rows) {
+        int col = 0;
+        foreach (var info in parameterEntries) {
+          if (ds.VariableHasType<double>(info.variableName)) {
+            x[row, col] = ds.GetDoubleValue(info.variableName, r + info.lag);
+          } else if (ds.VariableHasType<string>(info.variableName)) {
+            x[row, col] = ds.GetStringValue(info.variableName, r) == info.variableValue ? 1 : 0;
+          } else throw new InvalidProgramException("found a variable of unknown type");
+          col++;
+        }
+        row++;
+      }
+      double[] y = ds.GetDoubleValues(problemData.TargetVariable, rows).ToArray();
+      int n = x.GetLength(0);
+      int m = x.GetLength(1);
+      int k = c.Length;
+
+      alglib.ndimensional_pfunc function_cx_1_func = CreatePFunc(func);
+      alglib.ndimensional_pgrad function_cx_1_grad = CreatePGrad(func_grad);
+      alglib.ndimensional_rep xrep = (p, f, obj) => iterationCallback(p, f, obj);
+
+      try {
+        alglib.lsfitcreatefg(x, y, c, n, m, k, false, out state);
+        alglib.lsfitsetcond(state, 0.0, maxIterations);
+        alglib.lsfitsetxrep(state, iterationCallback != null);
+        alglib.lsfitfit(state, function_cx_1_func, function_cx_1_grad, xrep, rowEvaluationsCounter);
+        alglib.lsfitresults(state, out retVal, out c, out rep);
+      } catch (ArithmeticException) {
+        return originalQuality;
+      } catch (alglib.alglibexception) {
+        return originalQuality;
+      }
+
+      counter.FunctionEvaluations += rowEvaluationsCounter.FunctionEvaluations / n;
+      counter.GradientEvaluations += rowEvaluationsCounter.GradientEvaluations / n;
+
+      //retVal == -7  => parameter optimization failed due to wrong gradient
+      //          -8  => optimizer detected  NAN / INF  in  the target
+      //                 function and/ or gradient
+      if (retVal != -7 && retVal != -8) {
+        if (applyLinearScaling) {
+          var tmp = new double[c.Length - 2];
+          Array.Copy(c, 2, tmp, 0, tmp.Length);
+          UpdateParameters(tree, tmp, updateVariableWeights);
+        } else UpdateParameters(tree, c, updateVariableWeights);
+      }
+      var quality = SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.Calculate(interpreter, tree, lowerEstimationLimit, upperEstimationLimit, problemData, rows, applyLinearScaling);
+
+      if (!updateParametersInTree) UpdateParameters(tree, initialParameters, updateVariableWeights);
+
+      if (originalQuality - quality > 0.001 || double.IsNaN(quality)) {
+        UpdateParameters(tree, initialParameters, updateVariableWeights);
+        return originalQuality;
+      }
+      return quality;
+    }
+
+    private static void UpdateParameters(ISymbolicExpressionTree tree, double[] parameters, bool updateVariableWeights) {
+      int i = 0;
+      foreach (var node in tree.Root.IterateNodesPrefix().OfType<SymbolicExpressionTreeTerminalNode>()) {
+        NumberTreeNode numberTreeNode = node as NumberTreeNode;
+        VariableTreeNodeBase variableTreeNodeBase = node as VariableTreeNodeBase;
+        FactorVariableTreeNode factorVarTreeNode = node as FactorVariableTreeNode;
+        if (numberTreeNode != null) {
+          if (numberTreeNode.Parent.Symbol is Power 
+              && numberTreeNode.Parent.GetSubtree(1) == numberTreeNode) continue; // exponents in powers are not optimizated (see TreeToAutoDiffTermConverter)
+          numberTreeNode.Value = parameters[i++];
+        } else if (updateVariableWeights && variableTreeNodeBase != null)
+          variableTreeNodeBase.Weight = parameters[i++];
+        else if (factorVarTreeNode != null) {
+          for (int j = 0; j < factorVarTreeNode.Weights.Length; j++)
+            factorVarTreeNode.Weights[j] = parameters[i++];
+        }
+      }
+    }
+
+    private static alglib.ndimensional_pfunc CreatePFunc(TreeToAutoDiffTermConverter.ParametricFunction func) {
+      return (double[] c, double[] x, ref double fx, object o) => {
+        fx = func(c, x);
+        var counter = (EvaluationsCounter)o;
+        counter.FunctionEvaluations++;
+      };
+    }
+
+    private static alglib.ndimensional_pgrad CreatePGrad(TreeToAutoDiffTermConverter.ParametricFunctionGradient func_grad) {
+      return (double[] c, double[] x, ref double fx, double[] grad, object o) => {
+        var tuple = func_grad(c, x);
+        fx = tuple.Item2;
+        Array.Copy(tuple.Item1, grad, grad.Length);
+        var counter = (EvaluationsCounter)o;
+        counter.GradientEvaluations++;
+      };
+    }
+    public static bool CanOptimizeParameters(ISymbolicExpressionTree tree) {
+      return TreeToAutoDiffTermConverter.IsCompatible(tree);
+    }
+  }
+}
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/ParameterOptimizationAnalyzer.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/ParameterOptimizationAnalyzer.cs	(revision 18180)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/ParameterOptimizationAnalyzer.cs	(revision 18180)
@@ -0,0 +1,187 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Linq;
+using HeuristicLab.Analysis;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HEAL.Attic;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
+  /// <summary>
+  /// An operator that optimizes the parameters for the best symbolic expression tress in the current generation.
+  /// </summary>
+  [Item("ParameterOptimizationAnalyzer", "An operator that performs a parameter optimization on the best symbolic expression trees.")]
+  [StorableType("9FB87E7B-A9E2-49DD-A92A-78BD9FC17916")]
+  public sealed class ParameterOptimizationAnalyzer : SymbolicDataAnalysisSingleObjectiveAnalyzer, IStatefulItem {
+    private const string PercentageOfBestSolutionsParameterName = "PercentageOfBestSolutions";
+    private const string ParameterOptimizationEvaluatorParameterName = "ParameterOptimizationOperator";
+
+    private const string DataTableNameParameterOptimizationImprovement = "Parameter Optimization Improvement";
+    private const string DataRowNameMinimumImprovement = "Minimum improvement";
+    private const string DataRowNameMedianImprovement = "Median improvement";
+    private const string DataRowNameAverageImprovement = "Average improvement";
+    private const string DataRowNameMaximumImprovement = "Maximum improvement";
+
+    #region parameter properties
+    public IFixedValueParameter<PercentValue> PercentageOfBestSolutionsParameter {
+      get { return (IFixedValueParameter<PercentValue>)Parameters[PercentageOfBestSolutionsParameterName]; }
+    }
+
+    public IFixedValueParameter<SymbolicRegressionParameterOptimizationEvaluator> ParameterOptimizationEvaluatorParameter {
+      get { return (IFixedValueParameter<SymbolicRegressionParameterOptimizationEvaluator>)Parameters[ParameterOptimizationEvaluatorParameterName]; }
+    }
+    #endregion
+
+    #region properties
+    public SymbolicRegressionParameterOptimizationEvaluator ParameterOptimizationEvaluator {
+      get { return ParameterOptimizationEvaluatorParameter.Value; }
+    }
+    public double PercentageOfBestSolutions {
+      get { return PercentageOfBestSolutionsParameter.Value.Value; }
+    }
+
+    private DataTable ParameterOptimizationImprovementDataTable {
+      get {
+        IResult result;
+        ResultCollection.TryGetValue(DataTableNameParameterOptimizationImprovement, out result);
+        if (result == null) return null;
+        return (DataTable)result.Value;
+      }
+    }
+    private DataRow MinimumImprovement {
+      get { return ParameterOptimizationImprovementDataTable.Rows[DataRowNameMinimumImprovement]; }
+    }
+    private DataRow MedianImprovement {
+      get { return ParameterOptimizationImprovementDataTable.Rows[DataRowNameMedianImprovement]; }
+    }
+    private DataRow AverageImprovement {
+      get { return ParameterOptimizationImprovementDataTable.Rows[DataRowNameAverageImprovement]; }
+    }
+    private DataRow MaximumImprovement {
+      get { return ParameterOptimizationImprovementDataTable.Rows[DataRowNameMaximumImprovement]; }
+    }
+    #endregion
+
+    [StorableConstructor]
+    private ParameterOptimizationAnalyzer(StorableConstructorFlag _) : base(_) { }
+    private ParameterOptimizationAnalyzer(ParameterOptimizationAnalyzer original, Cloner cloner) : base(original, cloner) { }
+    public override IDeepCloneable Clone(Cloner cloner) { return new ParameterOptimizationAnalyzer(this, cloner); }
+    public ParameterOptimizationAnalyzer()
+      : base() {
+      Parameters.Add(new FixedValueParameter<PercentValue>(PercentageOfBestSolutionsParameterName, "The percentage of the top solutions which should be analyzed.", new PercentValue(0.1)));
+      Parameters.Add(new FixedValueParameter<SymbolicRegressionParameterOptimizationEvaluator>(ParameterOptimizationEvaluatorParameterName, "The operator used to perform the parameter optimization"));
+
+      //Changed the ActualName of the EvaluationPartitionParameter so that it matches the parameter name of symbolic regression problems.
+      ParameterOptimizationEvaluator.EvaluationPartitionParameter.ActualName = "FitnessCalculationPartition";
+    }
+
+    [StorableHook(HookType.AfterDeserialization)]
+    private void AfterDeserialization() {
+      if (!Parameters.ContainsKey(ParameterOptimizationEvaluatorParameterName)) {
+        if (Parameters.ContainsKey("ConstantOptimizationOperator")) {
+          Parameters.Add(new FixedValueParameter<SymbolicRegressionParameterOptimizationEvaluator>(ParameterOptimizationEvaluatorParameterName, "The operator used to perform the parameter optimization"));
+          Parameters.Remove("ConstantOptimizationOperator");
+        } else {
+          Parameters.Add(new FixedValueParameter<SymbolicRegressionParameterOptimizationEvaluator>(ParameterOptimizationEvaluatorParameterName, "The operator used to perform the parameter optimization"));
+        }
+      }
+    }
+
+
+    private double[] qualitiesBeforeCoOp = null;
+    private int[] scopeIndexes = null;
+    void IStatefulItem.InitializeState() {
+      qualitiesBeforeCoOp = null;
+      scopeIndexes = null;
+    }
+    void IStatefulItem.ClearState() {
+      qualitiesBeforeCoOp = null;
+      scopeIndexes = null;
+    }
+
+    public override IOperation Apply() {
+      //code executed in the first call of analyzer
+      if (qualitiesBeforeCoOp == null) {
+        double[] trainingQuality;
+        // sort is ascending and we take the first n% => order so that best solutions are smallest
+        // sort order is determined by maximization parameter
+        if (Maximization.Value) {
+          // largest values must be sorted first
+          trainingQuality = Quality.Select(x => -x.Value).ToArray();
+        } else {
+          // smallest values must be sorted first
+          trainingQuality = Quality.Select(x => x.Value).ToArray();
+        }
+        // sort trees by training qualities
+        int topN = (int)Math.Max(trainingQuality.Length * PercentageOfBestSolutions, 1);
+        scopeIndexes = Enumerable.Range(0, trainingQuality.Length).ToArray();
+        Array.Sort(trainingQuality, scopeIndexes);
+        scopeIndexes = scopeIndexes.Take(topN).ToArray();
+        qualitiesBeforeCoOp = scopeIndexes.Select(x => Quality[x].Value).ToArray();
+
+        OperationCollection operationCollection = new OperationCollection();
+        operationCollection.Parallel = true;
+        foreach (var scopeIndex in scopeIndexes) {
+          var childOperation = ExecutionContext.CreateChildOperation(ParameterOptimizationEvaluator, ExecutionContext.Scope.SubScopes[scopeIndex]);
+          operationCollection.Add(childOperation);
+        }
+
+        return new OperationCollection { operationCollection, ExecutionContext.CreateOperation(this) };
+      }
+
+      //code executed to analyze results of parameter optimization
+      double[] qualitiesAfterCoOp = scopeIndexes.Select(x => Quality[x].Value).ToArray();
+      var qualityImprovement = qualitiesBeforeCoOp.Zip(qualitiesAfterCoOp, (b, a) => a - b).ToArray();
+
+      if (!ResultCollection.ContainsKey(DataTableNameParameterOptimizationImprovement)) {
+        var dataTable = new DataTable(DataTableNameParameterOptimizationImprovement);
+        ResultCollection.Add(new Result(DataTableNameParameterOptimizationImprovement, dataTable));
+        dataTable.VisualProperties.YAxisTitle = "R²";
+
+        dataTable.Rows.Add(new DataRow(DataRowNameMinimumImprovement));
+        MinimumImprovement.VisualProperties.StartIndexZero = true;
+
+        dataTable.Rows.Add(new DataRow(DataRowNameMedianImprovement));
+        MedianImprovement.VisualProperties.StartIndexZero = true;
+
+        dataTable.Rows.Add(new DataRow(DataRowNameAverageImprovement));
+        AverageImprovement.VisualProperties.StartIndexZero = true;
+
+        dataTable.Rows.Add(new DataRow(DataRowNameMaximumImprovement));
+        MaximumImprovement.VisualProperties.StartIndexZero = true;
+      }
+
+      MinimumImprovement.Values.Add(qualityImprovement.Min());
+      MedianImprovement.Values.Add(qualityImprovement.Median());
+      AverageImprovement.Values.Add(qualityImprovement.Average());
+      MaximumImprovement.Values.Add(qualityImprovement.Max());
+
+      qualitiesBeforeCoOp = null;
+      scopeIndexes = null;
+      return base.Apply();
+    }
+  }
+}
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/ShapeConstrainedRegressionSingleObjectiveProblem.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/ShapeConstrainedRegressionSingleObjectiveProblem.cs	(revision 18078)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SingleObjective/ShapeConstrainedRegressionSingleObjectiveProblem.cs	(revision 18180)
@@ -28,5 +28,5 @@
   [StorableType("B35ADCA7-E902-4BEE-9DDE-DF8BBC1E27FE")]
   [Creatable(CreatableAttribute.Categories.GeneticProgrammingProblems, Priority = 150)]
-  public class ShapeConstrainedRegressionSingleObjectiveProblem : SymbolicRegressionSingleObjectiveProblem {
+  public class ShapeConstrainedRegressionSingleObjectiveProblem : SymbolicRegressionSingleObjectiveProblem, IShapeConstrainedRegressionProblem {
     [StorableConstructor]
     protected ShapeConstrainedRegressionSingleObjectiveProblem(StorableConstructorFlag _) : base(_) { }
@@ -34,4 +34,8 @@
     public override IDeepCloneable Clone(Cloner cloner) { return new ShapeConstrainedRegressionSingleObjectiveProblem(this, cloner); }
 
+    public ShapeConstrainedRegressionProblemData ShapeConstrainedRegressionProblemData {
+      get => (ShapeConstrainedRegressionProblemData)ProblemData;
+      set => ProblemData = value;
+    }
     public ShapeConstrainedRegressionSingleObjectiveProblem()
       : base(new ShapeConstrainedRegressionProblemData(), new NMSESingleObjectiveConstraintsEvaluator(), new SymbolicDataAnalysisExpressionTreeCreator()) {
@@ -51,9 +55,12 @@
 
     public override void Load(IRegressionProblemData data) {
-      var scProblemData = new ShapeConstrainedRegressionProblemData(data.Dataset, data.AllowedInputVariables, data.TargetVariable,
-                                                                    data.TrainingPartition, data.TestPartition) {
-        Name = data.Name,
-        Description = data.Description
-      };
+      if (data is ShapeConstrainedRegressionProblemData scProblemData) {
+      } else {
+        scProblemData = new ShapeConstrainedRegressionProblemData(data.Dataset, data.AllowedInputVariables, data.TargetVariable,
+                                                                  data.TrainingPartition, data.TestPartition) {
+          Name = data.Name,
+          Description = data.Description
+        };
+      }
 
       base.Load(scProblemData);
Index: branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPruningOperator.cs
===================================================================
--- branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPruningOperator.cs	(revision 18078)
+++ branches/3138_Shape_Constraints_Transformations/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionPruningOperator.cs	(revision 18180)
@@ -91,17 +91,16 @@
       for (int i = 0; i < nodes.Count; ++i) {
         var node = nodes[i];
-        if (node is ConstantTreeNode) continue;
+        if (node is INumericTreeNode) continue; // skip constants and numbers
 
-        double impactValue, replacementValue;
-        double newQualityForImpactsCalculation;
-        impactValuesCalculator.CalculateImpactAndReplacementValues(model, node, problemData, rows, out impactValue, out replacementValue, out newQualityForImpactsCalculation, qualityForImpactsCalculation);
+        impactValuesCalculator.CalculateImpactAndReplacementValues(model, node, problemData, rows, 
+          out double impactValue, out double replacementValue, out double newQualityForImpactsCalculation, qualityForImpactsCalculation);
 
         if (pruneOnlyZeroImpactNodes && !impactValue.IsAlmost(0.0)) continue;
         if (!pruneOnlyZeroImpactNodes && impactValue > nodeImpactThreshold) continue;
 
-        var constantNode = (ConstantTreeNode)node.Grammar.GetSymbol("Constant").CreateTreeNode();
-        constantNode.Value = replacementValue;
+        var numNode = (NumberTreeNode)node.Grammar.GetSymbol("Number").CreateTreeNode();
+        numNode.Value = replacementValue;
 
-        ReplaceWithConstant(node, constantNode);
+        ReplaceWithNumber(node, numNode);
         i += node.GetLength() - 1; // skip subtrees under the node that was folded
 
