Changeset 10838
- Timestamp:
- 05/11/14 21:17:30 (11 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeTile.cs
r10835 r10838 133 133 134 134 defaultBrush = new SolidBrush(Color.Transparent); 135 defaultPen = new Pen(Color. Black);135 defaultPen = new Pen(Color.DimGray); 136 136 defaultFont = new Font(FontFamily.GenericSansSerif, 12, GraphicsUnit.Pixel); 137 137 } … … 183 183 var start = new PointD(node.X + preferredNodeWidth / 2, node.Y + preferredNodeHeight); 184 184 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 }; 186 186 this.Add(line); 187 187 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/FragmentGraphView.cs
r10833 r10838 96 96 var aPos = aTile.Position; 97 97 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); 100 101 foreach (var s in subtree.IterateNodesPrefix()) { 101 102 var primitive = aTile.GetPrimitive(s); … … 103 104 var rpb = primitive as RectangularPrimitiveBase; 104 105 if (rpb != null) { 105 rpb.Pen = Pens.RoyalBlue;106 rpb.Pen = new Pen(Color.Black); 106 107 } 107 108 } 108 109 } 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); 109 130 } 110 131 … … 114 135 var bPos = bTile.Position; 115 136 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 }; 117 140 symbolicExpressionChartControl.Add(line); 118 141 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 // } 133 152 } 134 153 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionTracing.cs
r10837 r10838 29 29 if (!node.Parents.Any()) { 30 30 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 }, 32 36 Rank = node.Rank, 33 37 Quality = node.Quality … … 36 40 var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode }; 37 41 parent.AddForwardArc(arc); 42 fragmentNode.AddReverseArc(parent); 38 43 } 39 44 yield return fragmentNode; // no tracing if there are no parents … … 41 46 } 42 47 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) { 44 51 // 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 skip51 52 node = parents[0]; 52 53 continue; … … 60 61 // we are tracing a mutation operation 61 62 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 }, 63 69 Rank = node.Rank, 64 70 Quality = node.Quality … … 67 73 var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode }; 68 74 parent.AddForwardArc(arc); 75 fragmentNode.AddReverseArc(parent); 69 76 } 70 77 yield return fragmentNode; … … 98 105 // subtree contains fragment => bifurcation point in the fragment graph 99 106 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 }, 101 112 Rank = node.Rank, 102 113 Quality = node.Quality … … 105 116 var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode }; 106 117 parent.AddForwardArc(arc); 118 fragmentNode.AddReverseArc(parent); 107 119 } 108 fragmentNode.Content.Index1 = fragment.Index1 - index;120 // fragmentNode.Content.Index1 = fragment.Index1 - index; 109 121 yield return fragmentNode; 110 122 … … 131 143 } 132 144 #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 }138 145 private static ISymbolicExpressionTreeNode NodeAt(this ISymbolicExpressionTree tree, int position) { 139 146 return NodeAt(tree.Root, position); … … 142 149 return root.IterateNodesPrefix().ElementAt(position); 143 150 } 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 }155 151 #endregion 156 152 }
Note: See TracChangeset
for help on using the changeset viewer.