Changeset 10866
- Timestamp:
- 05/21/14 10:58:35 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TransformationToSymbolicTreeMapper.cs
r10853 r10866 65 65 return GenerateInverseModelForReciprocalTransformation(); 66 66 } else if (transformation is ShiftStandardDistributionTransformation) { 67 67 GenerateInverseModelForShiftStandardDistributionTransformation(); 68 68 } 69 69 … … 82 82 // k * x 83 83 var multiplicationNode = new Multiplication().CreateTreeNode(); 84 var kNode = new ConstantTreeNode(new Constant() { Description = "K" }) { Value = kValue };85 var xNode = new Variable(column, "x").CreateTreeNode();84 var kNode = CreateConstantTreeNode("k", kValue); 85 var xNode = CreateVariableTreeNode(column, "x"); 86 86 multiplicationNode.AddSubtree(kNode); 87 87 multiplicationNode.AddSubtree(xNode); … … 89 89 // ( k * x ) + d 90 90 var additionNode = new Addition().CreateTreeNode(); 91 var dNode = new ConstantTreeNode(new Constant() { Description = "d" }) { Value = dValue };91 var dNode = CreateConstantTreeNode("d", dValue); 92 92 additionNode.AddSubtree(multiplicationNode); 93 93 additionNode.AddSubtree(dNode); … … 104 104 // x - d 105 105 var substractionNode = new Subtraction().CreateTreeNode(); 106 var dNode = new ConstantTreeNode(new Constant() { Description = "d" }) { Value = dValue };107 var xNode = new Variable(column, "x").CreateTreeNode();106 var dNode = CreateConstantTreeNode("d", dValue); 107 var xNode = CreateVariableTreeNode(column, "x"); 108 108 substractionNode.AddSubtree(xNode); 109 109 substractionNode.AddSubtree(dNode); … … 111 111 // ( x - d ) / k 112 112 var divisionNode = new Division().CreateTreeNode(); 113 var kNode = new ConstantTreeNode(new Constant() { Description = "K" }) { Value = kValue };113 var kNode = CreateConstantTreeNode("k", kValue); 114 114 divisionNode.AddSubtree(substractionNode); 115 115 divisionNode.AddSubtree(kNode); … … 156 156 // x ^ exp 157 157 var powerNode = new Power().CreateTreeNode(); 158 var xNode = new Variable(column, "x").CreateTreeNode();159 var expNode = new ConstantTreeNode(new Constant() { Description = "exp" }) { Value = expValue };158 var xNode = CreateVariableTreeNode(column, "x"); 159 var expNode = CreateConstantTreeNode("exp", expValue); 160 160 powerNode.AddSubtree(xNode); 161 161 powerNode.AddSubtree(expNode); … … 171 171 // rt(x, b) 172 172 var rootNode = new Root().CreateTreeNode(); 173 var xNode = new Variable(column, "x").CreateTreeNode();174 var bNode = new ConstantTreeNode(new Constant() { Description = "b" }) { Value = expValue };173 var xNode = CreateVariableTreeNode(column, "x"); 174 var bNode = CreateConstantTreeNode("b", expValue); 175 175 rootNode.AddSubtree(xNode); 176 176 rootNode.AddSubtree(bNode); … … 196 196 var s_tarValue = shiftStandardDistributionTransformation.StandardDeviation; 197 197 198 return GenTreeShiftStdDist(column, m_orgValue, s_orgValue, m_tarValue, s_tarValue); 199 } 200 201 private ISymbolicExpressionTree GenerateInverseModelForShiftStandardDistributionTransformation() { 202 var shiftStandardDistributionTransformation = (ShiftStandardDistributionTransformation)transformation; 203 var m_orgValue = shiftStandardDistributionTransformation.OriginalMean; 204 var s_orgValue = shiftStandardDistributionTransformation.OriginalStandardDeviation; 205 var m_tarValue = shiftStandardDistributionTransformation.Mean; 206 var s_tarValue = shiftStandardDistributionTransformation.StandardDeviation; 207 208 return GenTreeShiftStdDist(column, m_tarValue, s_tarValue, m_orgValue, s_orgValue); 209 } 210 211 // helper's helper: 212 213 private ISymbolicExpressionTree GenTreeLog_x_b(double b) { 214 var tree = CreateNewTree(); 215 216 // log(x, b) 217 var logNode = new Logarithm().CreateTreeNode(); 218 var bNode = CreateConstantTreeNode("b", b); 219 var xNode = CreateVariableTreeNode(column, "x"); 220 logNode.AddSubtree(xNode); 221 logNode.AddSubtree(bNode); 222 223 tree.Root.AddSubtree(logNode); 224 return tree; 225 } 226 227 private ISymbolicExpressionTree GenTreePow_b_x(double b) { 228 var tree = CreateNewTree(); 229 230 // b ^ x 231 var powerNode = new Power().CreateTreeNode(); 232 var bNode = CreateConstantTreeNode("b", b); 233 var xNode = CreateVariableTreeNode(column, "x"); 234 powerNode.AddSubtree(bNode); 235 powerNode.AddSubtree(xNode); 236 237 tree.Root.AddSubtree(powerNode); 238 return tree; 239 } 240 241 private ISymbolicExpressionTree GenTreeDiv_1_x() { 242 var tree = CreateNewTree(); 243 244 // 1 / x 245 var divNode = new Division().CreateTreeNode(); 246 var oneNode = CreateConstantTreeNode("1", 1.0); 247 var xNode = CreateVariableTreeNode(column, "x"); 248 divNode.AddSubtree(oneNode); 249 divNode.AddSubtree(xNode); 250 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(); 198 256 // x - m_org 199 257 var substractionNode = new Subtraction().CreateTreeNode(); 200 var xNode = new Variable(column, "x").CreateTreeNode();201 var m_orgNode = new ConstantTreeNode(new Constant() { Description = "m_org" }) { Value = m_orgValue };258 var xNode = CreateVariableTreeNode(variable, "x"); 259 var m_orgNode = CreateConstantTreeNode("m_org", m_org); 202 260 substractionNode.AddSubtree(xNode); 203 261 substractionNode.AddSubtree(m_orgNode); … … 205 263 // (x - m_org) / s_org 206 264 var divisionNode = new Division().CreateTreeNode(); 207 var s_orgNode = new ConstantTreeNode(new Constant() { Description = "s_org" }) { Value = s_orgValue };265 var s_orgNode = CreateConstantTreeNode("s_org", s_org); 208 266 divisionNode.AddSubtree(substractionNode); 209 267 divisionNode.AddSubtree(s_orgNode); … … 211 269 // ((x - m_org) / s_org ) * s_tar 212 270 var multiplicationNode = new Multiplication().CreateTreeNode(); 213 var s_tarNode = new ConstantTreeNode(new Constant() { Description = "s_tar" }) { Value = s_tarValue };271 var s_tarNode = CreateConstantTreeNode("s_tar", s_tar); 214 272 multiplicationNode.AddSubtree(divisionNode); 215 273 multiplicationNode.AddSubtree(s_tarNode); … … 217 275 // ((x - m_org) / s_org ) * s_tar + m_tar 218 276 var additionNode = new Addition().CreateTreeNode(); 219 var m_tarNode = new ConstantTreeNode(new Constant() { Description = "m_tar" }) { Value = m_tarValue };277 var m_tarNode = CreateConstantTreeNode("m_tar", m_tar); 220 278 additionNode.AddSubtree(multiplicationNode); 221 279 additionNode.AddSubtree(m_tarNode); … … 225 283 } 226 284 227 // helper's helper: 228 229 private ISymbolicExpressionTree GenTreeLog_x_b(double b) { 230 var tree = CreateNewTree(); 231 232 // log(x, b) 233 var logNode = new Logarithm().CreateTreeNode(); 234 var bNode = new ConstantTreeNode(new Constant() { Description = "b" }) { Value = b }; 235 var xNode = new Variable(column, "x").CreateTreeNode(); 236 logNode.AddSubtree(xNode); 237 logNode.AddSubtree(bNode); 238 239 tree.Root.AddSubtree(logNode); 240 return tree; 241 } 242 243 private ISymbolicExpressionTree GenTreePow_b_x(double b) { 244 var tree = CreateNewTree(); 245 246 // b ^ x 247 var powerNode = new Power().CreateTreeNode(); 248 var bNode = new ConstantTreeNode(new Constant() { Description = "b" }) { Value = b }; 249 var xNode = new Variable(column, "x").CreateTreeNode(); 250 powerNode.AddSubtree(bNode); 251 powerNode.AddSubtree(xNode); 252 253 tree.Root.AddSubtree(powerNode); 254 return tree; 255 } 256 257 private ISymbolicExpressionTree GenTreeDiv_1_x() { 258 var tree = CreateNewTree(); 259 260 // 1 / x 261 var divNode = new Division().CreateTreeNode(); 262 var oneNode = new ConstantTreeNode(new Constant() { Description = "1" }) { Value = 1.0 }; 263 var xNode = new Variable(column, "x").CreateTreeNode(); 264 divNode.AddSubtree(oneNode); 265 divNode.AddSubtree(xNode); 266 267 tree.Root.AddSubtree(divNode); 268 return tree; 285 private ConstantTreeNode CreateConstantTreeNode(string description, double value) { 286 return new ConstantTreeNode(new Constant() { Description = description }) { Value = value }; 287 } 288 private ISymbolicExpressionTreeNode CreateVariableTreeNode(string name, string description) { 289 return new Variable(name, description).CreateTreeNode(); 269 290 } 270 291
Note: See TracChangeset
for help on using the changeset viewer.