Index: trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/HeuristicLab.Problems.DataAnalysis.Regression-3.3.csproj
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/HeuristicLab.Problems.DataAnalysis.Regression-3.3.csproj	(revision 3409)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/HeuristicLab.Problems.DataAnalysis.Regression-3.3.csproj	(revision 3442)
@@ -86,4 +86,7 @@
     <Compile Include="HeuristicLabProblemsDataAnalysisRegressionPlugin.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="Symbolic\BestValidationSymbolicRegressionSolutionVisualizer.cs" />
+    <Compile Include="Symbolic\SymbolicRegressionSolution.cs" />
+    <Compile Include="Symbolic\SymbolicRegressionModel.cs" />
     <Compile Include="Symbolic\ISymbolicRegressionEvaluator.cs">
       <SubType>Code</SubType>
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/BestValidationSymbolicRegressionSolutionVisualizer.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/BestValidationSymbolicRegressionSolutionVisualizer.cs	(revision 3442)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/BestValidationSymbolicRegressionSolutionVisualizer.cs	(revision 3442)
@@ -0,0 +1,95 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 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.Linq;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Operators;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+
+namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic {
+  /// <summary>
+  /// An operator for visualizing the best symbolic regression solution based on the validation set.
+  /// </summary>
+  [Item("BestSymbolicExpressionTreeVisualizer", "An operator for visualizing the best symbolic regression solution based on the validation set.")]
+  [StorableClass]
+  public sealed class BestValidationSymbolicRegressionSolutionVisualizer : SingleSuccessorOperator, ISingleObjectiveSolutionsVisualizer, ISolutionsVisualizer {
+    private const string SymbolicRegressionModelParameterName = "SymbolicRegressionModel";
+    private const string DataAnalysisProblemDataParameterName = "DataAnalysisProblemData";
+    private const string BestValidationSolutionParameterName = "BestValidationSolution";
+    private const string QualityParameterName = "Quality";
+    public ILookupParameter<ItemArray<SymbolicExpressionTree>> SymbolicExpressionTreeParameter {
+      get { return (ILookupParameter<ItemArray<SymbolicExpressionTree>>)Parameters[SymbolicRegressionModelParameterName]; }
+    }
+    public ILookupParameter<DataAnalysisProblemData> DataAnalysisProblemDataParameter {
+      get { return (ILookupParameter<DataAnalysisProblemData>)Parameters[DataAnalysisProblemDataParameterName]; }
+    }
+    public ILookupParameter<SymbolicRegressionSolution> BestValidationSolutionParameter {
+      get { return (ILookupParameter<SymbolicRegressionSolution>)Parameters[BestValidationSolutionParameterName]; }
+    }
+    ILookupParameter ISolutionsVisualizer.VisualizationParameter {
+      get { return BestValidationSolutionParameter; }
+    }
+
+    public ILookupParameter<ItemArray<DoubleValue>> QualityParameter {
+      get { return (ILookupParameter<ItemArray<DoubleValue>>)Parameters[QualityParameterName]; }
+    }
+
+    public BestValidationSymbolicRegressionSolutionVisualizer()
+      : base() {
+      Parameters.Add(new SubScopesLookupParameter<SymbolicExpressionTree>(SymbolicRegressionModelParameterName, "The symbolic regression solutions from which the best solution should be visualized."));
+      Parameters.Add(new SubScopesLookupParameter<DoubleValue>(QualityParameterName, "The quality of the symbolic regression solutions."));
+      Parameters.Add(new LookupParameter<DataAnalysisProblemData>(DataAnalysisProblemDataParameterName, "The symbolic regression problme data on which the best solution should be evaluated."));
+      Parameters.Add(new LookupParameter<SymbolicRegressionSolution>(BestValidationSolutionParameterName, "The best symbolic expression tree based on the validation data for the symbolic regression problem."));
+      Parameters.Add(new LookupParameter<ResultCollection>("Results"));
+    }
+
+    public override IOperation Apply() {
+      ItemArray<SymbolicExpressionTree> expressions = SymbolicExpressionTreeParameter.ActualValue;
+      DataAnalysisProblemData problemData = DataAnalysisProblemDataParameter.ActualValue;
+      ItemArray<DoubleValue> qualities = QualityParameter.ActualValue;
+
+      var bestExpressionIndex = (from index in Enumerable.Range(0, qualities.Count())
+                                 select new { Index = index, Quality = qualities[index] }).OrderBy(x => x.Quality).Select(x => x.Index).First();
+
+      var bestExpression = expressions[bestExpressionIndex];
+      SymbolicRegressionSolution bestSolution = BestValidationSolutionParameter.ActualValue;
+      if (bestSolution == null) BestValidationSolutionParameter.ActualValue = CreateDataAnalysisSolution(problemData, bestExpression);
+      else {
+        bestSolution.Model = CreateModel(problemData, bestExpression);
+      }
+      // ((ResultCollection)Parameters["Results"].ActualValue).Add(new Result("ValidationMSE", new DoubleValue(3.15)));
+      return base.Apply();
+    }
+
+    private SymbolicRegressionModel CreateModel(DataAnalysisProblemData problemData, SymbolicExpressionTree expression) {
+      return new SymbolicRegressionModel(expression, problemData.InputVariables.Select(x => x.Value));
+    }
+
+    private SymbolicRegressionSolution CreateDataAnalysisSolution(DataAnalysisProblemData problemData, SymbolicExpressionTree expression) {
+      return new SymbolicRegressionSolution(problemData, CreateModel(problemData, expression));
+    }
+  }
+}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionModel.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionModel.cs	(revision 3442)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionModel.cs	(revision 3442)
@@ -0,0 +1,75 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Drawing;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Optimization;
+using HeuristicLab.Parameters;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.PluginInfrastructure;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Operators;
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
+
+namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic {
+  [StorableClass]
+  public class SymbolicRegressionModel : DeepCloneable, IModel {
+    [Storable]
+    private SymbolicExpressionTree tree;
+    public SymbolicExpressionTree SymbolicExpressionTree {
+      get { return tree; }
+    }
+    [Storable]
+    private SimpleArithmeticExpressionEvaluator evaluator;
+    public SimpleArithmeticExpressionEvaluator Evaluator {
+      get { return evaluator; }
+    }
+    private Dataset emptyDataset;
+    private IEnumerable<int> firstRow = new int[] { 0 };
+
+    public SymbolicRegressionModel() : base() { } // for cloning
+
+    public SymbolicRegressionModel(SymbolicExpressionTree tree, IEnumerable<string> inputVariables)
+      : base() {
+      this.tree = tree;
+      this.evaluator = new SimpleArithmeticExpressionEvaluator();
+      emptyDataset = new Dataset(inputVariables, new double[1, inputVariables.Count()]);
+    }
+
+    #region IModel Members
+
+    public double GetValue(double[] xs) {
+      if (xs.Length != emptyDataset.Columns) throw new ArgumentException("Length of input vector doesn't match model");
+      for (int i = 0; i < xs.Length; i++) {
+        emptyDataset[0, i] = xs[i];
+      }
+      return evaluator.EstimatedValues(tree, emptyDataset, firstRow).First();
+    }
+
+    #endregion
+  }
+}
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionProblem.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionProblem.cs	(revision 3409)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionProblem.cs	(revision 3442)
@@ -118,6 +118,6 @@
       get { return EvaluatorParameter.Value; }
     }
