- Timestamp:
- 02/24/22 20:33:45 (3 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/InfixExpressionFormatter.cs
r18211 r18220 35 35 /// Performs some basic re-writing steps to simplify the code for formatting. Tree is changed. 36 36 /// Removes single-argument +, * which have no effect 37 /// Removes SubFunctions (no effect) 37 38 /// Replaces variables with coefficients by an explicitly multiplication 38 39 /// Replaces single-argument / with 1 / (..) … … 57 58 mul.AddSubtree(num); 58 59 mul.AddSubtree(varTreeNode); 60 } else if (n.Symbol is SubFunctionSymbol) { 61 parent.ReplaceSubtree(n, n.GetSubtree(0)); 59 62 } else if (n.SubtreeCount == 1 && (n.Symbol is Addition || n.Symbol is Multiplication || n.Symbol is And || n.Symbol is Or || n.Symbol is Xor)) { 60 63 // single-argument addition or multiplication has no effect -> remove … … 81 84 } 82 85 parent.InsertSubtree(childIdx, newChild); 83 } else if (n.SubtreeCount == 2 && n.GetSubtree(1).SubtreeCount == 2 && 84 IsAssocOp(n.Symbol) && IsOperator(n.GetSubtree(1).Symbol) && 86 } else if (n.SubtreeCount == 2 && n.GetSubtree(1).SubtreeCount == 2 && 87 IsAssocOp(n.Symbol) && IsOperator(n.GetSubtree(1).Symbol) && 85 88 Priority(n.Symbol) == Priority(n.GetSubtree(1).Symbol)) { 86 89 // f(x) <op> (g(x) <op> h(x))) is the same as (f(x) <op> g(x)) <op> h(x) for associative <op> … … 104 107 NumberFormatInfo numberFormat, string formatString, List<KeyValuePair<string, double>> parameters = null) { 105 108 // This method assumes that the tree has been converted to binary and left-assoc form (see ConvertToBinaryLeftAssocRec). 106 // An exception is thrown if the tree has a different shape.107 108 109 if (node.SubtreeCount == 0) { 109 110 // no subtrees -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionCSharpFormatter.cs
r18132 r18220 155 155 FormatRecursively(node.GetSubtree(1), strBuilder); 156 156 strBuilder.Append(" , 2) ) )"); 157 } else if (node.Symbol is SubFunctionSymbol) { 158 FormatRecursively(node.GetSubtree(0), strBuilder); 157 159 } else { 158 160 throw new NotSupportedException("Formatting of symbol: " + node.Symbol + " not supported for C# symbolic expression tree formatter."); -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs
r18132 r18220 310 310 stringBuilder.Append(FormatRecursively(node.GetSubtree(1))); 311 311 stringBuilder.Append("), 1.0, -1.0)"); 312 } else if (symbol is SubFunctionSymbol) { 313 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 312 314 } else { 313 315 throw new NotImplementedException("Excel export of " + node.Symbol + " is not implemented."); -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r18132 r18220 279 279 paramIdx++; 280 280 strBuilder.Append(@" \left( " + p + @"\cdot "); 281 } else if (node.Symbol is SubFunctionSymbol) { 282 // to nothing, skip symbol 281 283 } else { 282 284 throw new NotImplementedException("Export of " + node.Symbol + " is not implemented."); … … 387 389 paramIdx++; 388 390 strBuilder.Append(@" + \left( 1 - " + p + @" \right) \cdot "); 391 } else if (node.Symbol is SubFunctionSymbol) { 392 throw new InvalidOperationException(); 389 393 } else { 390 394 throw new NotImplementedException("Export of " + node.Symbol + " is not implemented."); … … 511 515 } else if (node.Symbol is VariableCondition) { 512 516 strBuilder.Append(@"\right) "); 517 } else if (node.Symbol is SubFunctionSymbol) { 513 518 } else { 514 519 throw new NotImplementedException("Export of " + node.Symbol + " is not implemented."); -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs
r18132 r18220 388 388 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 389 389 currentLag -= laggedNode.Lag; 390 } else if (symbol is SubFunctionSymbol) { 391 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 390 392 } else { 391 393 stringBuilder.Append("ERROR"); -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMathematicaFormatter.cs
r18132 r18220 122 122 } else if (node.Symbol is Root) { 123 123 FormatRoot(node, strBuilder); 124 } else if (node.Symbol is SubFunctionSymbol) { 125 FormatRecursively(node.GetSubtree(0), strBuilder); 124 126 } else { 125 127 throw new NotSupportedException("Formatting of symbol: " + node.Symbol + " is not supported."); -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionPythonFormatter.cs
r18132 r18220 204 204 else if (node is INumericTreeNode) 205 205 FormatNumericTreeNode(node, strBuilder); 206 else if (symbol is SubFunctionSymbol) 207 FormatRecursively(node.GetSubtree(0), strBuilder); 206 208 else 207 209 throw new NotSupportedException("Formatting of symbol: " + symbol + " not supported for Python symbolic expression tree formatter."); … … 228 230 229 231 private static void FormatNumericTreeNode(ISymbolicExpressionTreeNode node, StringBuilder strBuilder) { 230 var symbol = node.Symbol; 231 if (node is INumericTreeNode numNode) { 232 strBuilder.Append(numNode.Value.ToString("g17", CultureInfo.InvariantCulture)); 233 } else { 234 throw new NotSupportedException("Formatting of symbol: " + symbol + " not supported for Python symbolic expression tree formatter."); 235 } 232 var numNode = node as INumericTreeNode; 233 strBuilder.Append(numNode.Value.ToString("g17", CultureInfo.InvariantCulture)); 236 234 } 237 235 -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionSmalltalkFormatter.cs
r18132 r18220 184 184 } else if (symbol is BinaryFactorVariable || symbol is FactorVariable) { 185 185 stringBuilder.Append("factor variables are not supported"); 186 } else if (symbol is SubFunctionSymbol) { 187 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 186 188 } else { 187 189 stringBuilder.Append("("); -
trunk/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/TSQLExpressionFormatter.cs
r18132 r18220 157 157 } else if (node.Symbol is Root) { 158 158 FormatRoot(level, node, strBuilder); 159 } else if (node.Symbol is SubFunctionSymbol) { 160 FormatRecursively(level, node.GetSubtree(0), strBuilder); 159 161 } else { 160 162 throw new NotSupportedException("Formatting of symbol: " + node.Symbol + " not supported for TSQL symbolic expression tree formatter.");
Note: See TracChangeset
for help on using the changeset viewer.