Last change
on this file since 16725 was
16559,
checked in by jkarder, 6 years ago
|
#2520: renamed Fossil to Attic and set version to 1.0.0-pre01
|
File size:
922 bytes
|
Rev | Line | |
---|
[10562] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
|
---|
[16559] | 4 | using HEAL.Attic;
|
---|
[10562] | 5 |
|
---|
| 6 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
|
---|
[16476] | 7 | [StorableType("535830d4-551e-4b53-97e3-9605bd7e785f")]
|
---|
[10562] | 8 | public class SymbolicExpressionTreeEqualityComparer : IEqualityComparer<ISymbolicExpressionTree> {
|
---|
[16476] | 9 | [Storable]
|
---|
[11910] | 10 | public SymbolicExpressionTreeNodeEqualityComparer SimilarityComparer { get; set; }
|
---|
[10562] | 11 |
|
---|
| 12 | public bool Equals(ISymbolicExpressionTree a, ISymbolicExpressionTree b) {
|
---|
| 13 | if (SimilarityComparer == null) throw new Exception("SimilarityComparer needs to be initialized first.");
|
---|
[11910] | 14 | return a.Length == b.Length && SymbolicExpressionTreeMatching.Match(a.Root, b.Root, SimilarityComparer) == Math.Min(a.Length, b.Length);
|
---|
[10562] | 15 | }
|
---|
| 16 |
|
---|
| 17 | public int GetHashCode(ISymbolicExpressionTree tree) {
|
---|
| 18 | return (tree.Length << 8) % 12345;
|
---|
| 19 | }
|
---|
| 20 | }
|
---|
| 21 | }
|
---|
Note: See
TracBrowser
for help on using the repository browser.