Index: trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/DefaultStructureIdentificationOperators.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/DefaultStructureIdentificationOperators.cs	(revision 2976)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/DefaultStructureIdentificationOperators.cs	(revision 2977)
@@ -39,5 +39,5 @@
       SequentialProcessor seq = new SequentialProcessor();
       seq.AddSubOperator(new DefaultFunctionLibraryInjector());
-      seq.AddSubOperator(new ScalingTreeEvaluatorInjector());
+      seq.AddSubOperator(new HL3TreeEvaluatorInjector());
       op.OperatorGraph.AddOperator(seq);
       op.OperatorGraph.InitialOperator = seq;
@@ -46,10 +46,26 @@
 
     public static IOperator CreateInitialPopulationEvaluator() {
-      MeanSquaredErrorEvaluator eval = new MeanSquaredErrorEvaluator();
-      eval.Name = "Evaluator";
-      eval.GetVariableInfo("MSE").ActualName = "Quality";
+      CombinedOperator combinedOp = new CombinedOperator();
+      combinedOp.Name = "Evaluator";
+      SequentialProcessor seq = new SequentialProcessor();
+
+      SimpleEvaluator eval = new SimpleEvaluator();
+      eval.GetVariableInfo("Values").ActualName = "TrainingValues";
       eval.GetVariableInfo("SamplesStart").ActualName = "ActualTrainingSamplesStart";
       eval.GetVariableInfo("SamplesEnd").ActualName = "ActualTrainingSamplesEnd";
-      return eval;
+
+      LinearScaler scaler = new LinearScaler();
+      scaler.GetVariableInfo("Values").ActualName = "TrainingValues";
+
+      SimpleMSEEvaluator mseEval = new SimpleMSEEvaluator();
+      mseEval.GetVariableInfo("Values").ActualName = "TrainingValues";
+      mseEval.GetVariableInfo("MSE").ActualName = "Quality";
+
+      seq.AddSubOperator(eval);
+      seq.AddSubOperator(scaler);
+      seq.AddSubOperator(mseEval);
+      combinedOp.OperatorGraph.AddOperator(seq);
+      combinedOp.OperatorGraph.InitialOperator = seq;
+      return combinedOp;
     }
 
@@ -70,11 +86,17 @@
       UniformSequentialSubScopesProcessor subScopesProc = new UniformSequentialSubScopesProcessor();
       SequentialProcessor individualProc = new SequentialProcessor();
-      MeanSquaredErrorEvaluator validationEvaluator = new MeanSquaredErrorEvaluator();
+      SimpleEvaluator validationEvaluator = new SimpleEvaluator();
       validationEvaluator.Name = "ValidationEvaluator";
-      validationEvaluator.GetVariableInfo("MSE").ActualName = "ValidationQuality";
+      validationEvaluator.GetVariableInfo("Values").ActualName = "ValidationValues";
       validationEvaluator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
       validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
-
+      LinearScaler validationScaler = new LinearScaler();
+      validationScaler.GetVariableInfo("Values").ActualName = "ValidationValues";
+      SimpleMSEEvaluator mseEval = new SimpleMSEEvaluator();
+      mseEval.GetVariableInfo("Values").ActualName = "ValidationValues";
+      mseEval.GetVariableInfo("MSE").ActualName = "ValidationQuality";
       individualProc.AddSubOperator(validationEvaluator);
+      individualProc.AddSubOperator(validationScaler);
+      individualProc.AddSubOperator(mseEval);
 
       Counter bestValidationSolutionAgeCounter = new Counter();
@@ -127,8 +149,4 @@
       seqSubScopeProc.AddSubOperator(solutionProc);
 
-      ScalingTreeEvaluatorInjector evaluatorInjector = new ScalingTreeEvaluatorInjector();
-      evaluatorInjector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData(1000.0)));
-      evaluatorInjector.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
-
       #region simple evaluators
       SimpleEvaluator trainingEvaluator = new SimpleEvaluator();
