Index: /branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/ContinuedFractionRegression/Problem.cs
===================================================================
--- /branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/ContinuedFractionRegression/Problem.cs	(revision 17849)
+++ /branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/ContinuedFractionRegression/Problem.cs	(revision 17850)
@@ -9,7 +9,9 @@
 using HeuristicLab.Encodings.BinaryVectorEncoding;
 using HeuristicLab.Encodings.RealVectorEncoding;
+using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
 using HeuristicLab.Optimization;
 using HeuristicLab.Parameters;
 using HeuristicLab.Problems.DataAnalysis;
+using HeuristicLab.Problems.DataAnalysis.Symbolic;
 using HeuristicLab.Problems.Instances;
 
@@ -18,5 +20,5 @@
   [StorableType("CAC0F743-8524-436C-B81E-7C628A302DF8")]
   [Creatable(CreatableAttribute.Categories.DataAnalysisRegression, Priority = 999)]
-  public class Problem : HeuristicLab.Optimization.SingleObjectiveBasicProblem<MultiEncoding> 
+  public class Problem : HeuristicLab.Optimization.SingleObjectiveBasicProblem<MultiEncoding>
     /*, IProblemInstanceConsumer<IRegressionProblemData>, IProblemInstanceExporter<IRegressionProblemData>*/  // only if we can change the code to work with a single dataset
     {
@@ -121,5 +123,5 @@
       Parameters.Add(new FixedValueParameter<DoubleValue>("L1L2_mixing", "TODO Description", new DoubleValue(0.2)));
       Parameters.Add(new FixedValueParameter<DoubleValue>("L1L2_weight", "TODO Description", new DoubleValue(1)));
-      Parameters.Add(new FixedValueParameter<DoubleValue>("penality", "TODO Description", new DoubleValue(0.01)));
+      Parameters.Add(new FixedValueParameter<DoubleValue>("penalty", "TODO Description", new DoubleValue(0.01)));
       Parameters.Add(new FixedValueParameter<IntValue>("fraction_depth", "TODO Description", new IntValue(4)));
       Parameters.Add(new ValueParameter<Dataset>("dataset", "TODO Description", new Dataset()));
@@ -151,4 +153,9 @@
       TrainingTestDatasetParameter.ValueChanged += DatasetParameter_ValueChanged;
       Phi0_08DatasetParameter.ValueChanged += DatasetParameter_ValueChanged;
+
+      if (Parameters.ContainsKey("penality")) {
+        Parameters.Remove("penality");
+        Parameters.Add(new FixedValueParameter<DoubleValue>("penalty", "TODO Description", new DoubleValue(0.01)));
+      }
     }
 
