Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicClassificationSolutionSimplifierView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicClassificationSolutionSimplifierView.cs	(revision 8945)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicClassificationSolutionSimplifierView.cs	(revision 8946)
@@ -30,5 +30,9 @@
     }
 
-    public InteractiveSymbolicClassificationSolutionSimplifierView() : base() { }
+    public InteractiveSymbolicClassificationSolutionSimplifierView()
+      : base() {
+      InitializeComponent();
+      this.Caption = "Interactive Classification Solution Simplifier";
+    }
 
     protected override void UpdateModel(ISymbolicExpressionTree tree) {
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicClassificationSolutionSimplifierViewBase.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicClassificationSolutionSimplifierViewBase.cs	(revision 8945)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicClassificationSolutionSimplifierViewBase.cs	(revision 8946)
@@ -29,6 +29,5 @@
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views {
   public abstract partial class InteractiveSymbolicClassificationSolutionSimplifierViewBase : InteractiveSymbolicDataAnalysisSolutionSimplifierView {
-    private readonly ConstantTreeNode constantNode;
-    private readonly SymbolicExpressionTree tempTree;
+    private readonly SymbolicClassificationSolutionImpactValuesCalculator calculator;
 
     public new ISymbolicClassificationSolution Content {
@@ -42,9 +41,5 @@
       this.Caption = "Interactive Classification Solution Simplifier";
 
-      constantNode = ((ConstantTreeNode)new Constant().CreateTreeNode());
-      ISymbolicExpressionTreeNode root = new ProgramRootSymbol().CreateTreeNode();
-      ISymbolicExpressionTreeNode start = new StartSymbol().CreateTreeNode();
-      root.AddSubtree(start);
-      tempTree = new SymbolicExpressionTree(root);
+      calculator = new SymbolicClassificationSolutionImpactValuesCalculator();
     }
 
@@ -66,69 +61,15 @@
 
     protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) {
-      Dictionary<ISymbolicExpressionTreeNode, double> replacementValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
-      foreach (ISymbolicExpressionTreeNode node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) {
-        replacementValues[node] = CalculateReplacementValue(node, tree);
-      }
-      return replacementValues;
+      return tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToDictionary(
+        n => n,
+        n => calculator.CalculateReplacementValue(Content.Model, n, Content.ProblemData, Content.ProblemData.TrainingIndices)
+        );
     }
 
     protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree) {
-      var model = Content.Model;
-      var dataset = Content.ProblemData.Dataset;
-      var rows = Content.ProblemData.TrainingIndices;
-      string targetVariable = Content.ProblemData.TargetVariable;
-      Dictionary<ISymbolicExpressionTreeNode, double> impactValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
-      List<ISymbolicExpressionTreeNode> nodes = tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPostfix().ToList();
-
-      var targetClassValues = dataset.GetDoubleValues(targetVariable, rows);
-      var originalClassValues = model.GetEstimatedClassValues(dataset, rows);
-      OnlineCalculatorError errorState;
-      double originalAccuracy = OnlineAccuracyCalculator.Calculate(targetClassValues, originalClassValues, out errorState);
-      if (errorState != OnlineCalculatorError.None) originalAccuracy = 0.0;
-
-      foreach (ISymbolicExpressionTreeNode node in nodes) {
-        var parent = node.Parent;
-        constantNode.Value = CalculateReplacementValue(node, tree);
-        ISymbolicExpressionTreeNode replacementNode = constantNode;
-        SwitchNode(parent, node, replacementNode);
-        var newModel = CreateModel(tree);
-        var newClassValues = newModel.GetEstimatedClassValues(dataset, rows);
-        double newAccuracy = OnlineAccuracyCalculator.Calculate(targetClassValues, newClassValues, out errorState);
-        if (errorState != OnlineCalculatorError.None) newAccuracy = 0.0;
-
-        // impact = 0 if no change
-        // impact < 0 if new solution is better
-        // impact > 0 if new solution is worse
-        impactValues[node] = originalAccuracy - newAccuracy;
-        SwitchNode(parent, replacementNode, node);
-      }
-      return impactValues;
-    }
-
-    private double CalculateReplacementValue(ISymbolicExpressionTreeNode node, ISymbolicExpressionTree sourceTree) {
-      // remove old ADFs
-      while (tempTree.Root.SubtreeCount > 1) tempTree.Root.RemoveSubtree(1);
-      // clone ADFs of source tree
-      for (int i = 1; i < sourceTree.Root.SubtreeCount; i++) {
-        tempTree.Root.AddSubtree((ISymbolicExpressionTreeNode)sourceTree.Root.GetSubtree(i).Clone());
-      }
-      var start = tempTree.Root.GetSubtree(0);
-      while (start.SubtreeCount > 0) start.RemoveSubtree(0);
-      start.AddSubtree((ISymbolicExpressionTreeNode)node.Clone());
-      var interpreter = Content.Model.Interpreter;
-      var rows = Content.ProblemData.TrainingIndices;
-      return interpreter.GetSymbolicExpressionTreeValues(tempTree, Content.ProblemData.Dataset, rows)
-             .LimitToRange(Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit).Median();
-    }
-
-
-    private void SwitchNode(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode oldBranch, ISymbolicExpressionTreeNode newBranch) {
-      for (int i = 0; i < root.SubtreeCount; i++) {
-        if (root.GetSubtree(i) == oldBranch) {
-          root.RemoveSubtree(i);
-          root.InsertSubtree(i, newBranch);
-          return;
-        }
-      }
+      return tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToDictionary(
+        n => n,
+        n => calculator.CalculateImpactValue(Content.Model, n, Content.ProblemData, Content.ProblemData.TrainingIndices, Content.TrainingAccuracy)
+        );
     }
 
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs	(revision 8945)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views/3.4/InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView.cs	(revision 8946)
@@ -24,5 +24,4 @@
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification.Views {
   public partial class InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView : InteractiveSymbolicClassificationSolutionSimplifierViewBase {
-
     public new SymbolicDiscriminantFunctionClassificationSolution Content {
       get { return (SymbolicDiscriminantFunctionClassificationSolution)base.Content; }
@@ -30,9 +29,12 @@
     }
 
-    public InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView() : base() { }
+    public InteractiveSymbolicDiscriminantFunctionClassificationSolutionSimplifierView()
+      : base() {
+      InitializeComponent();
+      this.Caption = "Interactive Classification Solution Simplifier";
+    }
 
     protected override void UpdateModel(ISymbolicExpressionTree tree) {
       var model = CreateModel(tree);
-      model.RecalculateModelParameters(Content.ProblemData, Content.ProblemData.TrainingIndices);
       Content.Model = (ISymbolicDiscriminantFunctionClassificationModel)model;
     }
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.csproj	(revision 8945)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification-3.4.csproj	(revision 8946)
@@ -120,4 +120,5 @@
     <Compile Include="ModelCreators\NormalDistributedThresholdsModelCreator.cs" />
     <Compile Include="MultiObjective\SymbolicClassificationMultiObjectiveValidationBestSolutionAnalyzer.cs" />
+    <Compile Include="SymbolicClassificationSolutionImpactValuesCalculator.cs" />
     <Compile Include="SymbolicNearestNeighbourClassificationModel.cs" />
     <Compile Include="Plugin.cs" />
@@ -258,5 +259,5 @@
   -->
   <PropertyGroup>
-   <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
+    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
 set ProjectDir=$(ProjectDir)
 set SolutionDir=$(SolutionDir)
@@ -265,5 +266,5 @@
 call PreBuildEvent.cmd
 </PreBuildEvent>
-<PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
+    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
 export ProjectDir=$(ProjectDir)
 export SolutionDir=$(SolutionDir)
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationSolutionImpactValuesCalculator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationSolutionImpactValuesCalculator.cs	(revision 8946)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Classification/3.4/SymbolicClassificationSolutionImpactValuesCalculator.cs	(revision 8946)
@@ -0,0 +1,64 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Collections.Generic;
+using HeuristicLab.Common;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Classification {
+  public class SymbolicClassificationSolutionImpactValuesCalculator : SymbolicDataAnalysisSolutionImpactValuesCalculator {
+    public override double CalculateReplacementValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows) {
+      var classificationModel = (ISymbolicClassificationModel)model;
+      var classificationProblemData = (IClassificationProblemData)problemData;
+
+      return CalculateReplacementValue(node, classificationModel.SymbolicExpressionTree, classificationModel.Interpreter, classificationProblemData.Dataset, rows);
+    }
+
+    public override double CalculateImpactValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows, double originalQuality = double.NaN) {
+      var classificationModel = (ISymbolicClassificationModel)model;
+      var classificationProblemData = (IClassificationProblemData)problemData;
+
+      var dataset = classificationProblemData.Dataset;
+      var targetClassValues = dataset.GetDoubleValues(classificationProblemData.TargetVariable, rows);
+
+      OnlineCalculatorError errorState;
+      if (double.IsNaN(originalQuality)) {
+        var originalClassValues = classificationModel.GetEstimatedClassValues(dataset, rows);
+        originalQuality = OnlineAccuracyCalculator.Calculate(targetClassValues, originalClassValues, out errorState);
+        if (errorState != OnlineCalculatorError.None) originalQuality = 0.0;
+      }
+
+      var replacementValue = CalculateReplacementValue(classificationModel, node, classificationProblemData, rows);
+      var constantNode = new ConstantTreeNode(new Constant()) { Value = replacementValue };
+      var cloner = new Cloner();
+      cloner.RegisterClonedObject(node, constantNode);
+      var tempModel = cloner.Clone(classificationModel);
+      tempModel.RecalculateModelParameters(classificationProblemData, rows);
+
+      var estimatedClassValues = tempModel.GetEstimatedClassValues(dataset, rows);
+      double newQuality = OnlineAccuracyCalculator.Calculate(targetClassValues, estimatedClassValues, out errorState);
+      if (errorState != OnlineCalculatorError.None) newQuality = 0.0;
+
+      return originalQuality - newQuality;
+    }
+
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs	(revision 8945)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/InteractiveSymbolicRegressionSolutionSimplifierView.cs	(revision 8946)
@@ -23,5 +23,4 @@
 using System.Collections.Generic;
 using System.Linq;
-using HeuristicLab.Common;
 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 using HeuristicLab.Problems.DataAnalysis.Symbolic.Views;
@@ -29,6 +28,5 @@
 namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views {
   public partial class InteractiveSymbolicRegressionSolutionSimplifierView : InteractiveSymbolicDataAnalysisSolutionSimplifierView {
-    private readonly ConstantTreeNode constantNode;
-    private readonly SymbolicExpressionTree tempTree;
+    private readonly SymbolicRegressionSolutionImpactValuesCalculator calculator;
 
     public new SymbolicRegressionSolution Content {
@@ -41,10 +39,5 @@
       InitializeComponent();
       this.Caption = "Interactive Regression Solution Simplifier";
-
-      constantNode = ((ConstantTreeNode)new Constant().CreateTreeNode());
-      ISymbolicExpressionTreeNode root = new ProgramRootSymbol().CreateTreeNode();
-      ISymbolicExpressionTreeNode start = new StartSymbol().CreateTreeNode();
-      root.AddSubtree(start);
-      tempTree = new SymbolicExpressionTree(root);
+      calculator = new SymbolicRegressionSolutionImpactValuesCalculator();
     }
 
@@ -56,92 +49,20 @@
 
     protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree) {
-      Dictionary<ISymbolicExpressionTreeNode, double> replacementValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
-      foreach (ISymbolicExpressionTreeNode node in tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix()) {
-        replacementValues[node] = CalculateReplacementValue(node, tree);
-      }
-      return replacementValues;
+      return tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToDictionary(
+        n => n,
+        n => calculator.CalculateReplacementValue(Content.Model, n, Content.ProblemData, Content.ProblemData.TrainingIndices)
+        );
     }
 
     protected override Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree) {
-      var interpreter = Content.Model.Interpreter;
-      var dataset = Content.ProblemData.Dataset;
-      var rows = Content.ProblemData.TrainingIndices;
-      string targetVariable = Content.ProblemData.TargetVariable;
-      Dictionary<ISymbolicExpressionTreeNode, double> impactValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
-      List<ISymbolicExpressionTreeNode> nodes = tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPostfix().ToList();
-      var originalOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows).LimitToRange(Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit).ToArray();
-      var targetValues = dataset.GetDoubleValues(targetVariable, rows);
-      OnlineCalculatorError errorState;
-      double originalR2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, originalOutput, out errorState);
-      if (errorState != OnlineCalculatorError.None) originalR2 = 0.0;
-
-      foreach (ISymbolicExpressionTreeNode node in nodes) {
-        var parent = node.Parent;
-        constantNode.Value = CalculateReplacementValue(node, tree);
-        ISymbolicExpressionTreeNode replacementNode = constantNode;
-        SwitchNode(parent, node, replacementNode);
-        var newOutput = interpreter.GetSymbolicExpressionTreeValues(tree, dataset, rows).LimitToRange(Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit);
-        double newR2 = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, newOutput, out errorState);
-        if (errorState != OnlineCalculatorError.None) newR2 = 0.0;
-
-        // impact = 0 if no change
-        // impact < 0 if new solution is better
-        // impact > 0 if new solution is worse
-        impactValues[node] = originalR2 - newR2;
-        SwitchNode(parent, replacementNode, node);
-      }
-      return impactValues;
+      return tree.Root.GetSubtree(0).GetSubtree(0).IterateNodesPrefix().ToDictionary(
+        n => n,
+        n => calculator.CalculateImpactValue(Content.Model, n, Content.ProblemData, Content.ProblemData.TrainingIndices, Content.TrainingRSquared)
+        );
     }
