Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/08/11 10:42:57 (14 years ago)
Author:
mkommend
Message:

#1540: Added min and max arity to symbols and renamed SymbolicExpressionTreeNode.SubtreesCount to SymbolicExpressionTreeNode.SubtreeCount.

Location:
branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionLatexFormatter.cs

    r5817 r6387  
    7373      FormatBegin(node, strBuilder);
    7474
    75       if (node.SubtreesCount > 0) {
     75      if (node.SubtreeCount > 0) {
    7676        strBuilder.Append(FormatRecursively(node.GetSubtree(0)));
    7777      }
     
    9191        strBuilder.Append(@" \left( ");
    9292      } else if (node.Symbol is Subtraction) {
    93         if (node.SubtreesCount == 1) {
     93        if (node.SubtreeCount == 1) {
    9494          strBuilder.Append(@"- \left(");
    9595        } else {
     
    9898      } else if (node.Symbol is Multiplication) {
    9999      } else if (node.Symbol is Division) {
    100         if (node.SubtreesCount == 1) {
     100        if (node.SubtreeCount == 1) {
    101101          strBuilder.Append(@" \cfrac{1}{");
    102102        } else {
     
    105105      } else if (node.Symbol is Average) {
    106106        // skip output of (1/1) if only one subtree
    107         if (node.SubtreesCount > 1) {
    108           strBuilder.Append(@" \cfrac{1}{" + node.SubtreesCount + @"}");
     107        if (node.SubtreeCount > 1) {
     108          strBuilder.Append(@" \cfrac{1}{" + node.SubtreeCount + @"}");
    109109        }
    110110        strBuilder.Append(@" \left(");
     
    246246      } else if (node.Symbol is Division) {
    247247        strBuilder.Append("} ");
    248         if (node.SubtreesCount > 1)
     248        if (node.SubtreeCount > 1)
    249249          strBuilder.Append("{1} ");
    250         for (int i = 1; i < node.SubtreesCount; i++) {
     250        for (int i = 1; i < node.SubtreeCount; i++) {
    251251          strBuilder.Append(" } ");
    252252        }
  • branches/GP.Grammar.Editor/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionMATLABFormatter.cs

    r5809 r6387  
    106106
    107107      if (symbol is Addition) {
    108         for (int i = 0; i < node.SubtreesCount; i++) {
     108        for (int i = 0; i < node.SubtreeCount; i++) {
    109109          if (i > 0) stringBuilder.Append("+");
    110110          stringBuilder.Append(FormatRecursively(node.GetSubtree(i)));
     
    112112      } else if (symbol is And) {
    113113        stringBuilder.Append("((");
    114         for (int i = 0; i < node.SubtreesCount; i++) {
     114        for (int i = 0; i < node.SubtreeCount; i++) {
    115115          if (i > 0) stringBuilder.Append("&");
    116116          stringBuilder.Append("((");
     
    121121      } else if (symbol is Average) {
    122122        stringBuilder.Append("(1/");
    123         stringBuilder.Append(node.SubtreesCount);
     123        stringBuilder.Append(node.SubtreeCount);
    124124        stringBuilder.Append(")*(");
    125         for (int i = 0; i < node.SubtreesCount; i++) {
     125        for (int i = 0; i < node.SubtreeCount; i++) {
    126126          if (i > 0) stringBuilder.Append("+");
    127127          stringBuilder.Append("(");
     
    138138        stringBuilder.Append(")");
    139139      } else if (symbol is Division) {
    140         if (node.SubtreesCount == 1) {
     140        if (node.SubtreeCount == 1) {
    141141          stringBuilder.Append("1/");
    142142          stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
     
    144144          stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
    145145          stringBuilder.Append("/(");
    146           for (int i = 1; i < node.SubtreesCount; i++) {
     146          for (int i = 1; i < node.SubtreeCount; i++) {
    147147            if (i > 1) stringBuilder.Append("*");
    148148            stringBuilder.Append(FormatRecursively(node.GetSubtree(i)));
     
    187187        stringBuilder.Append(")");
    188188      } else if (symbol is Multiplication) {
    189         for (int i = 0; i < node.SubtreesCount; i++) {
     189        for (int i = 0; i < node.SubtreeCount; i++) {
    190190          if (i > 0) stringBuilder.Append("*");
    191191          stringBuilder.Append(FormatRecursively(node.GetSubtree(i)));
     
    197197      } else if (symbol is Or) {
    198198        stringBuilder.Append("((");
    199         for (int i = 0; i < node.SubtreesCount; i++) {
     199        for (int i = 0; i < node.SubtreeCount; i++) {
    200200          if (i > 0) stringBuilder.Append("|");
    201201          stringBuilder.Append("((");
     
    209209        stringBuilder.Append(")");
    210210      } else if (symbol is Subtraction) {
    211         if (node.SubtreesCount == 1) {
     211        if (node.SubtreeCount == 1) {
    212212          stringBuilder.Append("-1*");
    213213          stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
    214214        } else {
    215215          stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
    216           for (int i = 1; i < node.SubtreesCount; i++) {
     216          for (int i = 1; i < node.SubtreeCount; i++) {
    217217            stringBuilder.Append("-");
    218218            stringBuilder.Append(FormatRecursively(node.GetSubtree(i)));
Note: See TracChangeset for help on using the changeset viewer.