Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/11/14 18:29:47 (10 years ago)
Author:
bburlacu
Message:

#1772: Fixed identification of mutation fragments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionAfterManipulatorOperator.cs

    r10833 r10837  
    4848        var a = nodesAfter[i];
    4949        var b = nodesBefore[i];
    50         if (ReferenceEquals(a, b) && comparer.Equals(a, b)) continue;
     50
     51        bool found = false;
     52        if (comparer.Equals(a, b)) {
     53          int m = 0;
     54          for (int j = 0; j < a.SubtreeCount; ++j) {
     55            if (!AreSimilar(a.GetSubtree(j), b.GetSubtree(j), comparer)) { ++m; }
     56            if (m > 1) {
     57              found = true;
     58              break;
     59            }
     60          }
     61          if (m == 0) {
     62            // everything is similar so we skip the whole subtree
     63            i += a.GetLength();
     64          }
     65          if (!found) continue;
     66        }
    5167        fragment = new Fragment<ISymbolicExpressionTreeNode> {
    5268          Root = a,
     
    6076      return base.Apply();
    6177    }
     78
     79    private bool AreSimilar(ISymbolicExpressionTreeNode a, ISymbolicExpressionTreeNode b, SymbolicExpressionTreeNodeSimilarityComparer comp) {
     80      int length = a.GetLength();
     81      return comparer.Equals(a, b) && length.Equals(b.GetLength()) && SymbolicExpressionTreeMatching.Match(a, b, comp) == length;
     82    }
    6283  }
    6384}
Note: See TracChangeset for help on using the changeset viewer.