Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/27/12 11:02:09 (12 years ago)
Author:
mkommend
Message:

#1763: Merged remaining changes from the TreeSimplifier branch in the trunk and refactored impact values calculators.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic
Files:
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic

  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4

    • Property svn:ignore
      •  

        old new  
         1*.user
         2Plugin.cs
        13bin
        2 *.user
        3 HeuristicLabProblemsDataAnalysisSymbolicPlugin.cs
        44obj
        5 *.vs10x
        6 Plugin.cs
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r8895 r8946  
    140140    <Compile Include="Crossovers\SymbolicDataAnalysisExpressionSemanticSimilarityCrossover.cs" />
    141141    <Compile Include="Interfaces\ISymbolicDataAnalysisExpressionCrossover.cs" />
     142    <Compile Include="Interfaces\ISymbolicDataAnalysisImpactValuesCalculator.cs" />
    142143    <Compile Include="Interpreter\InterpreterState.cs" />
    143144    <Compile Include="Interpreter\OpCodes.cs" />
     
    164165    <Compile Include="SymbolicDataAnalysisExpressionTreeSimplifier.cs" />
    165166    <Compile Include="SymbolicDataAnalysisProblem.cs" />
     167    <Compile Include="SymbolicDataAnalysisSolutionImpactValuesCalculator.cs" />
    166168    <Compile Include="Symbols\Addition.cs" />
    167169    <Compile Include="Symbols\And.cs" />
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Interfaces/ISymbolicDataAnalysisImpactValuesCalculator.cs

    r8942 r8946  
    44namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    55  public interface ISymbolicDataAnalysisSolutionImpactValuesCalculator {
    6     Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree,
    7                                                                                ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
    8                                                                                IDataAnalysisProblemData problemData);
    9     Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree,
    10                                                                           ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
    11                                                                           IDataAnalysisProblemData problemData,
    12                                                                           double lowerEstimationLimit, double upperEstimationLimit);
     6    double CalculateReplacementValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows);
     7    double CalculateImpactValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows, double originalQuality = double.NaN);
    138  }
    149}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Properties

    • Property svn:ignore
      --- 
      +++ 
      
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisSolutionImpactValuesCalculator.cs

    r8942 r8946  
    2020#endregion
    2121
    22 using System;
    2322using System.Collections.Generic;
    2423using HeuristicLab.Common;
     
    2625
    2726namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    28   public abstract class SymbolicDataAnalysisSolutionImpactValuesCalculator {
    29     public abstract IEnumerable<Tuple<ISymbolicExpressionTreeNode, double>> CalculateReplacementValues(ISymbolicExpressionTree tree,
    30                                                                                                        ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
    31                                                                                                        IDataAnalysisProblemData problemData);
    32     public abstract IEnumerable<Tuple<ISymbolicExpressionTreeNode, double>> CalculateImpactValues(ISymbolicExpressionTree tree,
    33                                                                                                   ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
    34                                                                                                   IDataAnalysisProblemData problemData,
    35                                                                                                   double lowerEstimationLimit, double upperEstimationLimit);
     27  public abstract class SymbolicDataAnalysisSolutionImpactValuesCalculator : ISymbolicDataAnalysisSolutionImpactValuesCalculator {
     28    public abstract double CalculateReplacementValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows);
     29    public abstract double CalculateImpactValue(ISymbolicDataAnalysisModel model, ISymbolicExpressionTreeNode node, IDataAnalysisProblemData problemData, IEnumerable<int> rows, double originalQuality = double.NaN);
    3630
    37     protected static void SwitchNode(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode oldBranch, ISymbolicExpressionTreeNode newBranch) {
    38       for (int i = 0; i < root.SubtreeCount; i++) {
    39         if (root.GetSubtree(i) == oldBranch) {
    40           root.RemoveSubtree(i);
    41           root.InsertSubtree(i, newBranch);
    42           return;
    43         }
    44       }
    45     }
     31    protected static double CalculateReplacementValue(ISymbolicExpressionTreeNode node, ISymbolicExpressionTree sourceTree, ISymbolicDataAnalysisExpressionTreeInterpreter interpreter,
     32      Dataset dataset, IEnumerable<int> rows) {
     33      //optimization: constant nodes return always the same value
     34      ConstantTreeNode constantNode = node as ConstantTreeNode;
     35      if (constantNode != null) return constantNode.Value;
    4636
    47     protected static double CalculateReplacementValue(ISymbolicExpressionTreeNode node, ISymbolicExpressionTree sourceTree,
    48                                                       ISymbolicDataAnalysisExpressionTreeInterpreter interpreter, IDataAnalysisProblemData problemData) {
    4937      var rootSymbol = new ProgramRootSymbol().CreateTreeNode();
    5038      var startSymbol = new StartSymbol().CreateTreeNode();
    5139      rootSymbol.AddSubtree(startSymbol);
    5240      startSymbol.AddSubtree((ISymbolicExpressionTreeNode)node.Clone());
    53       var rows = problemData.TrainingIndices;
     41
    5442      var tempTree = new SymbolicExpressionTree(rootSymbol);
    55       return interpreter.GetSymbolicExpressionTreeValues(tempTree, problemData.Dataset, rows).Median();
     43      // clone ADFs of source tree
     44      for (int i = 1; i < sourceTree.Root.SubtreeCount; i++) {
     45        tempTree.Root.AddSubtree((ISymbolicExpressionTreeNode)sourceTree.Root.GetSubtree(i).Clone());
     46      }
     47      return interpreter.GetSymbolicExpressionTreeValues(tempTree, dataset, rows).Median();
    5648    }
    5749  }
Note: See TracChangeset for help on using the changeset viewer.