Changeset 10827 for branches/HeuristicLab.EvolutionTracking
- Timestamp:
- 05/08/14 17:26:32 (11 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeTile.cs
r10797 r10827 41 41 42 42 private const int labelHeight = 30; 43 44 private readonly SolidBrush defaultBrush; 45 private readonly Pen defaultPen; 46 private readonly Font defaultFont; 43 47 44 48 public ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> LayoutEngine { get; set; } … … 127 131 PreferredNodeHeight = 40; 128 132 Group = new Group(chart); 133 134 defaultBrush = new SolidBrush(Color.Transparent); 135 defaultPen = new Pen(Color.Black); 136 defaultFont = new Font(FontFamily.GenericSansSerif, 12, GraphicsUnit.Pixel); 129 137 } 130 138 public SymbolicExpressionTreeTile(IChart chart, ISymbolicExpressionTree tree) … … 142 150 var visualNodes = LayoutEngine.CalculateLayout(actualRoot).ToList(); 143 151 144 var font = new Font(FontFamily.GenericSansSerif, 10, GraphicsUnit.Pixel);145 146 152 var visualNodeMap = visualNodes.ToDictionary(x => x.Content, x => x); 147 153 … … 154 160 var shortenedLabel = ShortenLabel(node); 155 161 if (node.SubtreeCount == 0) { 156 rectangularPrimitive = new Rectangle(Chart, lowerLeft, upperRight) { Font = font, Text = shortenedLabel }; 162 rectangularPrimitive = new Rectangle(Chart, lowerLeft, upperRight) { 163 Font = defaultFont, Text = shortenedLabel, Brush = defaultBrush, Pen = defaultPen, MaximumFontSize = 12f 164 }; 157 165 } else { 158 rectangularPrimitive = new Ellipse(Chart, lowerLeft, upperRight) { Font = font, Text = shortenedLabel }; 166 rectangularPrimitive = new Ellipse(Chart, lowerLeft, upperRight) { 167 Font = defaultFont, Text = shortenedLabel, Brush = defaultBrush, Pen = defaultPen, MaximumFontSize = 12f 168 }; 159 169 } 160 170 … … 189 199 // draw a primitive to display the label 190 200 var labelRect = new Rectangle(this.Chart, new PointD(0, height), new PointD(width, height + labelHeight)) { 191 Pen = new Pen(Color.Black),192 Brush = new SolidBrush(Color.Transparent),201 Pen = defaultPen, 202 Brush = defaultBrush, 193 203 Text = Label, 194 Font = new Font(FontFamily.GenericSansSerif, 12)204 Font = defaultFont 195 205 }; 196 206 this.Add(labelRect); … … 200 210 201 211 var rectangle = new Rectangle(this.Chart, new PointD(0, 0), new PointD(Size.Width, Size.Height)) { 202 Pen = new Pen(Color.Gray),203 Brush = new SolidBrush(Color.Transparent)212 Pen = defaultPen, 213 Brush = defaultBrush 204 214 }; 205 215 this.Add(rectangle); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.cs
r10746 r10827 37 37 private const double Diameter = 20; 38 38 39 private readonly Brush defaultBrush; 40 private readonly Pen defaultPen; 41 39 42 public IGenealogyGraph GenealogyGraph { 40 43 get { return genealogyGraph; } … … 95 98 : base() { 96 99 InitializeComponent(); 100 101 defaultBrush = new SolidBrush(Color.Transparent); 102 defaultPen = new Pen(Color.DarkGray); 97 103 } 98 104 … … 111 117 112 118 foreach (var node in nodes) { 113 var pen = new Pen(Color.DarkGray);114 119 var brush = new SolidBrush(node.GetColor()); 115 120 116 var visualNode = new VisualGenealogyGraphNode(Chart, x, y, x + diameter, y + diameter, pen, brush) {121 var visualNode = new VisualGenealogyGraphNode(Chart, x, y, x + diameter, y + diameter, defaultPen, brush) { 117 122 Data = node, 118 123 ToolTipText = "Rank: " + node.Rank + nl + … … 138 143 var visualParent = GetMappedNode(parent); 139 144 if (visualParent == null) continue; 140 var pen = new Pen(Color.Transparent);145 var pen = Pens.Transparent; 141 146 var visualArc = AddArc(Chart, visualParent, visualNode, pen); 142 147 if (!arcMap.ContainsKey(Tuple.Create(visualParent, visualNode))) … … 233 238 var start = new Point((int)arc.Start.X, (int)arc.Start.Y); 234 239 var end = new Point((int)arc.End.X, (int)arc.End.Y); 240 arc.Pen = new Pen(Color.Transparent); 235 241 arc.Pen.Brush = new LinearGradientBrush(start, end, source.GetColor(), target.GetColor()); 236 arc.Pen.Color = Color.Transparent;237 242 DrawLineage(nodeSelector(arc), arcSelector, nodeSelector); 238 243 } … … 266 271 foreach (var primitive in Chart.Group.Primitives) { 267 272 if (primitive is VisualGenealogyGraphArc) { 268 primitive.Pen .Brush = new SolidBrush(Color.Transparent);273 primitive.Pen = Pens.Transparent; 269 274 } else if (primitive is VisualGenealogyGraphNode) { 270 var brush = (SolidBrush)primitive.Brush; 271 brush.Color = Color.Transparent; 272 primitive.Pen.Color = Color.DarkGray; 275 primitive.Brush = Brushes.Transparent; 276 primitive.Pen = Pens.DarkGray; 273 277 } 274 278 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj
r10823 r10827 237 237 <DependentUpon>GraphicalSymbolicDataAnalysisModelView.cs</DependentUpon> 238 238 </Compile> 239 <Compile Include="Symbols\ConstantView.cs" /> 239 <Compile Include="Symbols\ConstantView.cs"> 240 <SubType>UserControl</SubType> 241 </Compile> 240 242 <Compile Include="Symbols\ConstantView.Designer.cs"> 241 243 <DependentUpon>ConstantView.cs</DependentUpon> 242 244 </Compile> 243 <Compile Include="Symbols\LaggedVariableView.cs" /> 245 <Compile Include="Symbols\LaggedVariableView.cs"> 246 <SubType>UserControl</SubType> 247 </Compile> 244 248 <Compile Include="Symbols\LaggedVariableView.Designer.cs"> 245 249 <DependentUpon>LaggedVariableView.cs</DependentUpon> 246 250 </Compile> 247 <Compile Include="Symbols\TimeLagView.cs" /> 251 <Compile Include="Symbols\TimeLagView.cs"> 252 <SubType>UserControl</SubType> 253 </Compile> 248 254 <Compile Include="Symbols\TimeLagView.Designer.cs"> 249 255 <DependentUpon>TimeLagView.cs</DependentUpon> 250 256 </Compile> 251 <Compile Include="Symbols\VariableConditionView.cs" /> 257 <Compile Include="Symbols\VariableConditionView.cs"> 258 <SubType>UserControl</SubType> 259 </Compile> 252 260 <Compile Include="Symbols\VariableConditionView.Designer.cs"> 253 261 <DependentUpon>VariableConditionView.cs</DependentUpon> 254 262 </Compile> 255 <Compile Include="Symbols\VariableView.cs" /> 263 <Compile Include="Symbols\VariableView.cs"> 264 <SubType>UserControl</SubType> 265 </Compile> 256 266 <Compile Include="Symbols\VariableView.Designer.cs"> 257 267 <DependentUpon>VariableView.cs</DependentUpon> -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/FragmentGraphView.cs
r10797 r10827 101 101 var rpb = primitive as RectangularPrimitiveBase; 102 102 if (rpb != null) { 103 rpb.Pen = new Pen(Color.RoyalBlue);103 rpb.Pen = Pens.RoyalBlue; 104 104 } 105 105 } … … 123 123 var rpb = primitive as RectangularPrimitiveBase; 124 124 if (rpb != null) { 125 rpb.Pen = new Pen(Color.DarkOrange);125 rpb.Pen = Pens.DarkOrange; 126 126 } 127 127 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionAfterCrossoverOperator.cs
r10755 r10827 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; … … 25 46 break; 26 47 } 27 // if the fragment is null then it means crossover did not do anything 28 // if (fragment == null) throw new Exception("Could not determine fragment!"); 48 // 49 // if (fragment == null) { 50 // throw new Exception("SymbolicDataAnalysisExpressionAfterCrossoverOperator: Could not identify fragment"); 51 // } 29 52 30 53 arcs[0].Data = null; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionAfterManipulatorOperator.cs
r10822 r10827 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System; 2 23 using System.Collections.Generic; 3 24 using System.Linq; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionBeforeManipulatorOperator.cs
r10755 r10827 1 using System.Linq; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2014 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 * 5 * This file is part of HeuristicLab. 6 * 7 * HeuristicLab is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * HeuristicLab is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>. 19 */ 20 #endregion 21 22 using System.Linq; 2 23 using HeuristicLab.Core; 3 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/SymbolicDataAnalysisExpressionTracing.cs
r10797 r10827 10 10 using IGraphNode = HeuristicLab.EvolutionTracking.IGenealogyGraphNode<HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.ISymbolicExpressionTree>; 11 11 12 namespace HeuristicLab.Problems.DataAnalysis.Symbolic .Views{12 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 13 13 public static class SymbolicDataAnalysisExpressionTracing { 14 14 public static IGenealogyGraph<IFragment<ISymbolicExpressionTreeNode>> TraceSubtree(IGenealogyGraphNode<ISymbolicExpressionTree> graphNode, int subtreeIndex) { … … 40 40 break; 41 41 } 42 42 var parents = node.Parents.ToList(); 43 43 if (node.IsElite) { 44 node = node.Parents.First(); 44 // skip elite, go up the graph to original individual 45 node = parents[0]; 45 46 continue; 46 } // skip elite, go up the graph to original individual 47 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 51 node = parents[0]; 52 continue; 53 } 54 var fragmentLength = fragment.Root.GetLength(); 48 55 var tree = node.Content; 49 56 var subtree = tree.NodeAt(index); 50 57 var subtreeLength = subtree.GetLength(); 51 58 52 var fragment = (IFragment<ISymbolicExpressionTreeNode>)node.InArcs.Last().Data; 53 if (fragment == null) break; 54 var fragmentLength = fragment.Root.GetLength(); 59 if (parents.Count == 1) { 60 // we are tracing a mutation operation 61 var fragmentNode = new FragmentNode { 62 Content = new Fragment<ISymbolicExpressionTreeNode> { Root = subtree }, 63 Rank = node.Rank 64 }; 65 if (parent != null) { 66 var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode }; 67 parent.AddForwardArc(arc); 68 } 69 yield return fragmentNode; 70 var up = Trace(parents[0], fragment.Index1, fragmentNode); 71 foreach (var v in up) { yield return v; } 72 break; 73 } 55 74 56 if (fragment.Index1 == index) { 57 node = node.Parents.Last(); // take second parent which contains the fragment 58 index = fragment.Index2; 59 } else if (fragment.Index1 < index) { 60 if (fragment.Index1 + fragmentLength > index) { 61 node = node.Parents.Last(); // fragment contains subtree, take second parent 62 index += fragment.Index2 - fragment.Index1; // the subtree has the same index relative to the fragment 63 } else { 64 // fragment distinct from subtree 65 node = node.Parents.First(); // take first parent which contains the subtree 66 index += node.Content.NodeAt(fragment.Index1).GetLength() - fragmentLength; // subtreeIndex must be adjusted according to swapped fragments sizes 75 if (parents.Count == 2) { 76 // we are tracing a crossover operation 77 if (fragment.Index1 == index) { 78 node = parents[1]; // take second parent which contains the fragment 79 index = fragment.Index2; 80 continue; 67 81 } 68 } else if (fragment.Index1 > index) { 69 if (fragment.Index1 < index + subtreeLength) { 70 // subtree contains fragment => bifurcation point in the fragment graph 71 var fragmentNode = new FragmentNode { 72 Content = new Fragment<ISymbolicExpressionTreeNode> { Root = subtree }, 73 Rank = node.Rank 74 }; 75 if (parent != null) { 76 var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode }; 77 parent.AddForwardArc(arc); 82 83 if (fragment.Index1 < index) { 84 if (fragment.Index1 + fragmentLength > index) { 85 node = parents[1]; // fragment contains subtree, take second parent 86 index += fragment.Index2 - fragment.Index1; // the subtree has the same index relative to the fragment 87 } else { 88 // fragment distinct from subtree 89 node = parents[0]; // take first parent which contains the subtree 90 index += node.Content.NodeAt(fragment.Index1).GetLength() - fragmentLength; // subtreeIndex must be adjusted according to swapped fragments sizes 78 91 } 79 fragmentNode.Content.Index1 = fragment.Index1 - index;80 yield return fragmentNode;92 continue; 93 } 81 94 82 var left = Trace(node.Parents.First(), index, fragmentNode); // trace subtree 95 if (fragment.Index1 > index) { 96 if (fragment.Index1 < index + subtreeLength) { 97 // subtree contains fragment => bifurcation point in the fragment graph 98 var fragmentNode = new FragmentNode { 99 Content = new Fragment<ISymbolicExpressionTreeNode> { Root = subtree }, 100 Rank = node.Rank 101 }; 102 if (parent != null) { 103 var arc = new GenealogyGraphArc { Source = parent, Target = fragmentNode }; 104 parent.AddForwardArc(arc); 105 } 106 fragmentNode.Content.Index1 = fragment.Index1 - index; 107 yield return fragmentNode; 83 108 84 if (node.Parents.Last().Content.NodeAt(fragment.Index2).GetLength() != fragmentLength) { 85 throw new Exception("Fragment lengths should match!"); 109 if (parents[1].Content.NodeAt(fragment.Index2).GetLength() != fragmentLength) { 110 throw new Exception("Fragment lengths should match!"); 111 } 112 // the two paths below ("left" and "right") correspond to the subtree and the fragment, respectively 113 var left = Trace(parents[0], index, fragmentNode); // trace subtree 114 var right = Trace(parents[1], fragment.Index2, fragmentNode); // trace fragment 115 foreach (var v in left.Concat(right)) { yield return v; } 116 break; 117 } else { 118 node = parents[0]; // fragment distinct from subtree: update node, index remains unchanged 86 119 } 87 var right = Trace(node.Parents.Last(), fragment.Index2, fragmentNode); // trace fragment88 foreach (var v in left.Concat(right)) { yield return v; }89 break;90 } else {91 node = node.Parents.First(); // fragment distinct from subtree: update node, index remains unchanged92 120 } 93 121 } … … 101 129 } 102 130 #region some helper methods for shortening the tracing code 103 104 131 private static void AddChild(this IGenealogyGraphNode parent, IGenealogyGraphNode child) { 105 132 parent.AddForwardArc(child);
Note: See TracChangeset
for help on using the changeset viewer.