Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/11/14 21:17:30 (11 years ago)
Author:
bburlacu
Message:

#1772: Improved display of trees and fragments in the FragmentGraphView by displaying the whole tree and highlighting the subtree and the fragment inside it. Changed color scheme to look nicer.

File:
1 edited

Legend:

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

    r10837 r10838  
    2929        if (!node.Parents.Any()) {
    3030          var fragmentNode = new FragmentNode {
    31             Content = new Fragment<ISymbolicExpressionTreeNode> { Root = node.Content.NodeAt(index) },
     31            Content = new Fragment<ISymbolicExpressionTreeNode> {
     32              Root = node.Content.Root,
     33              //              Root = node.Content.NodeAt(index)
     34              Index1 = index
     35            },
    3236            Rank = node.Rank,
    3337            Quality = node.Quality
     
    3640            var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode };
    3741            parent.AddForwardArc(arc);
     42            fragmentNode.AddReverseArc(parent);
    3843          }
    3944          yield return fragmentNode; // no tracing if there are no parents
     
    4146        }
    4247        var parents = node.Parents.ToList();
    43         if (node.IsElite) {
     48        var fragment = (IFragment<ISymbolicExpressionTreeNode>)node.InArcs.Last().Data;
     49
     50        if (node.IsElite || fragment == null) {
    4451          // skip elite, go up the graph to original individual
    45           node = parents[0];
    46           continue;
    47         }
    48         var fragment = (IFragment<ISymbolicExpressionTreeNode>)node.InArcs.Last().Data;
    49         if (fragment == null) {
    50           // the fragment can be null when crossover or mutation did not actually make any change => then we skip
    5152          node = parents[0];
    5253          continue;
     
    6061          // we are tracing a mutation operation
    6162          var fragmentNode = new FragmentNode {
    62             Content = new Fragment<ISymbolicExpressionTreeNode> { Root = subtree },
     63            Content = new Fragment<ISymbolicExpressionTreeNode> {
     64              Root = tree.Root,
     65              //              Root = subtree
     66              Index1 = index,
     67              Index2 = fragment.Index1
     68            },
    6369            Rank = node.Rank,
    6470            Quality = node.Quality
     
    6773            var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode };
    6874            parent.AddForwardArc(arc);
     75            fragmentNode.AddReverseArc(parent);
    6976          }
    7077          yield return fragmentNode;
     
    98105              // subtree contains fragment => bifurcation point in the fragment graph
    99106              var fragmentNode = new FragmentNode {
    100                 Content = new Fragment<ISymbolicExpressionTreeNode> { Root = subtree },
     107                Content = new Fragment<ISymbolicExpressionTreeNode> {
     108                  Root = tree.Root,
     109                  Index1 = index,
     110                  Index2 = fragment.Index1
     111                },
    101112                Rank = node.Rank,
    102113                Quality = node.Quality
     
    105116                var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode };
    106117                parent.AddForwardArc(arc);
     118                fragmentNode.AddReverseArc(parent);
    107119              }
    108               fragmentNode.Content.Index1 = fragment.Index1 - index;
     120              //              fragmentNode.Content.Index1 = fragment.Index1 - index;
    109121              yield return fragmentNode;
    110122
     
    131143    }
    132144    #region some helper methods for shortening the tracing code
    133     private static void AddChild(this IGenealogyGraphNode parent, IGenealogyGraphNode child) {
    134       parent.AddForwardArc(child);
    135       child.AddReverseArc(parent);
    136       child.Rank = parent.Rank - 1;
    137     }
    138145    private static ISymbolicExpressionTreeNode NodeAt(this ISymbolicExpressionTree tree, int position) {
    139146      return NodeAt(tree.Root, position);
     
    142149      return root.IterateNodesPrefix().ElementAt(position);
    143150    }
    144     private static int IndexOf(this ISymbolicExpressionTree tree, ISymbolicExpressionTreeNode node) {
    145       return IndexOf(tree.Root, node);
    146     }
    147     private static int IndexOf(this ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode node) {
    148       int i = 0;
    149       foreach (var n in root.IterateNodesPrefix()) {
    150         if (n == node) return i;
    151         ++i;
    152       }
    153       return -1;
    154     }
    155151    #endregion
    156152  }
Note: See TracChangeset for help on using the changeset viewer.