@@ -176,5 +183,5 @@
 
     public override double Evaluate(Individual individual, IRandom random) {
-      if(dataMatrix == null) {
+      if (dataMatrix == null) {
         InitializeTransformedDatasets();
       }
@@ -277,7 +284,4 @@
 
     public override void Analyze(Individual[] individuals, double[] qualities, ResultCollection results, IRandom random) {
-      // Use vars.yourVariable to access variables in the variable store i.e. yourVariable
-      // Write or update results given the range of vectors and resulting qualities
-
       Individual bestIndividual = null;
       double bestQuality = double.MaxValue;
@@ -290,4 +294,8 @@
           theBest = i;
         }
+      }
+
+      if (dataMatrix == null) {
+        InitializeTransformedDatasets();
       }
 
@@ -316,7 +324,7 @@
 
       #region set dataTables      
-      var datatable = (DataTable)results["datatable"].Value;
-      var coefficients = (DataTable)results["coefficients"].Value;
-      var pearsonR2 = (DataTable)results["personR2"].Value;
+      var datatable = (DataTable)results["Datatable"].Value;
+      var coefficients = (DataTable)results["Coefficients"].Value;
+      var pearsonR2 = (DataTable)results["Pearson R2"].Value;
 
       datatable.Rows["MSE"].Values.Add(calculateRegMSE(((DoubleValue)bestIndividual["LS"]).Value, binar, 0.0));
@@ -408,4 +416,49 @@
       #endregion
       #endregion
+
+      results.AddOrUpdateResult("Model", CreateSymbolicExpressionTree(binar, coeff, TrainingTrainingDataset.VariableNames.ToArray()));
+    }
+
+    private ISymbolicExpressionTree CreateSymbolicExpressionTree(bool[] binar, double[] coeff, string[] varNames) {
+      bool firstCoeffUnequalZero = false;
+      var d = varNames.Length;
+      var expression = constSy.CreateTreeNode(); // zero
+
+      for (var i = coeff.Length - 1; i > 0; i = i - 2 * d) {
+
+        if ((linearFunctionEqualZero(coeff, binar, i - d + 1, i) == false)) {
+          firstCoeffUnequalZero = true;
+          var sum = addSy.CreateTreeNode();
+          sum.AddSubtree(createLinearExpression(coeff, binar, i - d + 1, i, varNames));
+          sum.AddSubtree(expression);
+          expression = sum;
+        }
+
+        if (firstCoeffUnequalZero == true && i > 2 * d) { // don't take the first coeffVecPart and don't take the last coeffVecPart (both are only to add)
+          if (linearFunctionEqualZero(coeff, binar, i - 2 * d + 1, i - d) == false) {
+            /* div-by-zero cannot be determined for the expression 
+            if (valueNearZero(value) == true)  // no division by zero
+              return double.MaxValue;
+            else {
+            */
+              var frac = divSy.CreateTreeNode();
+              frac.AddSubtree(createLinearExpression(coeff, binar, i - 2 * d + 1, i - d, varNames));
+              frac.AddSubtree(expression);
+              expression = frac;
+            /* } */
+          } else {
+            // don't allow coeffVecParts in middle to be equal zero
+            var errorConst = (ConstantTreeNode)constSy.CreateTreeNode();
+            errorConst.Value = double.MaxValue;
+            expression = errorConst; 
+          }
+        }
+      }
+
+      var startNode = startSy.CreateTreeNode();
+      var progRootNode = progRootSy.CreateTreeNode();
+      startNode.AddSubtree(progRootNode);
+      progRootNode.AddSubtree(expression);
+      return new SymbolicExpressionTree(progRootNode) ;
     }
 
@@ -444,11 +497,11 @@
       #region curves 0.001
       ScatterPlot curves0_001 = new ScatterPlot("Curves0_001", "Kurven mit Phi'=0.001");
-      readCurve(curves0_001, "data6082_350_0_001", "Temp350", System.Drawing.Color.Blue);
-      readCurve(curves0_001, "data6082_375_0_001", "Temp375", System.Drawing.Color.Orange);
-      readCurve(curves0_001, "data6082_400_0_001", "Temp400", System.Drawing.Color.Red);
-      readCurve(curves0_001, "data6082_425_0_001", "Temp425", System.Drawing.Color.Green);
-      readCurve(curves0_001, "data6082_450_0_001", "Temp450", System.Drawing.Color.Gray);
-      readCurve(curves0_001, "data6082_475_0_001", "Temp475", System.Drawing.Color.Olive);
-      readCurve(curves0_001, "data6082_500_0_001", "Temp500", System.Drawing.Color.Gold);
+      readCurve(curves0_001, "data_350_0_001", "Temp350", System.Drawing.Color.Blue);
+      readCurve(curves0_001, "data_375_0_001", "Temp375", System.Drawing.Color.Orange);
+      readCurve(curves0_001, "data_400_0_001", "Temp400", System.Drawing.Color.Red);
+      readCurve(curves0_001, "data_425_0_001", "Temp425", System.Drawing.Color.Green);
+      readCurve(curves0_001, "data_450_0_001", "Temp450", System.Drawing.Color.Gray);
+      readCurve(curves0_001, "data_475_0_001", "Temp475", System.Drawing.Color.Olive);
+      readCurve(curves0_001, "data_500_0_001", "Temp500", System.Drawing.Color.Gold);
 
       var empty0_001 = new Point2D<double>[0];
