Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/08/16 11:41:45 (8 years ago)
Author:
gkronber
Message:

#2650: merged r14245:14273 from trunk to branch (fixing conflicts in RegressionSolutionTargetResponseGradientView)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/symbreg-factors-2650/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs

    r14259 r14277  
    3737    private int targetCount;
    3838    private int currentLag;
     39    private string targetVariable;
     40    private bool containsTimeSeriesSymbol;
    3941
    4042    [StorableConstructor]
     
    5961
    6062    public string Format(ISymbolicExpressionTree symbolicExpressionTree) {
     63      return Format(symbolicExpressionTree, null);
     64    }
     65    public string Format(ISymbolicExpressionTree symbolicExpressionTree, string targetVariable) {
    6166      try {
    6267        StringBuilder strBuilder = new StringBuilder();
    6368        constants.Clear();
    6469        constIndex = 0;
     70        this.targetVariable = targetVariable;
     71        containsTimeSeriesSymbol = symbolicExpressionTree.IterateNodesBreadth().Any(n => IsTimeSeriesSymbol(n.Symbol));
    6572        strBuilder.AppendLine(FormatRecursively(symbolicExpressionTree.Root));
    6673        return strBuilder.ToString();
     
    6875        return ex.Message + Environment.NewLine + ex.StackTrace;
    6976      }
     77    }
     78    static bool IsTimeSeriesSymbol(ISymbol s) {
     79      return s is TimeLag || s is Integral || s is Derivative || s is LaggedVariable;
    7080    }
    7181
     
    227237        strBuilder.Append(invokeNode.Symbol.FunctionName + @" \left( ");
    228238      } else if (node.Symbol is StartSymbol) {
    229         strBuilder.Append("target_" + (targetCount++) + "(t) & = ");
     239        FormatStartSymbol(strBuilder);
    230240      } else if (node.Symbol is Argument) {
    231241        var argSym = node.Symbol as Argument;
     
    337347      } else if (node.Symbol is StartSymbol) {
    338348        strBuilder.Append(@"\\" + Environment.NewLine);
    339         strBuilder.Append("target_" + (targetCount++) + "(t) & = ");
     349        FormatStartSymbol(strBuilder);
    340350      } else if (node.Symbol is Power) {
    341351        strBuilder.Append(@"\right) ^ { \operatorname{round} \left(");
     
    471481    }
    472482
     483    private void FormatStartSymbol(StringBuilder strBuilder) {
     484      strBuilder.Append(targetVariable ?? "target_" + (targetCount++));
     485      if (containsTimeSeriesSymbol)
     486        strBuilder.Append("(t)");
     487      strBuilder.Append(" & = ");
     488    }
     489
    473490    private string LagToString(int lag) {
    474491      if (lag < 0) {
Note: See TracChangeset for help on using the changeset viewer.