Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/13/14 17:20:36 (11 years ago)
Author:
bburlacu
Message:

#1772: Added partially working implementation of a bottom-up distance calculator for symbolic expression trees. Changed latex formatter to also return a map of node ids (useful when wanting to display trees side by side).

Location:
branches/HeuristicLab.EvolutionTracking
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/Formatters/SymbolicExpressionTreeLatexFormatter.cs

    r10655 r11015  
    6565
    6666    public string Format(ISymbolicExpressionTree symbolicExpressionTree) {
     67      string s;
     68      Format(symbolicExpressionTree, out s);
     69      return s;
     70    }
     71
     72    public Dictionary<ISymbolicExpressionTreeNode, string> Format(ISymbolicExpressionTree symbolicExpressionTree, out string str, int offset = 0) {
     73      var nodeIds = new Dictionary<ISymbolicExpressionTreeNode, string>();
    6774      var root = symbolicExpressionTree.Root;
    6875      var actualRoot = root.SubtreeCount == 0 ? root.GetSubtree(0) : root;
     
    7885                "\\begin{tikzpicture}" + nl +
    7986                "\\def\\ws{1}" + nl +
    80                 "\\def\\hs{0.7}" + nl);
     87                "\\def\\hs{0.7}" + nl +
     88                "\\def\\offs{" + offset + "}" + nl);
    8189
    82       var nodeIndices = new Dictionary<ISymbolicExpressionTreeNode, int>();
    8390      var nodes = symbolicExpressionTree.IterateNodesBreadth().ToList();
    8491      for (int i = 0; i < nodes.Count; ++i) {
    8592        var node = nodes[i];
    86         nodeIndices.Add(node, i);
     93        var id = Guid.NewGuid().ToString();
     94        nodeIds[node] = id;
    8795        var coord = nodeCoordinates[node];
    8896        var nodeName = symbolNameMap.ContainsKey(node.Symbol.Name) ? symbolNameMap[node.Symbol.Name] : node.ToString();
    89         sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "\\node ({0}) at (\\ws*{1},\\hs*{2}) {{{3}}};", i, ws * coord.X, -hs * coord.Y, EscapeLatexString(nodeName)));
     97        sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "\\node ({0}) at (\\ws*{1} + {2},\\hs*{3}) {{{4}}};", nodeIds[node], ws * coord.X, offset, -hs * coord.Y, EscapeLatexString(nodeName)));
    9098      }
    9199
    92100      for (int i = 0; i < nodes.Count; ++i) {
     101        var n = nodes[i];
    93102        foreach (var s in nodes[i].Subtrees) {
    94           sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "\\draw ({0}) -- ({1});", i, nodeIndices[s]));
     103          sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "\\draw ({0}) -- ({1});", nodeIds[n], nodeIds[s]));
    95104        }
    96105      }
     
    98107      sb.Append("\\end{tikzpicture}" + nl +
    99108                "\\end{document}" + nl);
    100       return sb.ToString();
     109      str = sb.ToString();
     110      return nodeIds;
    101111    }
    102112
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/HeuristicLab.EvolutionTracking.Views-3.4.csproj

    r10936 r11015  
    9797      <DependentUpon>FrequentFragmentsDialog.cs</DependentUpon>
    9898    </Compile>
    99     <Compile Include="GenealogyGraphChart.cs" />
     99    <Compile Include="GenealogyGraphChart.cs">
     100      <SubType>UserControl</SubType>
     101    </Compile>
    100102    <Compile Include="GenealogyGraphChart.Designer.cs">
    101103      <DependentUpon>GenealogyGraphChart.cs</DependentUpon>
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj

    r10936 r11015  
    279279      <DependentUpon>SymboldDataAnalysisGenealogyView.cs</DependentUpon>
    280280    </Compile>
    281     <Compile Include="Tracking\SymbolicDataAnalysisExpressionGenealogyGraphChart.cs" />
     281    <Compile Include="Tracking\SymbolicDataAnalysisExpressionGenealogyGraphChart.cs">
     282      <SubType>UserControl</SubType>
     283    </Compile>
    282284    <Compile Include="Tracking\SymbolicDataAnalysisExpressionGenealogyGraphChart.Designer.cs">
    283285      <DependentUpon>SymbolicDataAnalysisExpressionGenealogyGraphChart.cs</DependentUpon>
     
    289291      <DependentUpon>SymbolicDataAnalysisExpressionLineageExplorerView.cs</DependentUpon>
    290292    </Compile>
    291     <Compile Include="Tracking\SymbolicExpressionChartControl.cs" />
     293    <Compile Include="Tracking\SymbolicExpressionChartControl.cs">
     294      <SubType>UserControl</SubType>
     295    </Compile>
    292296    <Compile Include="Tracking\SymbolicExpressionChartControl.Designer.cs">
    293297      <DependentUpon>SymbolicExpressionChartControl.cs</DependentUpon>
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/FragmentGraphView.cs

    r10888 r11015  
    6969      var chart = symbolicExpressionChartControl.Chart;
    7070      tileDictionary.Clear();
    71       foreach (var node in Content.Nodes) {
     71      foreach (var node in Content.Vertices) {
    7272        var graphNode = (IGenealogyGraphNode<ISymbolicExpressionTree>)node.Content;
    7373        var tile = new SymbolicExpressionTreeTile(chart);
     
    7979        tileDictionary.Add(node, tileNode);
    8080      }
    81       foreach (var node in Content.Nodes.Where(n => n.OutArcs.Any())) {
     81      foreach (var node in Content.Vertices.Where(n => n.OutArcs.Any())) {
    8282        var layoutNode = tileDictionary[node];
    8383        layoutNode.Children = new List<TileLayoutNode>(node.OutArcs.Select(a => tileDictionary[(FragmentNode)a.Target]));
     
    8787    private void Draw() {
    8888      var chart = symbolicExpressionChartControl.Chart;
    89       var nodes = Content.Nodes.ToList();
     89      var nodes = Content.Vertices.ToList();
    9090      var root = nodes[0];
    9191      var fragmentRoot = tileDictionary[root];
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymboldDataAnalysisGenealogyView.cs

    r10903 r11015  
    100100        var subtreeIndex = graphNode.Content.IterateNodesPrefix().ToList().IndexOf(subtree);
    101101        var fragmentGraph = SymbolicDataAnalysisExpressionTracing.TraceSubtree(graphNode, subtreeIndex);
    102         if (fragmentGraph.Nodes.Any()) {
     102        if (fragmentGraph.Vertices.Any()) {
    103103          MainFormManager.MainForm.ShowContent(fragmentGraph); // display the fragment graph on the screen
    104104        }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj

    r10888 r11015  
    306306    <Compile Include="Tracking\SymbolicDataAnalysisExpressionBeforeManipulatorOperator.cs" />
    307307    <Compile Include="Tracking\SymbolicDataAnalysisExpressionTracing.cs" />
     308    <Compile Include="TreeDistance\BottomUpDistanceCalculator.cs" />
    308309    <None Include="HeuristicLab.snk" />
    309310    <None Include="Plugin.cs.frame" />
     
    340341  </ItemGroup>
    341342  <ItemGroup>
     343    <ProjectReference Include="..\..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views\3.4\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4.csproj">
     344      <Project>{423bd94f-963a-438e-ba45-3bb3d61cd03b}</Project>
     345      <Name>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4</Name>
     346    </ProjectReference>
    342347    <ProjectReference Include="..\..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding\3.4\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj">
    343348      <Project>{06D4A186-9319-48A0-BADE-A2058D462EEA}</Project>
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionTreeSimilarityCalculator.cs

    r10650 r11015  
    103103
    104104        if (found) {
    105           similarity += MaxCommonSubtreeSimilarity(current, tree, SimilarityComparer);
     105          //          similarity += MaxCommonSubtreeSimilarity(current, tree, SimilarityComparer);
     106          var distance = BottomUpDistanceCalculator.CalculateDistance(current, tree) / (current.Length + tree.Length);
     107          similarity += 1 - distance;
    106108        }
    107109      }
Note: See TracChangeset for help on using the changeset viewer.