Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/28/16 15:59:11 (8 years ago)
Author:
bburlacu
Message:

#1772: Merge trunk changes. Delete unnecessary files (sliding window).

Location:
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs

    r12155 r14312  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    3636    private int targetCount;
    3737    private int currentLag;
     38    private string targetVariable;
     39    private bool containsTimeSeriesSymbol;
    3840
    3941    [StorableConstructor]
     
    5557
    5658    public string Format(ISymbolicExpressionTree symbolicExpressionTree) {
     59      return Format(symbolicExpressionTree, null);
     60    }
     61    public string Format(ISymbolicExpressionTree symbolicExpressionTree, string targetVariable) {
    5762      try {
    5863        StringBuilder strBuilder = new StringBuilder();
    5964        constants.Clear();
     65        this.targetVariable = targetVariable;
     66        containsTimeSeriesSymbol = symbolicExpressionTree.IterateNodesBreadth().Any(n => IsTimeSeriesSymbol(n.Symbol));
    6067        strBuilder.AppendLine(FormatRecursively(symbolicExpressionTree.Root));
    6168        return strBuilder.ToString();
     
    6471        return ex.Message + Environment.NewLine + ex.StackTrace;
    6572      }
     73    }
     74    static bool IsTimeSeriesSymbol(ISymbol s) {
     75      return s is TimeLag || s is Integral || s is Derivative || s is LaggedVariable;
    6676    }
    6777
     
    197207        strBuilder.Append(invokeNode.Symbol.FunctionName + @" \left( ");
    198208      } else if (node.Symbol is StartSymbol) {
    199         strBuilder.Append("target_" + (targetCount++) + "(t) & = ");
     209        FormatStartSymbol(strBuilder);
    200210      } else if (node.Symbol is Argument) {
    201211        var argSym = node.Symbol as Argument;
     
    303313      } else if (node.Symbol is StartSymbol) {
    304314        strBuilder.Append(@"\\" + Environment.NewLine);
    305         strBuilder.Append("target_" + (targetCount++) + "(t) & = ");
     315        FormatStartSymbol(strBuilder);
    306316      } else if (node.Symbol is Power) {
    307317        strBuilder.Append(@"\right) ^ { \operatorname{round} \left(");
     
    403413            var constStr = string.Format(System.Globalization.NumberFormatInfo.InvariantInfo, "{0:G5}", constant);
    404414            if (!constStr.Contains(".")) constStr = constStr + ".0";
    405             constStr = constStr.Replace(".", "\\negthickspace&.");  // fix problem in rendering of aligned expressions
     415            constStr = constStr.Replace(".", "&.");  // fix problem in rendering of aligned expressions
    406416            strBuilder.Append("c_{" + i + "}& = & " + constStr);
    407417            strBuilder.Append(@"\\");
     
    433443    }
    434444
     445    private void FormatStartSymbol(StringBuilder strBuilder) {
     446      strBuilder.Append(targetVariable ?? "target_" + (targetCount++));
     447      if (containsTimeSeriesSymbol)
     448        strBuilder.Append("(t)");
     449      strBuilder.Append(" & = ");
     450    }
     451
    435452    private string LagToString(int lag) {
    436453      if (lag < 0) {
Note: See TracChangeset for help on using the changeset viewer.