Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/13/14 13:03:24 (10 years ago)
Author:
bburlacu
Message:

#1772: HeuristicLab.Problems.DataAnalysis.Symbolic:

  • Merged trunk changes (SymbolicExpressionImporter)
  • Added Passthrough symbol (does not perform an operation, just transfers the input), adjusted interpreter and opcodes accordingly
  • Added diversity preserving crossover
  • Replaced IDistanceCalculator interface with ISymbolicDataAnalysisExpressionSimilarityCalculator and adjusted similarity calculators
  • Refactored tracing, moved functionality to the TraceCalculator (when this is complete the old code will be removed)
Location:
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4

    • Property svn:ignore
      •  

        old new  
        55TreeDistance
        66SymbolicDataAnalysisExpressionTreeMatching.cs
         7Importer
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SimilarityCalculators/BottomUpSimilarityCalculator.cs

    r11229 r11458  
    3232  [StorableClass]
    3333  [Item("BottomUpSimilarityCalculator", "A similarity calculator which uses the tree bottom-up distance as a similarity metric.")]
    34   public class BottomUpSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator {
     34  public class BottomUpSimilarityCalculator : SingleObjectiveSolutionSimilarityCalculator, ISymbolicDataAnalysisExpressionSimilarityCalculator {
    3535    private readonly HashSet<string> commutativeSymbols = new HashSet<string> { "Addition", "Multiplication", "Average", "And", "Or", "Xor" };
    3636
     
    3939    public override IDeepCloneable Clone(Cloner cloner) {
    4040      return new BottomUpSimilarityCalculator(this, cloner);
     41    }
     42
     43    public double CalculateSimilarity(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2) {
     44      if (t1 == t2)
     45        return 1;
     46
     47      var map = ComputeBottomUpMapping(t1.Root, t2.Root);
     48      return 2.0 * map.Count / (t1.Length + t2.Length);
    4149    }
    4250
     
    5260        throw new ArgumentException("Cannot calculate similarity when one of the arguments is null.");
    5361
    54       var similarity = CalculateSolutionSimilarity(t1, t2);
     62      var similarity = CalculateSimilarity(t1, t2);
    5563      if (similarity > 1.0)
    5664        throw new Exception("Similarity value cannot be greater than 1");
    5765
    5866      return similarity;
    59     }
    60 
    61     public double CalculateSolutionSimilarity(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2) {
    62       if (t1 == t2)
    63         return 1;
    64 
    65       var map = ComputeBottomUpMapping(t1.Root, t2.Root);
    66       return 2.0 * map.Count / (t1.Length + t2.Length);
    6767    }
    6868
     
    174174        }
    175175
     176        if (n == n1 || n == n2)
     177          continue;
     178
    176179        var p = n.Parent;
    177180        if (p == null)
Note: See TracChangeset for help on using the changeset viewer.