Changeset 6774
- Timestamp:
- 09/15/11 16:56:16 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimplifier.cs
r5936 r6774 538 538 } else if (IsExp(node)) { 539 539 return node.GetSubtree(0); 540 } else if (IsMultiplication(node)) {541 return node.Subtrees.Select(s => MakeLog(s)).Aggregate((x, y) => MakeSum(x, y));542 } else if (IsDivision(node)) {543 var subtractionNode = subSymbol.CreateTreeNode();544 foreach (var subtree in node.Subtrees) {545 subtractionNode.AddSubtree(MakeLog(subtree));546 }547 return subtractionNode;548 540 } else { 549 541 var logNode = logSymbol.CreateTreeNode(); -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tests/SymbolicDataAnalysisExpressionTreeSimplifierTest.cs
r5915 r6774 131 131 } 132 132 { 133 // log transformation134 var actualTree = simplifier.Simplify(importer.Import("(log (* (variable 2.0 a) (variable 3.0 b)))"));135 var expectedTree = importer.Import("( + (log (variable 1.0 a)) (log (variable 1.0 b)) 1.7918)");136 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 137 } 138 { 139 // log transformation140 var actualTree = simplifier.Simplify(importer.Import("(log (/ (variable 2.0 a) (variable 3.0 b)))"));141 var expectedTree = importer.Import("( - (log (variable 2.0 a)) (log (variable 3.0 b)))");133 // must not transform logs in this way as we do not know wether both variables are positive 134 var actualTree = simplifier.Simplify(importer.Import("(log (* (variable 1.0 a) (variable 1.0 b)))")); 135 var expectedTree = importer.Import("(log (* (variable 1.0 a) (variable 1.0 b)))"); 136 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 137 } 138 { 139 // must not transform logs in this way as we do not know wether both variables are positive 140 var actualTree = simplifier.Simplify(importer.Import("(log (/ (variable 1.0 a) (variable 1.0 b)))")); 141 var expectedTree = importer.Import("(log (/ (variable 1.0 a) (variable 1.0 b)))"); 142 142 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 143 143 }
Note: See TracChangeset
for help on using the changeset viewer.