Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11910


Ignore:
Timestamp:
02/05/15 12:09:18 (10 years ago)
Author:
bburlacu
Message:

#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.
Location:
branches/HeuristicLab.BottomUpTreeDistance
Files:
5 deleted
6 edited
3 copied
3 moved

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.BottomUpTreeDistance.sln

    r11894 r11910  
    3636    {07C05C8F-0769-4607-96C6-D90A219F4C85}.Release|Any CPU.ActiveCfg = Release|Any CPU
    3737    {07C05C8F-0769-4607-96C6-D90A219F4C85}.Release|Any CPU.Build.0 = Release|Any CPU
    38     {07C05C8F-0769-4607-96C6-D90A219F4C85}.Release|x64.ActiveCfg = Release|x64
    39     {07C05C8F-0769-4607-96C6-D90A219F4C85}.Release|x64.Build.0 = Release|x64
    40     {07C05C8F-0769-4607-96C6-D90A219F4C85}.Release|x86.ActiveCfg = Release|x86
    41     {07C05C8F-0769-4607-96C6-D90A219F4C85}.Release|x86.Build.0 = Release|x86
     38    {07C05C8F-0769-4607-96C6-D90A219F4C85}.Release|x64.ActiveCfg = Release|Any CPU
     39    {07C05C8F-0769-4607-96C6-D90A219F4C85}.Release|x86.ActiveCfg = Release|Any CPU
    4240  EndGlobalSection
    4341  GlobalSection(SolutionProperties) = preSolution
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r11887 r11910  
    203203  </ItemGroup>
    204204  <ItemGroup>
    205     <Compile Include="Analyzers\SymbolicDataAnalysisInternalDiversityAnalyzer.cs" />
    206205    <Compile Include="Analyzers\SymbolicDataAnalysisSingleObjectivePruningAnalyzer.cs" />
    207206    <Compile Include="Analyzers\SymbolicDataAnalysisSingleObjectiveValidationParetoBestSolutionAnalyzer.cs" />
     
    221220    <Compile Include="Importer\Token.cs" />
    222221    <Compile Include="Interfaces\IModelBacktransformator.cs" />
    223     <Compile Include="Matching\SymbolicExpressionTreeCanonicalSorter.cs" />
    224     <Compile Include="Matching\SymbolicExpressionTreeEqualityComparer.cs" />
    225     <Compile Include="Matching\SymbolicExpressionTreeMatching.cs" />
    226     <Compile Include="Matching\SymbolicExpressionTreeMaxCommonSequenceCalculator.cs" />
    227     <Compile Include="Matching\SymbolicExpressionTreeNodeComparer.cs" />
    228     <Compile Include="Matching\SymbolicExpressionTreeNodeSimilarityComparer.cs" />
    229     <Compile Include="SimilarityCalculators\BottomUpSimilarityCalculator.cs" />
    230     <Compile Include="SimilarityCalculators\MaxCommonSubtreeSimilarityCalculator.cs" />
     222    <Compile Include="TreeMatching\SymbolicExpressionTreeCanonicalSorter.cs" />
     223    <Compile Include="TreeMatching\SymbolicExpressionTreeEqualityComparer.cs" />
     224    <Compile Include="TreeMatching\SymbolicExpressionTreeMatching.cs" />
     225    <Compile Include="TreeMatching\SymbolicExpressionTreeNodeComparer.cs" />
     226    <Compile Include="TreeMatching\SymbolicExpressionTreeNodeEqualityComparer.cs" />
     227    <Compile Include="TreeMatching\SymbolicExpressionTreeBottomUpSimilarityCalculator.cs" />
     228    <Compile Include="TreeMatching\SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator.cs" />
    231229    <Compile Include="SymbolicExpressionTreeBacktransformator.cs" />
    232230    <Compile Include="SymbolicDataAnalysisExpressionPruningOperator.cs" />
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisProblem.cs

    r11486 r11910  
    358358      }
    359359      foreach (var op in operators.OfType<SingleObjectivePopulationDiversityAnalyzer>()) {
    360         op.SimilarityCalculator = new BottomUpSimilarityCalculator();
     360        op.SimilarityCalculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator();
    361361      }
    362362    }
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeBottomUpSimilarityCalculator.cs

    r11900 r11910  
    3333namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    3434  [StorableClass]
    35   [Item("BottomUpSimilarityCalculator", "A similarity calculator which uses the tree bottom-up distance as a similarity metric.")]
    36   public class BottomUpSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
     35  [Item("SymbolicExpressionTreeBottomUpSimilarityCalculator", "A similarity calculator which uses the tree bottom-up distance as a similarity metric.")]
     36  public class SymbolicExpressionTreeBottomUpSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
    3737    private readonly HashSet<string> commutativeSymbols = new HashSet<string> { "Addition", "Multiplication", "Average", "And", "Or", "Xor" };
    3838    public bool MatchVariableWeights { get; set; }
    3939    public bool MatchConstantValues { get; set; }
    4040
    41     public BottomUpSimilarityCalculator() { }
    42 
    43     protected BottomUpSimilarityCalculator(BottomUpSimilarityCalculator original, Cloner cloner)
     41    public SymbolicExpressionTreeBottomUpSimilarityCalculator() { }
     42
     43    protected SymbolicExpressionTreeBottomUpSimilarityCalculator(SymbolicExpressionTreeBottomUpSimilarityCalculator original, Cloner cloner)
    4444      : base(original, cloner) {
    4545      MatchVariableWeights = original.MatchVariableWeights;
     
    4848
    4949    public override IDeepCloneable Clone(Cloner cloner) {
    50       return new BottomUpSimilarityCalculator(this, cloner);
     50      return new SymbolicExpressionTreeBottomUpSimilarityCalculator(this, cloner);
    5151    }
    5252
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeEqualityComparer.cs

    r10562 r11910  
    55namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    66  public class SymbolicExpressionTreeEqualityComparer : IEqualityComparer<ISymbolicExpressionTree> {
    7     public SymbolicExpressionTreeNodeSimilarityComparer SimilarityComparer { get; set; }
     7    public SymbolicExpressionTreeNodeEqualityComparer SimilarityComparer { get; set; }
    88
    99    public bool Equals(ISymbolicExpressionTree a, ISymbolicExpressionTree b) {
    1010      if (SimilarityComparer == null) throw new Exception("SimilarityComparer needs to be initialized first.");
    11       return a.Length == b.Length &&
    12              SymbolicExpressionTreeMatching.Match(a.Root, b.Root, SimilarityComparer) == Math.Min(a.Length, b.Length);
     11      return a.Length == b.Length && SymbolicExpressionTreeMatching.Match(a.Root, b.Root, SimilarityComparer) == Math.Min(a.Length, b.Length);
    1312    }
    1413
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeMatching.cs

    r11887 r11910  
    3030namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    3131  public static class SymbolicExpressionTreeMatching {
    32     public static bool ContainsSubtree(this ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode subtree, SymbolicExpressionTreeNodeSimilarityComparer comparer) {
     32    public static bool ContainsSubtree(this ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode subtree, SymbolicExpressionTreeNodeEqualityComparer comparer) {
    3333      return FindMatches(root, subtree, comparer).Any();
    3434    }
    35     public static IEnumerable<ISymbolicExpressionTreeNode> FindMatches(ISymbolicExpressionTree tree, ISymbolicExpressionTreeNode subtree, SymbolicExpressionTreeNodeSimilarityComparer comparer) {
     35    public static IEnumerable<ISymbolicExpressionTreeNode> FindMatches(ISymbolicExpressionTree tree, ISymbolicExpressionTreeNode subtree, SymbolicExpressionTreeNodeEqualityComparer comparer) {
    3636      return FindMatches(tree.Root, subtree, comparer);
    3737    }
    3838
    39     public static IEnumerable<ISymbolicExpressionTreeNode> FindMatches(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode subtree, SymbolicExpressionTreeNodeSimilarityComparer comp) {
     39    public static IEnumerable<ISymbolicExpressionTreeNode> FindMatches(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode subtree, SymbolicExpressionTreeNodeEqualityComparer comp) {
    4040      var fragmentLength = subtree.GetLength();
    4141      // below, we use ">=" for Match(n, subtree, comp) >= fragmentLength because in case of relaxed conditions,
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator.cs

    r11900 r11910  
    2929namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    3030  [StorableClass]
    31   [Item("MaxCommonSubtreeSimilarityCalculator", "A similarity calculator based on the size of the maximum common subtree between two trees")]
    32   public class MaxCommonSubtreeSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
     31  [Item("SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator", "A similarity calculator based on the size of the maximum common subtree between two trees")]
     32  public class SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
    3333    [Storable]
    34     private readonly SymbolicExpressionTreeNodeSimilarityComparer comparer;
     34    private readonly SymbolicExpressionTreeNodeEqualityComparer comparer;
    3535    public bool MatchVariableWeights {
    3636      get { return comparer.MatchVariableWeights; }
     
    4444
    4545    [StorableConstructor]
    46     protected MaxCommonSubtreeSimilarityCalculator(bool deserializing) : base(deserializing) { }
     46    protected SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator(bool deserializing) : base(deserializing) { }
    4747
    4848    public override IDeepCloneable Clone(Cloner cloner) {
    49       return new MaxCommonSubtreeSimilarityCalculator(this, cloner);
     49      return new SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator(this, cloner);
    5050    }
    5151
    52     protected MaxCommonSubtreeSimilarityCalculator(MaxCommonSubtreeSimilarityCalculator original, Cloner cloner)
     52    protected SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator(SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator original, Cloner cloner)
    5353      : base(original, cloner) {
    5454      comparer = cloner.Clone(original.comparer);
    5555    }
    5656
    57     public MaxCommonSubtreeSimilarityCalculator() {
    58       comparer = new SymbolicExpressionTreeNodeSimilarityComparer {
     57    public SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator() {
     58      comparer = new SymbolicExpressionTreeNodeEqualityComparer {
    5959        MatchConstantValues = true,
    6060        MatchVariableNames = true,
     
    6363    }
    6464
    65     public MaxCommonSubtreeSimilarityCalculator(bool matchVariableWeights, bool matchConstantValues) {
    66       comparer = new SymbolicExpressionTreeNodeSimilarityComparer {
     65    public SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator(bool matchVariableWeights, bool matchConstantValues) {
     66      comparer = new SymbolicExpressionTreeNodeEqualityComparer {
    6767        MatchConstantValues = matchConstantValues,
    6868        MatchVariableNames = true,
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeNodeComparer.cs

    r11894 r11910  
    2121
    2222using System;
    23 using System.Collections.Generic;
    2423using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    2524
     
    3029  // - used for bringing subtrees to a "canonical" form when the operation allows reordering of arguments
    3130  public class SymbolicExpressionTreeNodeComparer : ISymbolicExpressionTreeNodeComparer {
    32     public static int Compare(ISymbolicExpressionTreeNode a, ISymbolicExpressionTreeNode b) {
     31    public static int CompareNodes(ISymbolicExpressionTreeNode a, ISymbolicExpressionTreeNode b) {
    3332      var ta = a as SymbolicExpressionTreeTerminalNode;
    3433      var tb = b as SymbolicExpressionTreeTerminalNode;
     
    6665    }
    6766
    68     int IComparer<ISymbolicExpressionTreeNode>.Compare(ISymbolicExpressionTreeNode x, ISymbolicExpressionTreeNode y) {
    69       return Compare(x, y);
     67    public int Compare(ISymbolicExpressionTreeNode x, ISymbolicExpressionTreeNode y) {
     68      return CompareNodes(x, y);
    7069    }
    7170  }
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeMatching/SymbolicExpressionTreeNodeEqualityComparer.cs

    r11900 r11910  
    2626
    2727namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
    28   [Item("SymbolicExpressionTreeNodeSimilarityComparer", "A comparison operator that checks node equality based on different similarity measures.")]
     28  [Item("SymbolicExpressionTreeNodeEqualityComparer", "An operator that checks node equality based on different similarity measures.")]
    2929  [StorableClass]
    30   public class SymbolicExpressionTreeNodeSimilarityComparer : Item, ISymbolicExpressionTreeNodeSimilarityComparer {
     30  public class SymbolicExpressionTreeNodeEqualityComparer : Item, ISymbolicExpressionTreeNodeSimilarityComparer {
    3131    [StorableConstructor]
    32     protected SymbolicExpressionTreeNodeSimilarityComparer(bool deserializing) : base(deserializing) { }
    33     protected SymbolicExpressionTreeNodeSimilarityComparer(SymbolicExpressionTreeNodeSimilarityComparer original, Cloner cloner)
     32    protected SymbolicExpressionTreeNodeEqualityComparer(bool deserializing) : base(deserializing) { }
     33    protected SymbolicExpressionTreeNodeEqualityComparer(SymbolicExpressionTreeNodeEqualityComparer original, Cloner cloner)
    3434      : base(original, cloner) {
    3535      matchConstantValues = original.matchConstantValues;
     
    3737      matchVariableWeights = original.matchVariableWeights;
    3838    }
    39     public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicExpressionTreeNodeSimilarityComparer(this, cloner); }
     39    public override IDeepCloneable Clone(Cloner cloner) { return new SymbolicExpressionTreeNodeEqualityComparer(this, cloner); }
    4040
    4141    // more flexible matching criteria
     
    6565    }
    6666
    67     public SymbolicExpressionTreeNodeSimilarityComparer() {
     67    public SymbolicExpressionTreeNodeEqualityComparer() {
    6868      matchConstantValues = true;
    6969      matchVariableNames = true;
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Tests/SymbolicExpressionTreeBottomUpSimilarityCalculatorTest.cs

    r11900 r11910  
    1414  [TestClass]
    1515  public class BottomUpSimilarityCalculatorTest {
    16     private readonly BottomUpSimilarityCalculator busCalculator;
     16    private readonly SymbolicExpressionTreeBottomUpSimilarityCalculator busCalculator;
    1717    private readonly SymbolicExpressionImporter importer;
    1818
     
    2222
    2323    public BottomUpSimilarityCalculatorTest() {
    24       busCalculator = new BottomUpSimilarityCalculator { MatchConstantValues = true, MatchVariableWeights = true };
     24      busCalculator = new SymbolicExpressionTreeBottomUpSimilarityCalculator { MatchConstantValues = true, MatchVariableWeights = true };
    2525      importer = new SymbolicExpressionImporter();
    2626    }
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Tests/SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculatorTest.cs

    r11900 r11910  
    1212  /// </summary>
    1313  [TestClass]
    14   public class MaxCommonSubtreeSimilarityCalculatorTest {
     14  public class SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculatorTest {
    1515    private readonly ISymbolicExpressionTreeNodeSimilarityComparer comparer;
    1616
     
    1919    private const int Columns = 10;
    2020
    21     public MaxCommonSubtreeSimilarityCalculatorTest() {
    22       comparer = new SymbolicExpressionTreeNodeSimilarityComparer();
     21    public SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculatorTest() {
     22      comparer = new SymbolicExpressionTreeNodeEqualityComparer();
    2323    }
    2424
     
    6161      for (int i = 0; i < trees.Length - 1; ++i) {
    6262        for (int j = i + 1; j < trees.Length; ++j) {
    63           s += MaxCommonSubtreeSimilarityCalculator.MaxCommonSubtreeSimilarity(trees[i], trees[j], comparer);
     63          s += SymbolicExpressionTreeMaxCommonSubtreeSimilarityCalculator.MaxCommonSubtreeSimilarity(trees[i], trees[j], comparer);
    6464        }
    6565      }
Note: See TracChangeset for help on using the changeset viewer.