Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10838


Ignore:
Timestamp:
05/11/14 21:17:30 (10 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.

Location:
branches/HeuristicLab.EvolutionTracking
Files:
3 edited

Legend:

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

    r10835 r10838  
    133133
    134134      defaultBrush = new SolidBrush(Color.Transparent);
    135       defaultPen = new Pen(Color.Black);
     135      defaultPen = new Pen(Color.DimGray);
    136136      defaultFont = new Font(FontFamily.GenericSansSerif, 12, GraphicsUnit.Pixel);
    137137    }
     
    183183          var start = new PointD(node.X + preferredNodeWidth / 2, node.Y + preferredNodeHeight);
    184184          var end = new PointD(child.X + preferredNodeWidth / 2, child.Y);
    185           var line = new Line(this.Chart, start, end);
     185          var line = new Line(this.Chart, start, end) { Pen = defaultPen };
    186186          this.Add(line);
    187187        }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/FragmentGraphView.cs

    r10833 r10838  
    9696        var aPos = aTile.Position;
    9797
    98         if (node.Content.Index1 > 0) {
    99           var subtree = node.Content.Root.NodeAt(node.Content.Index1);
     98        var fragment = node.Content;
     99        if (fragment.Index1 > 0) {
     100          var subtree = fragment.Root.NodeAt(fragment.Index1);
    100101          foreach (var s in subtree.IterateNodesPrefix()) {
    101102            var primitive = aTile.GetPrimitive(s);
     
    103104              var rpb = primitive as RectangularPrimitiveBase;
    104105              if (rpb != null) {
    105                 rpb.Pen = Pens.RoyalBlue;
     106                rpb.Pen = new Pen(Color.Black);
    106107              }
    107108            }
    108109          }
     110        }
     111        if (fragment.Index2 > 0) {
     112          var subtree = fragment.Root.NodeAt(fragment.Index2);
     113          foreach (var s in subtree.IterateNodesPrefix()) {
     114            var primitive = aTile.GetPrimitive(s);
     115            if (primitive != null) {
     116              var rpb = primitive as RectangularPrimitiveBase;
     117              if (rpb != null) {
     118                rpb.Brush = new SolidBrush(Color.LightGray);
     119              }
     120            }
     121          }
     122        }
     123
     124        if (node.Parents.Any() && node == node.Parents.First().Children.First()) {
     125          var parent = node.Parents.First();
     126          var index = fragment.Index1 + (parent.Content.Index2 - parent.Content.Index1);
     127          var subtree = fragment.Root.NodeAt(index);
     128          var primitive = aTile.GetPrimitive(subtree);
     129          primitive.Brush = new SolidBrush(Color.LightCoral);
    109130        }
    110131
     
    114135          var bPos = bTile.Position;
    115136
    116           var line = new Line(chart, new PointD(aPos.X + aSize.Width / 2.0, aPos.Y + aSize.Height), new PointD(bPos.X + bSize.Width / 2.0, bPos.Y));
     137          var line = new Line(chart, new PointD(aPos.X + aSize.Width / 2.0, aPos.Y + aSize.Height), new PointD(bPos.X + bSize.Width / 2.0, bPos.Y)) {
     138            Pen = Pens.DimGray
     139          };
    117140          symbolicExpressionChartControl.Add(line);
    118141
    119           if (child == node.Children.First()) {
    120             if (node.Content.Index1 > 0) {
    121               var subtree = child.Content.Root.NodeAt(node.Content.Index1);
    122               foreach (var s in subtree.IterateNodesPrefix()) {
    123                 var primitive = bTile.GetPrimitive(s);
    124                 if (primitive != null) {
    125                   var rpb = primitive as RectangularPrimitiveBase;
    126                   if (rpb != null) {
    127                     rpb.Pen = Pens.DarkOrange;
    128                   }
    129                 }
    130               }
    131             }
    132           }
     142          //          if (child == node.Children.First()) {
     143          //            var subtree = child.Content.Root.NodeAt(fragment.Index2);
     144          //            var primitive = bTile.GetPrimitive(subtree);
     145          //            if (primitive != null) {
     146          //              var rpb = primitive as RectangularPrimitiveBase;
     147          //              if (rpb != null) {
     148          //                rpb.Pen = new Pen(Color.RoyalBlue);
     149          //              }
     150          //            }
     151          //          }
    133152        }
    134153      }
  • 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.