Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10872


Ignore:
Timestamp:
05/21/14 12:54:01 (9 years ago)
Author:
tsteinre
Message:
  • modified TransformationToSymbolicTreeMapper Interface derivation
Location:
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicExpressionTreeBacktransformator.cs

    r10869 r10872  
    2727namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    2828  public class SymbolicExpressionTreeBacktransformator : IModelBacktransformator {
    29     private readonly ITransformationMapper<ISymbolicExpressionTree> transformationMapper;
     29    private readonly ITransformationMapper<ISymbolicExpressionTreeNode> transformationMapper;
    3030
    31     public SymbolicExpressionTreeBacktransformator(ITransformationMapper<ISymbolicExpressionTree> transformationMapper) {
     31    public SymbolicExpressionTreeBacktransformator(ITransformationMapper<ISymbolicExpressionTreeNode> transformationMapper) {
    3232      this.transformationMapper = transformationMapper;
    3333    }
     
    5151    }
    5252
    53     private void SwapTransformationTree(ISymbolicExpressionTree transformationTree, ISymbolicExpressionTreeNode targetNode) {
     53    private void SwapTransformationTree(ISymbolicExpressionTreeNode transformationTreeNode, ISymbolicExpressionTreeNode targetNode) {
    5454      var parent = targetNode.Parent;
    5555      int index = parent.IndexOfSubtree(targetNode);
    5656      parent.RemoveSubtree(index);
    57       parent.InsertSubtree(index, transformationTree.Root.GetSubtree(0));
     57      parent.InsertSubtree(index, transformationTreeNode);
    5858    }
    5959
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TransformationToSymbolicTreeMapper.cs

    r10869 r10872  
    2525
    2626namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    27   public class TransformationToSymbolicTreeMapper : ITransformationMapper<ISymbolicExpressionTree> {
     27  public class TransformationToSymbolicTreeMapper : ITransformationMapper<ISymbolicExpressionTreeNode> {
    2828    private ITransformation transformation;
    2929    private string column;
    30     private ISymbolicExpressionTree tree;
    3130
    3231    #region ITransformationMapper<ISymbolicExpressionTree> Members
    3332
    34     public ISymbolicExpressionTree GenerateModel(ITransformation transformation) {
     33    public ISymbolicExpressionTreeNode GenerateModel(ITransformation transformation) {
    3534      InitComponents(transformation);
    3635
     
    5150    }
    5251
    53     public ISymbolicExpressionTree GenerateInverseModel(ITransformation transformation) {
     52    public ISymbolicExpressionTreeNode GenerateInverseModel(ITransformation transformation) {
    5453      InitComponents(transformation);
    5554
     
    7574    // helper
    7675
    77     private ISymbolicExpressionTree GenerateModelForLinearTransformation() {
     76    private ISymbolicExpressionTreeNode GenerateModelForLinearTransformation() {
    7877      var linearTransformation = (LinearTransformation)transformation;
    7978      var kValue = linearTransformation.Multiplier;
     
    9392      additionNode.AddSubtree(dNode);
    9493
    95       tree.Root.AddSubtree(additionNode);
    96       return tree;
    97     }
    98 
    99     private ISymbolicExpressionTree GenerateInverseModelForLinearTransformation() {
     94      return additionNode;
     95    }
     96
     97    private ISymbolicExpressionTreeNode GenerateInverseModelForLinearTransformation() {
    10098      var linearTransformation = (LinearTransformation)transformation;
    10199      var kValue = linearTransformation.Multiplier;
     
    115113      divisionNode.AddSubtree(kNode);
    116114
    117       tree.Root.AddSubtree(divisionNode);
    118       return tree;
    119     }
    120 
    121 
    122     private ISymbolicExpressionTree GenerateModelForExponentialTransformation() {
     115      return divisionNode;
     116    }
     117
     118
     119    private ISymbolicExpressionTreeNode GenerateModelForExponentialTransformation() {
    123120      var exponentialTransformation = (ExponentialTransformation)transformation;
    124121      var bValue = exponentialTransformation.Base;
     
    127124    }
    128125
    129     private ISymbolicExpressionTree GenerateInverseModelForExponentialTransformation() {
     126    private ISymbolicExpressionTreeNode GenerateInverseModelForExponentialTransformation() {
    130127      var exponentialTransformation = (ExponentialTransformation)transformation;
    131128      var bValue = exponentialTransformation.Base;
     
    135132
    136133
    137     private ISymbolicExpressionTree GenerateModelForLogarithmicTransformation() {
     134    private ISymbolicExpressionTreeNode GenerateModelForLogarithmicTransformation() {
    138135      var logarithmicTransformation = (LogarithmicTransformation)transformation;
    139136      var bValue = logarithmicTransformation.Base;
     
    142139    }
    143140
    144     private ISymbolicExpressionTree GenerateInverseModelForLogarithmicTransformation() {
     141    private ISymbolicExpressionTreeNode GenerateInverseModelForLogarithmicTransformation() {
    145142      var logarithmicTransformation = (LogarithmicTransformation)transformation;
    146143      var bValue = logarithmicTransformation.Base;
     
    150147
    151148
    152     private ISymbolicExpressionTree GenerateModelForPowerTransformation() {
     149    private ISymbolicExpressionTreeNode GenerateModelForPowerTransformation() {
    153150      var powerTransformation = (PowerTransformation)transformation;
    154151      var expValue = powerTransformation.Exponent;
     
    161158      powerNode.AddSubtree(expNode);
    162159
    163       tree.Root.AddSubtree(powerNode);
    164       return tree;
    165     }
    166 
    167     private ISymbolicExpressionTree GenerateInverseModelForPowerTransformation() {
     160      return powerNode;
     161    }
     162
     163    private ISymbolicExpressionTreeNode GenerateInverseModelForPowerTransformation() {
    168164      var powerTransformation = (PowerTransformation)transformation;
    169165      var expValue = powerTransformation.Exponent;
     
    176172      rootNode.AddSubtree(bNode);
    177173
    178       tree.Root.AddSubtree(rootNode);
    179       return tree;
    180     }
    181 
    182 
    183     private ISymbolicExpressionTree GenerateModelForReciprocalTransformation() {
     174      return rootNode;
     175    }
     176
     177
     178    private ISymbolicExpressionTreeNode GenerateModelForReciprocalTransformation() {
    184179      return GenTreeDiv_1_x();
    185180    }
    186181
    187     private ISymbolicExpressionTree GenerateInverseModelForReciprocalTransformation() {
     182    private ISymbolicExpressionTreeNode GenerateInverseModelForReciprocalTransformation() {
    188183      return GenTreeDiv_1_x();
    189184    }
    190185
    191     private ISymbolicExpressionTree GenerateModelForShiftStandardDistributionTransformation() {
     186
     187    private ISymbolicExpressionTreeNode GenerateModelForShiftStandardDistributionTransformation() {
    192188      var shiftStandardDistributionTransformation = (ShiftStandardDistributionTransformation)transformation;
    193189      var m_orgValue = shiftStandardDistributionTransformation.OriginalMean;
     
    199195    }
    200196
    201     private ISymbolicExpressionTree GenerateInverseModelForShiftStandardDistributionTransformation() {
     197    private ISymbolicExpressionTreeNode GenerateInverseModelForShiftStandardDistributionTransformation() {
    202198      var shiftStandardDistributionTransformation = (ShiftStandardDistributionTransformation)transformation;
    203199      var m_orgValue = shiftStandardDistributionTransformation.OriginalMean;
     
    211207    // helper's helper:
    212208
    213     private ISymbolicExpressionTree GenTreeLog_x_b(double b) {
    214       var tree = CreateNewTree();
    215 
     209    private ISymbolicExpressionTreeNode GenTreeLog_x_b(double b) {
    216210      // log(x, b)
    217211      var logNode = new Logarithm().CreateTreeNode();
     
    221215      logNode.AddSubtree(bNode);
    222216
    223       tree.Root.AddSubtree(logNode);
    224       return tree;
    225     }
    226 
    227     private ISymbolicExpressionTree GenTreePow_b_x(double b) {
    228       var tree = CreateNewTree();
    229 
     217      return logNode;
     218    }
     219
     220    private ISymbolicExpressionTreeNode GenTreePow_b_x(double b) {
    230221      // b ^ x
    231222      var powerNode = new Power().CreateTreeNode();
     
    235226      powerNode.AddSubtree(xNode);
    236227
    237       tree.Root.AddSubtree(powerNode);
    238       return tree;
    239     }
    240 
    241     private ISymbolicExpressionTree GenTreeDiv_1_x() {
    242       var tree = CreateNewTree();
    243 
     228      return powerNode;
     229    }
     230
     231    private ISymbolicExpressionTreeNode GenTreeDiv_1_x() {
    244232      // 1 / x
    245233      var divNode = new Division().CreateTreeNode();
     
    249237      divNode.AddSubtree(xNode);
    250238
    251       tree.Root.AddSubtree(divNode);
    252       return tree;
    253     }
    254     private ISymbolicExpressionTree GenTreeShiftStdDist(string variable, double m_org, double s_org, double m_tar, double s_tar) {
    255       var tree = CreateNewTree();
     239      return divNode;
     240    }
     241
     242    private ISymbolicExpressionTreeNode GenTreeShiftStdDist(string variable, double m_org, double s_org, double m_tar, double s_tar) {
    256243      // x - m_org
    257244      var substractionNode = new Subtraction().CreateTreeNode();
     
    279266      additionNode.AddSubtree(m_tarNode);
    280267
    281       tree.Root.AddSubtree(additionNode);
    282       return tree;
     268      return additionNode;
    283269    }
    284270
     
    286272      return new ConstantTreeNode(new Constant()) { Value = value };
    287273    }
     274
    288275    private ISymbolicExpressionTreeNode CreateVariableTreeNode(string name, string description) {
    289276      return new Variable(name, description).CreateTreeNode();
    290     }
    291 
    292 
    293     private ISymbolicExpressionTree CreateNewTree() {
    294       return new SymbolicExpressionTree(new ProgramRootSymbol().CreateTreeNode());
    295277    }
    296278
     
    298280      this.transformation = transformation;
    299281      column = transformation.Column;
    300       tree = CreateNewTree();
    301282    }
    302283  }
Note: See TracChangeset for help on using the changeset viewer.