Changeset 5021 for branches/DataAnalysis.Extensions/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Formatters/SymbolicExpressionTreeMATLABFormatter.cs
- Timestamp:
- 12/04/10 13:07:50 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataAnalysis.Extensions/HeuristicLab.Problems.DataAnalysis/3.3/Symbolic/Formatters/SymbolicExpressionTreeMATLABFormatter.cs
r5020 r5021 77 77 } 78 78 } else if (symbol is And) { 79 stringBuilder.Append("( ");79 stringBuilder.Append("(("); 80 80 for (int i = 0; i < node.SubTrees.Count; i++) { 81 81 if (i > 0) stringBuilder.Append("&"); … … 84 84 stringBuilder.Append(")>0)"); 85 85 } 86 stringBuilder.Append(")-0.5 "); // MATLAB maps false and true to 0 and 1, resp., so we map this result to -0.5 and +0.5, resp.86 stringBuilder.Append(")-0.5)*2"); // MATLAB maps false and true to 0 and 1, resp., we map this result to -1.0 and +1.0, resp. 87 87 } else if (symbol is Average) { 88 88 stringBuilder.Append("(1/"); … … 121 121 stringBuilder.Append(")"); 122 122 } else if (symbol is GreaterThan) { 123 stringBuilder.Append("( ");123 stringBuilder.Append("(("); 124 124 stringBuilder.Append(FormatRecursively(node.SubTrees[0])); 125 125 stringBuilder.Append(">"); 126 126 stringBuilder.Append(FormatRecursively(node.SubTrees[1])); 127 stringBuilder.Append(")-0.5 "); // MATLAB maps false and true to 0 and 1, resp., so we map this result to -0.5 and +0.5, resp.127 stringBuilder.Append(")-0.5)*2"); // MATLAB maps false and true to 0 and 1, resp., we map this result to -1.0 and +1.0, resp. 128 128 } else if (symbol is IfThenElse) { 129 129 stringBuilder.Append("("); … … 134 134 stringBuilder.Append("("); 135 135 stringBuilder.Append(FormatRecursively(node.SubTrees[0])); 136 stringBuilder.Append("< 0)*");136 stringBuilder.Append("<=0)*"); 137 137 stringBuilder.Append(FormatRecursively(node.SubTrees[2])); 138 138 } else if (symbol is LaggedVariable) { … … 142 142 stringBuilder.Append(laggedVariableTreeNode.VariableName + "(i-" + laggedVariableTreeNode.Lag + ")"); 143 143 } else if (symbol is LessThan) { 144 stringBuilder.Append("( ");144 stringBuilder.Append("(("); 145 145 stringBuilder.Append(FormatRecursively(node.SubTrees[0])); 146 146 stringBuilder.Append("<"); 147 147 stringBuilder.Append(FormatRecursively(node.SubTrees[1])); 148 stringBuilder.Append(")-0.5 ");148 stringBuilder.Append(")-0.5)*2"); // MATLAB maps false and true to 0 and 1, resp., we map this result to -1.0 and +1.0, resp. 149 149 } else if (symbol is Logarithm) { 150 150 stringBuilder.Append("log("); … … 160 160 stringBuilder.Append("*-1"); 161 161 } else if (symbol is Or) { 162 stringBuilder.Append("( ");162 stringBuilder.Append("(("); 163 163 for (int i = 0; i < node.SubTrees.Count; i++) { 164 164 if (i > 0) stringBuilder.Append("|"); … … 167 167 stringBuilder.Append(")>0)"); 168 168 } 169 stringBuilder.Append(")-0.5 "); // MATLAB maps false and true to 0 and 1, resp., so we map this result to -0.5 and +0.5, resp.169 stringBuilder.Append(")-0.5)*2"); // MATLAB maps false and true to 0 and 1, resp., we map this result to -1.0 and +1.0, resp. 170 170 } else if (symbol is Sine) { 171 171 stringBuilder.Append("sin(");
Note: See TracChangeset
for help on using the changeset viewer.