@@ -137,5 +155,4 @@
       trainingEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TrainingSamplesEnd";
       trainingEvaluator.GetVariableInfo("Values").ActualName = "TrainingValues";
-      trainingEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
       SimpleEvaluator validationEvaluator = new SimpleEvaluator();
       validationEvaluator.Name = "ValidationEvaluator";
@@ -143,5 +160,4 @@
       validationEvaluator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
       validationEvaluator.GetVariableInfo("Values").ActualName = "ValidationValues";
-      validationEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
       SimpleEvaluator testEvaluator = new SimpleEvaluator();
       testEvaluator.Name = "TestEvaluator";
@@ -149,9 +165,20 @@
       testEvaluator.GetVariableInfo("SamplesEnd").ActualName = "TestSamplesEnd";
       testEvaluator.GetVariableInfo("Values").ActualName = "TestValues";
-      testEvaluator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
-      solutionProc.AddSubOperator(evaluatorInjector);
+
+      LinearScaler trainingScaler = new LinearScaler();
+      trainingScaler.GetVariableInfo("Values").ActualName = "TrainingValues";
+
+      LinearScaler validationScaler = new LinearScaler();
+      validationScaler.GetVariableInfo("Values").ActualName = "ValidationValues";
+
+      LinearScaler testScaler = new LinearScaler();
+      testEvaluator.GetVariableInfo("Values").ActualName = "TestValues";
+
       solutionProc.AddSubOperator(trainingEvaluator);
       solutionProc.AddSubOperator(validationEvaluator);
       solutionProc.AddSubOperator(testEvaluator);
+      solutionProc.AddSubOperator(trainingScaler);
+      solutionProc.AddSubOperator(validationScaler);
+      solutionProc.AddSubOperator(testScaler);
       #endregion
 
@@ -171,5 +198,4 @@
 
       NodeBasedVariableImpactCalculator nodeImpactCalculator = new NodeBasedVariableImpactCalculator();
-      nodeImpactCalculator.GetVariableInfo("TreeEvaluator").ActualName = "ModelAnalysisTreeEvaluator";
       nodeImpactCalculator.GetVariableInfo("SamplesStart").ActualName = "ValidationSamplesStart";
       nodeImpactCalculator.GetVariableInfo("SamplesEnd").ActualName = "ValidationSamplesEnd";
Index: trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj	(revision 2976)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/HeuristicLab.GP.StructureIdentification-3.3.csproj	(revision 2977)
@@ -88,6 +88,4 @@
     <Compile Include="LinearScalingPredictorBuilder.cs" />
     <Compile Include="Evaluators\VariableFrequencyBasedImpactCalculator.cs" />
-    <Compile Include="ScalingTreeEvaluator.cs" />
-    <Compile Include="ScalingTreeEvaluatorInjector.cs" />
     <Compile Include="Evaluators\TreeComplexityEvaluator.cs" />
     <Compile Include="FunctionLibraryInjectors\ArithmeticFunctionLibraryInjector.cs" />
