Index: /branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs
===================================================================
--- /branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs	(revision 14813)
+++ /branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs	(revision 14814)
@@ -56,9 +56,5 @@
     }
 
-    private string VariableName2Identifier(string name) {
-      // tries to convert a variable name to a valid C# identifier.
-      // the following code would work for all possible variable names
-      // return "_" + string.Join("_", Encoding.UTF8.GetBytes(name));
-
+    private string VariableName2Identifier(string name) {     
       /*
        * identifier-start-character:
@@ -100,46 +96,46 @@
     private void FormatRecursively(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
       // TODO: adapt to interpreter semantics. The HL interpreter also allows Boolean operations on reals
-      if(node.Subtrees.Any()) {
-        if(node.Symbol is Addition) {
+      if (node.Subtrees.Any()) {
+        if (node.Symbol is Addition) {
           FormatOperator(node, "+", strBuilder);
-        } else if(node.Symbol is And) {
+        } else if (node.Symbol is And) {
           FormatOperator(node, "&&", strBuilder);
-        } else if(node.Symbol is Average) {
+        } else if (node.Symbol is Average) {
           FormatFunction(node, "Average", strBuilder);
-        } else if(node.Symbol is Cosine) {
+        } else if (node.Symbol is Cosine) {
           FormatFunction(node, "Math.Cos", strBuilder);
-        } else if(node.Symbol is Division) {
+        } else if (node.Symbol is Division) {
           FormatDivision(node, strBuilder);
-        } else if(node.Symbol is Exponential) {
+        } else if (node.Symbol is Exponential) {
           FormatFunction(node, "Math.Exp", strBuilder);
-        } else if(node.Symbol is GreaterThan) {
+        } else if (node.Symbol is GreaterThan) {
           FormatOperator(node, ">", strBuilder);
-        } else if(node.Symbol is IfThenElse) {
+        } else if (node.Symbol is IfThenElse) {
           FormatFunction(node, "EvaluateIf", strBuilder);
-        } else if(node.Symbol is LessThan) {
+        } else if (node.Symbol is LessThan) {
           FormatOperator(node, "<", strBuilder);
-        } else if(node.Symbol is Logarithm) {
+        } else if (node.Symbol is Logarithm) {
           FormatFunction(node, "Math.Log", strBuilder);
-        } else if(node.Symbol is Multiplication) {
+        } else if (node.Symbol is Multiplication) {
           FormatOperator(node, "*", strBuilder);
-        } else if(node.Symbol is Not) {
+        } else if (node.Symbol is Not) {
           FormatOperator(node, "!", strBuilder);
-        } else if(node.Symbol is Or) {
+        } else if (node.Symbol is Or) {
           FormatOperator(node, "||", strBuilder);
-        } else if(node.Symbol is Xor) {
+        } else if (node.Symbol is Xor) {
           FormatOperator(node, "^", strBuilder);
-        } else if(node.Symbol is Sine) {
+        } else if (node.Symbol is Sine) {
           FormatFunction(node, "Math.Sin", strBuilder);
-        } else if(node.Symbol is Subtraction) {
+        } else if (node.Symbol is Subtraction) {
           FormatSubtraction(node, strBuilder);
-        } else if(node.Symbol is Tangent) {
+        } else if (node.Symbol is Tangent) {
           FormatFunction(node, "Math.Tan", strBuilder);
-        } else if(node.Symbol is Square) {
+        } else if (node.Symbol is Square) {
           FormatSquare(node, strBuilder);
-        } else if(node.Symbol is SquareRoot) {
+        } else if (node.Symbol is SquareRoot) {
           FormatFunction(node, "Math.Sqrt", strBuilder);
-        } else if(node.Symbol is Power) {
+        } else if (node.Symbol is Power) {
           FormatFunction(node, "Math.Pow", strBuilder);
-        } else if(node.Symbol is Root) {
+        } else if (node.Symbol is Root) {
           FormatRoot(node, strBuilder);
         } else {
@@ -147,14 +143,14 @@
         }
       } else {
-        if(node is VariableTreeNode) {
+        if (node is VariableTreeNode) {
           var varNode = node as VariableTreeNode;
           strBuilder.AppendFormat("{0} * {1}", VariableName2Identifier(varNode.VariableName), varNode.Weight.ToString("g17", CultureInfo.InvariantCulture));
-        } else if(node is ConstantTreeNode) {
+        } else if (node is ConstantTreeNode) {
           var constNode = node as ConstantTreeNode;
           strBuilder.Append(constNode.Value.ToString("g17", CultureInfo.InvariantCulture));
-        } else if(node.Symbol is FactorVariable) {
+        } else if (node.Symbol is FactorVariable) {
           var factorNode = node as FactorVariableTreeNode;
           FormatFactor(factorNode, strBuilder);
-        } else if(node.Symbol is BinaryFactorVariable) {
+        } else if (node.Symbol is BinaryFactorVariable) {
           var binFactorNode = node as BinaryFactorVariableTreeNode;
           FormatBinaryFactor(binFactorNode, strBuilder);
@@ -189,5 +185,5 @@
 
     private void FormatDivision(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
-      if(node.SubtreeCount == 1) {
+      if (node.SubtreeCount == 1) {
         strBuilder.Append("1.0 / ");
         FormatRecursively(node.GetSubtree(0), strBuilder);
@@ -195,6 +191,6 @@
         FormatRecursively(node.GetSubtree(0), strBuilder);
         strBuilder.Append("/ (");
-        for(int i = 1; i < node.SubtreeCount; i++) {
-          if(i > 1) strBuilder.Append(" * ");
+        for (int i = 1; i < node.SubtreeCount; i++) {
+          if (i > 1) strBuilder.Append(" * ");
           FormatRecursively(node.GetSubtree(i), strBuilder);
         }
@@ -204,5 +200,5 @@
 
     private void FormatSubtraction(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) {
-      if(node.SubtreeCount == 1) {
+      if (node.SubtreeCount == 1) {
         strBuilder.Append("-");
         FormatRecursively(node.GetSubtree(0), strBuilder);
@@ -215,7 +211,7 @@
     private void FormatOperator(ISymbolicExpressionTreeNode node, string symbol, StringBuilder strBuilder) {
       strBuilder.Append("(");
-      foreach(var child in node.Subtrees) {
+      foreach (var child in node.Subtrees) {
         FormatRecursively(child, strBuilder);
-        if(child != node.Subtrees.Last())
+        if (child != node.Subtrees.Last())
           strBuilder.Append(" " + symbol + " ");
       }
@@ -225,7 +221,7 @@
     private void FormatFunction(ISymbolicExpressionTreeNode node, string function, StringBuilder strBuilder) {
       strBuilder.Append(function + "(");
-      foreach(var child in node.Subtrees) {
+      foreach (var child in node.Subtrees) {
         FormatRecursively(child, strBuilder);
-        if(child != node.Subtrees.Last())
+        if (child != node.Subtrees.Last())
           strBuilder.Append(", ");
       }
@@ -246,10 +242,10 @@
       // here we don't have access to problemData to determine the type for each variable (double/string) therefore we must distinguish based on the symbol type
       HashSet<string> doubleVarNames = new HashSet<string>();
-      foreach(var node in symbolicExpressionTree.IterateNodesPostfix().Where(x => x is VariableTreeNode || x is VariableConditionTreeNode)) {
+      foreach (var node in symbolicExpressionTree.IterateNodesPostfix().Where(x => x is VariableTreeNode || x is VariableConditionTreeNode)) {
         doubleVarNames.Add(((IVariableTreeNode)node).VariableName);
       }
 
       HashSet<string> stringVarNames = new HashSet<string>();
-      foreach(var node in symbolicExpressionTree.IterateNodesPostfix().Where(x => x is BinaryFactorVariableTreeNode || x is FactorVariableTreeNode)) {
+      foreach (var node in symbolicExpressionTree.IterateNodesPostfix().Where(x => x is BinaryFactorVariableTreeNode || x is FactorVariableTreeNode)) {
         stringVarNames.Add(((IVariableTreeNode)node).VariableName);
       }
@@ -258,5 +254,5 @@
       strBuilder.Append(string.Join(", ", orderedNames));
 
-      if(stringVarNames.Any() && doubleVarNames.Any())
+      if (stringVarNames.Any() && doubleVarNames.Any())
         strBuilder.AppendLine(",");
       orderedNames = doubleVarNames.OrderBy(n => n, new NaturalStringComparer()).Select(n => "double " + VariableName2Identifier(n) + " /* " + n + " */");
