Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11986 for stable


Ignore:
Timestamp:
02/12/15 15:31:09 (9 years ago)
Author:
jkarder
Message:

#2313: merged r11978 into stable

Location:
stable
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic

  • stable/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeBottomUpSimilarityCalculator.cs

    r11964 r11986  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    8181
    8282      // visit nodes in order of decreasing height to ensure correct mapping
    83       var nodes1 = n1.IterateNodesPrefix().ToList();
     83      var nodes1 = n1.IterateNodesPrefix().OrderByDescending(x => x.GetDepth()).ToList();
    8484      var nodes2 = n2.IterateNodesPrefix().ToList();
    8585      for (int i = 0; i < nodes1.Count; ++i) {
     
    9898        if (w == null) continue;
    9999
    100         // at this point we know that v and w are isomorphic, however, the mapping cannot be done directly (as in the paper) because the trees are unordered (subtree order might differ)
    101         // the solution is to sort subtrees by label using IterateBreadthOrdered (this will work because the subtrees are isomorphic!) and simultaneously iterate over the two subtrees
     100        // at this point we know that v and w are isomorphic, however, the mapping cannot be done directly
     101        // (as in the paper) because the trees are unordered (subtree order might differ). the solution is
     102        // to sort subtrees from under commutative labels (this will work because the subtrees are isomorphic!)
     103        // while iterating over the two subtrees
    102104        var vv = IterateBreadthOrdered(v, comparer).ToList();
    103105        var ww = IterateBreadthOrdered(w, comparer).ToList();
     
    133135      foreach (var n in nodes) {
    134136        if (n.SubtreeCount == 0) {
    135           var label = Label(n);
     137          var label = GetLabel(n);
    136138          if (!labelMap.ContainsKey(label)) {
    137139            var z = new GraphNode { SymbolicExpressionTreeNode = n, Label = label };
     
    209211    }
    210212
    211     private string Label(ISymbolicExpressionTreeNode node) {
     213    private static string GetLabel(ISymbolicExpressionTreeNode node) {
    212214      if (node.SubtreeCount > 0)
    213215        return node.Symbol.Name;
  • stable/HeuristicLab.Tests

  • stable/HeuristicLab.Tests/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4/SymbolicExpressionTreeBottomUpSimilarityCalculatorTest.cs

    r11964 r11986  
    3636        "(* (- (variable 9.581e-1 X6) (+ (- (variable 5.1491e-1 X5) 1.614e+1) (+ (/ (variable 2.0539 X5) (variable -9.2452e-1 X6)) (log (/ (variable 2.0539 X5) (variable -9.2452e-1 X6)))))) 2.9081)",
    3737        9);
     38
     39      TestMatchedNodes("(* (* (* (variable 1.68 x) (* (variable 1.68 x) (variable 2.55 x))) (variable 1.68 x)) (* (* (variable 1.68 x) (* (variable 1.68 x) (* (variable 1.68 x) (variable 2.55 x)))) (variable 2.55 x)))", "(* (variable 2.55 x) (* (variable 1.68 x) (* (variable 1.68 x) (* (variable 1.68 x) (variable 2.55 x)))))", 9);
    3840
    3941      TestMatchedNodes("(+ (exp 2.1033) (/ -4.3072 (variable 2.4691 X7)))", "(/ 1 (+ (/ -4.3072 (variable 2.4691 X7)) (exp 2.1033)))", 6);
Note: See TracChangeset for help on using the changeset viewer.