Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11215


Ignore:
Timestamp:
07/22/14 12:42:20 (10 years ago)
Author:
bburlacu
Message:

#2215: Code clean-up and small performance improvements.

Location:
branches/HeuristicLab.BottomUpTreeDistance
Files:
4 edited

Legend:

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

    r11211 r11215  
    55MinimumVisualStudioVersion = 10.0.40219.1
    66Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HeuristicLab.Problems.DataAnalysis.Symbolic-3.4", "HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj", "{3D28463F-EC96-4D82-AFEE-38BE91A0CA00}"
     7EndProject
     8Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{296A2ED3-637A-4E1E-8C06-170651BF1F04}"
     9  ProjectSection(SolutionItems) = preProject
     10    Performance1.psess = Performance1.psess
     11  EndProjectSection
    712EndProject
    813Global
     
    3237    HideSolutionNode = FALSE
    3338  EndGlobalSection
     39  GlobalSection(Performance) = preSolution
     40    HasPerformanceSessions = true
     41  EndGlobalSection
    3442EndGlobal
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimilarityCalculator.cs

    r11211 r11215  
    3939    private const string MatchConstantValuesParameterName = "MatchConstantValues";
    4040
    41     private ISymbolicExpressionTreeDistanceCalculator distanceCalculator;
     41    private readonly ISymbolicExpressionTreeDistanceCalculator distanceCalculator;
    4242
    4343    public IScopeTreeLookupParameter<ISymbolicExpressionTree> SymbolicExpressionTreeParameter {
  • branches/HeuristicLab.BottomUpTreeDistance/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/TreeDistance/BottomUpTreeDistanceCalculator.cs

    r11212 r11215  
    2626using System.Linq;
    2727using System.Text;
    28 using System.Text.RegularExpressions;
    2928using HeuristicLab.Common;
    3029using HeuristicLab.Core;
     
    9493    private static Dictionary<ISymbolicExpressionTreeNode, IVertex> Compact(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2) {
    9594      var nodesToVertices = new Dictionary<ISymbolicExpressionTreeNode, IVertex>(); // K
    96       var disjointUnion = new DisjointUnion(t1, t2); // F
    9795      var labelsToVertices = new Dictionary<string, IVertex>(); // L
    9896      var childrenCount = new Dictionary<ISymbolicExpressionTreeNode, int>(); // Children
    9997      var vertices = new List<IVertex>(); // G
    100 
    101       var nodes = disjointUnion.Nodes.ToList();
     98      var nodes = t1.IterateNodesPostfix().Concat(t2.IterateNodesPostfix()); // the disjoint union F
    10299
    103100      // for all leaf labels l in F
     
    125122        } else {
    126123          bool found = false;
     124          var height = Height(v);
    127125          // for all nodes w in G in reverse order
    128126          for (int i = vertices.Count - 1; i >= 0; --i) {
    129127            var w = vertices[i];
    130             if (Height(v) != Height(w) || v.SubtreeCount != w.OutDegree || label != w.Label)
     128            if (height != Height(w) || v.SubtreeCount != w.OutDegree || label != w.Label)
    131129              continue;
    132130
     
    182180    }
    183181
    184 
    185182    private static string Label(ISymbolicExpressionTreeNode n) {
    186183      return n.ToString();
     
    195192    }
    196193
    197     private class DisjointUnion : Tuple<ISymbolicExpressionTree, ISymbolicExpressionTree> {
    198       public DisjointUnion(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2)
    199         : base(t1, t2) {
    200       }
    201 
    202       public IEnumerable<ISymbolicExpressionTreeNode> Nodes {
    203         get { return Item1.Root.IterateNodesPostfix().Concat(Item2.Root.IterateNodesPostfix()); }
    204       }
    205     }
    206 
    207     public static string RemoveFirstLines(string text, int linesCount) {
    208       var lines = Regex.Split(text, "\r\n|\r|\n").Skip(linesCount);
    209       return string.Join(Environment.NewLine, lines.ToArray());
    210     }
    211 
     194    // this is here for debugging purposes only
    212195    // draw the mapping between t1 and t2 as a tikz picture
    213196    private static string FormatMapping(ISymbolicExpressionTree t1, ISymbolicExpressionTree t2, Dictionary<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode> map) {
Note: See TracChangeset for help on using the changeset viewer.