-
-    private double CalculateReplacementValue(ISymbolicExpressionTreeNode node, ISymbolicExpressionTree sourceTree) {
-      // remove old ADFs
-      while (tempTree.Root.SubtreeCount > 1) tempTree.Root.RemoveSubtree(1);
-      // clone ADFs of source tree
-      for (int i = 1; i < sourceTree.Root.SubtreeCount; i++) {
-        tempTree.Root.AddSubtree((ISymbolicExpressionTreeNode)sourceTree.Root.GetSubtree(i).Clone());
-      }
-      var start = tempTree.Root.GetSubtree(0);
-      while (start.SubtreeCount > 0) start.RemoveSubtree(0);
-      start.AddSubtree((ISymbolicExpressionTreeNode)node.Clone());
-      var interpreter = Content.Model.Interpreter;
-      var rows = Content.ProblemData.TrainingIndices;
-      return interpreter.GetSymbolicExpressionTreeValues(tempTree, Content.ProblemData.Dataset, rows)
-                         .LimitToRange(Content.Model.LowerEstimationLimit, Content.Model.UpperEstimationLimit)
-                         .Median();
-    }
-
-
-    private void SwitchNode(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode oldBranch, ISymbolicExpressionTreeNode newBranch) {
-      for (int i = 0; i < root.SubtreeCount; i++) {
-        if (root.GetSubtree(i) == oldBranch) {
-          root.RemoveSubtree(i);
-          root.InsertSubtree(i, newBranch);
-          return;
-        }
-      }
-    }
-
-    protected override void OnModelChanged() {
-      base.OnModelChanged();
-      if (Content != null)
-        btnOptimizeConstants.Enabled =
-          SymbolicRegressionConstantOptimizationEvaluator.CanOptimizeConstants(Content.Model.SymbolicExpressionTree);
-      else
-        btnOptimizeConstants.Enabled = false;
-    }
-    protected override void OnContentChanged() {
-      base.OnContentChanged();
-      base.OnModelChanged();
-      if (Content != null)
-        btnOptimizeConstants.Enabled =
-          SymbolicRegressionConstantOptimizationEvaluator.CanOptimizeConstants(Content.Model.SymbolicExpressionTree);
-      else
-        btnOptimizeConstants.Enabled = false;
-    }
-
 
     protected override void btnOptimizeConstants_Click(object sender, EventArgs e) {
       var model = Content.Model;
-      SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(Content.Model.Interpreter, Content.Model.SymbolicExpressionTree, Content.ProblemData, Content.ProblemData.TrainingIndices,
+      SymbolicRegressionConstantOptimizationEvaluator.OptimizeConstants(model.Interpreter, model.SymbolicExpressionTree, Content.ProblemData, Content.ProblemData.TrainingIndices,
         applyLinearScaling: true, maxIterations: 50, upperEstimationLimit: model.UpperEstimationLimit, lowerEstimationLimit: model.LowerEstimationLimit);
       UpdateModel(Content.Model.SymbolicExpressionTree);
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj	(revision 8945)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.csproj	(revision 8946)
@@ -143,4 +143,5 @@
     <Compile Include="SingleObjective\Evaluators\SymbolicRegressionSingleObjectivePearsonRSquaredEvaluator.cs" />
     <Compile Include="SymbolicRegressionSolution.cs" />
+    <Compile Include="SymbolicRegressionSolutionImpactValuesCalculator.cs" />
     <None Include="HeuristicLab.snk" />
     <None Include="Plugin.cs.frame" />
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolutionImpactValuesCalculator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolutionImpactValuesCalculator.cs	(revision 8946)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression/3.4/SymbolicRegressionSolutionImpactValuesCalculator.cs	(revision 8946)
@@ -0,0 +1,64 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Collections.Generic;
+using HeuristicLab.Common;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Regression {
+  public class SymbolicRegressionSolutionImpactValuesCalculator : SymbolicDataAnalysisSolutionImpactValuesCalculator {
+    public override double CalculateReplacementValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows) {
+      var regressionModel = (ISymbolicRegressionModel)model;
+      var regressionProblemData = (IRegressionProblemData)problemData;
+
+      return CalculateReplacementValue(node, regressionModel.SymbolicExpressionTree, regressionModel.Interpreter, regressionProblemData.Dataset, rows);
+    }
+
+    public override double CalculateImpactValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows, double originalQuality = double.NaN) {
+      var regressionModel = (ISymbolicRegressionModel)model;
+      var regressionProblemData = (IRegressionProblemData)problemData;
+
+      var dataset = regressionProblemData.Dataset;
+      var targetValues = dataset.GetDoubleValues(regressionProblemData.TargetVariable, rows);
+
+      OnlineCalculatorError errorState;
+      if (double.IsNaN(originalQuality)) {
+        var originalClassValues = regressionModel.GetEstimatedValues(dataset, rows);
+        originalQuality = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, originalClassValues, out errorState);
+        if (errorState != OnlineCalculatorError.None) originalQuality = 0.0;
+      }
+
+      var replacementValue = CalculateReplacementValue(regressionModel, node, regressionProblemData, rows);
+      var constantNode = new ConstantTreeNode(new Constant()) { Value = replacementValue };
+      var cloner = new Cloner();
+      cloner.RegisterClonedObject(node, constantNode);
+      var tempModel = cloner.Clone(regressionModel);
+      SymbolicDataAnalysisModel.Scale(tempModel, regressionProblemData, regressionProblemData.TargetVariable);
+
+      var estimatedValues = tempModel.GetEstimatedValues(dataset, rows);
+      double newQuality = OnlinePearsonsRSquaredCalculator.Calculate(targetValues, estimatedValues, out errorState);
+      if (errorState != OnlineCalculatorError.None) newQuality = 0.0;
+
+      return originalQuality - newQuality;
+    }
+
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj	(revision 8945)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj	(revision 8946)
@@ -114,4 +114,10 @@
   </ItemGroup>
   <ItemGroup>
+    <Compile Include="InteractiveSymbolicExpressionTreeChart.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
+    <Compile Include="InteractiveSymbolicExpressionTreeChart.Designer.cs">
+      <DependentUpon>InteractiveSymbolicExpressionTreeChart.cs</DependentUpon>
+    </Compile>
     <Compile Include="MathSymbolicDataAnalysisModelView.cs">
       <SubType>UserControl</SubType>
@@ -121,4 +127,10 @@
     </Compile>
     <Compile Include="Plugin.cs" />
+    <Compile Include="SymbolicExpressionTreeNodeChangeValueDialog.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="SymbolicExpressionTreeNodeChangeValueDialog.Designer.cs">
+      <DependentUpon>SymbolicExpressionTreeNodeChangeValueDialog.cs</DependentUpon>
+    </Compile>
     <Compile Include="TextualSymbolicDataAnalysisModelView.cs">
       <SubType>UserControl</SubType>
@@ -168,4 +180,16 @@
     <Compile Include="Symbols\VariableView.Designer.cs">
       <DependentUpon>VariableView.cs</DependentUpon>
+    </Compile>
+    <Compile Include="TreeEditDialogs\SymbolicExpressionTreeNodeChangeValueDialog.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="TreeEditDialogs\SymbolicExpressionTreeNodeChangeValueDialog.Designer.cs">
+      <DependentUpon>SymbolicExpressionTreeNodeChangeValueDialog.cs</DependentUpon>
+    </Compile>
+    <Compile Include="TreeEditDialogs\SymbolicExpressionTreeNodeInsertDialog.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="TreeEditDialogs\SymbolicExpressionTreeNodeInsertDialog.Designer.cs">
+      <DependentUpon>SymbolicExpressionTreeNodeInsertDialog.cs</DependentUpon>
     </Compile>
     <None Include="HeuristicLab.snk" />
@@ -313,5 +337,5 @@
   -->
   <PropertyGroup>
-   <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
+    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
 set ProjectDir=$(ProjectDir)
 set SolutionDir=$(SolutionDir)
@@ -320,5 +344,5 @@
 call PreBuildEvent.cmd
 </PreBuildEvent>
-<PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
+    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
 export ProjectDir=$(ProjectDir)
 export SolutionDir=$(SolutionDir)
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs	(revision 8945)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.Designer.cs	(revision 8946)
@@ -1,5 +1,5 @@
 ﻿#region License Information
 /* HeuristicLab
- * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
  *
  * This file is part of HeuristicLab.
@@ -45,5 +45,5 @@
     /// </summary>
     private void InitializeComponent() {
-      this.treeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
+      this.components = new System.ComponentModel.Container();
       this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
       this.splitContainer = new System.Windows.Forms.SplitContainer();
@@ -52,4 +52,5 @@
       this.btnSimplify = new System.Windows.Forms.Button();
       this.btnOptimizeConstants = new System.Windows.Forms.Button();
+      this.treeChart = new HeuristicLab.Problems.DataAnalysis.Symbolic.Views.InteractiveSymbolicExpressionTreeChart();
       this.grpViewHost = new System.Windows.Forms.GroupBox();
       ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
@@ -61,20 +62,4 @@
       this.grpViewHost.SuspendLayout();
       this.SuspendLayout();
-      // 
-      // treeChart
-      // 
-      this.treeChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
-            | System.Windows.Forms.AnchorStyles.Left)
-            | System.Windows.Forms.AnchorStyles.Right)));
-      this.treeChart.BackgroundColor = System.Drawing.Color.White;
-      this.treeChart.LineColor = System.Drawing.Color.Black;
-      this.treeChart.Location = new System.Drawing.Point(6, 16);
-      this.treeChart.Name = "treeChart";
-      this.treeChart.Size = new System.Drawing.Size(201, 291);
-      this.treeChart.Spacing = 5;
-      this.treeChart.TabIndex = 0;
-      this.treeChart.TextFont = new System.Drawing.Font("Times New Roman", 8F);
-      this.treeChart.Tree = null;
-      this.treeChart.SymbolicExpressionTreeNodeDoubleClicked += new System.Windows.Forms.MouseEventHandler(this.treeChart_SymbolicExpressionTreeNodeDoubleClicked);
       // 
       // viewHost
@@ -113,4 +98,5 @@
       // grpSimplify
       // 
+      this.grpSimplify.AutoSize = true;
       this.grpSimplify.Controls.Add(this.flowLayoutPanel);
       this.grpSimplify.Controls.Add(this.treeChart);
@@ -157,4 +143,23 @@
       this.btnOptimizeConstants.Click += new System.EventHandler(this.btnOptimizeConstants_Click);
       // 
+      // treeChart
+      // 
+      this.treeChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
+            | System.Windows.Forms.AnchorStyles.Left)
+            | System.Windows.Forms.AnchorStyles.Right)));
+      this.treeChart.BackgroundColor = System.Drawing.Color.White;
+      this.treeChart.LineColor = System.Drawing.Color.Black;
+      this.treeChart.Location = new System.Drawing.Point(6, 16);
+      this.treeChart.Name = "treeChart";
+      this.treeChart.Size = new System.Drawing.Size(201, 291);
+      this.treeChart.Spacing = 5;
+      this.treeChart.SuspendRepaint = false;
+      this.treeChart.TabIndex = 0;
+      this.treeChart.TextFont = new System.Drawing.Font("Times New Roman", 8F);
+      this.treeChart.Tree = null;
+      this.treeChart.SymbolicExpressionTreeChanged += new System.EventHandler(this.treeChart_SymbolicExpressionTreeChanged);
+      this.treeChart.SymbolicExpressionTreeNodeChanged += new System.EventHandler(this.treeChart_SymbolicExpressionTreeNodeChanged);
+      this.treeChart.SymbolicExpressionTreeNodeDoubleClicked += new System.Windows.Forms.MouseEventHandler(this.treeChart_SymbolicExpressionTreeNodeDoubleClicked);
+      // 
       // grpViewHost
       // 
@@ -171,9 +176,11 @@
       // 
       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
-      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
+      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
       this.Controls.Add(this.splitContainer);
+      this.DoubleBuffered = true;
       this.Name = "InteractiveSymbolicDataAnalysisSolutionSimplifierView";
       this.Size = new System.Drawing.Size(564, 348);
       this.splitContainer.Panel1.ResumeLayout(false);
+      this.splitContainer.Panel1.PerformLayout();
       this.splitContainer.Panel2.ResumeLayout(false);
       ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
@@ -188,5 +195,5 @@
     #endregion
 
-    private HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart treeChart;
+    private InteractiveSymbolicExpressionTreeChart treeChart;
     private System.Windows.Forms.SplitContainer splitContainer;
     private HeuristicLab.MainForm.WindowsForms.ViewHost viewHost;
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs	(revision 8945)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs	(revision 8946)
@@ -34,10 +34,14 @@
     private Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> replacementNodes;
     private Dictionary<ISymbolicExpressionTreeNode, double> nodeImpacts;
-    private bool updateInProgress = false;
+    private Dictionary<ISymbolicExpressionTreeNode, double> originalValues;
+    private Dictionary<ISymbolicExpressionTreeNode, string> originalVariableNames;
 
     public InteractiveSymbolicDataAnalysisSolutionSimplifierView() {
       InitializeComponent();
-      this.replacementNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();
-      this.nodeImpacts = new Dictionary<ISymbolicExpressionTreeNode, double>();
+      replacementNodes = new Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>();
+      nodeImpacts = new Dictionary<ISymbolicExpressionTreeNode, double>();
+      originalValues = new Dictionary<ISymbolicExpressionTreeNode, double>();
+      originalVariableNames = new Dictionary<ISymbolicExpressionTreeNode, string>();
+
       this.Caption = "Interactive Solution Simplifier";
     }
@@ -50,65 +54,37 @@
     protected override void RegisterContentEvents() {
       base.RegisterContentEvents();
-      Content.ModelChanged += new EventHandler(Content_ModelChanged);
-      Content.ProblemDataChanged += new EventHandler(Content_ProblemDataChanged);
+      Content.ModelChanged += Content_Changed;
+      Content.ProblemDataChanged += Content_Changed;
     }
     protected override void DeregisterContentEvents() {
       base.DeregisterContentEvents();
-      Content.ModelChanged -= new EventHandler(Content_ModelChanged);
-      Content.ProblemDataChanged -= new EventHandler(Content_ProblemDataChanged);
-    }
-
-    private void Content_ModelChanged(object sender, EventArgs e) {
-      OnModelChanged();
-    }
-    private void Content_ProblemDataChanged(object sender, EventArgs e) {
-      OnProblemDataChanged();
-    }
-
-    protected virtual void OnModelChanged() {
-      this.CalculateReplacementNodesAndNodeImpacts();
-    }
-
-    protected virtual void OnProblemDataChanged() {
-      this.CalculateReplacementNodesAndNodeImpacts();
+      Content.ModelChanged -= Content_Changed;
+      Content.ProblemDataChanged -= Content_Changed;
+    }
+
+    private void Content_Changed(object sender, EventArgs e) {
+      UpdateView();
     }
 
     protected override void OnContentChanged() {
       base.OnContentChanged();
-      this.CalculateReplacementNodesAndNodeImpacts();
-      this.viewHost.Content = this.Content;
-    }
-
-    private void CalculateReplacementNodesAndNodeImpacts() {
-      if (Content != null && Content.Model != null && Content.ProblemData != null) {
-        var tree = Content.Model.SymbolicExpressionTree;
-        var replacementValues = CalculateReplacementValues(tree);
-        foreach (var pair in replacementValues) {
-          if (!(pair.Key is ConstantTreeNode)) {
-            replacementNodes[pair.Key] = MakeConstantTreeNode(pair.Value);
-          }
-        }
-        nodeImpacts = CalculateImpactValues(Content.Model.SymbolicExpressionTree);
-
-        if (!updateInProgress) {
-          // automatically fold all branches with impact = 1
-          List<ISymbolicExpressionTreeNode> nodeList = Content.Model.SymbolicExpressionTree.Root.GetSubtree(0).IterateNodesPrefix().ToList();
-          foreach (var parent in nodeList) {
-            for (int subTreeIndex = 0; subTreeIndex < parent.SubtreeCount; subTreeIndex++) {
-              var child = parent.GetSubtree(subTreeIndex);
-              if (!(child.Symbol is Constant) && nodeImpacts[child].IsAlmost(0.0)) {
-                SwitchNodeWithReplacementNode(parent, subTreeIndex);
-              }
-            }
-          }
-        }
-
-        // show only interesting part of solution 
-        if (tree.Root.SubtreeCount > 1)
-          this.treeChart.Tree = new SymbolicExpressionTree(tree.Root); // RPB + ADFs
-        else
-          this.treeChart.Tree = new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0)); // 1st child of RPB
-        this.PaintNodeImpacts();
-      }
+      UpdateView();
+      viewHost.Content = this.Content;
+    }
+
+    private void UpdateView() {
+      if (Content == null || Content.Model == null || Content.ProblemData == null) return;
+      var tree = Content.Model.SymbolicExpressionTree;
+
+      var replacementValues = CalculateReplacementValues(tree);
+      foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) {
+        replacementNodes[pair.Key] = MakeConstantTreeNode(pair.Value);
+      }
+
+      nodeImpacts = CalculateImpactValues(tree);
+
+      var model = Content.Model.SymbolicExpressionTree;
+      treeChart.Tree = model.Root.SubtreeCount > 1 ? new SymbolicExpressionTree(model.Root) : new SymbolicExpressionTree(model.Root.GetSubtree(0).GetSubtree(0));
+      PaintNodeImpacts();
     }
 
@@ -117,9 +93,7 @@
     protected abstract void UpdateModel(ISymbolicExpressionTree tree);
 
-    private ConstantTreeNode MakeConstantTreeNode(double value) {
-      Constant constant = new Constant();
-      constant.MinValue = value - 1;
-      constant.MaxValue = value + 1;
-      ConstantTreeNode constantTreeNode = (ConstantTreeNode)constant.CreateTreeNode();
+    private static ConstantTreeNode MakeConstantTreeNode(double value) {
+      var constant = new Constant { MinValue = value - 1, MaxValue = value + 1 };
+      var constantTreeNode = (ConstantTreeNode)constant.CreateTreeNode();
       constantTreeNode.Value = value;
       return constantTreeNode;
@@ -127,25 +101,84 @@
 
     private void treeChart_SymbolicExpressionTreeNodeDoubleClicked(object sender, MouseEventArgs e) {
-      VisualSymbolicExpressionTreeNode visualTreeNode = (VisualSymbolicExpressionTreeNode)sender;
+      if (!treeChart.TreeValid) return;
+      var visualNode = (VisualSymbolicExpressionTreeNode)sender;
+      var symbExprTreeNode = (SymbolicExpressionTreeNode)visualNode.SymbolicExpressionTreeNode;
+      if (symbExprTreeNode == null) return;
       var tree = Content.Model.SymbolicExpressionTree;
-      foreach (SymbolicExpressionTreeNode treeNode in tree.IterateNodesPostfix()) {
-        for (int i = 0; i < treeNode.SubtreeCount; i++) {
-          ISymbolicExpressionTreeNode subTree = treeNode.GetSubtree(i);
-          // only allow to replace nodes for which a replacement value is known (replacement value for ADF nodes are not available)
-          if (subTree == visualTreeNode.SymbolicExpressionTreeNode && replacementNodes.ContainsKey(subTree)) {
-            SwitchNodeWithReplacementNode(treeNode, i);
-
-            // show only interesting part of solution 
-            if (tree.Root.SubtreeCount > 1)
-              this.treeChart.Tree = new SymbolicExpressionTree(tree.Root); // RPB + ADFs
-            else
-              this.treeChart.Tree = new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0)); // 1st child of RPB
-
-            updateInProgress = true;
-            UpdateModel(tree);
-            updateInProgress = false;
-            return; // break all loops
+
+      bool update = false;
+      // check if the node value/weight has been altered
+      // if so, the first double click will return the node to its original value/weight/variable name
+      // the next double click will replace the ConstantNode with the original SymbolicExpressionTreeNode
+      if (originalVariableNames.ContainsKey(symbExprTreeNode)) {
+        var variable = (VariableTreeNode)symbExprTreeNode;
+        variable.VariableName = originalVariableNames[symbExprTreeNode];
+        originalVariableNames.Remove(variable);
+        update = true;
+      } else if (originalValues.ContainsKey(symbExprTreeNode)) {
+        double value = originalValues[symbExprTreeNode];
+        if (symbExprTreeNode.Symbol is Constant) {
+          var constantTreeNode = (ConstantTreeNode)symbExprTreeNode;
+          constantTreeNode.Value = value;
+        } else if (symbExprTreeNode.Symbol is Variable) {
+          var variable = (VariableTreeNode)symbExprTreeNode;
+          variable.Weight = value;
+        }
+        originalValues.Remove(symbExprTreeNode);
+        update = true;
+      } else if (replacementNodes.ContainsKey(symbExprTreeNode)) {
+        foreach (var treeNode in tree.IterateNodesPostfix()) {
+          for (int i = 0; i < treeNode.SubtreeCount; i++) {
+            var subtree = treeNode.GetSubtree(i);
+            if (subtree == symbExprTreeNode) {
+              SwitchNodeWithReplacementNode(treeNode, i);
+              // show only interesting part of solution 
+              treeChart.Tree = tree.Root.SubtreeCount > 1
+                                 ? new SymbolicExpressionTree(tree.Root)
+                                 : new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0));
+              update = true;
+            }
           }
-        }
+          if (update) break;
+        }
+      }
+      if (update) UpdateModel(tree);
+    }
+
+    private void treeChart_SymbolicExpressionTreeChanged(object sender, EventArgs e) {
+      UpdateModel(Content.Model.SymbolicExpressionTree);
+      UpdateView();
+    }
+
+    private void treeChart_SymbolicExpressionTreeNodeChanged(object sender, EventArgs e) {
+      var dialog = (ValueChangeDialog)sender;
+      bool flag1 = false, flag2 = false;
+      var node = dialog.Content;
+
+      if (node is VariableTreeNode) {
+        var variable = (VariableTreeNode)node;
+        var weight = double.Parse(dialog.newValueTextBox.Text);
+        var name = (string)dialog.variableNamesCombo.SelectedItem;
+        if (!variable.Weight.Equals(weight)) {
+          flag1 = true;
+          originalValues[variable] = variable.Weight;
+          variable.Weight = weight;
+        }
+        if (!variable.VariableName.Equals(name)) {
+          flag2 = true;
+          originalVariableNames[variable] = variable.VariableName;
+          variable.VariableName = name;
+        }
+      } else if (node is ConstantTreeNode) {
+        var constant = (ConstantTreeNode)node;
+        var value = double.Parse(dialog.newValueTextBox.Text);
+        if (!constant.Value.Equals(value)) {
+          flag1 = true;
+          originalValues[constant] = constant.Value;
+          constant.Value = value;
+        }
+      }
+      if (flag1 || flag2) {
+        UpdateView();
       }
     }
@@ -168,7 +201,16 @@
       double min = impacts.Min();
       foreach (ISymbolicExpressionTreeNode treeNode in Content.Model.SymbolicExpressionTree.IterateNodesPostfix()) {
+        VisualSymbolicExpressionTreeNode visualTree = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode);
+        bool flag1 = replacementNodes.ContainsKey(treeNode);
+        bool flag2 = originalValues.ContainsKey(treeNode);
+        bool flag3 = treeNode is ConstantTreeNode;
+
+        if (flag2) // constant or variable node was changed
+          visualTree.ToolTip += Environment.NewLine + "Original value: " + originalValues[treeNode];
+        else if (flag1 && flag3) // symbol node was folded to a constant
+          visualTree.ToolTip += Environment.NewLine + "Original node: " + replacementNodes[treeNode];
+
         if (!(treeNode is ConstantTreeNode) && nodeImpacts.ContainsKey(treeNode)) {
           double impact = nodeImpacts[treeNode];
-          VisualSymbolicExpressionTreeNode visualTree = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode);
 
           // impact = 0 if no change
@@ -197,10 +239,10 @@
     private void PaintCollapsedNodes() {
       foreach (ISymbolicExpressionTreeNode treeNode in Content.Model.SymbolicExpressionTree.IterateNodesPostfix()) {
-        if (treeNode is ConstantTreeNode && replacementNodes.ContainsKey(treeNode))
-          this.treeChart.GetVisualSymbolicExpressionTreeNode(treeNode).LineColor = Color.DarkOrange;
-        else {
-          VisualSymbolicExpressionTreeNode visNode = treeChart.GetVisualSymbolicExpressionTreeNode(treeNode);
-          if (visNode != null)
-            visNode.LineColor = Color.Black;
+        bool flag1 = replacementNodes.ContainsKey(treeNode);
+        bool flag2 = originalValues.ContainsKey(treeNode);
+        if (flag1 && treeNode is ConstantTreeNode) {
+          this.treeChart.GetVisualSymbolicExpressionTreeNode(treeNode).LineColor = flag2 ? Color.DarkViolet : Color.DarkOrange;
+        } else if (flag2) {
+          this.treeChart.GetVisualSymbolicExpressionTreeNode(treeNode).LineColor = Color.DodgerBlue;
         }
       }
@@ -208,5 +250,5 @@
 
     private void btnSimplify_Click(object sender, EventArgs e) {
-      SymbolicDataAnalysisExpressionTreeSimplifier simplifier = new SymbolicDataAnalysisExpressionTreeSimplifier();
+      var simplifier = new SymbolicDataAnalysisExpressionTreeSimplifier();
       var simplifiedExpressionTree = simplifier.Simplify(Content.Model.SymbolicExpressionTree);
       UpdateModel(simplifiedExpressionTree);
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.Designer.cs	(revision 8946)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.Designer.cs	(revision 8946)
@@ -0,0 +1,216 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Windows.Forms;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
+  partial class InteractiveSymbolicExpressionTreeChart {
+    /// <summary> 
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary> 
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing) {
+      if (disposing && (components != null)) {
+        components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Component Designer generated code
+
+    /// <summary> 
+    /// Required method for Designer support - do not modify 
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent() {
+      this.DoubleBuffered = true;
+      this.insertNodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+      this.changeValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+      this.copyToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+      this.copyNodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+      this.copySubtreeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+      this.cutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+      this.cutNodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+      this.cutSubtreeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+      this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+      this.deleteNodeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+      this.deleteSubtreeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+      this.pasteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+      this.treeStatusLabel = new System.Windows.Forms.Label();
+      this.treeStatusValue = new System.Windows.Forms.Label();
+      this.SuspendLayout();
+      // 
+      // insertNodeToolStripMenuItem
+      // 
+      this.insertNodeToolStripMenuItem.Name = "insertNodeToolStripMenuItem";
+      this.insertNodeToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+      this.insertNodeToolStripMenuItem.Text = "Insert Node";
+      this.insertNodeToolStripMenuItem.Click += new System.EventHandler(this.insertNodeToolStripMenuItem_Click);
+      // 
+      // changeValueToolStripMenuItem
+      // 
+      this.changeValueToolStripMenuItem.Name = "changeValueToolStripMenuItem";
+      this.changeValueToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+      this.changeValueToolStripMenuItem.Text = "Change Value";
+      this.changeValueToolStripMenuItem.Click += new System.EventHandler(this.changeValueToolStripMenuItem_Click);
+      // 
+      // copyToolStripMenuItem
+      // 
+      this.copyToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.copyNodeToolStripMenuItem,
+            this.copySubtreeToolStripMenuItem});
+      this.copyToolStripMenuItem.Name = "copyToolStripMenuItem";
+      this.copyToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+      this.copyToolStripMenuItem.Text = "Copy";
+      // 
+      // copyNodeToolStripMenuItem
+      // 
+      this.copyNodeToolStripMenuItem.Name = "copyNodeToolStripMenuItem";
+      this.copyNodeToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
+      this.copyNodeToolStripMenuItem.Text = "Node";
+      this.copyNodeToolStripMenuItem.Click += new System.EventHandler(this.copyNodeToolStripMenuItem_Click);
+      // 
+      // copySubtreeToolStripMenuItem
+      // 
+      this.copySubtreeToolStripMenuItem.Name = "copySubtreeToolStripMenuItem";
+      this.copySubtreeToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
+      this.copySubtreeToolStripMenuItem.Text = "Subtree";
+      this.copySubtreeToolStripMenuItem.Click += new System.EventHandler(this.copySubtreeToolStripMenuItem_Click);
+      // 
+      // cutToolStripMenuItem
+      // 
+      this.cutToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.cutNodeToolStripMenuItem,
+            this.cutSubtreeToolStripMenuItem});
+      this.cutToolStripMenuItem.Name = "cutToolStripMenuItem";
+      this.cutToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+      this.cutToolStripMenuItem.Text = "Cut";
+      // 
+      // cutNodeToolStripMenuItem
+      // 
+      this.cutNodeToolStripMenuItem.Name = "cutNodeToolStripMenuItem";
+      this.cutNodeToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
+      this.cutNodeToolStripMenuItem.Text = "Node";
+      this.cutNodeToolStripMenuItem.Click += new System.EventHandler(this.cutNodeToolStripMenuItem_Click);
+      // 
+      // cutSubtreeToolStripMenuItem
+      // 
+      this.cutSubtreeToolStripMenuItem.Name = "cutSubtreeToolStripMenuItem";
+      this.cutSubtreeToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
+      this.cutSubtreeToolStripMenuItem.Text = "Subtree";
+      this.cutSubtreeToolStripMenuItem.Click += new System.EventHandler(this.cutSubtreeToolStripMenuItem_Click);
+      // 
+      // deleteToolStripMenuItem
+      // 
+      this.deleteToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+            this.deleteNodeToolStripMenuItem,
+            this.deleteSubtreeToolStripMenuItem});
+      this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
+      this.deleteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+      this.deleteToolStripMenuItem.Text = "Delete";
+      // 
+      // deleteNodeToolStripMenuItem
+      // 
+      this.deleteNodeToolStripMenuItem.Name = "deleteNodeToolStripMenuItem";
+      this.deleteNodeToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
+      this.deleteNodeToolStripMenuItem.Text = "Node";
+      this.deleteNodeToolStripMenuItem.Click += new System.EventHandler(this.deleteNodeToolStripMenuItem_Click);
+      // 
+      // deleteSubtreeToolStripMenuItem
+      // 
+      this.deleteSubtreeToolStripMenuItem.Name = "deleteSubtreeToolStripMenuItem";
+      this.deleteSubtreeToolStripMenuItem.Size = new System.Drawing.Size(114, 22);
+      this.deleteSubtreeToolStripMenuItem.Text = "Subtree";
+      this.deleteSubtreeToolStripMenuItem.Click += new System.EventHandler(this.deleteSubtreeToolStripMenuItem_Click);
+      // 
+      // pasteToolStripMenuItem
+      // 
+      this.pasteToolStripMenuItem.Name = "pasteToolStripMenuItem";
+      this.pasteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+      this.pasteToolStripMenuItem.Text = "Paste";
+      this.pasteToolStripMenuItem.Click += new System.EventHandler(this.pasteToolStripMenuItem_Clicked);
+      //
+      // contextMenuStrip
+      //
+      this.contextMenuStrip.Opened += this.contextMenuStrip_Opened;
+      this.contextMenuStrip.Items.AddRange(new ToolStripItem[] { insertNodeToolStripMenuItem,
+                                                                 changeValueToolStripMenuItem, 
+                                                                 copyToolStripMenuItem, 
+                                                                 cutToolStripMenuItem, 
+                                                                 deleteToolStripMenuItem, 
+                                                                 pasteToolStripMenuItem });
+      // 
+      // treeStatusLabel
+      // 
+      this.treeStatusLabel.AutoSize = true;
+      this.treeStatusLabel.BackColor = System.Drawing.Color.Transparent;
+      this.treeStatusLabel.Location = new System.Drawing.Point(3, 0);
+      this.treeStatusLabel.Name = "treeStatusLabel";
+      this.treeStatusLabel.Size = new System.Drawing.Size(68, 13);
+      this.treeStatusLabel.TabIndex = 0;
+      this.treeStatusLabel.Text = "Tree Status: ";
+      // 
+      // treeStatusValue
+      // 
+      this.treeStatusValue.AutoSize = true;
+      this.treeStatusValue.BackColor = System.Drawing.Color.Transparent;
+      this.treeStatusValue.ForeColor = System.Drawing.Color.Green;
+      this.treeStatusValue.Location = new System.Drawing.Point(77, 0);
+      this.treeStatusValue.Name = "treeStatusValue";
+      this.treeStatusValue.Size = new System.Drawing.Size(30, 13);
+      this.treeStatusValue.TabIndex = 1;
+      this.treeStatusValue.Text = "Valid";
+      // 
+      // InteractiveSymbolicExpressionTreeChart
+      // 
+      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+      this.Controls.Add(this.treeStatusLabel);
+      this.Controls.Add(this.treeStatusValue);
+      this.Name = "InteractiveSymbolicExpressionTreeChart";
+      this.ResumeLayout(false);
+      this.PerformLayout();
+
+    }
+
+    private ToolStripMenuItem insertNodeToolStripMenuItem;
+    private ToolStripMenuItem changeValueToolStripMenuItem;
+    private ToolStripMenuItem copyToolStripMenuItem;
+    private ToolStripMenuItem copyNodeToolStripMenuItem;
+    private ToolStripMenuItem copySubtreeToolStripMenuItem;
+    private ToolStripMenuItem cutToolStripMenuItem;
+    private ToolStripMenuItem cutNodeToolStripMenuItem;
+    private ToolStripMenuItem cutSubtreeToolStripMenuItem;
+    private ToolStripMenuItem pasteToolStripMenuItem;
+    private ToolStripMenuItem deleteToolStripMenuItem;
+    private ToolStripMenuItem deleteNodeToolStripMenuItem;
+    private ToolStripMenuItem deleteSubtreeToolStripMenuItem;
+
+    #endregion
+    private Label treeStatusLabel;
+    private Label treeStatusValue;
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs	(revision 8946)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicExpressionTreeChart.cs	(revision 8946)
@@ -0,0 +1,308 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Drawing;
+using System.Linq;
+using System.Windows.Forms;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
+  public sealed partial class InteractiveSymbolicExpressionTreeChart : SymbolicExpressionTreeChart {
+    private ISymbolicExpressionTreeNode tempNode;
+    private VisualSymbolicExpressionTreeNode lastSelected; // previously selected node
+    private VisualSymbolicExpressionTreeNode currSelected; // currently selected node
+    private enum EditOp { NoOp, CopyNode, CopySubtree, CutNode, CutSubtree, DeleteNode, DeleteSubtree }
+    private enum TreeState { Valid, Invalid }
+    private EditOp lastOp = EditOp.NoOp;
+    private TreeState treeState = TreeState.Valid; // tree edit operations must leave the tree in a valid state
+
+    public InteractiveSymbolicExpressionTreeChart() {
+      InitializeComponent();
+      // add extra actions in the context menu strips
+
+
+      lastSelected = null;
+      currSelected = null;
+      tempNode = null;
+    }
+
+    public bool TreeValid { get { return TreeState.Valid == treeState; } }
+    // expose an additional event for signaling to the parent view when the tree structure was modified
+    // the emitting of the signal is conditional on the tree being valid, otherwise only a Repaint is issued
+    public event EventHandler SymbolicExpressionTreeChanged;
+    private void OnSymbolicExpressionTreeChanged(object sender, EventArgs e) {
+      if (IsValid(Tree)) {
+        treeStatusValue.Text = "Valid";
+        treeStatusValue.ForeColor = Color.Green;
+        treeState = TreeState.Valid;
+        var changed = SymbolicExpressionTreeChanged;
+        if (changed != null)
+          changed(sender, e);
+      } else {
+        treeStatusValue.Text = "Invalid";
+        treeStatusValue.ForeColor = Color.Red;
+        treeState = TreeState.Invalid;
+        Repaint();
+      }
+    }
+
+    private void contextMenuStrip_Opened(object sender, EventArgs e) {
+      var menu = sender as ContextMenuStrip;
+      if (menu == null) return;
+      if (currSelected == null) {
+        insertNodeToolStripMenuItem.Visible = false;
+        changeValueToolStripMenuItem.Visible = false;
+        copyToolStripMenuItem.Visible = false;
+        cutToolStripMenuItem.Visible = false;
+        deleteToolStripMenuItem.Visible = false;
+        pasteToolStripMenuItem.Visible = false;
+      } else {
+        var node = currSelected.SymbolicExpressionTreeNode;
+        changeValueToolStripMenuItem.Visible = (node is SymbolicExpressionTreeTerminalNode);
+        insertNodeToolStripMenuItem.Visible = !changeValueToolStripMenuItem.Visible;
+        copyToolStripMenuItem.Visible = true;
+        cutToolStripMenuItem.Visible = true;
+        deleteToolStripMenuItem.Visible = true;
+        pasteToolStripMenuItem.Visible = tempNode != null && insertNodeToolStripMenuItem.Visible;
+      }
+    }
+
+    protected override void OnSymbolicExpressionTreeNodeClicked(object sender, MouseEventArgs e) {
+      var visualTreeNode = FindVisualSymbolicExpressionTreeNodeAt(e.X, e.Y);
+      if (visualTreeNode == null || visualTreeNode == currSelected) return;
+      lastSelected = currSelected;
+      if (lastSelected != null)
+        lastSelected.LineColor = Color.Black;
+      currSelected = visualTreeNode;
+      currSelected.LineColor = Color.LightGreen;
+      Repaint();
+      base.OnSymbolicExpressionTreeNodeClicked(sender, e);
+    }
+
+    private void insertNodeToolStripMenuItem_Click(object sender, EventArgs e) {
+      if (currSelected == null || currSelected.SymbolicExpressionTreeNode is SymbolicExpressionTreeTerminalNode) return;
+      var node = currSelected.SymbolicExpressionTreeNode;
+
+      using (var dialog = new InsertNodeDialog()) {
+        dialog.SetAllowedSymbols(node.Grammar.AllowedSymbols.Where(s => s.Enabled && s.InitialFrequency > 0.0 && !(s is ProgramRootSymbol || s is StartSymbol || s is Defun)));
+        dialog.DialogValidated += InsertNodeDialog_Validated;
+        dialog.ShowDialog(this);
+      }
+    }
+
+    private void changeValueToolStripMenuItem_Click(object sender, EventArgs e) {
+      if (currSelected == null) return;
+      var node = currSelected.SymbolicExpressionTreeNode;
+      using (var dialog = new ValueChangeDialog()) {
+        dialog.SetContent(node);
+        dialog.DialogValidated += ChangeValueDialog_Validated;
+        dialog.ShowDialog(this);
+      }
+    }
+
+    public event EventHandler SymbolicExpressionTreeNodeChanged;
+    private void OnSymbolicExpressionTreeNodeChanged(object sender, EventArgs e) {
+      var changed = SymbolicExpressionTreeNodeChanged;
+      if (changed != null)
+        SymbolicExpressionTreeNodeChanged(sender, e);
+    }
+
+    private void ChangeValueDialog_Validated(object sender, EventArgs e) {
+      OnSymbolicExpressionTreeNodeChanged(sender, e);
+    }
+
+    private void InsertNodeDialog_Validated(object sender, EventArgs e) {
+      var dialog = (InsertNodeDialog)sender;
+      var symbol = dialog.SelectedSymbol();
+      var node = symbol.CreateTreeNode();
+      var parent = currSelected.SymbolicExpressionTreeNode;
+      if (node is ConstantTreeNode) {
+        var constant = node as ConstantTreeNode;
+        constant.Value = double.Parse(dialog.constantValueTextBox.Text);
+      } else if (node is VariableTreeNode) {
+        var variable = node as VariableTreeNode;
+        variable.Weight = double.Parse(dialog.variableWeightTextBox.Text);
+        variable.VariableName = dialog.variableNamesCombo.Text;
+      } else {
+        if (node.Symbol.MinimumArity <= parent.SubtreeCount && node.Symbol.MaximumArity >= parent.SubtreeCount) {
+          for (int i = parent.SubtreeCount - 1; i >= 0; --i) {
+            var child = parent.GetSubtree(i);
+            parent.RemoveSubtree(i);
+            node.AddSubtree(child);
+          }
+        }
+      }
+      if (parent.Symbol.MaximumArity > parent.SubtreeCount) {
+        parent.AddSubtree(node);
+        Tree = Tree;
+      }
+      OnSymbolicExpressionTreeChanged(sender, e);
+    }
+
+    private void cutNodeToolStripMenuItem_Click(object sender, EventArgs e) {
+      lastOp = EditOp.CutNode;
+      tempNode = currSelected.SymbolicExpressionTreeNode;
+      var visualNode = GetVisualSymbolicExpressionTreeNode(tempNode);
+      visualNode.LineColor = Color.LightGray;
+      visualNode.TextColor = Color.LightGray;
+      Repaint();
+    }
+
+    private void cutSubtreeToolStripMenuItem_Click(object sender, EventArgs e) {
+      lastOp = EditOp.CutSubtree;
+      tempNode = currSelected.SymbolicExpressionTreeNode; // should never be null
+      foreach (var node in tempNode.IterateNodesPostfix()) {
+        var visualNode = GetVisualSymbolicExpressionTreeNode(node);
+        visualNode.LineColor = Color.LightGray;
+        visualNode.TextColor = Color.LightGray;
+        if (node.SubtreeCount > 0) {
+          foreach (var subtree in node.Subtrees) {
+            var visualLine = GetVisualSymbolicExpressionTreeNodeConnection(node, subtree);
+            visualLine.LineColor = Color.LightGray;
+          }
+        }
+      }
+      Repaint();
+    }
+
+    private void copyNodeToolStripMenuItem_Click(object sender, EventArgs e) {
+      lastOp = EditOp.CopyNode;
+      tempNode = currSelected.SymbolicExpressionTreeNode;
+      currSelected.LineColor = Color.LightGray;
+      currSelected.TextColor = Color.LightGray;
+      Repaint();
+    }
+
+    private void copySubtreeToolStripMenuItem_Click(object sender, EventArgs e) {
+      lastOp = EditOp.CopySubtree;
+      tempNode = currSelected.SymbolicExpressionTreeNode;
+      foreach (var node in tempNode.IterateNodesPostfix()) {
+        var visualNode = GetVisualSymbolicExpressionTreeNode(node);
+        visualNode.LineColor = Color.LightGray;
+        visualNode.TextColor = Color.LightGray;
+        if (node.SubtreeCount <= 0) continue;
+        foreach (var subtree in node.Subtrees) {
+          var visualLine = GetVisualSymbolicExpressionTreeNodeConnection(node, subtree);
+          visualLine.LineColor = Color.LightGray;
+        }
+      }
+      Repaint();
+    }
+
+    private void deleteNodeToolStripMenuItem_Click(object sender, EventArgs e) {
+      lastOp = EditOp.DeleteNode;
+      var node = currSelected.SymbolicExpressionTreeNode;
+      var parent = node.Parent;
+      if (parent == null || parent.Symbol is StartSymbol || parent.Symbol is ProgramRootSymbol)
+        return; // the operation would result in the deletion of the entire tree
+      if (parent.Symbol.MaximumArity >= node.SubtreeCount + parent.SubtreeCount - 1) { // -1 because tempNode will be removed
+        parent.RemoveSubtree(parent.IndexOfSubtree(node));
+        for (int i = node.SubtreeCount - 1; i >= 0; --i) {
+          var child = node.GetSubtree(i);
+          node.RemoveSubtree(i);
+          parent.AddSubtree(child);
+        }
+      }
+      currSelected = null; // because the currently selected node was just deleted
+      OnSymbolicExpressionTreeChanged(sender, e);
+    }
+
+    private void deleteSubtreeToolStripMenuItem_Click(object sender, EventArgs e) {
+      lastOp = EditOp.DeleteSubtree;
+      var node = currSelected.SymbolicExpressionTreeNode;
+      var parent = node.Parent;
+      if (parent == null || parent.Symbol is StartSymbol || parent.Symbol is ProgramRootSymbol)
+        return; // the operation makes no sense as it would result in the deletion of the entire tree
+      parent.RemoveSubtree(parent.IndexOfSubtree(node));
+      currSelected = null; // because the currently selected node was just deleted
+      OnSymbolicExpressionTreeChanged(sender, e);
+    }
+
+    private void pasteToolStripMenuItem_Clicked(object sender, EventArgs e) {
+      if (!(lastOp == EditOp.CopyNode || lastOp == EditOp.CopySubtree || lastOp == EditOp.CutNode || lastOp == EditOp.CutSubtree))
+        return;
+      // check if the copied/cut node (stored in the tempNode) can be inserted as a child of the current selected node
+      var node = currSelected.SymbolicExpressionTreeNode;
+      if (node is ConstantTreeNode || node is VariableTreeNode) return; // nothing to do
+      // check if the currently selected node can accept the copied node as a child 
+      // no need to check the grammar, an arity check will do just fine here
+      if (node.Symbol.MaximumArity > node.SubtreeCount) {
+        switch (lastOp) {
+          case (EditOp.CutNode): {
+              // when cutting a node from the tree, it's children become children of it's parent
+              var parent = tempNode.Parent;
+              // arity checks to see if parent can accept node's children (we assume the grammar is already ok with that)
+              // (otherise, the 'cut' part of the operation will just not do anything)
+              if (parent.Symbol.MaximumArity >= tempNode.SubtreeCount + parent.SubtreeCount - 1) {
+                // -1 because tempNode will be removed
+                parent.RemoveSubtree(parent.IndexOfSubtree(tempNode));
+                for (int i = tempNode.SubtreeCount - 1; i >= 0; --i) {
+                  var child = tempNode.GetSubtree(i);
+                  tempNode.RemoveSubtree(i);
+                  parent.AddSubtree(child);
+                }
+                lastOp = EditOp.CopyNode;
+                currSelected = null;
+              }
+              break;
+            }
+          case (EditOp.CutSubtree): {
+              // cut subtree
+              var parent = tempNode.Parent;
+              parent.RemoveSubtree(parent.IndexOfSubtree(tempNode));
+              lastOp = EditOp.CopySubtree; // do this so the next paste will actually perform a copy   
+              currSelected = null;
+              break;
+            }
+          case (EditOp.CopyNode): {
+              // copy node
+              var clone = (SymbolicExpressionTreeNode)tempNode.Clone(); // should never be null
+              clone.Parent = tempNode.Parent;
+              tempNode = clone;
+              for (int i = tempNode.SubtreeCount - 1; i >= 0; --i) tempNode.RemoveSubtree(i);
+              break;
+            }
+          case (EditOp.CopySubtree): {
+              // copy subtree
+              var clone = (SymbolicExpressionTreeNode)tempNode.Clone();
+              clone.Parent = tempNode.Parent;
+              tempNode = clone;
+              break;
+            }
+        }
+        node.AddSubtree(tempNode);
+        Tree = Tree; // hack in order to trigger the reinitialization of the dictionaries after new nodes appeared in the graph
+        OnSymbolicExpressionTreeChanged(sender, e);
+      }
+    }
+
+    private bool IsValid(ISymbolicExpressionTree tree) {
+      if (tree.IterateNodesPostfix().Any(node => node.SubtreeCount < node.Symbol.MinimumArity || node.SubtreeCount > node.Symbol.MaximumArity)) {
+        treeState = TreeState.Invalid;
+        return false;
+      }
+      treeState = TreeState.Valid;
+      return true;
+    }
+  }
+}
Index: unk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymbolicDataAnalysisModelView.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymbolicDataAnalysisModelView.cs	(revision 8945)
+++ 	(revision )
@@ -1,52 +1,0 @@
-﻿#region License Information
-/* HeuristicLab
- * Copyright (C) 2002-2011 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.Windows.Forms;
-using HeuristicLab.MainForm;
-using HeuristicLab.MainForm.WindowsForms;
-
-namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
-  [View("Symbolic data analysis model view")]
-  [Content(typeof(ISymbolicDataAnalysisModel), true)]
-  public partial class SymbolicExpressionModelView : AsynchronousContentView {
-    public SymbolicExpressionModelView()
-      : base() {
-      InitializeComponent();
-    }
-
-    public new ISymbolicDataAnalysisModel Content {
-      get { return (ISymbolicDataAnalysisModel)base.Content; }
-      set { base.Content = value; }
-    }
-
-    protected override void OnContentChanged() {
-      base.OnContentChanged();
-      if (Content != null)
-        UpdateTreeChart();
-      else
-        viewHost.Content = null;
-    }
-
-    private void UpdateTreeChart() {
-      viewHost.Content = Content.SymbolicExpressionTree;
-    }
-  }
-}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymbolicExpressionTreeNodeChangeValueDialog.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymbolicExpressionTreeNodeChangeValueDialog.Designer.cs	(revision 8946)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymbolicExpressionTreeNodeChangeValueDialog.Designer.cs	(revision 8946)
@@ -0,0 +1,129 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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
+
+namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
+  partial class ValueChangeDialog {
+    /// <summary>
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary>
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing) {
+      if (disposing) {
+        if (components != null) components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Windows Form Designer generated code
+
+    /// <summary>
+    /// Required method for Designer support - do not modify
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent() {
+      this.components = new System.ComponentModel.Container();
+      this.originalValueLabel = new System.Windows.Forms.Label();
+      this.originalValueTextBox = new System.Windows.Forms.TextBox();
+      this.newValueTextBox = new System.Windows.Forms.TextBox();
+      this.newValueLabel = new System.Windows.Forms.Label();
+      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
+      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
+      this.SuspendLayout();
+      // 
+      // originalValueLabel
+      // 
+      this.originalValueLabel.AutoSize = true;
+      this.originalValueLabel.Location = new System.Drawing.Point(14, 15);
+      this.originalValueLabel.Name = "originalValueLabel";
+      this.originalValueLabel.Size = new System.Drawing.Size(72, 13);
+      this.originalValueLabel.TabIndex = 2;
+      this.originalValueLabel.Text = "Original Value";
+      // 
+      // originalValueTextBox
+      // 
+      this.originalValueTextBox.Location = new System.Drawing.Point(91, 12);
+      this.originalValueTextBox.Name = "originalValueTextBox";
+      this.originalValueTextBox.ReadOnly = true;
+      this.originalValueTextBox.Size = new System.Drawing.Size(100, 20);
+      this.originalValueTextBox.TabIndex = 3;
+      // 
+      // newValueTextBox
+      // 
+      this.newValueTextBox.Location = new System.Drawing.Point(91, 38);
+      this.newValueTextBox.Name = "newValueTextBox";
+      this.newValueTextBox.Size = new System.Drawing.Size(100, 20);
+      this.newValueTextBox.TabIndex = 0;
+      this.newValueTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.newValueTextBox_KeyDown);
+      this.newValueTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.newValueTextBox_Validating);
+      this.newValueTextBox.Validated += new System.EventHandler(this.newValueTextBox_Validated);
+      // 
+      // newValueLabel
+      // 
+      this.newValueLabel.AutoSize = true;
+      this.newValueLabel.Location = new System.Drawing.Point(14, 41);
+      this.newValueLabel.Name = "newValueLabel";
+      this.newValueLabel.Size = new System.Drawing.Size(59, 13);
+      this.newValueLabel.TabIndex = 5;
+      this.newValueLabel.Text = "New Value";
+      // 
+      // errorProvider
+      // 
+      this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+      this.errorProvider.ContainerControl = this;
+      this.errorProvider.RightToLeft = true;
+      // 
+      // ValueChangeDialog
+      // 
+      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+      this.AutoSize = true;
+      this.ClientSize = new System.Drawing.Size(209, 71);
+      this.Controls.Add(this.newValueLabel);
+      this.Controls.Add(this.newValueTextBox);
+      this.Controls.Add(this.originalValueTextBox);
+      this.Controls.Add(this.originalValueLabel);
+      this.MaximizeBox = false;
+      this.MinimizeBox = false;
+      this.Name = "ValueChangeDialog";
+      this.ShowIcon = false;
+      this.ShowInTaskbar = false;
+      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+      this.Text = "Change Value or Weight";
+      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
+      this.ResumeLayout(false);
+      this.PerformLayout();
+
+    }
+
+    #endregion
+
+    private System.Windows.Forms.Label originalValueLabel;
+    private System.Windows.Forms.TextBox originalValueTextBox;
+    private System.Windows.Forms.TextBox newValueTextBox;
+    private System.Windows.Forms.Label newValueLabel;
+    private System.Windows.Forms.ErrorProvider errorProvider;
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymbolicExpressionTreeNodeChangeValueDialog.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymbolicExpressionTreeNodeChangeValueDialog.cs	(revision 8946)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/SymbolicExpressionTreeNodeChangeValueDialog.cs	(revision 8946)
@@ -0,0 +1,111 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.ComponentModel;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.Data;
+
+namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
+  public partial class ValueChangeDialog : Form {
+    public string Caption {
+      get { return this.Text; }
+      set {
+        if (InvokeRequired)
+          Invoke(new Action<string>(x => this.Caption = x), value);
+        else
+          this.Text = value;
+      }
+    }
+    public string OriginalValue {
+      get { return originalValueTextBox.Text; }
+      set {
+        if (InvokeRequired)
+          Invoke(new Action<string>(x => this.NewValue = x), value);
+        else
+          originalValueTextBox.Text = value;
+      }
+    }
+    public string NewValue {
+      get { return newValueTextBox.Text; }
+      set {
+        if (InvokeRequired)
+          Invoke(new Action<string>(x => this.NewValue = x), value);
+        else
+          newValueTextBox.Text = value;
+      }
+    }
+    public TextBox NewValueTextBox {
+      get { return newValueTextBox; }
+    }
+
+    public ValueChangeDialog() {
+      InitializeComponent();
+      originalValueTextBox.TabStop = false; // cannot receive focus using tab key
+    }
+    public ValueChangeDialog(string caption, string originalValue, string newValue)
+      : this() {
+      Caption = caption;
+      OriginalValue = originalValue;
+      NewValue = newValue;
+    }
+
+    protected virtual void okButton_Click(object sender, EventArgs e) {
+      Close();
+    }
+
+    private void newValueTextBox_KeyDown(object sender, KeyEventArgs e) {
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
+        newValueLabel.Select();  // select label to validate data
+
+      if (e.KeyCode == Keys.Escape) {
+        newValueTextBox.Text = String.Empty;
+        newValueLabel.Select();  // select label to validate data
+      }
+    }
+    private void newValueTextBox_Validating(object sender, CancelEventArgs e) {
+      string errorMessage;
+      if (!Validate(newValueTextBox.Text, out errorMessage)) {
+        e.Cancel = true;
+        errorProvider.SetError(newValueTextBox, errorMessage);
+        newValueTextBox.SelectAll();
+      }
+    }
+    private void newValueTextBox_Validated(object sender, EventArgs e) {
+      errorProvider.SetError(newValueTextBox, string.Empty);
+    }
+
+    private static bool Validate(string value, out string errorMessage) {
+      double val;
+      bool valid = double.TryParse(value, out val);
+      errorMessage = string.Empty;
+      if (!valid) {
+        var sb = new StringBuilder();
+        sb.Append("Invalid Value (Valid Value Format: \"");
+        sb.Append(FormatPatterns.GetDoubleFormatPattern());
+        sb.Append("\")");
+        errorMessage = sb.ToString();
+      }
+      return valid;
+    }
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeChangeValueDialog.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeChangeValueDialog.Designer.cs	(revision 8946)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeChangeValueDialog.Designer.cs	(revision 8946)
@@ -0,0 +1,190 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
+  partial class ValueChangeDialog {
+    /// <summary>
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary>
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing) {
+      if (disposing) {
+        if (components != null) components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Windows Form Designer generated code
+
+    /// <summary>
+    /// Required method for Designer support - do not modify
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent() {
+      this.components = new System.ComponentModel.Container();
+      this.originalValueLabel = new System.Windows.Forms.Label();
+      this.oldValueTextBox = new System.Windows.Forms.TextBox();
+      this.newValueTextBox = new System.Windows.Forms.TextBox();
+      this.newValueLabel = new System.Windows.Forms.Label();
+      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
+      this.variableNameLabel = new System.Windows.Forms.Label();
+      this.variableNamesCombo = new System.Windows.Forms.ComboBox();
+      this.okButton = new System.Windows.Forms.Button();
+      this.cancelButton = new System.Windows.Forms.Button();
+      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
+      this.SuspendLayout();
+      // 
+      // originalValueLabel
+      // 
+      this.originalValueLabel.AutoSize = true;
+      this.originalValueLabel.Location = new System.Drawing.Point(12, 45);
+      this.originalValueLabel.Name = "originalValueLabel";
+      this.originalValueLabel.Size = new System.Drawing.Size(72, 13);
+      this.originalValueLabel.TabIndex = 2;
+      this.originalValueLabel.Text = "Original Value";
+      // 
+      // oldValueTextBox
+      // 
+      this.oldValueTextBox.Location = new System.Drawing.Point(123, 42);
+      this.oldValueTextBox.Name = "oldValueTextBox";
+      this.oldValueTextBox.ReadOnly = true;
+      this.oldValueTextBox.Size = new System.Drawing.Size(131, 20);
+      this.oldValueTextBox.TabIndex = 3;
+      // 
+      // newValueTextBox
+      // 
+      this.newValueTextBox.Location = new System.Drawing.Point(123, 82);
+      this.newValueTextBox.Name = "newValueTextBox";
+      this.newValueTextBox.Size = new System.Drawing.Size(131, 20);
+      this.newValueTextBox.TabIndex = 0;
+      this.newValueTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.childControl_KeyDown);
+      this.newValueTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.newValueTextBox_Validating);
+      this.newValueTextBox.Validated += new System.EventHandler(this.newValueTextBox_Validated);
+      // 
+      // newValueLabel
+      // 
+      this.newValueLabel.AutoSize = true;
+      this.newValueLabel.Location = new System.Drawing.Point(12, 85);
+      this.newValueLabel.Name = "newValueLabel";
+      this.newValueLabel.Size = new System.Drawing.Size(59, 13);
+      this.newValueLabel.TabIndex = 5;
+      this.newValueLabel.Text = "New Value";
+      // 
+      // errorProvider
+      // 
+      this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+      this.errorProvider.ContainerControl = this;
+      this.errorProvider.RightToLeft = true;
+      // 
+      // variableNameLabel
+      // 
+      this.variableNameLabel.AutoSize = true;
+      this.variableNameLabel.Location = new System.Drawing.Point(12, 7);
+      this.variableNameLabel.Name = "variableNameLabel";
+      this.variableNameLabel.Size = new System.Drawing.Size(76, 13);
+      this.variableNameLabel.TabIndex = 6;
+      this.variableNameLabel.Text = "Variable Name";
+      this.variableNameLabel.Visible = false;
+      // 
+      // variableNamesCombo
+      // 
+      this.variableNamesCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+      this.variableNamesCombo.FormattingEnabled = true;
+      this.variableNamesCombo.Location = new System.Drawing.Point(123, 4);
+      this.variableNamesCombo.Name = "variableNamesCombo";
+      this.variableNamesCombo.Size = new System.Drawing.Size(131, 21);
+      this.variableNamesCombo.TabIndex = 7;
+      this.variableNamesCombo.Visible = false;
+      this.variableNamesCombo.KeyDown += new System.Windows.Forms.KeyEventHandler(this.childControl_KeyDown);
+      this.variableNamesCombo.Validating += new System.ComponentModel.CancelEventHandler(this.variableNamesCombo_Validating);
+      this.variableNamesCombo.Validated += new System.EventHandler(this.variableNamesCombo_Validated);
+      // 
+      // okButton
+      // 
+      this.okButton.Location = new System.Drawing.Point(15, 119);
+      this.okButton.Name = "okButton";
+      this.okButton.Size = new System.Drawing.Size(75, 23);
+      this.okButton.TabIndex = 8;
+      this.okButton.Text = "OK";
+      this.okButton.UseVisualStyleBackColor = true;
+      this.okButton.Click += new System.EventHandler(this.okButton_Click);
+      // 
+      // cancelButton
+      // 
+      this.cancelButton.CausesValidation = false;
+      this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+      this.cancelButton.Location = new System.Drawing.Point(179, 119);
+      this.cancelButton.Name = "cancelButton";
+      this.cancelButton.Size = new System.Drawing.Size(75, 23);
+      this.cancelButton.TabIndex = 9;
+      this.cancelButton.Text = "Cancel";
+      this.cancelButton.UseVisualStyleBackColor = true;
+      this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
+      // 
+      // ValueChangeDialog
+      // 
+      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+      this.AutoSize = true;
+      this.CancelButton = this.cancelButton;
+      this.ClientSize = new System.Drawing.Size(269, 154);
+      this.ControlBox = false;
+      this.Controls.Add(this.cancelButton);
+      this.Controls.Add(this.okButton);
+      this.Controls.Add(this.variableNamesCombo);
+      this.Controls.Add(this.variableNameLabel);
+      this.Controls.Add(this.newValueLabel);
+      this.Controls.Add(this.newValueTextBox);
+      this.Controls.Add(this.oldValueTextBox);
+      this.Controls.Add(this.originalValueLabel);
+      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+      this.MaximizeBox = false;
+      this.MinimizeBox = false;
+      this.Name = "ValueChangeDialog";
+      this.ShowIcon = false;
+      this.ShowInTaskbar = false;
+      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
+      this.Text = "Change Value or Weight";
+      this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.ValueChangeDialog_KeyDown);
+      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
+      this.ResumeLayout(false);
+      this.PerformLayout();
+
+    }
+
+    #endregion
+
+    private System.Windows.Forms.Label originalValueLabel;
+    private System.Windows.Forms.TextBox oldValueTextBox;
+    private System.Windows.Forms.Label newValueLabel;
+    private System.Windows.Forms.ErrorProvider errorProvider;
+    private System.Windows.Forms.Label variableNameLabel;
+    private System.Windows.Forms.Button cancelButton;
+    private System.Windows.Forms.Button okButton;
+    public System.Windows.Forms.TextBox newValueTextBox;
+    public System.Windows.Forms.ComboBox variableNamesCombo;
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeChangeValueDialog.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeChangeValueDialog.cs	(revision 8946)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeChangeValueDialog.cs	(revision 8946)
@@ -0,0 +1,139 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.ComponentModel;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
+  public partial class ValueChangeDialog : Form {
+    private ISymbolicExpressionTreeNode content;
+    public ISymbolicExpressionTreeNode Content {
+      get { return content; }
+      set {
+        if (InvokeRequired)
+          Invoke(new Action<SymbolicExpressionTreeNode>(x => content = x), value);
+        else
+          content = value;
+      }
+    }
+
+    public ValueChangeDialog() {
+      InitializeComponent();
+      oldValueTextBox.TabStop = false; // cannot receive focus using tab key
+    }
+
+    public void SetContent(ISymbolicExpressionTreeNode content) {
+      Content = content;
+      if (Content is VariableTreeNode) {
+        this.Text = "Change variable name or weight";
+        var variable = Content as VariableTreeNode;
+        newValueTextBox.Text = oldValueTextBox.Text = Math.Round(variable.Weight, 4).ToString();
+        // add a dropbox containing all the available variable names
+        variableNameLabel.Visible = true;
+        variableNamesCombo.Visible = true;
+        foreach (var name in variable.Symbol.VariableNames) variableNamesCombo.Items.Add(name);
+        variableNamesCombo.SelectedIndex = variableNamesCombo.Items.IndexOf(variable.VariableName);
+      } else if (Content is ConstantTreeNode) {
+        this.Text = "Change constant value";
+        var constant = Content as ConstantTreeNode;
+        newValueTextBox.Text = oldValueTextBox.Text = Math.Round(constant.Value, 4).ToString();
+      }
+    }
+
+    #region text box validation and events
+    private void newValueTextBox_Validating(object sender, CancelEventArgs e) {
+      string errorMessage;
+      if (!ValidateNewValue(newValueTextBox.Text, out errorMessage)) {
+        e.Cancel = true;
+        errorProvider.SetError(newValueTextBox, errorMessage);
+        newValueTextBox.SelectAll();
+      }
+    }
+
+    private void newValueTextBox_Validated(object sender, EventArgs e) {
+      errorProvider.SetError(newValueTextBox, string.Empty);
+    }
+
+    private static bool ValidateNewValue(string value, out string errorMessage) {
+      double val;
+      bool valid = double.TryParse(value, out val);
+      errorMessage = string.Empty;
+      if (!valid) {
+        var sb = new StringBuilder();
+        sb.Append("Invalid Value (Valid Value Format: \"");
+        sb.Append(FormatPatterns.GetDoubleFormatPattern());
+        sb.Append("\")");
+        errorMessage = sb.ToString();
+      }
+      return valid;
+    }
+    #endregion
+
+    #region combo box validation and events
+    private void variableNamesCombo_Validating(object sender, CancelEventArgs e) {
+      if (!(Content is VariableTreeNode)) return;
+      if (variableNamesCombo.Items.Contains(variableNamesCombo.SelectedItem)) return;
+      e.Cancel = true;
+      errorProvider.SetError(variableNamesCombo, "Invalid variable name");
+      variableNamesCombo.SelectAll();
+    }
+
+    private void variableNamesCombo_Validated(object sender, EventArgs e) {
+      errorProvider.SetError(variableNamesCombo, String.Empty);
+    }
+    #endregion
+    // proxy handler passing key strokes to the parent control
+    private void childControl_KeyDown(object sender, KeyEventArgs e) {
+      ValueChangeDialog_KeyDown(sender, e);
+    }
+
+    private void ValueChangeDialog_KeyDown(object sender, KeyEventArgs e) {
+      if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return)) {
+        if (!ValidateChildren()) return;
+        OnDialogValidated(this, e); // emit validated effect
+        Close();
+      }
+    }
+
+    public event EventHandler DialogValidated;
+    private void OnDialogValidated(object sender, EventArgs e) {
+      var dialogValidated = DialogValidated;
+      if (dialogValidated != null)
+        dialogValidated(sender, e);
+    }
+
+    private void cancelButton_Click(object sender, EventArgs e) {
+      Close();
+    }
+
+    private void okButton_Click(object sender, EventArgs e) {
+      if (ValidateChildren()) {
+        OnDialogValidated(this, e);
+        Close();
+      }
+    }
+
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.Designer.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.Designer.cs	(revision 8946)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.Designer.cs	(revision 8946)
@@ -0,0 +1,210 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
+  partial class InsertNodeDialog {
+    /// <summary>
+    /// Required designer variable.
+    /// </summary>
+    private System.ComponentModel.IContainer components = null;
+
+    /// <summary>
+    /// Clean up any resources being used.
+    /// </summary>
+    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+    protected override void Dispose(bool disposing) {
+      if (disposing && (components != null)) {
+        components.Dispose();
+      }
+      base.Dispose(disposing);
+    }
+
+    #region Windows Form Designer generated code
+
+    /// <summary>
+    /// Required method for Designer support - do not modify
+    /// the contents of this method with the code editor.
+    /// </summary>
+    private void InitializeComponent() {
+      this.components = new System.ComponentModel.Container();
+      this.nodeSymbolLabel = new System.Windows.Forms.Label();
+      this.allowedSymbolsCombo = new System.Windows.Forms.ComboBox();
+      this.variableWeightLabel = new System.Windows.Forms.Label();
+      this.variableNameLabel = new System.Windows.Forms.Label();
+      this.variableNamesCombo = new System.Windows.Forms.ComboBox();
+      this.variableWeightTextBox = new System.Windows.Forms.TextBox();
+      this.constantValueTextBox = new System.Windows.Forms.TextBox();
+      this.constantValueLabel = new System.Windows.Forms.Label();
+      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
+      this.okButton = new System.Windows.Forms.Button();
+      this.cancelButton = new System.Windows.Forms.Button();
+      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
+      this.SuspendLayout();
+      // 
+      // nodeSymbolLabel
+      // 
+      this.nodeSymbolLabel.AutoSize = true;
+      this.nodeSymbolLabel.Location = new System.Drawing.Point(13, 13);
+      this.nodeSymbolLabel.Name = "nodeSymbolLabel";
+      this.nodeSymbolLabel.Size = new System.Drawing.Size(41, 13);
+      this.nodeSymbolLabel.TabIndex = 0;
+      this.nodeSymbolLabel.Text = "Symbol";
+      // 
+      // allowedSymbolsCombo
+      // 
+      this.allowedSymbolsCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+      this.allowedSymbolsCombo.FormattingEnabled = true;
+      this.allowedSymbolsCombo.Location = new System.Drawing.Point(120, 10);
+      this.allowedSymbolsCombo.Name = "allowedSymbolsCombo";
+      this.allowedSymbolsCombo.Size = new System.Drawing.Size(108, 21);
+      this.allowedSymbolsCombo.TabIndex = 1;
+      this.allowedSymbolsCombo.SelectedIndexChanged += new System.EventHandler(this.allowedSymbolsCombo_SelectedIndexChanged);
+      this.allowedSymbolsCombo.KeyDown += new System.Windows.Forms.KeyEventHandler(this.childControl_KeyDown);
+      // 
+      // variableWeightLabel
+      // 
+      this.variableWeightLabel.AutoSize = true;
+      this.variableWeightLabel.Location = new System.Drawing.Point(13, 44);
+      this.variableWeightLabel.Name = "variableWeightLabel";
+      this.variableWeightLabel.Size = new System.Drawing.Size(41, 13);
+      this.variableWeightLabel.TabIndex = 2;
+      this.variableWeightLabel.Text = "Weight";
+      this.variableWeightLabel.Visible = false;
+      // 
+      // variableNameLabel
+      // 
+      this.variableNameLabel.AutoSize = true;
+      this.variableNameLabel.Location = new System.Drawing.Point(13, 74);
+      this.variableNameLabel.Name = "variableNameLabel";
+      this.variableNameLabel.Size = new System.Drawing.Size(35, 13);
+      this.variableNameLabel.TabIndex = 3;
+      this.variableNameLabel.Text = "Name";
+      this.variableNameLabel.Visible = false;
+      // 
+      // variableNamesCombo
+      // 
+      this.variableNamesCombo.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+      this.variableNamesCombo.FormattingEnabled = true;
+      this.variableNamesCombo.Location = new System.Drawing.Point(120, 71);
+      this.variableNamesCombo.Name = "variableNamesCombo";
+      this.variableNamesCombo.Size = new System.Drawing.Size(108, 21);
+      this.variableNamesCombo.TabIndex = 5;
+      this.variableNamesCombo.Visible = false;
+      // 
+      // variableWeightTextBox
+      // 
+      this.variableWeightTextBox.Location = new System.Drawing.Point(120, 41);
+      this.variableWeightTextBox.Name = "variableWeightTextBox";
+      this.variableWeightTextBox.Size = new System.Drawing.Size(108, 20);
+      this.variableWeightTextBox.TabIndex = 6;
+      this.variableWeightTextBox.Text = "0.0";
+      this.variableWeightTextBox.Visible = false;
+      this.variableWeightTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.variableWeightTextBox_Validating);
+      // 
+      // constantValueTextBox
+      // 
+      this.constantValueTextBox.Location = new System.Drawing.Point(120, 41);
+      this.constantValueTextBox.Name = "constantValueTextBox";
+      this.constantValueTextBox.Size = new System.Drawing.Size(108, 20);
+      this.constantValueTextBox.TabIndex = 7;
+      this.constantValueTextBox.Text = "0.0";
+      this.constantValueTextBox.Visible = false;
+      this.constantValueTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.constantValueTextBox_Validating);
+      // 
+      // constantValueLabel
+      // 
+      this.constantValueLabel.AutoSize = true;
+      this.constantValueLabel.Location = new System.Drawing.Point(13, 44);
+      this.constantValueLabel.Name = "constantValueLabel";
+      this.constantValueLabel.Size = new System.Drawing.Size(34, 13);
+      this.constantValueLabel.TabIndex = 8;
+      this.constantValueLabel.Text = "Value";
+      this.constantValueLabel.Visible = false;
+      // 
+      // errorProvider
+      // 
+      this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
+      this.errorProvider.ContainerControl = this;
+      this.errorProvider.RightToLeft = true;
+      // 
+      // okButton
+      // 
+      this.okButton.Location = new System.Drawing.Point(12, 112);
+      this.okButton.Name = "okButton";
+      this.okButton.Size = new System.Drawing.Size(75, 23);
+      this.okButton.TabIndex = 9;
+      this.okButton.Text = "OK";
+      this.okButton.UseVisualStyleBackColor = true;
+      this.okButton.Click += new System.EventHandler(this.okButton_Click);
+      // 
+      // cancelButton
+      // 
+      this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
+      this.cancelButton.Location = new System.Drawing.Point(153, 112);
+      this.cancelButton.Name = "cancelButton";
+      this.cancelButton.Size = new System.Drawing.Size(75, 23);
+      this.cancelButton.TabIndex = 10;
+      this.cancelButton.Text = "Cancel";
+      this.cancelButton.UseVisualStyleBackColor = true;
+      this.cancelButton.Click += new System.EventHandler(this.cancelButton_Click);
+      // 
+      // InsertNodeDialog
+      // 
+      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
+      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+      this.CancelButton = this.cancelButton;
+      this.ClientSize = new System.Drawing.Size(240, 147);
+      this.ControlBox = false;
+      this.Controls.Add(this.cancelButton);
+      this.Controls.Add(this.okButton);
+      this.Controls.Add(this.constantValueLabel);
+      this.Controls.Add(this.constantValueTextBox);
+      this.Controls.Add(this.variableWeightTextBox);
+      this.Controls.Add(this.variableNamesCombo);
+      this.Controls.Add(this.variableNameLabel);
+      this.Controls.Add(this.variableWeightLabel);
+      this.Controls.Add(this.allowedSymbolsCombo);
+      this.Controls.Add(this.nodeSymbolLabel);
+      this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
+      this.Name = "InsertNodeDialog";
+      this.Text = "SymbolicExpressionTreeNodeInsertDialog";
+      this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.insertNodeDialog_KeyDown);
+      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
+      this.ResumeLayout(false);
+      this.PerformLayout();
+
+    }
+
+    #endregion
+
+    private System.Windows.Forms.Label nodeSymbolLabel;
+    private System.Windows.Forms.ComboBox allowedSymbolsCombo;
+    private System.Windows.Forms.Label variableWeightLabel;
+    private System.Windows.Forms.Label variableNameLabel;
+    private System.Windows.Forms.Label constantValueLabel;
+    private System.Windows.Forms.ErrorProvider errorProvider;
+    internal System.Windows.Forms.TextBox constantValueTextBox;
+    internal System.Windows.Forms.TextBox variableWeightTextBox;
+    internal System.Windows.Forms.ComboBox variableNamesCombo;
+    private System.Windows.Forms.Button cancelButton;
+    private System.Windows.Forms.Button okButton;
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.cs	(revision 8946)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/TreeEditDialogs/SymbolicExpressionTreeNodeInsertDialog.cs	(revision 8946)
@@ -0,0 +1,140 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.ComponentModel;
+using System.Text;
+using System.Windows.Forms;
+using HeuristicLab.Data;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
+  public partial class InsertNodeDialog : Form {
+    public InsertNodeDialog() {
+      InitializeComponent();
+    }
+
+    public void SetAllowedSymbols(IEnumerable<ISymbol> symbols) {
+      allowedSymbolsCombo.Items.Clear();
+      foreach (var s in symbols) allowedSymbolsCombo.Items.Add(s);
+      allowedSymbolsCombo.SelectedIndex = 0;
+    }
+
+    public ISymbol SelectedSymbol() {
+      return (ISymbol)allowedSymbolsCombo.SelectedItem;
+    }
+
+    private void allowedSymbolsCombo_SelectedIndexChanged(object sender, EventArgs e) {
+      var combo = (ComboBox)sender;
+      var symbol = combo.Items[combo.SelectedIndex];
+      if (symbol is Constant) {
+        // add controls to the dialog for changing the constant value
+        variableNameLabel.Visible = false;
+        variableNamesCombo.Visible = false;
+        variableWeightLabel.Visible = false;
+        variableWeightTextBox.Visible = false;
+        constantValueLabel.Visible = true;
+        constantValueTextBox.Visible = true;
+      } else if (symbol is Variable) {
+        var variable = (Variable)symbol;
+        foreach (var name in variable.VariableNames) variableNamesCombo.Items.Add(name);
+        variableNamesCombo.SelectedIndex = 0;
+        variableNameLabel.Visible = true;
+        variableNamesCombo.Visible = true;
+        variableWeightLabel.Visible = true;
+        variableWeightTextBox.Visible = true;
+        constantValueLabel.Visible = false;
+        constantValueTextBox.Visible = false;
+        // add controls to the dialog for changing the variable name or weight
+      } else {
+        variableNameLabel.Visible = false;
+        variableNamesCombo.Visible = false;
+        variableWeightLabel.Visible = false;
+        variableWeightTextBox.Visible = false;
+        constantValueLabel.Visible = false;
+        constantValueTextBox.Visible = false;
+      }
+    }
+
+    // validation
+    private void variableWeightTextBox_Validating(object sender, CancelEventArgs e) {
+      string errorMessage;
+      if (ValidateDoubleValue(variableWeightTextBox.Text, out errorMessage)) return;
+      e.Cancel = true;
+      errorProvider.SetError(variableWeightTextBox, errorMessage);
+      variableWeightTextBox.SelectAll();
+    }
+
+    private void constantValueTextBox_Validating(object sender, CancelEventArgs e) {
+      string errorMessage;
+      if (ValidateDoubleValue(constantValueTextBox.Text, out errorMessage)) return;
+      e.Cancel = true;
+      errorProvider.SetError(constantValueTextBox, errorMessage);
+      constantValueTextBox.SelectAll();
+    }
+
+    private static bool ValidateDoubleValue(string value, out string errorMessage) {
+      double val;
+      bool valid = double.TryParse(value, out val);
+      errorMessage = string.Empty;
+      if (!valid) {
+        var sb = new StringBuilder();
+        sb.Append("Invalid Value (Valid Value Format: \"");
+        sb.Append(FormatPatterns.GetDoubleFormatPattern());
+        sb.Append("\")");
+        errorMessage = sb.ToString();
+      }
+      return valid;
+    }
+
+    public event EventHandler DialogValidated;
+    private void OnDialogValidated(object sender, EventArgs e) {
+      var dialogValidated = DialogValidated;
+      if (dialogValidated != null)
+        dialogValidated(sender, e);
+    }
+
+    private void childControl_KeyDown(object sender, KeyEventArgs e) {
+      insertNodeDialog_KeyDown(sender, e);
+    }
+
+    private void insertNodeDialog_KeyDown(object sender, KeyEventArgs e) {
+      if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Return) {
+        if (ValidateChildren()) {
+          OnDialogValidated(this, e);
+          Close();
+        }
+      }
+    }
+
+    private void okButton_Click(object sender, EventArgs e) {
+      if (ValidateChildren()) {
+        OnDialogValidated(this, e);
+        Close();
+      }
+    }
+
+    private void cancelButton_Click(object sender, EventArgs e) {
+      Close();
+    }
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj	(revision 8945)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj	(revision 8946)
@@ -140,4 +140,5 @@
     <Compile Include="Crossovers\SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs" />
     <Compile Include="Interfaces\ISymbolicDataAnalysisExpressionCrossover.cs" />
+    <Compile Include="Interfaces\ISymbolicDataAnalysisImpactValuesCalculator.cs" />
     <Compile Include="Interpreter\InterpreterState.cs" />
     <Compile Include="Interpreter\OpCodes.cs" />
@@ -164,4 +165,5 @@
     <Compile Include="SymbolicDataAnalysisExpressionTreeSimplifier.cs" />
     <Compile Include="SymbolicDataAnalysisProblem.cs" />
+    <Compile Include="SymbolicDataAnalysisSolutionImpactValuesCalculator.cs" />
     <Compile Include="Symbols\Addition.cs" />
     <Compile Include="Symbols\And.cs" />
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisImpactValuesCalculator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisImpactValuesCalculator.cs	(revision 8946)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisImpactValuesCalculator.cs	(revision 8946)
@@ -0,0 +1,9 @@
+﻿using System.Collections.Generic;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
+  public interface ISymbolicDataAnalysisSolutionImpactValuesCalculator {
+    double CalculateReplacementValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows);
+    double CalculateImpactValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows, double originalQuality = double.NaN);
+  }
+}
Index: /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisSolutionImpactValuesCalculator.cs
===================================================================
--- /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisSolutionImpactValuesCalculator.cs	(revision 8946)
+++ /trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisSolutionImpactValuesCalculator.cs	(revision 8946)
@@ -0,0 +1,50 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2012 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.Collections.Generic;
+using HeuristicLab.Common;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+
+namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
+  public abstract class SymbolicDataAnalysisSolutionImpactValuesCalculator : ISymbolicDataAnalysisSolutionImpactValuesCalculator {
+    public abstract double CalculateReplacementValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows);
+    public abstract double CalculateImpactValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows, double originalQuality = double.NaN);
+
+    protected static double CalculateReplacementValue(ISymbolicExpressionTreeNode node, ISymbolicExpressionTree sourceTree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
+      Dataset dataset, IEnumerable<int> rows) {
+      //optimization: constant nodes return always the same value
+      ConstantTreeNode constantNode = node as ConstantTreeNode;
+      if (constantNode != null) return constantNode.Value;
+
+      var rootSymbol = new ProgramRootSymbol().CreateTreeNode();
+      var startSymbol = new StartSymbol().CreateTreeNode();
+      rootSymbol.AddSubtree(startSymbol);
+      startSymbol.AddSubtree((ISymbolicExpressionTreeNode)node.Clone());
+
+      var tempTree = new SymbolicExpressionTree(rootSymbol);
+      // clone ADFs of source tree
+      for (int i = 1; i < sourceTree.Root.SubtreeCount; i++) {
+        tempTree.Root.AddSubtree((ISymbolicExpressionTreeNode)sourceTree.Root.GetSubtree(i).Clone());
+      }
+      return interpreter.GetSymbolicExpressionTreeValues(tempTree, dataset, rows).Median();
+    }
+  }
+}
