Changeset 10347 for branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeMatching.cs
- Timestamp:
- 01/16/14 16:37:56 (11 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic merged: 10346
- Property svn:mergeinfo changed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeMatching.cs
r10302 r10347 5 5 using HeuristicLab.Core; 6 6 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; 7 using HeuristicLab.EvolutionTracking; 7 8 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 8 9 using HeuristicLab.Problems.DataAnalysis.Symbolic; … … 79 80 } 80 81 81 public class SymbolicExpressionTreeFragmentSimilarityComparer : IEqualityComparer<IFragment > {82 public class SymbolicExpressionTreeFragmentSimilarityComparer : IEqualityComparer<IFragment<ISymbolicExpressionTreeNode>> { 82 83 public SymbolicExpressionTreeNodeSimilarityComparer SimilarityComparer { get; set; } 83 84 84 public bool Equals(IFragment x, IFragmenty) {85 public bool Equals(IFragment<ISymbolicExpressionTreeNode> x, IFragment<ISymbolicExpressionTreeNode> y) { 85 86 if (SimilarityComparer == null) 86 87 throw new ArgumentNullException("SimilarityComparer needs to be initialized first."); 87 return x. Length == y.Length && SymbolicExpressionTreeMatching.Match(x.Root, y.Root, SimilarityComparer) == x.Length;88 } 89 90 public int GetHashCode(IFragment fragment) {88 return x.Root.GetLength() == y.Root.GetLength() && SymbolicExpressionTreeMatching.Match(x.Root, y.Root, SimilarityComparer) == x.Root.GetLength(); 89 } 90 91 public int GetHashCode(IFragment<ISymbolicExpressionTreeNode> fragment) { 91 92 return fragment.Root.Symbol.Name.ToLower().GetHashCode(); 92 93 } … … 162 163 163 164 public static class SymbolicExpressionTreeMatching { 164 public static bool ContainsFragment(this ISymbolicExpressionTreeNode root, IFragment fragment, SymbolicExpressionTreeNodeSimilarityComparer comparer) {165 public static bool ContainsFragment(this ISymbolicExpressionTreeNode root, IFragment<ISymbolicExpressionTreeNode> fragment, SymbolicExpressionTreeNodeSimilarityComparer comparer) { 165 166 return FindMatches(root, fragment.Root, comparer).Any(); 166 167 }
Note: See TracChangeset
for help on using the changeset viewer.