Changeset 10746 for branches/HeuristicLab.EvolutionTracking
- Timestamp:
- 04/14/14 17:15:32 (11 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 1 added
- 5 edited
- 10 moved
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeTile.cs
r10730 r10746 23 23 using System.Collections.Generic; 24 24 using System.Drawing; 25 using System.Drawing.Drawing2D; 25 26 using System.Linq; 26 27 using HeuristicLab.Common; … … 37 38 public int PreferredNodeWidth { get; set; } 38 39 public int PreferredNodeHeight { get; set; } 40 public ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> LayoutEngine { get; set; } 41 private readonly Dictionary<IPrimitive, ISymbolicExpressionTreeNode> primitivesToNodes; 42 private readonly Dictionary<ISymbolicExpressionTreeNode, IPrimitive> nodesToPrimitives; 39 43 40 44 private Size size; … … 70 74 } 71 75 76 public IPrimitive GetPrimitive(ISymbolicExpressionTreeNode node) { 77 IPrimitive primitive; 78 nodesToPrimitives.TryGetValue(node, out primitive); 79 return primitive; 80 } 81 82 public ISymbolicExpressionTreeNode GetExpressionTreeNode(IPrimitive primitive) { 83 ISymbolicExpressionTreeNode node; 84 primitivesToNodes.TryGetValue(primitive, out node); 85 return node; 86 } 87 72 88 private ISymbolicExpressionTree symbolicExpressionTree; 73 89 public ISymbolicExpressionTree SymbolicExpressionTree { … … 81 97 new private void Clear() { 82 98 Group.Clear(); 83 primitiveMap.Clear(); 99 primitivesToNodes.Clear(); 100 nodesToPrimitives.Clear(); 84 101 } 85 102 … … 92 109 } 93 110 } 94 public ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> LayoutEngine { get; set; }95 private readonly Dictionary<IPrimitive, ISymbolicExpressionTreeNode> primitiveMap;96 111 97 112 public SymbolicExpressionTreeTile(IChart chart) 98 113 : base(chart) { 99 primitiveMap = new Dictionary<IPrimitive, ISymbolicExpressionTreeNode>(); 114 primitivesToNodes = new Dictionary<IPrimitive, ISymbolicExpressionTreeNode>(); 115 nodesToPrimitives = new Dictionary<ISymbolicExpressionTreeNode, IPrimitive>(); 100 116 PreferredNodeWidth = 80; 101 117 PreferredNodeHeight = 40; … … 124 140 var upperRight = new PointD(visualNode.X + preferredNodeWidth, visualNode.Y + preferredNodeHeight); 125 141 var node = visualNode.Content; 142 126 143 RectangularPrimitiveBase rectangularPrimitive; 127 144 if (node.SubtreeCount == 0) { … … 131 148 } 132 149 133 primitiveMap.Add(rectangularPrimitive, node); // to be able to retrieve nodes via primitives 150 primitivesToNodes.Add(rectangularPrimitive, node); // to be able to retrieve nodes via primitives 151 nodesToPrimitives.Add(node, rectangularPrimitive); 134 152 this.Add(rectangularPrimitive); 135 153 … … 179 197 } 180 198 } 199 200 public override void Draw(Graphics graphics) { 201 graphics.SmoothingMode = SmoothingMode.HighQuality; 202 base.Draw(graphics); 203 } 181 204 } 182 205 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphChart.cs
r10732 r10746 225 225 private static void DrawLineage(VisualGenealogyGraphNode node, Func<VisualGenealogyGraphNode, IEnumerable<VisualGenealogyGraphArc>> arcSelector, Func<VisualGenealogyGraphArc, VisualGenealogyGraphNode> nodeSelector) { 226 226 var brush = (SolidBrush)node.Brush; 227 if (brush.Color != Color.Transparent) return; // this lineage was already drawn (avoid redrawing common ancestors) 227 228 brush.Color = node.Data.GetColor(); 228 var arcs = arcSelector(node) .ToList();229 var arcs = arcSelector(node); 229 230 foreach (var arc in arcs) { 230 231 var source = arc.Source.Data; … … 234 235 arc.Pen.Brush = new LinearGradientBrush(start, end, source.GetColor(), target.GetColor()); 235 236 arc.Pen.Color = Color.Transparent; 236 // if (arc == arcs[0]) { arc.Pen.Width = 2; } // mark connection to the root parent237 237 DrawLineage(nodeSelector(arc), arcSelector, nodeSelector); 238 238 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/HeuristicLab.Problems.DataAnalysis.Symbolic.Views-3.4.csproj
r10728 r10746 193 193 <ItemGroup> 194 194 <Compile Include="Exporters\SymbolicSolutionExcelExporter.cs" /> 195 <Compile Include="FragmentGraphView.cs">196 <SubType>UserControl</SubType>197 </Compile>198 <Compile Include="FragmentGraphView.Designer.cs">199 <DependentUpon>FragmentGraphView.cs</DependentUpon>200 </Compile>201 195 <Compile Include="InteractiveSymbolicExpressionTreeChart.cs"> 202 196 <SubType>UserControl</SubType> … … 225 219 <DependentUpon>SlidingWindowDataView.cs</DependentUpon> 226 220 </Compile> 227 <Compile Include="SymboldDataAnalysisGenealogyView.cs">228 <SubType>UserControl</SubType>229 </Compile>230 <Compile Include="SymboldDataAnalysisGenealogyView.Designer.cs">231 <DependentUpon>SymboldDataAnalysisGenealogyView.cs</DependentUpon>232 </Compile>233 <Compile Include="SymbolicDataAnalysisExpressionGenealogyGraphChart.cs" />234 <Compile Include="SymbolicDataAnalysisExpressionGenealogyGraphChart.Designer.cs">235 <DependentUpon>SymbolicDataAnalysisExpressionGenealogyGraphChart.cs</DependentUpon>236 </Compile>237 <Compile Include="SymbolicExpressionChartControl.cs">238 <SubType>UserControl</SubType>239 </Compile>240 <Compile Include="SymbolicExpressionChartControl.Designer.cs">241 <DependentUpon>SymbolicExpressionChartControl.cs</DependentUpon>242 </Compile>243 <Compile Include="SymbolicDataAnalysisExpressionLineageExplorerView.cs">244 <SubType>UserControl</SubType>245 </Compile>246 <Compile Include="SymbolicDataAnalysisExpressionLineageExplorerView.Designer.cs">247 <DependentUpon>SymbolicDataAnalysisExpressionLineageExplorerView.cs</DependentUpon>248 </Compile>249 221 <Compile Include="TextualSymbolicDataAnalysisModelView.cs"> 250 222 <SubType>UserControl</SubType> … … 294 266 <Compile Include="Symbols\VariableView.Designer.cs"> 295 267 <DependentUpon>VariableView.cs</DependentUpon> 268 </Compile> 269 <Compile Include="Tracking\FragmentGraphView.cs"> 270 <SubType>UserControl</SubType> 271 </Compile> 272 <Compile Include="Tracking\FragmentGraphView.Designer.cs"> 273 <DependentUpon>FragmentGraphView.cs</DependentUpon> 274 </Compile> 275 <Compile Include="Tracking\SymboldDataAnalysisGenealogyView.cs"> 276 <SubType>UserControl</SubType> 277 </Compile> 278 <Compile Include="Tracking\SymboldDataAnalysisGenealogyView.Designer.cs"> 279 <DependentUpon>SymboldDataAnalysisGenealogyView.cs</DependentUpon> 280 </Compile> 281 <Compile Include="Tracking\SymbolicDataAnalysisExpressionGenealogyGraphChart.cs"> 282 <SubType>UserControl</SubType> 283 </Compile> 284 <Compile Include="Tracking\SymbolicDataAnalysisExpressionGenealogyGraphChart.Designer.cs"> 285 <DependentUpon>SymbolicDataAnalysisExpressionGenealogyGraphChart.cs</DependentUpon> 286 </Compile> 287 <Compile Include="Tracking\SymbolicDataAnalysisExpressionLineageExplorerView.cs"> 288 <SubType>UserControl</SubType> 289 </Compile> 290 <Compile Include="Tracking\SymbolicDataAnalysisExpressionLineageExplorerView.Designer.cs"> 291 <DependentUpon>SymbolicDataAnalysisExpressionLineageExplorerView.cs</DependentUpon> 292 </Compile> 293 <Compile Include="Tracking\SymbolicExpressionChartControl.cs"> 294 <SubType>UserControl</SubType> 295 </Compile> 296 <Compile Include="Tracking\SymbolicExpressionChartControl.Designer.cs"> 297 <DependentUpon>SymbolicExpressionChartControl.cs</DependentUpon> 296 298 </Compile> 297 299 <Compile Include="TreeEditDialogs\SymbolicExpressionTreeConstantNodeEditDialog.cs"> … … 366 368 </Content> 367 369 </ItemGroup> 370 <ItemGroup /> 368 371 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 369 372 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/FragmentGraphView.cs
r10732 r10746 13 13 [Content(typeof(IGenealogyGraph<IFragment<ISymbolicExpressionTreeNode>>), IsDefaultView = true)] 14 14 public sealed partial class FragmentGraphView : ItemView { 15 private int PreferredSpacing = 50; 15 private const int PreferredHorizontalSpacing = 10; 16 private const int PreferredVerticalSpacing = 25; 16 17 17 18 private ReingoldTilfordLayoutEngine<TileLayoutNode> layoutEngine; … … 31 32 32 33 layoutEngine = new ReingoldTilfordLayoutEngine<TileLayoutNode>(n => n.Children) { 33 HorizontalSpacing = 50,34 VerticalSpacing = 50,34 HorizontalSpacing = PreferredHorizontalSpacing, 35 VerticalSpacing = PreferredVerticalSpacing, 35 36 }; 36 37 symbolicExpressionEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(n => n.Subtrees) { 37 HorizontalSpacing = 50,38 VerticalSpacing = 50,38 HorizontalSpacing = PreferredHorizontalSpacing, 39 VerticalSpacing = PreferredVerticalSpacing, 39 40 NodeWidth = 80, 40 41 NodeHeight = 40 … … 74 75 layoutEngine.NodeWidth = maxTileWidth; 75 76 layoutEngine.NodeHeight = maxTileHeight; 76 layoutEngine.HorizontalSpacing = Preferred Spacing;77 layoutEngine.VerticalSpacing = Preferred Spacing;77 layoutEngine.HorizontalSpacing = PreferredHorizontalSpacing; 78 layoutEngine.VerticalSpacing = PreferredVerticalSpacing; 78 79 79 80 var visualNodes = layoutEngine.CalculateLayout(fragmentRoot); … … 92 93 var aPos = aTile.Position; 93 94 94 var lowerLeftMarker = new FixedSizeCircle(chart, aTile.Position, 5, new Pen(Color.Red), new SolidBrush(Color.Transparent)); 95 var upperRightMarker = new FixedSizeCircle(chart, new PointD(aPos.X + aSize.Width, aPos.Y + aSize.Height), 5, 96 new Pen(Color.Blue), new SolidBrush(Color.Transparent)); 97 symbolicExpressionChartControl.Add(lowerLeftMarker); symbolicExpressionChartControl.Add(upperRightMarker); 95 // mark swapped fragment 96 if (node.Content.Index != 0) { 97 var subtree = node.Content.Root.NodeAt(node.Content.Index); 98 foreach (var s in subtree.IterateNodesPrefix()) { 99 var primitive = aTile.GetPrimitive(s); 100 if (primitive != null) { 101 var rpb = primitive as RectangularPrimitiveBase; 102 if (rpb != null) { 103 rpb.Pen = new Pen(Color.RoyalBlue); 104 } 105 } 106 } 107 } 108 109 // mark the subtree that was replaced by the fragment 110 if (node.Children.Any() && node.Content.Index != 0) { 111 var child = node.Children.First(); 112 { 113 var subtree = child.Content.Root.NodeAt(node.Content.Index); 114 var tile = tileDictionary[child].Tile; 115 foreach (var s in subtree.IterateNodesPrefix()) { 116 var primitive = tile.GetPrimitive(s); 117 if (primitive != null) { 118 var rpb = primitive as RectangularPrimitiveBase; 119 if (rpb != null) { 120 rpb.Pen = new Pen(Color.DarkOrange); 121 } 122 } 123 } 124 } 125 } 98 126 99 127 foreach (var child in node.Children) { … … 104 132 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)); 105 133 symbolicExpressionChartControl.Add(line); 134 135 106 136 } 107 137 } 108 // symbolicExpressionChartControl.FlipVertical();109 138 symbolicExpressionChartControl.UpdateEnabled = true; 110 139 symbolicExpressionChartControl.EnforceUpdate(); -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/Tracking/SymboldDataAnalysisGenealogyView.cs
r10732 r10746 182 182 var fragmentLength = fragment.Root.GetLength(); 183 183 184 var fragmentNode = new FragmentNode { Content = new Fragment<ISymbolicExpressionTreeNode> { Root = subtree }, Rank = graphNode.Rank }; 184 var fragmentNode = new FragmentNode { 185 Content = new Fragment<ISymbolicExpressionTreeNode> { 186 Root = subtree, 187 }, 188 Rank = graphNode.Rank 189 }; 190 185 191 if (parentNode != null) { 186 if (parentNode == fragmentNode) 192 if (parentNode == fragmentNode) { 187 193 throw new Exception("Node cannot be a child of itself!"); 194 } 188 195 var arc = new GenealogyGraphArc { Source = parentNode, Target = fragmentNode }; 189 196 parentNode.AddForwardArc(arc); 190 197 } 191 198 fragmentGraph.AddVertex(fragmentNode); 199 192 200 parentNode = fragmentNode; 193 201 … … 213 221 if (subtreeIndex < fragment.Index && fragment.Index < subtreeIndex + subtreeLength) { 214 222 if (fragmentLength >= subtreeLength) throw new Exception("Subtree contains fragment, so fragment length should be less than the subtree length."); 215 223 fragmentNode.Content.Index = fragment.Index - subtreeIndex; 216 224 graphNode = parentVertices[0]; 225 // debug check 217 226 tree = graphNode.Content; 218 227 subtree = tree.NodeAt(subtreeIndex); 228 if (subtree.GetLength() <= fragmentNode.Content.Index) { 229 throw new Exception("Index exceeds subtree length."); 230 } 219 231 // track subtree 220 232 Trace(graphNode, subtree, fragmentGraph, fragmentNode); … … 222 234 // track fragment 223 235 if (parentVertices.Count > 1) { 236 // save the index of the current fragment in the tree where it was swapped 224 237 graphNode = parentVertices[1]; 225 238 tree = graphNode.Content; -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Matching/SymbolicExpressionTreeMatching.cs
r10650 r10746 16 16 public static IEnumerable<ISymbolicExpressionTreeNode> FindMatches(ISymbolicExpressionTreeNode root, ISymbolicExpressionTreeNode subtree, ISymbolicExpressionTreeNodeSimilarityComparer comp) { 17 17 var fragmentLength = subtree.GetLength(); 18 // below, we use ">=" for Match(n, subtree, comp) >= fragmentLength because in case of relaxed conditions, 19 // we can have multiple matches of the same node 20 21 return root.IterateNodesBreadth().Where(n => n.GetLength() >= fragmentLength && Match(n, subtree, comp) == fragmentLength); 18 return root.IterateNodesBreadth().Where(n => n.GetLength() >= fragmentLength && Match(n, subtree, comp) >= fragmentLength); 22 19 } 23 20 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Tracking.sln
r10300 r10746 2 2 Microsoft Visual Studio Solution File, Format Version 12.00 3 3 # Visual Studio 2013 4 VisualStudioVersion = 12.0. 21005.14 VisualStudioVersion = 12.0.30110.0 5 5 MinimumVisualStudioVersion = 10.0.40219.1 6 6 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C80F4C35-CB87-4695-8A53-6F2D08275253}" … … 9 9 HeuristicLab.Tracking.vsmdi = HeuristicLab.Tracking.vsmdi 10 10 Local.testsettings = Local.testsettings 11 Performance1.psess = Performance1.psess 11 12 PreBuildEvent.cmd = PreBuildEvent.cmd 12 13 TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings … … 169 170 HideSolutionNode = FALSE 170 171 EndGlobalSection 172 GlobalSection(Performance) = preSolution 173 HasPerformanceSessions = true 174 EndGlobalSection 171 175 GlobalSection(TestCaseManagementSettings) = postSolution 172 176 CategoryFile = HeuristicLab.Tracking.vsmdi
Note: See TracChangeset
for help on using the changeset viewer.