Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/15/11 16:56:16 (13 years ago)
Author:
gkronber
Message:

#1645: fixed bug related to simplification of logarithmic expressions

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  
    538538      } else if (IsExp(node)) {
    539539        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;
    548540      } else {
    549541        var logNode = logSymbol.CreateTreeNode();
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tests/SymbolicDataAnalysisExpressionTreeSimplifierTest.cs

    r5915 r6774  
    131131      }
    132132      {
    133         // log transformation
    134         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 transformation
    140         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)))");
    142142        Assert.AreEqual(formatter.Format(expectedTree), formatter.Format(actualTree));
    143143      }
Note: See TracChangeset for help on using the changeset viewer.