- Timestamp:
- 03/31/11 18:41:41 (14 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
r5809 r5915 905 905 } else if (IsMultiplication(x) || IsDivision(x)) { 906 906 // x0 * x1 * .. * xn * -1 => x0 * x1 * .. * -xn 907 x.RemoveSubtree(x.Subtrees.Count() - 1); 908 x.AddSubtree(Negate(x.Subtrees.Last())); // last is maybe a constant, prefer to negate the constant 907 var lastSubTree = x.Subtrees.Last(); 908 x.RemoveSubtree(x.SubtreesCount - 1); 909 x.AddSubtree(Negate(lastSubTree)); // last is maybe a constant, prefer to negate the constant 909 910 } else { 910 911 // any other function -
trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tests/SymbolicDataAnalysisExpressionTreeSimplifierTest.cs
r5809 r5915 162 162 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 163 163 } 164 { 165 // exp transformation 166 var actualTree = simplifier.Simplify(importer.Import("(exp (- (variable 2.0 a) (* (variable 3.0 b) (variable 4.0 c))))")); 167 var expectedTree = importer.Import("(* (exp (variable 2.0 a)) (exp (* (variable 1.0 b) (variable 1.0 c) -12.0)))"); 168 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 169 } 170 { 171 // exp transformation 172 var actualTree = simplifier.Simplify(importer.Import("(exp (- (variable 2.0 a) (* (variable 3.0 b) (cos (variable 4.0 c)))))")); 173 var expectedTree = importer.Import("(* (exp (variable 2.0 a)) (exp (* (variable 1.0 b) (cos (variable 4.0 c)) -3.0)))"); 174 Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree)); 175 } 164 176 #endregion 165 177 #region power rules
Note: See TracChangeset
for help on using the changeset viewer.