Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6975


Ignore:
Timestamp:
11/09/11 14:32:19 (13 years ago)
Author:
mkommend
Message:

#1579: Corrected handling of underscores in SymbolicDataAnalysisExpressionLatexFormatter.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs

    r6803 r6975  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
     24using System.Linq;
    2225using System.Text;
    23 using System.Linq;
     26using HeuristicLab.Common;
     27using HeuristicLab.Core;
     28using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2429using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
    25 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    26 using System.Collections.Generic;
    27 using System;
    28 using HeuristicLab.Core;
    29 using HeuristicLab.Common;
    3030
    3131namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
     
    137137      } else if (node.Symbol is LaggedVariable) {
    138138        var laggedVarNode = node as LaggedVariableTreeNode;
    139         strBuilder.Append("c_{" + constants.Count + "} " + laggedVarNode.VariableName);
     139        strBuilder.Append("c_{" + constants.Count + "} " + EscapeLatexString(laggedVarNode.VariableName));
    140140        strBuilder.Append(LagToString(currentLag + laggedVarNode.Lag));
    141141        constants.Add(laggedVarNode.Weight);
    142142      } else if (node.Symbol is HeuristicLab.Problems.DataAnalysis.Symbolic.Variable) {
    143143        var varNode = node as VariableTreeNode;
    144         strBuilder.Append("c_{" + constants.Count + "} " + varNode.VariableName);
     144        strBuilder.Append("c_{" + constants.Count + "} " + EscapeLatexString(varNode.VariableName));
    145145        strBuilder.Append(LagToString(currentLag));
    146146        constants.Add(varNode.Weight);
     
    174174        string p = @"1 / \left( 1 + \exp \left( - c_{" + constants.Count + "} ";
    175175        constants.Add(conditionTreeNode.Slope);
    176         p += @" \cdot \left(" + conditionTreeNode.VariableName + LagToString(currentLag) + " - c_{" + constants.Count + @"} \right) \right) \right)";
     176        p += @" \cdot \left(" + EscapeLatexString(conditionTreeNode.VariableName) + LagToString(currentLag) + " - c_{" + constants.Count + @"} \right) \right) \right)";
    177177        constants.Add(conditionTreeNode.Threshold);
    178178        strBuilder.Append(@"\left( " + p + @"\cdot ");
     
    230230        string p = @"1 / \left( 1 + \exp \left( - c_{" + constants.Count + "} ";
    231231        constants.Add(conditionTreeNode.Slope);
    232         p += @" \cdot \left(" + conditionTreeNode.VariableName + LagToString(currentLag) + " - c_{" + constants.Count + @"} \right) \right) \right)";
     232        p += @" \cdot \left(" + EscapeLatexString(conditionTreeNode.VariableName) + LagToString(currentLag) + " - c_{" + constants.Count + @"} \right) \right) \right)";
    233233        constants.Add(conditionTreeNode.Threshold);
    234234        strBuilder.Append(@" + \left( 1 - " + p + @" \right) \cdot ");
     
    311311      }
    312312    }
     313
    313314    private string LagToString(int lag) {
    314315      if (lag < 0) {
     
    318319      } else return "(t)";
    319320    }
     321
     322    private string EscapeLatexString(string s) {
     323      return s.Replace(@"_", @"\_");
     324    }
    320325  }
    321326}
Note: See TracChangeset for help on using the changeset viewer.