@@ -487,16 +540,16 @@
       Temp500Convergence0_001.VisualProperties.PointSize = 2;
       curves0_001.Rows.Add(Temp500Convergence0_001);
-      results.Add(new Result("Curves0_001", curves0_001));
+      results.AddOrUpdateResult("Curves0_001", curves0_001);
 
       #endregion
       #region curves 0.01
       ScatterPlot curves0_01 = new ScatterPlot("Curves0_01", "Kurven mit Phi'=0.01");
-      readCurve(curves0_01, "data6082_350_0_01", "Temp350", System.Drawing.Color.Blue);
-      readCurve(curves0_01, "data6082_375_0_01", "Temp375", System.Drawing.Color.Orange);
-      readCurve(curves0_01, "data6082_400_0_01", "Temp400", System.Drawing.Color.Red);
-      readCurve(curves0_01, "data6082_425_0_01", "Temp425", System.Drawing.Color.Green);
-      readCurve(curves0_01, "data6082_450_0_01", "Temp450", System.Drawing.Color.Gray);
-      readCurve(curves0_01, "data6082_475_0_01", "Temp475", System.Drawing.Color.Olive);
-      readCurve(curves0_01, "data6082_500_0_01", "Temp500", System.Drawing.Color.Gold);
+      readCurve(curves0_01, "data_350_0_01", "Temp350", System.Drawing.Color.Blue);
+      readCurve(curves0_01, "data_375_0_01", "Temp375", System.Drawing.Color.Orange);
+      readCurve(curves0_01, "data_400_0_01", "Temp400", System.Drawing.Color.Red);
+      readCurve(curves0_01, "data_425_0_01", "Temp425", System.Drawing.Color.Green);
+      readCurve(curves0_01, "data_450_0_01", "Temp450", System.Drawing.Color.Gray);
+      readCurve(curves0_01, "data_475_0_01", "Temp475", System.Drawing.Color.Olive);
+      readCurve(curves0_01, "data_500_0_01", "Temp500", System.Drawing.Color.Gold);
 
       var empty0_01 = new Point2D<double>[0];
@@ -535,16 +588,16 @@
       Temp500Convergence0_01.VisualProperties.PointSize = 2;
       curves0_01.Rows.Add(Temp500Convergence0_01);
-      results.Add(new Result("Curves0_01", curves0_01));
+      results.AddOrUpdateResult("Curves0_01", curves0_01);
 
       #endregion
       #region curves 0.1
       ScatterPlot curves0_1 = new ScatterPlot("Curves0_1", "Kurven mit Phi'=0.1");
-      readCurve(curves0_1, "data6082_350_0_1", "Temp350", System.Drawing.Color.Blue);
-      readCurve(curves0_1, "data6082_375_0_1", "Temp375", System.Drawing.Color.Orange);
-      readCurve(curves0_1, "data6082_400_0_1", "Temp400", System.Drawing.Color.Red);
-      readCurve(curves0_1, "data6082_425_0_1", "Temp425", System.Drawing.Color.Green);
-      readCurve(curves0_1, "data6082_450_0_1", "Temp450", System.Drawing.Color.Gray);
-      readCurve(curves0_1, "data6082_475_0_1", "Temp475", System.Drawing.Color.Olive);
-      readCurve(curves0_1, "data6082_500_0_1", "Temp500", System.Drawing.Color.Gold);
+      readCurve(curves0_1, "data_350_0_1", "Temp350", System.Drawing.Color.Blue);
+      readCurve(curves0_1, "data_375_0_1", "Temp375", System.Drawing.Color.Orange);
+      readCurve(curves0_1, "data_400_0_1", "Temp400", System.Drawing.Color.Red);
+      readCurve(curves0_1, "data_425_0_1", "Temp425", System.Drawing.Color.Green);
+      readCurve(curves0_1, "data_450_0_1", "Temp450", System.Drawing.Color.Gray);
+      readCurve(curves0_1, "data_475_0_1", "Temp475", System.Drawing.Color.Olive);
+      readCurve(curves0_1, "data_500_0_1", "Temp500", System.Drawing.Color.Gold);
 
       var empty0_1 = new Point2D<double>[0];
