- Timestamp:
- 06/24/13 20:22:11 (11 years ago)
- Location:
- branches/HivePerformance/sources
- Files:
-
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/HivePerformance/sources
- Property svn:mergeinfo changed
/trunk/sources merged: 9618,9623-9624,9626,9647-9649,9652
- Property svn:mergeinfo changed
-
branches/HivePerformance/sources/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic merged: 9626,9647,9649
- Property svn:mergeinfo changed
-
branches/HivePerformance/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs
r9616 r9655 23 23 using System.Collections.Generic; 24 24 using System.Globalization; 25 using System.Linq; 25 26 using System.Text; 26 27 using HeuristicLab.Common; … … 66 67 return string.Format("${0}1", variableNameMapping[variabelName]); 67 68 } 68 69 69 public string Format(ISymbolicExpressionTree symbolicExpressionTree) { 70 return Format(symbolicExpressionTree, null); 71 } 72 73 public string Format(ISymbolicExpressionTree symbolicExpressionTree, Dataset dataset) { 70 74 var stringBuilder = new StringBuilder(); 75 if (dataset != null) CalculateVariableMapping(symbolicExpressionTree, dataset); 76 71 77 stringBuilder.Append("="); 72 78 stringBuilder.Append(FormatRecursively(symbolicExpressionTree.Root)); 79 73 80 foreach (var variable in variableNameMapping) { 74 81 stringBuilder.AppendLine(); … … 76 83 } 77 84 return stringBuilder.ToString(); 85 } 86 87 private void CalculateVariableMapping(ISymbolicExpressionTree tree, Dataset dataset) { 88 int columnIndex = 0; 89 int inputIndex = 0; 90 var usedVariables = tree.IterateNodesPrefix().OfType<VariableTreeNode>().Select(v => v.VariableName).Distinct(); 91 foreach (var variable in dataset.VariableNames) { 92 columnIndex++; 93 if (!usedVariables.Contains(variable)) continue; 94 inputIndex++; 95 variableNameMapping[variable] = GetExcelColumnName(inputIndex); 96 } 78 97 } 79 98 … … 137 156 stringBuilder.Append(")"); 138 157 } else if (symbol is Logarithm) { 139 stringBuilder.Append("L OG(");140 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 141 stringBuilder.Append(" , EXP(1))"); // Excel does not use the natural logarithm, therefor the base has to be set158 stringBuilder.Append("LN("); 159 stringBuilder.Append(FormatRecursively(node.GetSubtree(0))); 160 stringBuilder.Append(")"); 142 161 } else if (symbol is Multiplication) { 143 162 for (int i = 0; i < node.SubtreeCount; i++) { -
branches/HivePerformance/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj
r9616 r9655 140 140 <Compile Include="Crossovers\SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs" /> 141 141 <Compile Include="Formatters\SymbolicDataAnalysisExpressionExcelFormatter.cs" /> 142 <Compile Include="Formatters\SymbolicExpressionTreeSmalltalkStringFormatter.cs" /> 142 143 <Compile Include="Interfaces\ISymbolicDataAnalysisExpressionCrossover.cs" /> 143 144 <Compile Include="Interfaces\ISymbolicDataAnalysisImpactValuesCalculator.cs" />
Note: See TracChangeset
for help on using the changeset viewer.