-    public ArithmeticExpressionGrammar FunctionTreeGrammar {
-      get { return (ArithmeticExpressionGrammar)FunctionTreeGrammarParameter.Value; }
+    public ISymbolicExpressionGrammar FunctionTreeGrammar {
+      get { return (ISymbolicExpressionGrammar)FunctionTreeGrammarParameter.Value; }
     }
     public ISingleObjectiveSolutionsVisualizer Visualizer {
@@ -141,10 +141,12 @@
       SymbolicExpressionTreeCreator creator = new ProbabilisticTreeCreator();
       var evaluator = new SymbolicRegressionMeanSquaredErrorEvaluator();
-      var grammar = new GlobalSymbolicExpressionGrammar(new ArithmeticExpressionGrammar());
+      var grammar = new ArithmeticExpressionGrammar();
+      var globalGrammar = new GlobalSymbolicExpressionGrammar(grammar);
+      var visualizer = new BestValidationSymbolicRegressionSolutionVisualizer();
       Parameters.Add(new ValueParameter<BoolValue>("Maximization", "Set to false as the error of the regression model should be minimized.", new BoolValue(false)));
       Parameters.Add(new ValueParameter<SymbolicExpressionTreeCreator>("SolutionCreator", "The operator which should be used to create new symbolic regression solutions.", creator));
       Parameters.Add(new ValueParameter<ISymbolicRegressionEvaluator>("Evaluator", "The operator which should be used to evaluate symbolic regression solutions.", evaluator));
       Parameters.Add(new ValueParameter<DoubleValue>("BestKnownQuality", "The minimal error value that can be reached by symbolic regression models.", new DoubleValue(0)));
-      Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>("FunctionTreeGrammar", "The grammar that should be used for symbolic regression models.", grammar));
+      Parameters.Add(new ValueParameter<ISymbolicExpressionGrammar>("FunctionTreeGrammar", "The grammar that should be used for symbolic regression models.", globalGrammar));
       Parameters.Add(new ValueParameter<IntValue>("MaxExpressionLength", "Maximal length of the symbolic expression.", new IntValue(100)));
       Parameters.Add(new ValueParameter<IntValue>("MaxExpressionDepth", "Maximal depth of the symbolic expression.", new IntValue(10)));
@@ -152,10 +154,12 @@
       Parameters.Add(new ValueParameter<IntValue>("MaxFunctionArguments", "Maximal number of arguments of automatically defined functions.", new IntValue(3)));
       Parameters.Add(new ValueParameter<DoubleValue>("NumberOfEvaluatedNodes", "The total number of evaluated function tree nodes (for performance measurements.)", new DoubleValue()));
-      Parameters.Add(new ValueParameter<ISingleObjectiveSolutionsVisualizer>("Visualizer", "The operator which should be used to visualize artificial ant solutions.", null));
+      Parameters.Add(new ValueParameter<ISingleObjectiveSolutionsVisualizer>("Visualizer", "The operator which should be used to visualize symbolic regression solutions.", visualizer));
 
       creator.SymbolicExpressionTreeParameter.ActualName = "SymbolicRegressionModel";
+      creator.MaxFunctionArgumentsParameter.ActualName = "MaxFunctionArguments";
+      creator.MaxFunctionDefinitionsParameter.ActualName = "MaxFunctionDefiningBranches";
       evaluator.QualityParameter.ActualName = "TrainingMeanSquaredError";
       DataAnalysisProblemDataParameter.ValueChanged += new EventHandler(DataAnalysisProblemDataParameter_ValueChanged);
-      DataAnalysisProblemData.InputVariablesChanged += new EventHandler(DataAnalysisProblemData_InputVariablesChanged);
+      DataAnalysisProblemData.ProblemDataChanged += new EventHandler(DataAnalysisProblemData_Changed);
       ParameterizeSolutionCreator();
       ParameterizeEvaluator();
@@ -166,9 +170,11 @@
 
     void DataAnalysisProblemDataParameter_ValueChanged(object sender, EventArgs e) {
-      DataAnalysisProblemData.InputVariablesChanged += new EventHandler(DataAnalysisProblemData_InputVariablesChanged);
-    }
-
-    void DataAnalysisProblemData_InputVariablesChanged(object sender, EventArgs e) {
-      FunctionTreeGrammar.VariableNames = DataAnalysisProblemData.InputVariables.Select(x => x.Value);
+      DataAnalysisProblemData.ProblemDataChanged += new EventHandler(DataAnalysisProblemData_Changed);
+    }
+
+    void DataAnalysisProblemData_Changed(object sender, EventArgs e) {
+      foreach (var varSymbol in FunctionTreeGrammar.Symbols.OfType<HeuristicLab.Problems.DataAnalysis.Symbolic.Symbols.Variable>()) {
+        varSymbol.VariableNames = DataAnalysisProblemData.InputVariables.Select(x => x.Value);
+      }
     }
 
@@ -268,15 +274,9 @@
     private void ParameterizeVisualizer() {
       if (Visualizer != null) {
-        //Visualizer.QualityParameter.ActualName = Evaluator.QualityParameter.ActualName;
-        //var antTrailVisualizer = Visualizer as IAntTrailVisualizer;
-        //if (antTrailVisualizer != null) {
-        //  antTrailVisualizer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
-        //  antTrailVisualizer.WorldParameter.ActualName = WorldParameter.Name;
-        //  antTrailVisualizer.MaxTimeStepsParameter.ActualName = MaxTimeStepsParameter.Name;
-        //}
-        //var bestSymExpressionVisualizer = Visualizer as BestSymbolicExpressionTreeVisualizer;
-        //if (bestSymExpressionVisualizer != null) {
-        //  bestSymExpressionVisualizer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
-        //}
+        var solutionVisualizer = Visualizer as BestValidationSymbolicRegressionSolutionVisualizer;
+        if (solutionVisualizer != null) {
+          solutionVisualizer.SymbolicExpressionTreeParameter.ActualName = SolutionCreator.SymbolicExpressionTreeParameter.ActualName;
+          solutionVisualizer.DataAnalysisProblemDataParameter.ActualName = DataAnalysisProblemDataParameter.Name;
+        }
       }
     }
Index: trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionSolution.cs
===================================================================
--- trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionSolution.cs	(revision 3442)
+++ trunk/sources/HeuristicLab.Problems.DataAnalysis.Regression/3.3/Symbolic/SymbolicRegressionSolution.cs	(revision 3442)
@@ -0,0 +1,48 @@
+#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2010 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 HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Data;
+using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace HeuristicLab.Problems.DataAnalysis.Regression.Symbolic {
+  /// <summary>
+  /// Represents a solution for a symbolic regression problem which can be visualized in the GUI.
+  /// </summary>
+  [Item("SymbolicRegressionSolution", "Represents a solution for a symbolic regression problem which can be visualized in the GUI.")]
+  [StorableClass]
+  public sealed class SymbolicRegressionSolution : DataAnalysisSolution {
+    public new SymbolicRegressionModel Model {
+      get { return (SymbolicRegressionModel)base.Model; }
+      set { base.Model = value; }
+    }
+
+    public SymbolicRegressionSolution() : base() { }
+    public SymbolicRegressionSolution(DataAnalysisProblemData problemData, SymbolicRegressionModel model)
+      : base(problemData, model) {
+    }
+  }
+}
