- Timestamp:
- 09/08/16 11:41:45 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs
r14259 r14277 37 37 private int targetCount; 38 38 private int currentLag; 39 private string targetVariable; 40 private bool containsTimeSeriesSymbol; 39 41 40 42 [StorableConstructor] … … 59 61 60 62 public string Format(ISymbolicExpressionTree symbolicExpressionTree) { 63 return Format(symbolicExpressionTree, null); 64 } 65 public string Format(ISymbolicExpressionTree symbolicExpressionTree, string targetVariable) { 61 66 try { 62 67 StringBuilder strBuilder = new StringBuilder(); 63 68 constants.Clear(); 64 69 constIndex = 0; 70 this.targetVariable = targetVariable; 71 containsTimeSeriesSymbol = symbolicExpressionTree.IterateNodesBreadth().Any(n => IsTimeSeriesSymbol(n.Symbol)); 65 72 strBuilder.AppendLine(FormatRecursively(symbolicExpressionTree.Root)); 66 73 return strBuilder.ToString(); … … 68 75 return ex.Message + Environment.NewLine + ex.StackTrace; 69 76 } 77 } 78 static bool IsTimeSeriesSymbol(ISymbol s) { 79 return s is TimeLag || s is Integral || s is Derivative || s is LaggedVariable; 70 80 } 71 81 … … 227 237 strBuilder.Append(invokeNode.Symbol.FunctionName + @" \left( "); 228 238 } else if (node.Symbol is StartSymbol) { 229 strBuilder.Append("target_" + (targetCount++) + "(t) & = ");239 FormatStartSymbol(strBuilder); 230 240 } else if (node.Symbol is Argument) { 231 241 var argSym = node.Symbol as Argument; … … 337 347 } else if (node.Symbol is StartSymbol) { 338 348 strBuilder.Append(@"\\" + Environment.NewLine); 339 strBuilder.Append("target_" + (targetCount++) + "(t) & = ");349 FormatStartSymbol(strBuilder); 340 350 } else if (node.Symbol is Power) { 341 351 strBuilder.Append(@"\right) ^ { \operatorname{round} \left("); … … 471 481 } 472 482 483 private void FormatStartSymbol(StringBuilder strBuilder) { 484 strBuilder.Append(targetVariable ?? "target_" + (targetCount++)); 485 if (containsTimeSeriesSymbol) 486 strBuilder.Append("(t)"); 487 strBuilder.Append(" & = "); 488 } 489 473 490 private string LagToString(int lag) { 474 491 if (lag < 0) {
Note: See TracChangeset
for help on using the changeset viewer.