Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/03/13 15:46:01 (11 years ago)
Author:
ascheibe
Message:

#1730 merged r9587,r9590, r9600, r9607, r9626, r9658, r9659, r9699, r9906 into stable

Location:
stable
Files:
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Formatters/SymbolicDataAnalysisExpressionExcelFormatter.cs

    r9587 r9931  
    2323using System.Collections.Generic;
    2424using System.Globalization;
     25using System.Linq;
    2526using System.Text;
    2627using HeuristicLab.Common;
     
    6667      return string.Format("${0}1", variableNameMapping[variabelName]);
    6768    }
    68 
    6969    public string Format(ISymbolicExpressionTree symbolicExpressionTree) {
     70      return Format(symbolicExpressionTree, null);
     71    }
     72
     73    public string Format(ISymbolicExpressionTree symbolicExpressionTree, Dataset dataset) {
    7074      var stringBuilder = new StringBuilder();
     75      if (dataset != null) CalculateVariableMapping(symbolicExpressionTree, dataset);
     76
    7177      stringBuilder.Append("=");
    7278      stringBuilder.Append(FormatRecursively(symbolicExpressionTree.Root));
     79
    7380      foreach (var variable in variableNameMapping) {
    7481        stringBuilder.AppendLine();
     
    7683      }
    7784      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      }
    7897    }
    7998
     
    137156        stringBuilder.Append(")");
    138157      } else if (symbol is Logarithm) {
    139         stringBuilder.Append("LOG(");
    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 set
     158        stringBuilder.Append("LN(");
     159        stringBuilder.Append(FormatRecursively(node.GetSubtree(0)));
     160        stringBuilder.Append(")");
    142161      } else if (symbol is Multiplication) {
    143162        for (int i = 0; i < node.SubtreeCount; i++) {
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r9862 r9931  
    139139    <Compile Include="Crossovers\SymbolicDataAnalysisExpressionProbabilisticFunctionalCrossover.cs" />
    140140    <Compile Include="Crossovers\SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs" />
    141     <Compile Include="Formatters\SymbolicDataAnalysisExpressionSmalltalkFormatter.cs" />
     141    <Compile Include="Formatters\SymbolicDataAnalysisExpressionExcelFormatter.cs" />
     142  <Compile Include="Formatters\SymbolicDataAnalysisExpressionSmalltalkFormatter.cs" />
    142143    <Compile Include="Interfaces\ISymbolicDataAnalysisExpressionCrossover.cs" />
    143144    <Compile Include="Interfaces\ISymbolicDataAnalysisImpactValuesCalculator.cs" />
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisModel.cs

    r9456 r9931  
    2525    ISymbolicExpressionTree SymbolicExpressionTree { get; }
    2626    ISymbolicDataAnalysisExpressionTreeInterpreter Interpreter { get; }
     27
     28    double LowerEstimationLimit { get; }
     29    double UpperEstimationLimit { get; }
    2730  }
    2831}
  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisModel.cs

    r9456 r9931  
    3838
    3939    #region properties
     40    [Storable]
     41    private double lowerEstimationLimit;
     42    public double LowerEstimationLimit { get { return lowerEstimationLimit; } }
     43    [Storable]
     44    private double upperEstimationLimit;
     45    public double UpperEstimationLimit { get { return upperEstimationLimit; } }
    4046
    4147    [Storable]
     
    5056      get { return interpreter; }
    5157    }
    52 
    5358    #endregion
    5459
     
    5964      this.symbolicExpressionTree = cloner.Clone(original.symbolicExpressionTree);
    6065      this.interpreter = cloner.Clone(original.interpreter);
     66      this.lowerEstimationLimit = original.lowerEstimationLimit;
     67      this.upperEstimationLimit = original.upperEstimationLimit;
    6168    }
    62     public SymbolicDataAnalysisModel(ISymbolicExpressionTree tree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter)
     69    protected SymbolicDataAnalysisModel(ISymbolicExpressionTree tree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     70       double lowerEstimationLimit, double upperEstimationLimit)
    6371      : base() {
    6472      this.name = ItemName;
     
    6674      this.symbolicExpressionTree = tree;
    6775      this.interpreter = interpreter;
     76      this.lowerEstimationLimit = lowerEstimationLimit;
     77      this.upperEstimationLimit = upperEstimationLimit;
    6878    }
    6979
Note: See TracChangeset for help on using the changeset viewer.