Changeset 11927 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching
- Timestamp:
- 02/06/15 00:45:30 (10 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching
- Files:
-
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeBottomUpSimilarityCalculator.cs
r11921 r11927 34 34 [StorableClass] 35 35 [Item("SymbolicExpressionTreeBottomUpSimilarityCalculator", "A similarity calculator which uses the tree bottom-up distance as a similarity metric.")] 36 public class SymbolicExpressionTreeBottomUpSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {36 public class SymbolicExpressionTreeBottomUpSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator, ISymbolicDataAnalysisExpressionSimilarityCalculator { 37 37 private readonly HashSet<string> commutativeSymbols = new HashSet<string> { "Addition", "Multiplication", "Average", "And", "Or", "Xor" }; 38 38 public bool MatchVariableWeights { get; set; } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeMatching.cs
r11910 r11927 30 30 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 31 31 public static class SymbolicExpressionTreeMatching { 32 public static bool ContainsSubtree(this ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode subtree, SymbolicExpressionTreeNodeEqualityComparer comparer) {32 public static bool ContainsSubtree(this ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode subtree, ISymbolicExpressionTreeNodeEqualityComparer comparer) { 33 33 return FindMatches(root, subtree, comparer).Any(); 34 34 } 35 public static IEnumerable<ISymbolicExpressionTreeNode> FindMatches(ISymbolicExpressionTree tree, ISymbolicExpressionTreeNode subtree, SymbolicExpressionTreeNodeEqualityComparer comparer) {35 public static IEnumerable<ISymbolicExpressionTreeNode> FindMatches(ISymbolicExpressionTree tree, ISymbolicExpressionTreeNode subtree, ISymbolicExpressionTreeNodeEqualityComparer comparer) { 36 36 return FindMatches(tree.Root, subtree, comparer); 37 37 } 38 38 39 public static IEnumerable<ISymbolicExpressionTreeNode> FindMatches(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode subtree, SymbolicExpressionTreeNodeEqualityComparer comp) {39 public static IEnumerable<ISymbolicExpressionTreeNode> FindMatches(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode subtree, ISymbolicExpressionTreeNodeEqualityComparer comp) { 40 40 var fragmentLength = subtree.GetLength(); 41 41 // below, we use ">=" for Match(n, subtree, comp) >= fragmentLength because in case of relaxed conditions, … … 52 52 /// </summary> 53 53 /// <returns>Number of pairs that were matched</returns> 54 public static int Match(ISymbolicExpressionTreeNode a, ISymbolicExpressionTreeNode b, ISymbolicExpressionTreeNode SimilarityComparer comp) {54 public static int Match(ISymbolicExpressionTreeNode a, ISymbolicExpressionTreeNode b, ISymbolicExpressionTreeNodeEqualityComparer comp) { 55 55 if (!comp.Equals(a, b)) return 0; 56 56 int m = a.SubtreeCount; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator.cs
r11910 r11927 30 30 [StorableClass] 31 31 [Item("SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator", "A similarity calculator based on the size of the maximum common subtree between two trees")] 32 public class SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {32 public class SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator, ISymbolicDataAnalysisExpressionSimilarityCalculator { 33 33 [Storable] 34 34 private readonly SymbolicExpressionTreeNodeEqualityComparer comparer; … … 85 85 } 86 86 87 public static double MaxCommonSubtreeSimilarity(ISymbolicExpressionTree a, ISymbolicExpressionTree b, ISymbolicExpressionTreeNode SimilarityComparer comparer) {87 public static double MaxCommonSubtreeSimilarity(ISymbolicExpressionTree a, ISymbolicExpressionTree b, ISymbolicExpressionTreeNodeEqualityComparer comparer) { 88 88 int max = 0; 89 89 var rootA = a.Root.GetSubtree(0).GetSubtree(0); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeNodeEqualityComparer.cs
r11910 r11927 28 28 [Item("SymbolicExpressionTreeNodeEqualityComparer", "An operator that checks node equality based on different similarity measures.")] 29 29 [StorableClass] 30 public class SymbolicExpressionTreeNodeEqualityComparer : Item, ISymbolicExpressionTreeNode SimilarityComparer {30 public class SymbolicExpressionTreeNodeEqualityComparer : Item, ISymbolicExpressionTreeNodeEqualityComparer { 31 31 [StorableConstructor] 32 32 protected SymbolicExpressionTreeNodeEqualityComparer(bool deserializing) : base(deserializing) { }
Note: See TracChangeset
for help on using the changeset viewer.