Last change
on this file since 14427 was
11910,
checked in by bburlacu, 10 years ago
|
#2215:
- Unified the similarity and matching/equality classes under the same folder.
- Renamed SymbolicExpressionTreeNodeSimilarityComparer to SymbolicExpressionTreeNodeEqualityComparer, renamed other classes to more descriptive names.
- Removed unused classes (SymbolicDataAnalysisInternalDiversityAnalyzer.cs, SymbolicExpressionTreeMaxCommonSequenceCalculator.cs
- Renamed tests and test files.
|
File size:
829 bytes
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
4 |
|
---|
5 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
|
---|
6 | public class SymbolicExpressionTreeEqualityComparer : IEqualityComparer<ISymbolicExpressionTree> {
|
---|
7 | public SymbolicExpressionTreeNodeEqualityComparer SimilarityComparer { get; set; }
|
---|
8 |
|
---|
9 | public bool Equals(ISymbolicExpressionTree a, ISymbolicExpressionTree b) {
|
---|
10 | if (SimilarityComparer == null) throw new Exception("SimilarityComparer needs to be initialized first.");
|
---|
11 | return a.Length == b.Length && SymbolicExpressionTreeMatching.Match(a.Root, b.Root, SimilarityComparer) == Math.Min(a.Length, b.Length);
|
---|
12 | }
|
---|
13 |
|
---|
14 | public int GetHashCode(ISymbolicExpressionTree tree) {
|
---|
15 | return (tree.Length << 8) % 12345;
|
---|
16 | }
|
---|
17 | }
|
---|
18 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.