@@ -583,15 +636,15 @@
       Temp500Convergence0_1.VisualProperties.PointSize = 2;
       curves0_1.Rows.Add(Temp500Convergence0_1);
-      results.Add(new Result("Curves0_1", curves0_1));
+      results.AddOrUpdateResult("Curves0_1", curves0_1);
       #endregion
       #region curves 1
       ScatterPlot curves1 = new ScatterPlot("Curves1", "Kurven mit Phi'=1");
-      readCurve(curves1, "data6082_350_1", "Temp350", System.Drawing.Color.Blue);
-      readCurve(curves1, "data6082_375_1", "Temp375", System.Drawing.Color.Orange);
-      readCurve(curves1, "data6082_400_1", "Temp400", System.Drawing.Color.Red);
-      readCurve(curves1, "data6082_425_1", "Temp425", System.Drawing.Color.Green);
-      readCurve(curves1, "data6082_450_1", "Temp450", System.Drawing.Color.Gray);
-      readCurve(curves1, "data6082_475_1", "Temp475", System.Drawing.Color.Olive);
-      readCurve(curves1, "data6082_500_1", "Temp500", System.Drawing.Color.Gold);
+      readCurve(curves1, "data_350_1", "Temp350", System.Drawing.Color.Blue);
+      readCurve(curves1, "data_375_1", "Temp375", System.Drawing.Color.Orange);
+      readCurve(curves1, "data_400_1", "Temp400", System.Drawing.Color.Red);
+      readCurve(curves1, "data_425_1", "Temp425", System.Drawing.Color.Green);
+      readCurve(curves1, "data_450_1", "Temp450", System.Drawing.Color.Gray);
+      readCurve(curves1, "data_475_1", "Temp475", System.Drawing.Color.Olive);
+      readCurve(curves1, "data_500_1", "Temp500", System.Drawing.Color.Gold);
 
       var empty1 = new Point2D<double>[0];
@@ -630,5 +683,5 @@
       Temp500Convergence1.VisualProperties.PointSize = 2;
       curves1.Rows.Add(Temp500Convergence1);
-      results.Add(new Result("Curves1", curves1));
+      results.AddOrUpdateResult("Curves1", curves1);
       #endregion
     }
@@ -732,4 +785,32 @@
     }
 
