- Timestamp:
- 02/21/14 18:20:47 (11 years ago)
- Location:
- branches/HeuristicLab.EvolutionTracking
- Files:
-
- 3 added
- 1 deleted
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding
- Property svn:mergeinfo changed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/GraphicalSymbolicExpressionTreeView.Designer.cs
r9456 r10501 19 19 */ 20 20 #endregion 21 22 using System.Drawing; 21 23 22 24 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views { … … 59 61 this.symbolicExpressionTreeChart.Spacing = 5; 60 62 this.symbolicExpressionTreeChart.TabIndex = 0; 61 this.symbolicExpressionTreeChart.TextFont = new System.Drawing.Font( "Times New Roman", 6F);63 this.symbolicExpressionTreeChart.TextFont = new System.Drawing.Font(FontFamily.GenericSerif, 8F); 62 64 // 63 65 // FunctionTreeView -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/GraphicalSymbolicExpressionTreeView.cs
r10347 r10501 20 20 #endregion 21 21 22 using System.Drawing;23 22 using System.Windows.Forms; 24 23 using HeuristicLab.Core.Views; … … 53 52 symbolicExpressionTreeChart.Enabled = Content != null; 54 53 } 55 56 public void HighlightNode(ISymbolicExpressionTreeNode node, Color color) {57 symbolicExpressionTreeChart.HighlightNode(node, color);58 }59 60 public void HighlightSubtree(ISymbolicExpressionTreeNode subtree, Color color) {61 symbolicExpressionTreeChart.HighlightSubtree(subtree, color);62 }63 54 } 64 55 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.Designer.cs
r10302 r10501 50 50 this.saveImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 51 51 this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); 52 this.export LatexToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();52 this.exportPgfLaTeXToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 53 53 this.contextMenuStrip.SuspendLayout(); 54 54 this.SuspendLayout(); … … 58 58 this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 59 59 this.saveImageToolStripMenuItem, 60 this.export LatexToolStripMenuItem});60 this.exportPgfLaTeXToolStripMenuItem}); 61 61 this.contextMenuStrip.Name = "contextMenuStrip"; 62 this.contextMenuStrip.Size = new System.Drawing.Size(16 1, 70);62 this.contextMenuStrip.Size = new System.Drawing.Size(166, 70); 63 63 // 64 64 // saveImageToolStripMenuItem 65 65 // 66 66 this.saveImageToolStripMenuItem.Name = "saveImageToolStripMenuItem"; 67 this.saveImageToolStripMenuItem.Size = new System.Drawing.Size(1 60, 22);67 this.saveImageToolStripMenuItem.Size = new System.Drawing.Size(152, 22); 68 68 this.saveImageToolStripMenuItem.Text = "Save Image"; 69 69 this.saveImageToolStripMenuItem.Click += new System.EventHandler(this.saveImageToolStripMenuItem_Click); … … 73 73 this.saveFileDialog.Filter = "Bitmap (*.bmp)|*.bmp|EMF (*.emf)|*.emf"; 74 74 // 75 // export LatexToolStripMenuItem75 // exportPgfLaTeXToolStripMenuItem 76 76 // 77 this.export LatexToolStripMenuItem.Name = "exportLatexToolStripMenuItem";78 this.export LatexToolStripMenuItem.Size = new System.Drawing.Size(160, 22);79 this.export LatexToolStripMenuItem.Text = "Export Pgf/Latex";80 this.export LatexToolStripMenuItem.Click += new System.EventHandler(this.exportLatexToolStripMenuItem_Click);77 this.exportPgfLaTeXToolStripMenuItem.Name = "exportPgfLaTeXToolStripMenuItem"; 78 this.exportPgfLaTeXToolStripMenuItem.Size = new System.Drawing.Size(165, 22); 79 this.exportPgfLaTeXToolStripMenuItem.Text = "Export Pgf/LaTeX"; 80 this.exportPgfLaTeXToolStripMenuItem.Click += new System.EventHandler(this.exportLatexToolStripMenuItem_Click); 81 81 // 82 82 // SymbolicExpressionTreeChart … … 102 102 protected System.Windows.Forms.ToolStripMenuItem saveImageToolStripMenuItem; 103 103 protected System.Windows.Forms.SaveFileDialog saveFileDialog; 104 private System.Windows.Forms.ToolStripMenuItem export LatexToolStripMenuItem;104 private System.Windows.Forms.ToolStripMenuItem exportPgfLaTeXToolStripMenuItem; 105 105 } 106 106 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs
r10456 r10501 32 32 public partial class SymbolicExpressionTreeChart : UserControl { 33 33 private Image image; 34 private StringFormat stringFormat;34 private readonly StringFormat stringFormat; 35 35 private Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes; 36 36 private Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualSymbolicExpressionTreeNodeConnection> visualLines; … … 51 51 this.lineColor = Color.Black; 52 52 this.backgroundColor = Color.White; 53 this.textFont = new Font(FontFamily.GenericS erif, 14, GraphicsUnit.Pixel);53 this.textFont = new Font(FontFamily.GenericSansSerif, 12); 54 54 layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(); 55 55 layoutAdapter = new SymbolicExpressionTreeLayoutAdapter(); … … 108 108 visualLines = new Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualSymbolicExpressionTreeNodeConnection>(); 109 109 if (tree != null) { 110 foreach (ISymbolicExpressionTreeNode node in tree.IterateNodesPrefix()) { 110 IEnumerable<ISymbolicExpressionTreeNode> nodes; 111 if (tree.Root.SubtreeCount == 1) nodes = tree.Root.GetSubtree(0).IterateNodesPrefix(); 112 else nodes = tree.Root.IterateNodesPrefix(); 113 foreach (ISymbolicExpressionTreeNode node in nodes) { 111 114 visualTreeNodes[node] = new VisualSymbolicExpressionTreeNode(node); 112 115 if (node.Parent != null) visualLines[Tuple.Create(node.Parent, node)] = new VisualSymbolicExpressionTreeNodeConnection(); … … 166 169 this.Refresh(); 167 170 } 168 }169 170 public void HighlightNode(ISymbolicExpressionTreeNode node, Color color) {171 var visualNode = GetVisualSymbolicExpressionTreeNode(node);172 if (visualNode == null) return;173 visualNode.LineColor = color;174 RepaintNode(visualNode);175 }176 177 public void HighlightSubtree(ISymbolicExpressionTreeNode subtree, Color color) {178 foreach (var node in subtree.IterateNodesBreadth())179 HighlightNode(node, color);180 171 } 181 172 … … 280 271 private void DrawFunctionTree(ISymbolicExpressionTree symbolicExpressionTree, Graphics graphics, int preferredWidth, int preferredHeight, int minHDistance, int minVDistance) { 281 272 var layoutNodes = layoutAdapter.Convert(symbolicExpressionTree).ToList(); 273 if (symbolicExpressionTree.Root.SubtreeCount == 1) layoutNodes.RemoveAt(0); 282 274 layoutEngine.Reset(); 283 275 layoutEngine.Root = layoutNodes[0]; 284 foreach (var ln in layoutNodes) 285 layoutEngine.AddNode(ln.Content, ln); 286 layoutEngine.MinHorizontalSpacing = (preferredNodeWidth + minHDistance); 287 layoutEngine.MinVerticalSpacing = (preferredNodeHeight + minVDistance); 276 layoutEngine.AddNodes(layoutNodes); 277 layoutEngine.MinHorizontalSpacing = (preferredWidth + minHDistance); 278 layoutEngine.MinVerticalSpacing = (preferredHeight + minVDistance); 288 279 layoutEngine.CalculateLayout(); 289 280 var bounds = layoutEngine.Bounds(); 290 double sx = this.Width / (bounds.Width + preferredWidth); 291 if (sx > 1) sx = 1; 292 double sy = this.Height / bounds.Height; 293 if (sy > 1) sy = 1; 294 double dx = (this.Width - bounds.Width) / 2; 295 if (dx < 0) dx = 0; 296 double dy = (this.Height - bounds.Height) / 2; 297 if (dy < 0) dy = 0; 298 299 var levels = layoutNodes.GroupBy(n => n.Level, n => n); 300 301 foreach (var level in levels) { 302 var nodes = level.ToList(); 303 double min = 0; 304 for (int i = 0; i < nodes.Count - 1; ++i) { 305 var w = (nodes[i + 1].X - nodes[i].X) * sx - preferredWidth; 306 if (w < min) min = w; 307 } 308 if (min > 0) min = 0; 309 310 foreach (var layoutNode in level) { 281 282 double verticalScalingFactor = 1.0; 283 double layoutHeight = (bounds.Height + preferredHeight); 284 if (this.Height < layoutHeight) 285 verticalScalingFactor = this.Height / layoutHeight; 286 287 double horizontalScalingFactor = 1.0; 288 double layoutWidth = (bounds.Width + preferredWidth); 289 if (this.Width < layoutWidth) 290 horizontalScalingFactor = this.Width / layoutWidth; 291 292 double horizontalOffset; 293 if (this.Width > layoutWidth) 294 horizontalOffset = (this.Width - layoutWidth) / 2.0; 295 else 296 horizontalOffset = preferredWidth / 2.0; 297 298 var levels = layoutNodes.GroupBy(n => n.Level, n => n).ToList(); 299 for (int i = levels.Count - 1; i >= 0; --i) { 300 var nodes = levels[i].ToList(); 301 302 double minSpacing = double.MaxValue; 303 if (nodes.Count > 1) { 304 for (int j = 1; j < nodes.Count() - 1; ++j) { 305 var distance = nodes[j].X - nodes[j - 1].X; // guaranteed to be > 0 306 if (minSpacing > distance) minSpacing = distance; 307 } 308 } 309 minSpacing *= horizontalScalingFactor; 310 311 int minWidth = (int)Math.Round(preferredWidth * horizontalScalingFactor); 312 int width = (int)Math.Min(minSpacing, preferredWidth) - 2; // leave some pixels so that node margins don't overlap 313 314 foreach (var layoutNode in nodes) { 311 315 var visualNode = visualTreeNodes[layoutNode.Content]; 312 visualNode.Width = (int)Math.Round(preferredWidth + min) - 2; // -2 to allow enough padding (1px on each side) for the node contour to be drawn313 visualNode.Height = (int)Math.Round(preferredHeight * sy);314 visualNode.X = (int) (Math.Round(layoutNode.X * sx + dx));315 visualNode.Y = (int) (Math.Round(layoutNode.Y * sy + dy));316 visualNode.Width = width; 317 visualNode.Height = (int)Math.Round(preferredHeight * verticalScalingFactor); 318 visualNode.X = (int)Math.Round((layoutNode.X + horizontalOffset) * horizontalScalingFactor + (minWidth - width) / 2.0); 319 visualNode.Y = (int)Math.Round(layoutNode.Y * verticalScalingFactor); 316 320 DrawTreeNode(graphics, visualNode); 317 321 } 318 322 } 319 320 graphics.ResetClip(); // reset clip region321 323 // draw node connections 322 324 foreach (var visualNode in visualTreeNodes.Values) { … … 327 329 var origin = new Point(visualNode.X + visualNode.Width / 2, visualNode.Y + visualNode.Height); 328 330 var target = new Point(visualSubtree.X + visualSubtree.Width / 2, visualSubtree.Y); 331 graphics.Clip = new Region(new Rectangle(Math.Min(origin.X, target.X), origin.Y, Math.Max(origin.X, target.X), target.Y)); 329 332 using (var linePen = new Pen(visualLine.LineColor)) { 330 333 linePen.DashStyle = visualLine.DashStyle; … … 378 381 Image image = new Bitmap(Width, Height); 379 382 using (Graphics g = Graphics.FromImage(image)) { 380 int height = this.Height / tree.Depth; 381 DrawFunctionTree(tree, g, 0, 0, Width, height); 383 DrawFunctionTree(tree, g, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance); 382 384 } 383 385 image.Save(filename); … … 386 388 public void SaveImageAsEmf(string filename) { 387 389 if (tree == null) return; 388 using (var graphics = Graphics.FromImage(image)) { 389 var rectangle = new Rectangle(0, 0, image.Width, image.Height); 390 using (var metafile = new Metafile(filename, graphics.GetHdc(), rectangle, MetafileFrameUnit.Pixel, EmfType.EmfPlusDual)) { 391 graphics.ReleaseHdc(); 392 using (var g = Graphics.FromImage(metafile)) { 393 DrawFunctionTree(tree, g, 0, 0, image.Width, image.Height); 390 using (Graphics g = CreateGraphics()) { 391 using (Metafile file = new Metafile(filename, g.GetHdc())) { 392 using (Graphics emfFile = Graphics.FromImage(file)) { 393 DrawFunctionTree(tree, emfFile, preferredNodeWidth, preferredNodeHeight, minHorizontalDistance, minVerticalDistance); 394 394 } 395 395 } 396 g.ReleaseHdc(); 396 397 } 397 398 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Formatters/SymbolicExpressionTreeLatexFormatter.cs
r10459 r10501 1 using System; 1 #region License Information 2 /* HeuristicLab 3 * Copyright (C) 2002-2013 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.Globalization; … … 8 29 9 30 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 10 [Item("LaTeX/PDF Formatter", "Formatter for symbolic expression trees for use with latex .")]31 [Item("LaTeX/PDF Formatter", "Formatter for symbolic expression trees for use with latex package tikz.")] 11 32 public class SymbolicExpressionTreeLatexFormatter : NamedItem, ISymbolicExpressionTreeStringFormatter { 12 private readonly static Dictionary<string, string> SymbolNamesMap = new Dictionary<string, string>33 private readonly static Dictionary<string, string> symbolNameMap = new Dictionary<string, string> 13 34 { 14 35 {"ProgramRootSymbol", "Prog"}, 15 {"StartSymbol","RPB"}, 16 {"Addition", "$+$"}, 17 {"Subtraction", "$-$"}, 18 {"Multiplication", "$\\times$"}, 19 {"Division", "$\\div$"}, 20 {"Logarithm", "$\\log$"}, 21 {"Exponential", "$\\exp$"} 36 {"StartSymbol","RPB"} 22 37 }; 23 private readonly ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> layoutEngine ;24 private readonly SymbolicExpressionTreeLayoutAdapter layoutAdapter ;38 private readonly ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode> layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(); 39 private readonly SymbolicExpressionTreeLayoutAdapter layoutAdapter = new SymbolicExpressionTreeLayoutAdapter(); 25 40 26 public SymbolicExpressionTreeLatexFormatter() { 41 public SymbolicExpressionTreeLatexFormatter() 42 : base("LaTeX/PDF Formatter", "Formatter for symbolic expression trees for use with latex package tikz.") { 27 43 layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>(); 28 layoutAdapter = new SymbolicExpressionTreeLayoutAdapter();29 44 } 30 45 31 46 protected SymbolicExpressionTreeLatexFormatter(SymbolicExpressionTreeLatexFormatter original, Cloner cloner) 32 47 : base(original, cloner) { 33 layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>();34 layoutAdapter = new SymbolicExpressionTreeLayoutAdapter();35 48 } 36 49 … … 40 53 41 54 public string Format(ISymbolicExpressionTree symbolicExpressionTree) { 55 layoutEngine.Reset(); 42 56 var layoutNodes = layoutAdapter.Convert(symbolicExpressionTree).ToList(); 43 layoutEngine.Reset();44 57 layoutEngine.Root = layoutNodes[0]; 45 foreach (var ln in layoutNodes) 46 layoutEngine.AddNode(ln.Content, ln); 58 layoutEngine.AddNodes(layoutNodes); 47 59 layoutEngine.CalculateLayout(); 48 60 var nodeCoordinates = layoutEngine.GetNodeCoordinates(); 49 61 var sb = new StringBuilder(); 50 62 var nl = Environment.NewLine; 63 double ws = 1; 64 double hs = 0.7; 65 51 66 sb.Append("\\documentclass[class=minimal,border=0pt]{standalone}" + nl + 52 67 "\\usepackage{tikz}" + nl + … … 56 71 "\\def\\hs{0.7}" + nl); 57 72 58 const double ws = 1.0, hs = 0.7; // some scaling factors useful for fine-tuning document appearance before latex compilation73 var nodeIndices = new Dictionary<ISymbolicExpressionTreeNode, int>(); 59 74 var nodes = symbolicExpressionTree.IterateNodesBreadth().ToList(); 60 var nodeIndices = new Dictionary<ISymbolicExpressionTreeNode, int>();61 75 for (int i = 0; i < nodes.Count; ++i) { 62 76 var node = nodes[i]; 63 77 nodeIndices.Add(node, i); 64 var symbolName = node.Symbol.Name;65 var nodeName = SymbolNamesMap.ContainsKey(symbolName) ? SymbolNamesMap[symbolName] : symbolName;66 78 var coord = nodeCoordinates[node]; 67 79 var nodeName = symbolNameMap.ContainsKey(node.Symbol.Name) ? symbolNameMap[node.Symbol.Name] : node.ToString(); 68 80 sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "\\node ({0}) at (\\ws*{1},\\hs*{2}) {{{3}}};", i, ws * coord.X, -hs * coord.Y, EscapeLatexString(nodeName))); 69 81 } … … 75 87 } 76 88 77 sb.Append Line("\\end{tikzpicture}" + nl + "\\end{document}" + nl);78 89 sb.Append("\\end{tikzpicture}" + nl + 90 "\\end{document}" + nl); 79 91 return sb.ToString(); 80 92 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ILayoutAdapter.cs
r10269 r10501 4 4 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 5 5 public interface ILayoutAdapter<T> where T : class { 6 IEnumerable< ILayoutNode<T>> Convert(T root, Func<T, ILayoutNode<T>> convertFunc);6 IEnumerable<LayoutNode<T>> Convert(T root, Func<T, LayoutNode<T>> convertFunc); 7 7 } 8 8 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/branches/HeuristicLab.ReingoldTilfordTreeLayout/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs merged eligible /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs merged eligible /branches/Benchmarking/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 6917-7005 /branches/CloningRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 4656-4721 /branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 5471-5808 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 5815-6180 /branches/DataAnalysis/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 4458-4459,4462,4464 /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 6284-6795 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 5060 /branches/HLScript/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 10331-10358 /branches/HeuristicLab.Crossovers/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 7343-7503 /branches/HeuristicLab.DataAnalysis.Symbolic.LinearInterpreter/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 9271-9826 /branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 7098-8789 /branches/LogResidualEvaluator/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 10202-10483 /branches/NET40/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 5138-5162 /branches/ParallelEngine/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 5175-5192 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 7568-7810 /branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 6350-6627 /branches/Restructure trunk solution/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 6828 /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 10204-10479 /branches/SuccessProgressAnalysis/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 5370-5682 /branches/Trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 6829-6865 /branches/VNS/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 5594-5752 /branches/histogram/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 5959-6341 /stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs 10032-10033
r10269 r10501 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; 24 25 25 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding .LayoutEngines{26 public class LayoutNode<T> : ILayoutNode<T>where T : class {27 public ILayoutNode<T> NextLeft {26 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 27 public class LayoutNode<T> where T : class { 28 public LayoutNode<T> NextLeft { 28 29 get { 29 30 return Children == null ? Thread : Children.First(); 30 31 } 31 32 } 32 public ILayoutNode<T> NextRight {33 public LayoutNode<T> NextRight { 33 34 get { 34 35 return Children == null ? Thread : Children.Last(); 35 36 } 36 37 } 37 public ILayoutNode<T> LeftSibling {38 public LayoutNode<T> LeftSibling { 38 39 get { 39 40 if (Parent == null) return null; … … 41 42 } 42 43 } 43 public ILayoutNode<T> LeftmostSibling {44 public LayoutNode<T> LeftmostSibling { 44 45 get { 45 46 if (Parent == null) return null; … … 48 49 } 49 50 50 public ILayoutNode<T> Thread { get; set; }51 public ILayoutNode<T> Ancestor { get; set; }52 public ILayoutNode<T> Parent { get; set; }53 public List< ILayoutNode<T>> Children { get; set; }51 public LayoutNode<T> Thread { get; set; } 52 public LayoutNode<T> Ancestor { get; set; } 53 public LayoutNode<T> Parent { get; set; } 54 public List<LayoutNode<T>> Children { get; set; } 54 55 public float Mod { get; set; } 55 56 public float Prelim { get; set; } … … 65 66 } 66 67 67 public T Content { get; set; } 68 private T content; 69 public T Content { 70 get { return content; } 71 set { 72 if (value == null) 73 throw new ArgumentNullException("LayoutNode: Content cannot be null."); 74 content = value; 75 } 76 } 68 77 } 69 78 } -
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/branches/HeuristicLab.ReingoldTilfordTreeLayout/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs merged eligible /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs merged eligible /branches/Benchmarking/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 6917-7005 /branches/CloningRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 4656-4721 /branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 5471-5808 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 5815-6180 /branches/DataAnalysis/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 4458-4459,4462,4464 /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 6284-6795 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 5060 /branches/HLScript/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 10331-10358 /branches/HeuristicLab.Crossovers/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 7343-7503 /branches/HeuristicLab.DataAnalysis.Symbolic.LinearInterpreter/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 9271-9826 /branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 7098-8789 /branches/LogResidualEvaluator/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 10202-10483 /branches/NET40/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 5138-5162 /branches/ParallelEngine/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 5175-5192 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 7568-7810 /branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 6350-6627 /branches/Restructure trunk solution/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 6828 /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 10204-10479 /branches/SuccessProgressAnalysis/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 5370-5682 /branches/Trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 6829-6865 /branches/VNS/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 5594-5752 /branches/histogram/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 5959-6341 /stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs 10032-10033
r10269 r10501 7 7 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 8 8 public class ReingoldTilfordLayoutEngine<T> where T : class { 9 private readonly Dictionary<T, ILayoutNode<T>> nodes; // provides a reverse mapping T => ILayoutNode9 private readonly Dictionary<T, LayoutNode<T>> nodeMap; // provides a reverse mapping T => LayoutNode 10 10 11 11 public ReingoldTilfordLayoutEngine() { 12 node s = new Dictionary<T, ILayoutNode<T>>();13 } 14 15 public Dictionary<T, ILayoutNode<T>> Nodes { get { return nodes; } }16 17 public void AddNode(T content , ILayoutNode<T> node) {18 if (node s.ContainsKey(content)) {12 nodeMap = new Dictionary<T, LayoutNode<T>>(); 13 } 14 15 public Dictionary<T, LayoutNode<T>> NodeMap { get { return nodeMap; } } 16 17 public void AddNode(T content) { 18 if (nodeMap.ContainsKey(content)) { 19 19 throw new ArgumentException("Content already present in the dictionary."); 20 20 } 21 nodes.Add(content, node); 22 } 23 24 public ILayoutNode<T> GetNode(T content) { 25 ILayoutNode<T> ILayoutNode; 26 nodes.TryGetValue(content, out ILayoutNode); 27 return ILayoutNode; 21 var node = new LayoutNode<T> { Content = content }; 22 nodeMap.Add(content, node); 23 } 24 25 public void AddNode(LayoutNode<T> node) { 26 var content = node.Content; 27 if (nodeMap.ContainsKey(content)) { 28 throw new ArgumentException("Content already present in the dictionary."); 29 } 30 nodeMap.Add(content, node); 31 } 32 33 public void AddNodes(IEnumerable<LayoutNode<T>> nodes) { 34 foreach (var node in nodes) 35 nodeMap.Add(node.Content, node); 36 } 37 38 public LayoutNode<T> GetNode(T content) { 39 LayoutNode<T> layoutNode; 40 nodeMap.TryGetValue(content, out layoutNode); 41 return layoutNode; 28 42 } 29 43 … … 40 54 } 41 55 42 private ILayoutNode<T> root;43 public ILayoutNode<T> Root {56 private LayoutNode<T> root; 57 public LayoutNode<T> Root { 44 58 get { return root; } 45 59 set { … … 49 63 50 64 public void ResetCoordinates() { 51 foreach (var node in node s.Values) {65 foreach (var node in nodeMap.Values) { 52 66 node.X = 0; 53 67 node.Y = 0; … … 56 70 57 71 /// <summary> 58 /// Transform ILayoutNode coordinates so that all coordinates are positive and start from 0.72 /// Transform LayoutNode coordinates so that all coordinates are positive and start from 0. 59 73 /// </summary> 60 74 private void NormalizeCoordinates() { 61 var list = node s.Values.ToList();75 var list = nodeMap.Values.ToList(); 62 76 float xmin = 0, ymin = 0; 63 for (int i = 0; i !=list.Count; ++i) {77 for (int i = 0; i < list.Count; ++i) { 64 78 if (xmin > list[i].X) xmin = list[i].X; 65 79 if (ymin > list[i].Y) ymin = list[i].Y; 66 80 } 67 for (int i = 0; i !=list.Count; ++i) {81 for (int i = 0; i < list.Count; ++i) { 68 82 list[i].X -= xmin; 69 83 list[i].Y -= ymin; … … 73 87 public void Reset() { 74 88 root = null; 75 node s.Clear();89 nodeMap.Clear(); 76 90 } 77 91 78 92 public void ResetParameters() { 79 foreach (var layoutNode in node s.Values) {93 foreach (var layoutNode in nodeMap.Values) { 80 94 // reset layout-related parameters 81 95 layoutNode.Ancestor = layoutNode; … … 99 113 100 114 /// <summary> 101 /// Returns a map of coordinates for each ILayoutNode in the symbolic expression tree.115 /// Returns a map of coordinates for each LayoutNode in the symbolic expression tree. 102 116 /// </summary> 103 117 /// <returns></returns> 104 118 public Dictionary<T, PointF> GetNodeCoordinates() { 105 return node s.ToDictionary(x => x.Key, x => new PointF(x.Value.X, x.Value.Y));119 return nodeMap.ToDictionary(x => x.Key, x => new PointF(x.Value.X, x.Value.Y)); 106 120 } 107 121 … … 112 126 public RectangleF Bounds() { 113 127 float xmin, xmax, ymin, ymax; xmin = xmax = ymin = ymax = 0; 114 var list = node s.Values.ToList();115 for (int i = 0; i !=list.Count; ++i) {128 var list = nodeMap.Values.ToList(); 129 for (int i = 0; i < list.Count; ++i) { 116 130 float x = list[i].X, y = list[i].Y; 117 131 if (xmin > x) xmin = x; … … 123 137 } 124 138 125 private void FirstWalk( ILayoutNode<T> v) {126 ILayoutNode<T> w;139 private void FirstWalk(LayoutNode<T> v) { 140 LayoutNode<T> w; 127 141 if (v.IsLeaf) { 128 142 w = v.LeftSibling; … … 151 165 } 152 166 153 private void SecondWalk( ILayoutNode<T> v, float m) {167 private void SecondWalk(LayoutNode<T> v, float m) { 154 168 v.X = v.Prelim + m; 155 169 v.Y = v.Level * minVerticalSpacing; … … 160 174 } 161 175 162 private void Apportion( ILayoutNode<T> v, ref ILayoutNode<T> defaultAncestor) {176 private void Apportion(LayoutNode<T> v, ref LayoutNode<T> defaultAncestor) { 163 177 var w = v.LeftSibling; 164 178 if (w == null) return; 165 ILayoutNode<T> vip = v;166 ILayoutNode<T> vop = v;167 ILayoutNode<T> vim = w;168 ILayoutNode<T> vom = vip.LeftmostSibling;179 LayoutNode<T> vip = v; 180 LayoutNode<T> vop = v; 181 LayoutNode<T> vim = w; 182 LayoutNode<T> vom = vip.LeftmostSibling; 169 183 170 184 float sip = vip.Mod; … … 202 216 } 203 217 204 private void MoveSubtree( ILayoutNode<T> wm, ILayoutNode<T> wp, float shift) {205 int subtrees = wp.Number - wm.Number; // TODO: Investigate possible bug (if the value ever happens to be zero) - happens when the tree is actually a graph 206 if (subtrees == 0) throw new Exception( );218 private void MoveSubtree(LayoutNode<T> wm, LayoutNode<T> wp, float shift) { 219 int subtrees = wp.Number - wm.Number; // TODO: Investigate possible bug (if the value ever happens to be zero) - happens when the tree is actually a graph (but that's outside the use case of this algorithm which only works with trees) 220 if (subtrees == 0) throw new Exception("MoveSubtree failed: check if object is really a tree (no cycles)"); 207 221 wp.Change -= shift / subtrees; 208 222 wp.Shift += shift; … … 212 226 } 213 227 214 private void ExecuteShifts( ILayoutNode<T> v) {228 private void ExecuteShifts(LayoutNode<T> v) { 215 229 if (v.IsLeaf) return; 216 230 float shift = 0; … … 225 239 } 226 240 227 private ILayoutNode<T> Ancestor(ILayoutNode<T> u, ILayoutNode<T> v) {241 private LayoutNode<T> Ancestor(LayoutNode<T> u, LayoutNode<T> v) { 228 242 var ancestor = u.Ancestor; 229 243 if (ancestor == null) return null; -
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/branches/HeuristicLab.ReingoldTilfordTreeLayout/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs merged eligible /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs merged eligible /branches/Benchmarking/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 6917-7005 /branches/CloningRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 4656-4721 /branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 5471-5808 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 5815-6180 /branches/DataAnalysis/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 4458-4459,4462,4464 /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 6284-6795 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 5060 /branches/HLScript/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 10331-10358 /branches/HeuristicLab.Crossovers/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 7343-7503 /branches/HeuristicLab.DataAnalysis.Symbolic.LinearInterpreter/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 9271-9826 /branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 7098-8789 /branches/LogResidualEvaluator/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 10202-10483 /branches/NET40/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 5138-5162 /branches/ParallelEngine/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 5175-5192 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 7568-7810 /branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 6350-6627 /branches/Restructure trunk solution/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 6828 /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 10204-10479 /branches/SuccessProgressAnalysis/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 5370-5682 /branches/Trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 6829-6865 /branches/VNS/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 5594-5752 /branches/histogram/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 5959-6341 /stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs 10032-10033
r10456 r10501 22 22 using System; 23 23 using System.Collections.Generic; 24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.LayoutEngines;25 24 26 25 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding { 27 26 // adapter class that provides some conversion methods from symbolic expression trees to layout nodes (preserving the tree structure) 28 27 public class SymbolicExpressionTreeLayoutAdapter : ILayoutAdapter<ISymbolicExpressionTreeNode> { 29 // default conversion function between ISymbolicExpressionTreeNode and ILayoutNode<ISymbolicExpressionTree>30 static ILayoutNode<ISymbolicExpressionTreeNode> DefaultConvert(ISymbolicExpressionTreeNode node) {28 // default conversion function between ISymbolicExpressionTreeNode and LayoutNode<ISymbolicExpressionTree> 29 LayoutNode<ISymbolicExpressionTreeNode> defaultConvert(ISymbolicExpressionTreeNode node) { 31 30 var layoutNode = new LayoutNode<ISymbolicExpressionTreeNode> { Content = node }; 32 31 layoutNode.Ancestor = layoutNode; … … 34 33 } 35 34 36 public IEnumerable< ILayoutNode<ISymbolicExpressionTreeNode>> Convert(ISymbolicExpressionTree tree, Func<ISymbolicExpressionTreeNode, ILayoutNode<ISymbolicExpressionTreeNode>> convertFunc = null) {35 public IEnumerable<LayoutNode<ISymbolicExpressionTreeNode>> Convert(ISymbolicExpressionTree tree, Func<ISymbolicExpressionTreeNode, LayoutNode<ISymbolicExpressionTreeNode>> convertFunc = null) { 37 36 return Convert(tree.Root, convertFunc); 38 37 } 39 38 // translate the symbolic expression tree structure to a layout node tree structure 40 39 // return an enumerable containing all the layout nodes 41 public IEnumerable< ILayoutNode<ISymbolicExpressionTreeNode>> Convert(ISymbolicExpressionTreeNode root, Func<ISymbolicExpressionTreeNode, ILayoutNode<ISymbolicExpressionTreeNode>> convertFunc = null) {42 var rootLayoutNode = convertFunc == null ? DefaultConvert(root) : convertFunc(root);40 public IEnumerable<LayoutNode<ISymbolicExpressionTreeNode>> Convert(ISymbolicExpressionTreeNode root, Func<ISymbolicExpressionTreeNode, LayoutNode<ISymbolicExpressionTreeNode>> convertFunc = null) { 41 var rootLayoutNode = convertFunc == null ? defaultConvert(root) : convertFunc(root); 43 42 rootLayoutNode.Ancestor = rootLayoutNode; 44 43 45 44 if (root.SubtreeCount > 0) { 46 rootLayoutNode.Children = new List< ILayoutNode<ISymbolicExpressionTreeNode>>(root.SubtreeCount);45 rootLayoutNode.Children = new List<LayoutNode<ISymbolicExpressionTreeNode>>(root.SubtreeCount); 47 46 Expand(rootLayoutNode, convertFunc); 48 47 } 49 48 50 var list = new List< ILayoutNode<ISymbolicExpressionTreeNode>> { rootLayoutNode };49 var list = new List<LayoutNode<ISymbolicExpressionTreeNode>> { rootLayoutNode }; 51 50 int i = 0; 52 51 while (i < list.Count) { 53 if (list[i].Children != null) 54 foreach (ILayoutNode<ISymbolicExpressionTreeNode> child in list[i].Children) 55 list.Add(child); 52 if (list[i].Children != null) list.AddRange(list[i].Children); 56 53 ++i; 57 54 } … … 59 56 } 60 57 61 private void Expand( ILayoutNode<ISymbolicExpressionTreeNode> layoutNode, Func<ISymbolicExpressionTreeNode, ILayoutNode<ISymbolicExpressionTreeNode>> convertFunc = null) {58 private void Expand(LayoutNode<ISymbolicExpressionTreeNode> layoutNode, Func<ISymbolicExpressionTreeNode, LayoutNode<ISymbolicExpressionTreeNode>> convertFunc = null) { 62 59 if (layoutNode.Children == null) return; 63 60 for (int i = 0; i < layoutNode.Content.SubtreeCount; ++i) { 64 61 var subtree = layoutNode.Content.GetSubtree(i); 65 var childLayoutNode = convertFunc == null ? DefaultConvert(subtree) : convertFunc(subtree);62 var childLayoutNode = convertFunc == null ? defaultConvert(subtree) : convertFunc(subtree); 66 63 childLayoutNode.Parent = layoutNode; 67 64 childLayoutNode.Number = i; 68 65 childLayoutNode.Level = layoutNode.Level + 1; 69 66 childLayoutNode.Ancestor = childLayoutNode; 70 childLayoutNode.Children = subtree.SubtreeCount > 0 ? new List< ILayoutNode<ISymbolicExpressionTreeNode>>(subtree.SubtreeCount) : null;67 childLayoutNode.Children = subtree.SubtreeCount > 0 ? new List<LayoutNode<ISymbolicExpressionTreeNode>>(subtree.SubtreeCount) : null; 71 68 layoutNode.Children.Add(childLayoutNode); 72 69 Expand(childLayoutNode, convertFunc); -
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphView.cs
r10347 r10501 15 15 public GenealogyGraphView() { 16 16 InitializeComponent(); 17 18 genealogyGraphChart.GenealogyGraphNodeClicked += graphChart_GenealogyGraphNodeClicked;19 17 } 20 18 21 19 protected override void DeregisterContentEvents() { 22 20 // TODO: Deregister your event handlers here 21 genealogyGraphChart.GenealogyGraphNodeClicked -= graphChart_GenealogyGraphNodeClicked; 23 22 base.DeregisterContentEvents(); 24 23 } … … 27 26 base.RegisterContentEvents(); 28 27 // TODO: Register your event handlers here 28 genealogyGraphChart.GenealogyGraphNodeClicked += graphChart_GenealogyGraphNodeClicked; 29 29 } 30 30 31 31 #region Event Handlers (Content) 32 33 public virtual void graphChart_GenealogyGraphNodeClicked(object sender, MouseEventArgs args) {34 var content = ((VisualGenealogyGraphNode)sender).Data.Content;35 if (content != null) {36 viewHost.Content = (IContent)content;37 }38 }39 32 // TODO: Put event handlers of the content here 40 #endregion41 42 33 protected override void OnContentChanged() { 43 34 base.OnContentChanged(); 44 if (Content == null) { 45 } else { 46 genealogyGraphChart.GenealogyGraph = Content; 47 } 35 if (Content != null) { genealogyGraphChart.GenealogyGraph = Content; } 48 36 } 37 #endregion 49 38 50 39 protected override void SetEnabledStateOfControls() { … … 55 44 #region Event Handlers (child controls) 56 45 // TODO: Put event handlers of child controls here. 46 public virtual void graphChart_GenealogyGraphNodeClicked(object sender, MouseEventArgs args) { 47 var content = ((VisualGenealogyGraphNode)sender).Data.Content; 48 if (content != null) { 49 viewHost.Content = (IContent)content; 50 } 51 } 57 52 #endregion 58 53 } -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/HeuristicLab.EvolutionTracking.Views-3.4.csproj
r10458 r10501 105 105 <Compile Include="Plugin.cs" /> 106 106 <Compile Include="Properties\AssemblyInfo.cs" /> 107 <Compile Include="Properties\Resources.Designer.cs">108 <AutoGen>True</AutoGen>109 <DesignTime>True</DesignTime>110 <DependentUpon>Resources.resx</DependentUpon>111 </Compile>112 107 <Compile Include="GenealogyGraphView.cs"> 113 108 <SubType>UserControl</SubType> … … 130 125 <None Include="HeuristicLab.snk" /> 131 126 </ItemGroup> 132 <ItemGroup>133 <EmbeddedResource Include="Properties\Resources.resx">134 <Generator>ResXFileCodeGenerator</Generator>135 <LastGenOutput>Resources.Designer.cs</LastGenOutput>136 </EmbeddedResource>137 </ItemGroup>138 127 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 139 128 <PropertyGroup> -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Fragment.cs
r10347 r10501 5 5 namespace HeuristicLab.EvolutionTracking { 6 6 [StorableClass] 7 [Item("Fragment", "A n object that stores a")]7 [Item("Fragment", "A fragment is an object that represents a piece of genetic information that was transferred from parent to child.")] 8 8 public class Fragment : Item, IFragment { 9 9 [Storable] 10 private int newPos; 11 public int NewPos { get { return newPos; } set { newPos = value; } } 10 public int NewPos { get; set; } 12 11 13 12 [Storable] 14 private int oldPos; 15 public int OldPos { get { return oldPos; } set { oldPos = value; } } 13 public int OldPos { get; set; } 16 14 17 15 [Storable] -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Symbolic.Views merged: 10492
- Property svn:mergeinfo changed
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs
r9478 r10501 75 75 treeChart.Tree = tree.Root.SubtreeCount > 1 ? new SymbolicExpressionTree(tree.Root) : new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0)); 76 76 77 var replacementValues = CalculateReplacementValues(tree); 77 var impactAndReplacementValues = CalculateImpactAndReplacementValues(tree); 78 nodeImpacts = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item1); 79 var replacementValues = impactAndReplacementValues.ToDictionary(x => x.Key, x => x.Value.Item2); 78 80 foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) { 79 81 foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value); 80 82 } 81 82 nodeImpacts = CalculateImpactValues(tree);83 83 PaintNodeImpacts(); 84 84 } … … 86 86 protected abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree); 87 87 protected abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree); 88 protected abstract Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>> CalculateImpactAndReplacementValues(ISymbolicExpressionTree tree); 88 89 protected abstract void UpdateModel(ISymbolicExpressionTree tree); 89 90 -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectivePruningAnalyzer.cs
r10459 r10501 90 90 protected SymbolicDataAnalysisSingleObjectivePruningAnalyzer(SymbolicDataAnalysisSingleObjectivePruningAnalyzer original, Cloner cloner) 91 91 : base(original, cloner) { 92 this.prunedSubtreesReducer = (DataReducer)original.prunedSubtreesReducer.Clone(); 93 this.prunedTreesReducer = (DataReducer)original.prunedTreesReducer.Clone(); 94 this.valuesCollector = (DataTableValuesCollector)original.valuesCollector.Clone(); 95 this.resultsCollector = (ResultsCollector)original.resultsCollector.Clone(); 92 if (original.prunedSubtreesReducer != null) 93 this.prunedSubtreesReducer = (DataReducer)original.prunedSubtreesReducer.Clone(); 94 if (original.prunedTreesReducer != null) 95 this.prunedTreesReducer = (DataReducer)original.prunedTreesReducer.Clone(); 96 if (original.valuesCollector != null) 97 this.valuesCollector = (DataTableValuesCollector)original.valuesCollector.Clone(); 98 if (original.resultsCollector != null) 99 this.resultsCollector = (ResultsCollector)original.resultsCollector.Clone(); 96 100 } 97 101 protected SymbolicDataAnalysisSingleObjectivePruningAnalyzer() { -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame
r10037 r10501 38 38 [PluginDependency("HeuristicLab.Operators", "3.3")] 39 39 [PluginDependency("HeuristicLab.Optimization", "3.3")] 40 [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")] 40 41 [PluginDependency("HeuristicLab.Parameters", "3.3")] 41 42 [PluginDependency("HeuristicLab.Persistence", "3.3")] -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionPruningOperator.cs
r10464 r10501 125 125 var prunedTrees = 0; 126 126 127 double quality = Evaluate( (IRegressionModel)model);127 double quality = Evaluate(model); 128 128 129 129 for (int i = 0; i < nodes.Count; ++i) { -
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.TravelingSalesman
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.TravelingSalesman.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.TravelingSalesman (added) merged: 10037,10291
- Property svn:mergeinfo changed
Note: See TracChangeset
for help on using the changeset viewer.