- Timestamp:
- 05/21/14 12:54:01 (11 years ago)
- 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 27 27 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 28 28 public class SymbolicExpressionTreeBacktransformator : IModelBacktransformator { 29 private readonly ITransformationMapper<ISymbolicExpressionTree > transformationMapper;29 private readonly ITransformationMapper<ISymbolicExpressionTreeNode> transformationMapper; 30 30 31 public SymbolicExpressionTreeBacktransformator(ITransformationMapper<ISymbolicExpressionTree > transformationMapper) {31 public SymbolicExpressionTreeBacktransformator(ITransformationMapper<ISymbolicExpressionTreeNode> transformationMapper) { 32 32 this.transformationMapper = transformationMapper; 33 33 } … … 51 51 } 52 52 53 private void SwapTransformationTree(ISymbolicExpressionTree transformationTree, ISymbolicExpressionTreeNode targetNode) {53 private void SwapTransformationTree(ISymbolicExpressionTreeNode transformationTreeNode, ISymbolicExpressionTreeNode targetNode) { 54 54 var parent = targetNode.Parent; 55 55 int index = parent.IndexOfSubtree(targetNode); 56 56 parent.RemoveSubtree(index); 57 parent.InsertSubtree(index, transformationTree .Root.GetSubtree(0));57 parent.InsertSubtree(index, transformationTreeNode); 58 58 } 59 59 -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TransformationToSymbolicTreeMapper.cs
r10869 r10872 25 25 26 26 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 27 public class TransformationToSymbolicTreeMapper : ITransformationMapper<ISymbolicExpressionTree > {27 public class TransformationToSymbolicTreeMapper : ITransformationMapper<ISymbolicExpressionTreeNode> { 28 28 private ITransformation transformation; 29 29 private string column; 30 private ISymbolicExpressionTree tree;31 30 32 31 #region ITransformationMapper<ISymbolicExpressionTree> Members 33 32 34 public ISymbolicExpressionTree GenerateModel(ITransformation transformation) {33 public ISymbolicExpressionTreeNode GenerateModel(ITransformation transformation) { 35 34 InitComponents(transformation); 36 35 … … 51 50 } 52 51 53 public ISymbolicExpressionTree GenerateInverseModel(ITransformation transformation) {52 public ISymbolicExpressionTreeNode GenerateInverseModel(ITransformation transformation) { 54 53 InitComponents(transformation); 55 54 … … 75 74 // helper 76 75 77 private ISymbolicExpressionTree GenerateModelForLinearTransformation() {76 private ISymbolicExpressionTreeNode GenerateModelForLinearTransformation() { 78 77 var linearTransformation = (LinearTransformation)transformation; 79 78 var kValue = linearTransformation.Multiplier; … … 93 92 additionNode.AddSubtree(dNode); 94 93 95 tree.Root.AddSubtree(additionNode); 96 return tree; 97 } 98 99 private ISymbolicExpressionTree GenerateInverseModelForLinearTransformation() { 94 return additionNode; 95 } 96 97 private ISymbolicExpressionTreeNode GenerateInverseModelForLinearTransformation() { 100 98 var linearTransformation = (LinearTransformation)transformation; 101 99 var kValue = linearTransformation.Multiplier; … … 115 113 divisionNode.AddSubtree(kNode); 116 114 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() { 123 120 var exponentialTransformation = (ExponentialTransformation)transformation; 124 121 var bValue = exponentialTransformation.Base; … … 127 124 } 128 125 129 private ISymbolicExpressionTree GenerateInverseModelForExponentialTransformation() {126 private ISymbolicExpressionTreeNode GenerateInverseModelForExponentialTransformation() { 130 127 var exponentialTransformation = (ExponentialTransformation)transformation; 131 128 var bValue = exponentialTransformation.Base; … … 135 132 136 133 137 private ISymbolicExpressionTree GenerateModelForLogarithmicTransformation() {134 private ISymbolicExpressionTreeNode GenerateModelForLogarithmicTransformation() { 138 135 var logarithmicTransformation = (LogarithmicTransformation)transformation; 139 136 var bValue = logarithmicTransformation.Base; … … 142 139 } 143 140 144 private ISymbolicExpressionTree GenerateInverseModelForLogarithmicTransformation() {141 private ISymbolicExpressionTreeNode GenerateInverseModelForLogarithmicTransformation() { 145 142 var logarithmicTransformation = (LogarithmicTransformation)transformation; 146 143 var bValue = logarithmicTransformation.Base; … … 150 147 151 148 152 private ISymbolicExpressionTree GenerateModelForPowerTransformation() {149 private ISymbolicExpressionTreeNode GenerateModelForPowerTransformation() { 153 150 var powerTransformation = (PowerTransformation)transformation; 154 151 var expValue = powerTransformation.Exponent; … … 161 158 powerNode.AddSubtree(expNode); 162 159 163 tree.Root.AddSubtree(powerNode); 164 return tree; 165 } 166 167 private ISymbolicExpressionTree GenerateInverseModelForPowerTransformation() { 160 return powerNode; 161 } 162 163 private ISymbolicExpressionTreeNode GenerateInverseModelForPowerTransformation() { 168 164 var powerTransformation = (PowerTransformation)transformation; 169 165 var expValue = powerTransformation.Exponent; … … 176 172 rootNode.AddSubtree(bNode); 177 173 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() { 184 179 return GenTreeDiv_1_x(); 185 180 } 186 181 187 private ISymbolicExpressionTree GenerateInverseModelForReciprocalTransformation() {182 private ISymbolicExpressionTreeNode GenerateInverseModelForReciprocalTransformation() { 188 183 return GenTreeDiv_1_x(); 189 184 } 190 185 191 private ISymbolicExpressionTree GenerateModelForShiftStandardDistributionTransformation() { 186 187 private ISymbolicExpressionTreeNode GenerateModelForShiftStandardDistributionTransformation() { 192 188 var shiftStandardDistributionTransformation = (ShiftStandardDistributionTransformation)transformation; 193 189 var m_orgValue = shiftStandardDistributionTransformation.OriginalMean; … … 199 195 } 200 196 201 private ISymbolicExpressionTree GenerateInverseModelForShiftStandardDistributionTransformation() {197 private ISymbolicExpressionTreeNode GenerateInverseModelForShiftStandardDistributionTransformation() { 202 198 var shiftStandardDistributionTransformation = (ShiftStandardDistributionTransformation)transformation; 203 199 var m_orgValue = shiftStandardDistributionTransformation.OriginalMean; … … 211 207 // helper's helper: 212 208 213 private ISymbolicExpressionTree GenTreeLog_x_b(double b) { 214 var tree = CreateNewTree(); 215 209 private ISymbolicExpressionTreeNode GenTreeLog_x_b(double b) { 216 210 // log(x, b) 217 211 var logNode = new Logarithm().CreateTreeNode(); … … 221 215 logNode.AddSubtree(bNode); 222 216 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) { 230 221 // b ^ x 231 222 var powerNode = new Power().CreateTreeNode(); … … 235 226 powerNode.AddSubtree(xNode); 236 227 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() { 244 232 // 1 / x 245 233 var divNode = new Division().CreateTreeNode(); … … 249 237 divNode.AddSubtree(xNode); 250 238 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) { 256 243 // x - m_org 257 244 var substractionNode = new Subtraction().CreateTreeNode(); … … 279 266 additionNode.AddSubtree(m_tarNode); 280 267 281 tree.Root.AddSubtree(additionNode); 282 return tree; 268 return additionNode; 283 269 } 284 270 … … 286 272 return new ConstantTreeNode(new Constant()) { Value = value }; 287 273 } 274 288 275 private ISymbolicExpressionTreeNode CreateVariableTreeNode(string name, string description) { 289 276 return new Variable(name, description).CreateTreeNode(); 290 }291 292 293 private ISymbolicExpressionTree CreateNewTree() {294 return new SymbolicExpressionTree(new ProgramRootSymbol().CreateTreeNode());295 277 } 296 278 … … 298 280 this.transformation = transformation; 299 281 column = transformation.Column; 300 tree = CreateNewTree();301 282 } 302 283 }
Note: See TracChangeset
for help on using the changeset viewer.