+    // symbols to be used in expression trees
+    private static Addition addSy = new Addition();
+    private static Division divSy = new Division();
+    private static HeuristicLab.Problems.DataAnalysis.Symbolic.Variable varSy = new Problems.DataAnalysis.Symbolic.Variable();
+    private static Constant constSy = new Constant();
+    private static StartSymbol startSy = new StartSymbol();
+    private static ProgramRootSymbol progRootSy = new ProgramRootSymbol();
+    private ISymbolicExpressionTreeNode createLinearExpression(double[] coeff, bool[] binar, int start, int end, string[] varNames) {
+      var sum = addSy.CreateTreeNode();
+
+      for (int i = start; i < end; i++) {
+        if (binar[i] == true) {
+          var varNode = (VariableTreeNode)varSy.CreateTreeNode();
+          varNode.VariableName = varNames[i - start];
+          varNode.Weight = coeff[i];
+          sum.AddSubtree(varNode);
+        }
+      }
+      if (binar[end] == true) {
+        var constNode = (ConstantTreeNode)constSy.CreateTreeNode();
+        constNode.Value = coeff[end];
+        sum.AddSubtree(constNode);
+      }
+
+      //doubleThrowInvOrNaN(value, "evaluateLinearFunctionValue");
+      return sum;
+    }
+
     private bool valueNearZero(double value) {
       if (Math.Abs(value) < epsilon)
@@ -755,5 +836,5 @@
 
     private double calculateRegMSE(double quality, bool[] binar, double penalty) {
-      return (quality / dataMatrix.Rows) * (1 + penalty * (double)numVariablesUsed(binar));
+      return (quality / dataMatrix.Rows) * (1 + penalty * numVariablesUsed(binar));
     }
 
Index: anches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/ContinuedFractionRegression/Tests.cs
===================================================================
--- /branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/ContinuedFractionRegression/Tests.cs	(revision 17849)
+++ 	(revision )
@@ -1,10 +1,0 @@
-﻿using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace HeuristicLab.Algorithms.DataAnalysis.ContinuedFractionRegression {
-  class Tests {
-  }
-}
Index: /branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj
===================================================================
--- /branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj	(revision 17849)
+++ /branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Algorithms.DataAnalysis/3.4/HeuristicLab.Algorithms.DataAnalysis-3.4.csproj	(revision 17850)
@@ -134,5 +134,4 @@
     <Compile Include="ContinuedFractionRegression\RegressionResult.cs" />
     <Compile Include="ContinuedFractionRegression\SimplexConstant.cs" />
-    <Compile Include="ContinuedFractionRegression\Tests.cs" />
     <Compile Include="ContinuedFractionRegression\Transformation.cs" />
     <Compile Include="ContinuedFractionRegression\Vector.cs" />
Index: /branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj
===================================================================
--- /branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj	(revision 17849)
+++ /branches/3106_AnalyticContinuedFractionsRegression/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj	(revision 17850)
@@ -115,5 +115,7 @@
   <ItemGroup>
     <Compile Include="Exporters\SymbolicSolutionExcelExporter.cs" />
-    <Compile Include="InteractiveSymbolicExpressionTreeChart.cs" />
+    <Compile Include="InteractiveSymbolicExpressionTreeChart.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
     <Compile Include="InteractiveSymbolicExpressionTreeChart.Designer.cs">
       <DependentUpon>InteractiveSymbolicExpressionTreeChart.cs</DependentUpon>
@@ -144,21 +146,31 @@
       <DependentUpon>GraphicalSymbolicDataAnalysisModelView.cs</DependentUpon>
     </Compile>
-    <Compile Include="Symbols\ConstantView.cs" />
+    <Compile Include="Symbols\ConstantView.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
     <Compile Include="Symbols\ConstantView.Designer.cs">
       <DependentUpon>ConstantView.cs</DependentUpon>
     </Compile>
-    <Compile Include="Symbols\LaggedVariableView.cs" />
+    <Compile Include="Symbols\LaggedVariableView.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
     <Compile Include="Symbols\LaggedVariableView.Designer.cs">
       <DependentUpon>LaggedVariableView.cs</DependentUpon>
     </Compile>
-    <Compile Include="Symbols\TimeLagView.cs" />
+    <Compile Include="Symbols\TimeLagView.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
     <Compile Include="Symbols\TimeLagView.Designer.cs">
       <DependentUpon>TimeLagView.cs</DependentUpon>
     </Compile>
-    <Compile Include="Symbols\VariableConditionView.cs" />
+    <Compile Include="Symbols\VariableConditionView.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
     <Compile Include="Symbols\VariableConditionView.Designer.cs">
       <DependentUpon>VariableConditionView.cs</DependentUpon>
     </Compile>
-    <Compile Include="Symbols\VariableView.cs" />
+    <Compile Include="Symbols\VariableView.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
     <Compile Include="Symbols\VariableView.Designer.cs">
       <DependentUpon>VariableView.cs</DependentUpon>
