Changeset 14576 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters
- Timestamp:
- 01/15/17 14:17:06 (8 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic merged: 14319,14345,14347,14350,14353-14354,14367,14378,14390-14391,14400
- Property svn:mergeinfo changed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/InfixExpressionFormatter.cs
r14307 r14576 81 81 } 82 82 strBuilder.Append(")"); 83 } else { 84 // function with multiple arguments 85 strBuilder.Append(token).Append("("); 86 FormatRecursively(node.Subtrees.First(), strBuilder); 87 foreach (var subtree in node.Subtrees.Skip(1)) { 88 strBuilder.Append(", "); 89 FormatRecursively(subtree, strBuilder); 90 } 91 strBuilder.Append(")"); 83 92 } 84 93 } else if (node.SubtreeCount == 1) { … … 94 103 FormatRecursively(node.GetSubtree(0), strBuilder); 95 104 } else { 96 // function 105 // function with only one argument 97 106 strBuilder.Append(token).Append("("); 98 107 FormatRecursively(node.GetSubtree(0), strBuilder); … … 101 110 } else { 102 111 // no subtrees 103 if (node.Symbol is Variable) { 112 if (node.Symbol is LaggedVariable) { 113 var varNode = node as LaggedVariableTreeNode; 114 if (!varNode.Weight.IsAlmost(1.0)) { 115 strBuilder.Append("("); 116 strBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}", varNode.Weight); 117 strBuilder.Append("*"); 118 } 119 strBuilder.Append("LAG("); 120 if (varNode.VariableName.Contains("'")) { 121 strBuilder.AppendFormat("\"{0}\"", varNode.VariableName); 122 } else { 123 strBuilder.AppendFormat("'{0}'", varNode.VariableName); 124 } 125 strBuilder.Append(", ") 126 .AppendFormat(CultureInfo.InvariantCulture, "{0}", varNode.Lag) 127 .Append(")"); 128 } else if (node.Symbol is Variable) { 104 129 var varNode = node as VariableTreeNode; 105 130 if (!varNode.Weight.IsAlmost(1.0)) { … … 121 146 strBuilder.AppendFormat(CultureInfo.InvariantCulture, "{0}", constNode.Value); 122 147 else 123 strBuilder.AppendFormat(CultureInfo.InvariantCulture, "({0})", constNode.Value); // (-1)148 strBuilder.AppendFormat(CultureInfo.InvariantCulture, "({0})", constNode.Value); // (-1 124 149 } 125 150 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r14312 r14576 67 67 strBuilder.AppendLine(FormatRecursively(symbolicExpressionTree.Root)); 68 68 return strBuilder.ToString(); 69 } 70 catch (NotImplementedException ex) { 69 } catch (NotImplementedException ex) { 71 70 return ex.Message + Environment.NewLine + ex.StackTrace; 72 71 } … … 109 108 } else if (node.Symbol is Division) { 110 109 if (node.SubtreeCount == 1) { 111 strBuilder.Append(@" \cfrac{1 ");110 strBuilder.Append(@" \cfrac{1}{"); 112 111 } else { 113 112 strBuilder.Append(@" \cfrac{ "); … … 176 175 strBuilder.Append(@" \operatorname{if} \left( "); 177 176 } else if (node.Symbol is Constant) { 178 strBuilder.Append("c_{" + constants.Count + "} ");179 177 var constNode = node as ConstantTreeNode; 180 constants.Add(constNode.Value); 178 if (constNode.Value.IsAlmost(1.0)) { 179 strBuilder.Append("1 "); 180 } else { 181 strBuilder.Append("c_{" + constants.Count + "} "); 182 constants.Add(constNode.Value); 183 } 181 184 } else if (node.Symbol is LaggedVariable) { 182 185 var laggedVarNode = node as LaggedVariableTreeNode;
Note: See TracChangeset
for help on using the changeset viewer.