- Timestamp:
- 08/16/16 12:04:56 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r14185 r14255 36 36 private int targetCount; 37 37 private int currentLag; 38 private string targetVariable; 39 private bool containsTimeSeriesSymbol; 38 40 39 41 [StorableConstructor] … … 55 57 56 58 public string Format(ISymbolicExpressionTree symbolicExpressionTree) { 59 return Format(symbolicExpressionTree, null); 60 } 61 public string Format(ISymbolicExpressionTree symbolicExpressionTree, string targetVariable) { 57 62 try { 58 63 StringBuilder strBuilder = new StringBuilder(); 59 64 constants.Clear(); 65 this.targetVariable = targetVariable; 66 containsTimeSeriesSymbol = symbolicExpressionTree.IterateNodesBreadth().Any(n => IsTimeSeriesSymbol(n.Symbol)); 60 67 strBuilder.AppendLine(FormatRecursively(symbolicExpressionTree.Root)); 61 68 return strBuilder.ToString(); … … 64 71 return ex.Message + Environment.NewLine + ex.StackTrace; 65 72 } 73 } 74 static bool IsTimeSeriesSymbol(ISymbol s) { 75 return s is TimeLag || s is Integral || s is Derivative || s is LaggedVariable; 66 76 } 67 77 … … 197 207 strBuilder.Append(invokeNode.Symbol.FunctionName + @" \left( "); 198 208 } else if (node.Symbol is StartSymbol) { 199 strBuilder.Append("target_" + (targetCount++) + "(t) & = ");209 FormatStartSymbol(strBuilder); 200 210 } else if (node.Symbol is Argument) { 201 211 var argSym = node.Symbol as Argument; … … 303 313 } else if (node.Symbol is StartSymbol) { 304 314 strBuilder.Append(@"\\" + Environment.NewLine); 305 strBuilder.Append("target_" + (targetCount++) + "(t) & = ");315 FormatStartSymbol(strBuilder); 306 316 } else if (node.Symbol is Power) { 307 317 strBuilder.Append(@"\right) ^ { \operatorname{round} \left("); … … 433 443 } 434 444 445 private void FormatStartSymbol(StringBuilder strBuilder) { 446 strBuilder.Append(targetVariable ?? "target_" + (targetCount++)); 447 if (containsTimeSeriesSymbol) 448 strBuilder.Append("(t)"); 449 strBuilder.Append(" & = "); 450 } 451 435 452 private string LagToString(int lag) { 436 453 if (lag < 0) {
Note: See TracChangeset
for help on using the changeset viewer.