Index: trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/LinearScalingPredictorBuilder.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/LinearScalingPredictorBuilder.cs	(revision 2976)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/LinearScalingPredictorBuilder.cs	(revision 2977)
@@ -35,9 +35,8 @@
       : base() {
       AddVariableInfo(new VariableInfo("FunctionTree", "The function tree", typeof(IGeneticProgrammingModel), VariableKind.In));
-      AddVariableInfo(new VariableInfo("PunishmentFactor", "The punishment factor limits the estimated values to a certain range", typeof(DoubleData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("Dataset", "The dataset", typeof(Dataset), VariableKind.In));
-      AddVariableInfo(new VariableInfo("TrainingSamplesStart", "Start index of training set", typeof(DoubleData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("TrainingSamplesEnd", "End index of training set", typeof(DoubleData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("TargetVariable", "Name of the target variable", typeof(StringData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("Beta", "Beta parameter for linear scaling as calculated by LinearScaler", typeof(DoubleData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("Alpha", "Alpha parameter for linear scaling as calculated by LinearScaler", typeof(DoubleData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("UpperEstimationLimit", "Upper limit for estimated value (optional)", typeof(DoubleData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("LowerEstimationLimit", "Lower limit for estimated value (optional)", typeof(DoubleData), VariableKind.In));
       AddVariableInfo(new VariableInfo("Predictor", "The predictor combines the function tree and the evaluator and can be used to generate estimated values", typeof(IPredictor), VariableKind.New));
     }
@@ -49,67 +48,30 @@
     public override IOperation Apply(IScope scope) {
       IGeneticProgrammingModel model = GetVariableValue<IGeneticProgrammingModel>("FunctionTree", scope, true);
-      double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data;
-      Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
-      int start = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
-      int end = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
-      string targetVariable = GetVariableValue<StringData>("TargetVariable", scope, true).Data;
-      IPredictor predictor = CreatePredictor(model, punishmentFactor, dataset, targetVariable, start, end);
+      //double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data;
+      //Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
+      //int start = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
+      //int end = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
+      //string targetVariable = GetVariableValue<StringData>("TargetVariable", scope, true).Data;
+      double alpha = GetVariableValue<DoubleData>("Alpha", scope, true).Data;
+      double beta = GetVariableValue<DoubleData>("Beta", scope, true).Data;
+      DoubleData lowerLimit = GetVariableValue<DoubleData>("LowerEstimationLimit", scope, true, false);
+      DoubleData upperLimit = GetVariableValue<DoubleData>("UpperEstimationLimit", scope, true, false);
+      IPredictor predictor;
+      if (lowerLimit == null || upperLimit == null)
+        predictor = CreatePredictor(model, beta, alpha, double.NegativeInfinity, double.PositiveInfinity);
+      else
+        predictor = CreatePredictor(model, beta, alpha, lowerLimit.Data, upperLimit.Data);
       scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("Predictor"), predictor));
       return null;
     }
 
-    public static IPredictor CreatePredictor(IGeneticProgrammingModel model, double punishmentFactor,
-  Dataset dataset, string targetVariable, int start, int end) {
-      return CreatePredictor(model, punishmentFactor, dataset, dataset.GetVariableIndex(targetVariable), start, end);
-    }
-
-
-    public static IPredictor CreatePredictor(IGeneticProgrammingModel model, double punishmentFactor,
-      Dataset dataset, int targetVariable, int start, int end) {
+    public static IPredictor CreatePredictor(IGeneticProgrammingModel model, double beta, double alpha, double lowerLimit, double upperLimit) {
 
       var evaluator = new HL3TreeEvaluator();
-      // evaluate for all rows
-      evaluator.PrepareForEvaluation(dataset, model.FunctionTree);
-      var result = from row in Enumerable.Range(start, end - start)
-                   let y = evaluator.Evaluate(row)
-                   let y_ = dataset.GetValue(row, targetVariable)
-                   select new { Row = row, Estimation = y, Target = y_ };
-
-      // calculate alpha and beta on the subset of rows with valid values 
-      var filteredResult = result.Where(x => IsValidValue(x.Target) && IsValidValue(x.Estimation));
-      var target = filteredResult.Select(x => x.Target);
-      var estimation = filteredResult.Select(x => x.Estimation);
-      double a, b;
-      if (filteredResult.Count() > 2) {
-        double tMean = target.Sum() / target.Count();
-        double xMean = estimation.Sum() / estimation.Count();
-        double sumXT = 0;
-        double sumXX = 0;
-        foreach (var r in result) {
-          double x = r.Estimation;
-          double t = r.Target;
-          sumXT += (x - xMean) * (t - tMean);
-          sumXX += (x - xMean) * (x - xMean);
-        }
-        b = sumXT / sumXX;
-        a = tMean - b * xMean;
-      } else {
-        b = 1.0;
-        a = 0.0;
-      }
-      double mean = dataset.GetMean(targetVariable, start, end);
-      double range = dataset.GetRange(targetVariable, start, end);
-      double minEstimatedValue = mean - punishmentFactor * range;
-      double maxEstimatedValue = mean + punishmentFactor * range;
-      evaluator.LowerEvaluationLimit = minEstimatedValue;
-      evaluator.UpperEvaluationLimit = maxEstimatedValue;
-      var resultModel = new GeneticProgrammingModel(MakeSum(MakeProduct(model.FunctionTree, b), a));
-      return new Predictor(evaluator, resultModel, minEstimatedValue, maxEstimatedValue);
+      evaluator.LowerEvaluationLimit = lowerLimit;
+      evaluator.UpperEvaluationLimit = upperLimit;
+      var resultModel = new GeneticProgrammingModel(MakeSum(MakeProduct(model.FunctionTree, beta), alpha));
+      return new Predictor(evaluator, resultModel, lowerLimit, upperLimit);
     }
-
-    private static bool IsValidValue(double d) {
-      return !double.IsInfinity(d) && !double.IsNaN(d);
-    }
-
 
     private static IFunctionTree MakeSum(IFunctionTree tree, double x) {
@@ -134,23 +96,4 @@
       return constX;
     }
-
-    private static void CalculateScalingParameters(IEnumerable<double> xs, IEnumerable<double> ys, out double k, out double d) {
-      if (xs.Count() != ys.Count()) throw new ArgumentException();
-      double xMean = xs.Sum() / xs.Count();
-      double yMean = ys.Sum() / ys.Count();
-
-      var yEnumerator = ys.GetEnumerator();
-      var xEnumerator = xs.GetEnumerator();
-
-      double sumXY = 0.0;
-      double sumXX = 0.0;
-      while (xEnumerator.MoveNext() && yEnumerator.MoveNext()) {
-        sumXY += (xEnumerator.Current - xMean) * (yEnumerator.Current - yMean);
-        sumXX += (xEnumerator.Current - xMean) * (xEnumerator.Current - xMean);
-      }
-
-      k = sumXY / sumXX;
-      d = yMean - k * xMean;
-    }
   }
 }
Index: trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/OffspringSelectionGPRegression.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/OffspringSelectionGPRegression.cs	(revision 2976)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/OffspringSelectionGPRegression.cs	(revision 2977)
@@ -198,4 +198,7 @@
       VariableInjector injector = base.CreateGlobalInjector();
       injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData()));
+      // NB: LowerEstimationLimit and UpperEstimationLimit should replace the direct use of PunishmentFactor in the algorithm (gkronber 9 March, 2010)
+      injector.AddVariable(new HeuristicLab.Core.Variable("LowerEstimationLimit", new DoubleData(double.NegativeInfinity)));
+      injector.AddVariable(new HeuristicLab.Core.Variable("UpperEstimationLimit", new DoubleData(double.PositiveInfinity)));
       injector.AddVariable(new HeuristicLab.Core.Variable("BestValidationSolutionAge", new IntData()));
       injector.AddVariable(new HeuristicLab.Core.Variable("MaxBestValidationSolutionAge", new IntData()));
Index: trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/ScalingTreeEvaluator.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/ScalingTreeEvaluator.cs	(revision 2976)
+++ 	(revision )
@@ -1,119 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 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.Diagnostics;
-using HeuristicLab.Common;
-using HeuristicLab.DataAnalysis;
-using HeuristicLab.GP.Interfaces;
-using System.Collections.Generic; // double.IsAlmost extension
-using System.Linq;
-using System.Xml;
-namespace HeuristicLab.GP.StructureIdentification {
-  /// <summary>
-  /// Evaluates FunctionTrees recursively by interpretation of the function symbols in each node.
-  /// Scales the output of the function-tree to the desired output range of the target variable by linear transformation
-  /// Not thread-safe!
-  /// </summary>
-  public class ScalingTreeEvaluator : HL3TreeEvaluator, ITreeEvaluator {
-    public ScalingTreeEvaluator() : base() { } // for persistence
-    public ScalingTreeEvaluator(double minValue, double maxValue)
-      : base(minValue, maxValue) {
-    }
-
-    private string targetVariable;
-    public string TargetVariable {
-      get { return targetVariable; }
-      set { targetVariable = value; }
-    }
-
-
-    public override double Evaluate(int sampleIndex) {
-      PC = 0;
-      this.sampleIndex = sampleIndex;
-      double estimation = EvaluateBakedCode();
-      //if (double.IsPositiveInfinity(estimation)) estimation = UpperEvaluationLimit;
-      //else if (double.IsNegativeInfinity(estimation)) estimation = LowerEvaluationLimit;
-      //else if (double.IsNaN(estimation)) estimation = UpperEvaluationLimit;
-      return estimation;
-    }
-
-    public override IEnumerable<double> Evaluate(Dataset dataset, IFunctionTree tree, IEnumerable<int> rows) {
-      int targetVariableIndex = dataset.GetVariableIndex(targetVariable);
-      // evaluate for all rows
-      PrepareForEvaluation(dataset, tree);
-      var result = (from row in rows
-                    let y = Evaluate(row)
-                    let y_ = dataset.GetValue(row, targetVariableIndex)
-                    select new { Row = row, Estimation = y, Target = y_ }).ToArray();
-
-      // calculate alpha and beta on the subset of rows with valid values 
-      var filteredResult = result.Where(x => IsValidValue(x.Target) && IsValidValue(x.Estimation));
-      var target = filteredResult.Select(x => x.Target);
-      var estimation = filteredResult.Select(x => x.Estimation);
-      double a, b;
-      if (filteredResult.Count() > 2) {
-        double tMean = target.Sum() / target.Count();
-        double xMean = estimation.Sum() / estimation.Count();
-        double sumXT = 0;
-        double sumXX = 0;
-        foreach (var r in result) {
-          double x = r.Estimation;
-          double t = r.Target;
-          sumXT += (x - xMean) * (t - tMean);
-          sumXX += (x - xMean) * (x - xMean);
-        }
-        b = sumXT / sumXX;
-        a = tMean - b * xMean;
-      } else {
-        b = 1.0;
-        a = 0.0;
-      }
-      // return scaled results
-      return from r in result
-             let scaledR = Math.Min(Math.Max(r.Estimation * b + a, LowerEvaluationLimit), UpperEvaluationLimit)
-             select double.IsNaN(scaledR) ? UpperEvaluationLimit : scaledR;
-    }
-
-    private bool IsValidValue(double d) {
-      return !double.IsInfinity(d) && !double.IsNaN(d);
-    }
-
-    public override object Clone(IDictionary<Guid, object> clonedObjects) {
-      ScalingTreeEvaluator clone = (ScalingTreeEvaluator)base.Clone(clonedObjects);
-      clone.targetVariable = targetVariable;
-      return clone;
-    }
-
-    public override System.Xml.XmlNode GetXmlNode(string name, System.Xml.XmlDocument document, IDictionary<Guid, HeuristicLab.Core.IStorable> persistedObjects) {
-      XmlNode node = base.GetXmlNode(name, document, persistedObjects);
-      XmlAttribute targetVariableAttribute = document.CreateAttribute("TargetVariable");
-      targetVariableAttribute.Value = targetVariable;
-      node.Attributes.Append(targetVariableAttribute);
-      return node;
-    }
-
-    public override void Populate(XmlNode node, IDictionary<Guid, HeuristicLab.Core.IStorable> restoredObjects) {
-      base.Populate(node, restoredObjects);
-      targetVariable = node.Attributes["TargetVariable"].Value;
-    }
-  }
-}
Index: trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/ScalingTreeEvaluatorInjector.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/ScalingTreeEvaluatorInjector.cs	(revision 2976)
+++ 	(revision )
@@ -1,64 +1,0 @@
-#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2008 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 System.Text;
-using HeuristicLab.Core;
-using HeuristicLab.Data;
-using HeuristicLab.GP.Interfaces;
-using HeuristicLab.Modeling;
-using HeuristicLab.DataAnalysis;
-
-namespace HeuristicLab.GP.StructureIdentification {
-  public class ScalingTreeEvaluatorInjector : OperatorBase {
-    public ScalingTreeEvaluatorInjector()
-      : base() {
-      AddVariableInfo(new VariableInfo("Dataset", "The dataset", typeof(Dataset), VariableKind.In));
-      AddVariableInfo(new VariableInfo("TrainingSamplesStart", "Start index of training set", typeof(DoubleData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("TrainingSamplesEnd", "End index of training set", typeof(DoubleData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("TargetVariable", "Name of the target variable", typeof(StringData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("PunishmentFactor", "The punishment factor limits the estimated values to a certain range", typeof(DoubleData), VariableKind.In));
-      AddVariableInfo(new VariableInfo("TreeEvaluator", "The tree evaluator to evaluate models", typeof(ITreeEvaluator), VariableKind.New));
-    }
-
-    public override string Description {
-      get { return "Injects a tree evaluator."; }
-    }
-
-    public override IOperation Apply(IScope scope) {
-      double punishmentFactor = GetVariableValue<DoubleData>("PunishmentFactor", scope, true).Data;
-      Dataset dataset = GetVariableValue<Dataset>("Dataset", scope, true);
-      int start = GetVariableValue<IntData>("TrainingSamplesStart", scope, true).Data;
-      int end = GetVariableValue<IntData>("TrainingSamplesEnd", scope, true).Data;
-      string targetVariable = GetVariableValue<StringData>("TargetVariable", scope, true).Data;
-      double mean = dataset.GetMean(targetVariable, start, end);
-      double range = dataset.GetRange(targetVariable, start, end);
-      double minEstimatedValue = mean - punishmentFactor * range;
-      double maxEstimatedValue = mean + punishmentFactor * range;
-      ScalingTreeEvaluator evaluator = new ScalingTreeEvaluator(minEstimatedValue, maxEstimatedValue);
-      evaluator.TargetVariable = targetVariable;
-      scope.AddVariable(new HeuristicLab.Core.Variable(scope.TranslateName("TreeEvaluator"), evaluator));
-      return null;
-    }
-  }
-}
Index: trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGPRegression.cs
===================================================================
--- trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGPRegression.cs	(revision 2976)
+++ trunk/sources/HeuristicLab.GP.StructureIdentification/3.3/StandardGPRegression.cs	(revision 2977)
@@ -41,10 +41,14 @@
     public virtual string TargetVariable {
       get { return ProblemInjector.GetVariableValue<StringData>("TargetVariable", null, false).Data; }
-      set { ProblemInjector.GetVariableValue<StringData>("TargetVariable", null, false).Data = value; }
+      set {
+        ProblemInjector.GetVariableValue<StringData>("TargetVariable", null, false).Data = value;
+      }
     }
 
     public virtual Dataset Dataset {
       get { return ProblemInjector.GetVariableValue<Dataset>("Dataset", null, false); }
-      set { ProblemInjector.GetVariable("Dataset").Value = value; }
+      set {
+        ProblemInjector.GetVariable("Dataset").Value = value;
+      }
     }
 
@@ -101,5 +105,16 @@
     public virtual double PunishmentFactor {
       get { return GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data; }
-      set { GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data = value; }
+      set {
+        GetVariableInjector().GetVariable("PunishmentFactor").GetValue<DoubleData>().Data = value;
+      }
+    }
+
+    public virtual double UpperEstimationLimit {
+      get { return GetVariableInjector().GetVariable("UpperEstimationLimit").GetValue<DoubleData>().Data; }
+      set { GetVariableInjector().GetVariable("UpperEstimationLimit").GetValue<DoubleData>().Data = value; }
+    }
+    public virtual double LowerEstimationLimit {
+      get { return GetVariableInjector().GetVariable("LowerEstimationLimit").GetValue<DoubleData>().Data; }
+      set { GetVariableInjector().GetVariable("LowerEstimationLimit").GetValue<DoubleData>().Data = value; }
     }
 
@@ -193,4 +208,7 @@
       VariableInjector injector = base.CreateGlobalInjector();
       injector.AddVariable(new HeuristicLab.Core.Variable("PunishmentFactor", new DoubleData()));
+      // NB: LowerEstimationLimit and UpperEstimationLimit should replace the direct use of PunishmentFactor in the algorithm (gkronber 9 March, 2010)
+      injector.AddVariable(new HeuristicLab.Core.Variable("LowerEstimationLimit", new DoubleData(double.NegativeInfinity)));
+      injector.AddVariable(new HeuristicLab.Core.Variable("UpperEstimationLimit", new DoubleData(double.PositiveInfinity)));
       injector.AddVariable(new HeuristicLab.Core.Variable("BestValidationSolutionAge", new IntData()));
       injector.AddVariable(new HeuristicLab.Core.Variable("MaxBestValidationSolutionAge", new IntData()));
@@ -235,5 +253,5 @@
 
       IOperator combinedTerminationCriterion = AlgorithmBase.CombineTerminationCriterions(base.CreateTerminationCondition(), bestSolutionAge);
-      
+
       terminationCritertion.OperatorGraph.AddOperator(combinedTerminationCriterion);
       terminationCritertion.OperatorGraph.InitialOperator = combinedTerminationCriterion;
Index: trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj
===================================================================
--- trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj	(revision 2976)
+++ trunk/sources/HeuristicLab.Modeling/3.2/HeuristicLab.Modeling-3.2.csproj	(revision 2977)
@@ -84,4 +84,5 @@
     <Compile Include="AnalyzerModel.cs" />
     <Compile Include="BestSolutionStorer.cs" />
+    <Compile Include="LinearScaler.cs" />
     <Compile Include="SimpleStableCorrelationCoefficientEvaluator.cs" />
     <Compile Include="SimplePearsonCorrelationCoefficientEvaluator.cs" />
Index: trunk/sources/HeuristicLab.Modeling/3.2/LinearScaler.cs
===================================================================
--- trunk/sources/HeuristicLab.Modeling/3.2/LinearScaler.cs	(revision 2977)
+++ trunk/sources/HeuristicLab.Modeling/3.2/LinearScaler.cs	(revision 2977)
@@ -0,0 +1,111 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2008 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.Text;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using System.Linq;
+
+namespace HeuristicLab.Modeling {
+  public class LinearScaler : OperatorBase {
+    public LinearScaler()
+      : base() {
+      AddVariableInfo(new VariableInfo("Values", "Matrix of predicted and original values that should be scaled", typeof(DoubleMatrixData), VariableKind.In | VariableKind.Out));
+      AddVariableInfo(new VariableInfo("Alpha", "Maximization problem", typeof(BoolData), VariableKind.New | VariableKind.In));
+      AddVariableInfo(new VariableInfo("Beta", "The best solution of the run", typeof(IScope), VariableKind.New | VariableKind.In));
+      AddVariableInfo(new VariableInfo("UpperEstimationLimit", "Upper limit for estimated value (optional)", typeof(DoubleData), VariableKind.In));
+      AddVariableInfo(new VariableInfo("LowerEstimationLimit", "Lower limit for estimated value (optional)", typeof(DoubleData), VariableKind.In));
+    }
+
+    public override IOperation Apply(IScope scope) {
+      double[,] values = GetVariableValue<DoubleMatrixData>("Values", scope, true).Data;
+      DoubleData alpha = GetVariableValue<DoubleData>("Alpha", scope, true, false);
+      DoubleData beta = GetVariableValue<DoubleData>("Beta", scope, true, false);
+      DoubleData lowerEstimationLimit = GetVariableValue<DoubleData>("LowerEstimationLimit", scope, true, false);
+      DoubleData upperEstimationLimit = GetVariableValue<DoubleData>("UpperEstimationLimit", scope, true, false);
+
+      double a, b;
+      if (alpha == null || beta == null) {
+        // one of the variables is missing -> recalculate 
+        CalculateScalingParameters(values, out b, out a);
+        scope.AddVariable(new Variable(scope.TranslateName("Alpha"), new DoubleData(a)));
+        scope.AddVariable(new Variable(scope.TranslateName("Beta"), new DoubleData(b)));
+      } else {
+        // both variables are set already
+        a = alpha.Data;
+        b = beta.Data;
+      }
+      // check if upper and lower limit are set and use -Inf and +Inf as a default
+      double lowerLimit = lowerEstimationLimit == null ? double.NegativeInfinity : lowerEstimationLimit.Data;
+      double upperLimit = upperEstimationLimit == null ? double.PositiveInfinity : upperEstimationLimit.Data;
+      // apply scaling
+      Scale(values, a, b, lowerLimit, upperLimit);
+
+      return null;
+    }
+
+
+    public static void CalculateScalingParameters(double[,] values, out double beta, out double alpha) {
+      var result = from row in Enumerable.Range(0, values.GetLength(0))
+                   let t = values[row, SimpleEvaluatorBase.ORIGINAL_INDEX]
+                   let e = values[row, SimpleEvaluatorBase.ESTIMATION_INDEX]
+                   select new { Estimation = e, Target = t };
+
+      // calculate alpha and beta on the subset of rows with valid values 
+      var filteredResult = result.Where(x => IsValidValue(x.Target) && IsValidValue(x.Estimation));
+      var target = filteredResult.Select(x => x.Target);
+      var estimation = filteredResult.Select(x => x.Estimation);
+      double tMean = target.Sum() / target.Count();
+      double xMean = estimation.Sum() / estimation.Count();
+      double sumXT = 0;
+      double sumXX = 0;
+      foreach (var r in result) {
+        double x = r.Estimation;
+        double t = r.Target;
+        sumXT += (x - xMean) * (t - tMean);
+        sumXX += (x - xMean) * (x - xMean);
+      }
+      if (sumXX != 0) {
+        beta = sumXT / sumXX;
+      } else {
+        beta = 1;
+      }
+      alpha = tMean - beta * xMean;
+    }
+
+    public static void Scale(double[,] values, double alpha, double beta, double lowerEstimationLimit, double upperEstimationLimit) {
+      int rows = values.GetLength(0);
+      for (int row = 0; row < rows; row++) {
+        double estimatedValue = values[row, SimpleEvaluatorBase.ESTIMATION_INDEX];
+        if (double.IsNaN(estimatedValue))
+          estimatedValue = upperEstimationLimit;
+        values[row, SimpleEvaluatorBase.ESTIMATION_INDEX] =
+          Math.Min(Math.Max(estimatedValue * beta + alpha, lowerEstimationLimit), upperEstimationLimit); ;
+      }
+    }
+
+    private static bool IsValidValue(double d) {
+      return !double.IsInfinity(d) && !double.IsNaN(d);
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Modeling/3.2/SimpleEvaluatorBase.cs
===================================================================
--- trunk/sources/HeuristicLab.Modeling/3.2/SimpleEvaluatorBase.cs	(revision 2976)
+++ trunk/sources/HeuristicLab.Modeling/3.2/SimpleEvaluatorBase.cs	(revision 2977)
@@ -9,6 +9,6 @@
 namespace HeuristicLab.Modeling {
   public abstract class SimpleEvaluatorBase : OperatorBase {
-    protected const int ORIGINAL_INDEX = 0;
-    protected const int ESTIMATION_INDEX = 1;
+    public const int ORIGINAL_INDEX = 0;
+    public const int ESTIMATION_INDEX = 1;
 
     public virtual string OutputVariableName {
