Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10501 for branches


Ignore:
Timestamp:
02/21/14 18:20:47 (11 years ago)
Author:
bburlacu
Message:

#1772: Merged trunk changes and added missing frame files (for HeuristicLab.EvolutionTracking and HeuristicLab.EvolutionTracking.Views.

Location:
branches/HeuristicLab.EvolutionTracking
Files:
3 added
1 deleted
21 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding

  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/GraphicalSymbolicExpressionTreeView.Designer.cs

    r9456 r10501  
    1919 */
    2020#endregion
     21
     22using System.Drawing;
    2123
    2224namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views {
     
    5961      this.symbolicExpressionTreeChart.Spacing = 5;
    6062      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);
    6264      //
    6365      // FunctionTreeView
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/GraphicalSymbolicExpressionTreeView.cs

    r10347 r10501  
    2020#endregion
    2121
    22 using System.Drawing;
    2322using System.Windows.Forms;
    2423using HeuristicLab.Core.Views;
     
    5352      symbolicExpressionTreeChart.Enabled = Content != null;
    5453    }
    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     }
    6354  }
    6455}
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.Designer.cs

    r10302 r10501  
    5050      this.saveImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5151      this.saveFileDialog = new System.Windows.Forms.SaveFileDialog();
    52       this.exportLatexToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     52      this.exportPgfLaTeXToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    5353      this.contextMenuStrip.SuspendLayout();
    5454      this.SuspendLayout();
     
    5858      this.contextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    5959            this.saveImageToolStripMenuItem,
    60             this.exportLatexToolStripMenuItem});
     60            this.exportPgfLaTeXToolStripMenuItem});
    6161      this.contextMenuStrip.Name = "contextMenuStrip";
    62       this.contextMenuStrip.Size = new System.Drawing.Size(161, 70);
     62      this.contextMenuStrip.Size = new System.Drawing.Size(166, 70);
    6363      //
    6464      // saveImageToolStripMenuItem
    6565      //
    6666      this.saveImageToolStripMenuItem.Name = "saveImageToolStripMenuItem";
    67       this.saveImageToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
     67      this.saveImageToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
    6868      this.saveImageToolStripMenuItem.Text = "Save Image";
    6969      this.saveImageToolStripMenuItem.Click += new System.EventHandler(this.saveImageToolStripMenuItem_Click);
     
    7373      this.saveFileDialog.Filter = "Bitmap (*.bmp)|*.bmp|EMF (*.emf)|*.emf";
    7474      //
    75       // exportLatexToolStripMenuItem
     75      // exportPgfLaTeXToolStripMenuItem
    7676      //
    77       this.exportLatexToolStripMenuItem.Name = "exportLatexToolStripMenuItem";
    78       this.exportLatexToolStripMenuItem.Size = new System.Drawing.Size(160, 22);
    79       this.exportLatexToolStripMenuItem.Text = "Export Pgf/Latex";
    80       this.exportLatexToolStripMenuItem.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);
    8181      //
    8282      // SymbolicExpressionTreeChart
     
    102102    protected System.Windows.Forms.ToolStripMenuItem saveImageToolStripMenuItem;
    103103    protected System.Windows.Forms.SaveFileDialog saveFileDialog;
    104     private System.Windows.Forms.ToolStripMenuItem exportLatexToolStripMenuItem;
     104    private System.Windows.Forms.ToolStripMenuItem exportPgfLaTeXToolStripMenuItem;
    105105  }
    106106}
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views/3.4/SymbolicExpressionTreeChart.cs

    r10456 r10501  
    3232  public partial class SymbolicExpressionTreeChart : UserControl {
    3333    private Image image;
    34     private StringFormat stringFormat;
     34    private readonly StringFormat stringFormat;
    3535    private Dictionary<ISymbolicExpressionTreeNode, VisualSymbolicExpressionTreeNode> visualTreeNodes;
    3636    private Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualSymbolicExpressionTreeNodeConnection> visualLines;
     
    5151      this.lineColor = Color.Black;
    5252      this.backgroundColor = Color.White;
    53       this.textFont = new Font(FontFamily.GenericSerif, 14, GraphicsUnit.Pixel);
     53      this.textFont = new Font(FontFamily.GenericSansSerif, 12);
    5454      layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>();
    5555      layoutAdapter = new SymbolicExpressionTreeLayoutAdapter();
     
    108108        visualLines = new Dictionary<Tuple<ISymbolicExpressionTreeNode, ISymbolicExpressionTreeNode>, VisualSymbolicExpressionTreeNodeConnection>();
    109109        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) {
    111114            visualTreeNodes[node] = new VisualSymbolicExpressionTreeNode(node);
    112115            if (node.Parent != null) visualLines[Tuple.Create(node.Parent, node)] = new VisualSymbolicExpressionTreeNodeConnection();
     
    166169        this.Refresh();
    167170      }
    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);
    180171    }
    181172
     
    280271    private void DrawFunctionTree(ISymbolicExpressionTree symbolicExpressionTree, Graphics graphics, int preferredWidth, int preferredHeight, int minHDistance, int minVDistance) {
    281272      var layoutNodes = layoutAdapter.Convert(symbolicExpressionTree).ToList();
     273      if (symbolicExpressionTree.Root.SubtreeCount == 1) layoutNodes.RemoveAt(0);
    282274      layoutEngine.Reset();
    283275      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);
    288279      layoutEngine.CalculateLayout();
    289280      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) {
    311315          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 drawn
    313           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);
    316320          DrawTreeNode(graphics, visualNode);
    317321        }
    318322      }
    319 
    320       graphics.ResetClip(); // reset clip region
    321323      // draw node connections
    322324      foreach (var visualNode in visualTreeNodes.Values) {
     
    327329          var origin = new Point(visualNode.X + visualNode.Width / 2, visualNode.Y + visualNode.Height);
    328330          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));
    329332          using (var linePen = new Pen(visualLine.LineColor)) {
    330333            linePen.DashStyle = visualLine.DashStyle;
     
    378381      Image image = new Bitmap(Width, Height);
    379382      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);
    382384      }
    383385      image.Save(filename);
     
    386388    public void SaveImageAsEmf(string filename) {
    387389      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);
    394394          }
    395395        }
     396        g.ReleaseHdc();
    396397      }
    397398    }
  • 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
     22using System;
    223using System.Collections.Generic;
    324using System.Globalization;
     
    829
    930namespace 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.")]
    1132  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>
    1334    {
    1435      {"ProgramRootSymbol", "Prog"},
    15       {"StartSymbol","RPB"},
    16       {"Addition", "$+$"},
    17       {"Subtraction", "$-$"},
    18       {"Multiplication", "$\\times$"},
    19       {"Division", "$\\div$"},
    20       {"Logarithm", "$\\log$"},
    21       {"Exponential", "$\\exp$"}
     36      {"StartSymbol","RPB"}
    2237    };
    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();
    2540
    26     public SymbolicExpressionTreeLatexFormatter() {
     41    public SymbolicExpressionTreeLatexFormatter()
     42      : base("LaTeX/PDF Formatter", "Formatter for symbolic expression trees for use with latex package tikz.") {
    2743      layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>();
    28       layoutAdapter = new SymbolicExpressionTreeLayoutAdapter();
    2944    }
    3045
    3146    protected SymbolicExpressionTreeLatexFormatter(SymbolicExpressionTreeLatexFormatter original, Cloner cloner)
    3247      : base(original, cloner) {
    33       layoutEngine = new ReingoldTilfordLayoutEngine<ISymbolicExpressionTreeNode>();
    34       layoutAdapter = new SymbolicExpressionTreeLayoutAdapter();
    3548    }
    3649
     
    4053
    4154    public string Format(ISymbolicExpressionTree symbolicExpressionTree) {
     55      layoutEngine.Reset();
    4256      var layoutNodes = layoutAdapter.Convert(symbolicExpressionTree).ToList();
    43       layoutEngine.Reset();
    4457      layoutEngine.Root = layoutNodes[0];
    45       foreach (var ln in layoutNodes)
    46         layoutEngine.AddNode(ln.Content, ln);
     58      layoutEngine.AddNodes(layoutNodes);
    4759      layoutEngine.CalculateLayout();
    4860      var nodeCoordinates = layoutEngine.GetNodeCoordinates();
    4961      var sb = new StringBuilder();
    5062      var nl = Environment.NewLine;
     63      double ws = 1;
     64      double hs = 0.7;
     65
    5166      sb.Append("\\documentclass[class=minimal,border=0pt]{standalone}" + nl +
    5267                "\\usepackage{tikz}" + nl +
     
    5671                "\\def\\hs{0.7}" + nl);
    5772
    58       const double ws = 1.0, hs = 0.7; // some scaling factors useful for fine-tuning document appearance before latex compilation
     73      var nodeIndices = new Dictionary<ISymbolicExpressionTreeNode, int>();
    5974      var nodes = symbolicExpressionTree.IterateNodesBreadth().ToList();
    60       var nodeIndices = new Dictionary<ISymbolicExpressionTreeNode, int>();
    6175      for (int i = 0; i < nodes.Count; ++i) {
    6276        var node = nodes[i];
    6377        nodeIndices.Add(node, i);
    64         var symbolName = node.Symbol.Name;
    65         var nodeName = SymbolNamesMap.ContainsKey(symbolName) ? SymbolNamesMap[symbolName] : symbolName;
    6678        var coord = nodeCoordinates[node];
    67 
     79        var nodeName = symbolNameMap.ContainsKey(node.Symbol.Name) ? symbolNameMap[node.Symbol.Name] : node.ToString();
    6880        sb.AppendLine(string.Format(CultureInfo.InvariantCulture, "\\node ({0}) at (\\ws*{1},\\hs*{2}) {{{3}}};", i, ws * coord.X, -hs * coord.Y, EscapeLatexString(nodeName)));
    6981      }
     
    7587      }
    7688
    77       sb.AppendLine("\\end{tikzpicture}" + nl + "\\end{document}" + nl);
    78 
     89      sb.Append("\\end{tikzpicture}" + nl +
     90                "\\end{document}" + nl);
    7991      return sb.ToString();
    8092    }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/Interfaces/ILayoutAdapter.cs

    r10269 r10501  
    44namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    55  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);
    77  }
    88}
  • 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.csmergedeligible
      /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.csmergedeligible
      /branches/Benchmarking/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs6917-7005
      /branches/CloningRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs4656-4721
      /branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs5471-5808
      /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs5815-6180
      /branches/DataAnalysis/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs4458-4459,​4462,​4464
      /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs6284-6795
      /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs5060
      /branches/HLScript/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs10331-10358
      /branches/HeuristicLab.Crossovers/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs7343-7503
      /branches/HeuristicLab.DataAnalysis.Symbolic.LinearInterpreter/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs9271-9826
      /branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs7098-8789
      /branches/LogResidualEvaluator/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs10202-10483
      /branches/NET40/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs5138-5162
      /branches/ParallelEngine/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs5175-5192
      /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs7568-7810
      /branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs6350-6627
      /branches/Restructure trunk solution/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs6828
      /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs10204-10479
      /branches/SuccessProgressAnalysis/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs5370-5682
      /branches/Trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs6829-6865
      /branches/VNS/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs5594-5752
      /branches/histogram/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs5959-6341
      /stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/LayoutNode.cs10032-10033
    r10269 r10501  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
    2425
    25 namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.LayoutEngines {
    26   public class LayoutNode<T> : ILayoutNode<T> where T : class {
    27     public ILayoutNode<T> NextLeft {
     26namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
     27  public class LayoutNode<T> where T : class {
     28    public LayoutNode<T> NextLeft {
    2829      get {
    2930        return Children == null ? Thread : Children.First();
    3031      }
    3132    }
    32     public ILayoutNode<T> NextRight {
     33    public LayoutNode<T> NextRight {
    3334      get {
    3435        return Children == null ? Thread : Children.Last();
    3536      }
    3637    }
    37     public ILayoutNode<T> LeftSibling {
     38    public LayoutNode<T> LeftSibling {
    3839      get {
    3940        if (Parent == null) return null;
     
    4142      }
    4243    }
    43     public ILayoutNode<T> LeftmostSibling {
     44    public LayoutNode<T> LeftmostSibling {
    4445      get {
    4546        if (Parent == null) return null;
     
    4849    }
    4950
    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; }
    5455    public float Mod { get; set; }
    5556    public float Prelim { get; set; }
     
    6566    }
    6667
    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    }
    6877  }
    6978}
  • 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.csmergedeligible
      /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.csmergedeligible
      /branches/Benchmarking/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs6917-7005
      /branches/CloningRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs4656-4721
      /branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs5471-5808
      /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs5815-6180
      /branches/DataAnalysis/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs4458-4459,​4462,​4464
      /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs6284-6795
      /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs5060
      /branches/HLScript/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs10331-10358
      /branches/HeuristicLab.Crossovers/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs7343-7503
      /branches/HeuristicLab.DataAnalysis.Symbolic.LinearInterpreter/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs9271-9826
      /branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs7098-8789
      /branches/LogResidualEvaluator/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs10202-10483
      /branches/NET40/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs5138-5162
      /branches/ParallelEngine/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs5175-5192
      /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs7568-7810
      /branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs6350-6627
      /branches/Restructure trunk solution/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs6828
      /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs10204-10479
      /branches/SuccessProgressAnalysis/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs5370-5682
      /branches/Trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs6829-6865
      /branches/VNS/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs5594-5752
      /branches/histogram/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs5959-6341
      /stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/ReingoldTilfordLayoutEngine.cs10032-10033
    r10269 r10501  
    77namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    88  public class ReingoldTilfordLayoutEngine<T> where T : class {
    9     private readonly Dictionary<T, ILayoutNode<T>> nodes; // provides a reverse mapping T => ILayoutNode
     9    private readonly Dictionary<T, LayoutNode<T>> nodeMap; // provides a reverse mapping T => LayoutNode
    1010
    1111    public ReingoldTilfordLayoutEngine() {
    12       nodes = 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 (nodes.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)) {
    1919        throw new ArgumentException("Content already present in the dictionary.");
    2020      }
    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;
    2842    }
    2943
     
    4054    }
    4155
    42     private ILayoutNode<T> root;
    43     public ILayoutNode<T> Root {
     56    private LayoutNode<T> root;
     57    public LayoutNode<T> Root {
    4458      get { return root; }
    4559      set {
     
    4963
    5064    public void ResetCoordinates() {
    51       foreach (var node in nodes.Values) {
     65      foreach (var node in nodeMap.Values) {
    5266        node.X = 0;
    5367        node.Y = 0;
     
    5670
    5771    /// <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.
    5973    /// </summary>
    6074    private void NormalizeCoordinates() {
    61       var list = nodes.Values.ToList();
     75      var list = nodeMap.Values.ToList();
    6276      float xmin = 0, ymin = 0;
    63       for (int i = 0; i != list.Count; ++i) {
     77      for (int i = 0; i < list.Count; ++i) {
    6478        if (xmin > list[i].X) xmin = list[i].X;
    6579        if (ymin > list[i].Y) ymin = list[i].Y;
    6680      }
    67       for (int i = 0; i != list.Count; ++i) {
     81      for (int i = 0; i < list.Count; ++i) {
    6882        list[i].X -= xmin;
    6983        list[i].Y -= ymin;
     
    7387    public void Reset() {
    7488      root = null;
    75       nodes.Clear();
     89      nodeMap.Clear();
    7690    }
    7791
    7892    public void ResetParameters() {
    79       foreach (var layoutNode in nodes.Values) {
     93      foreach (var layoutNode in nodeMap.Values) {
    8094        // reset layout-related parameters
    8195        layoutNode.Ancestor = layoutNode;
     
    99113
    100114    /// <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.
    102116    /// </summary>
    103117    /// <returns></returns>
    104118    public Dictionary<T, PointF> GetNodeCoordinates() {
    105       return nodes.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));
    106120    }
    107121
     
    112126    public RectangleF Bounds() {
    113127      float xmin, xmax, ymin, ymax; xmin = xmax = ymin = ymax = 0;
    114       var list = nodes.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) {
    116130        float x = list[i].X, y = list[i].Y;
    117131        if (xmin > x) xmin = x;
     
    123137    }
    124138
    125     private void FirstWalk(ILayoutNode<T> v) {
    126       ILayoutNode<T> w;
     139    private void FirstWalk(LayoutNode<T> v) {
     140      LayoutNode<T> w;
    127141      if (v.IsLeaf) {
    128142        w = v.LeftSibling;
     
    151165    }
    152166
    153     private void SecondWalk(ILayoutNode<T> v, float m) {
     167    private void SecondWalk(LayoutNode<T> v, float m) {
    154168      v.X = v.Prelim + m;
    155169      v.Y = v.Level * minVerticalSpacing;
     
    160174    }
    161175
    162     private void Apportion(ILayoutNode<T> v, ref ILayoutNode<T> defaultAncestor) {
     176    private void Apportion(LayoutNode<T> v, ref LayoutNode<T> defaultAncestor) {
    163177      var w = v.LeftSibling;
    164178      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;
    169183
    170184      float sip = vip.Mod;
     
    202216    }
    203217
    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)");
    207221      wp.Change -= shift / subtrees;
    208222      wp.Shift += shift;
     
    212226    }
    213227
    214     private void ExecuteShifts(ILayoutNode<T> v) {
     228    private void ExecuteShifts(LayoutNode<T> v) {
    215229      if (v.IsLeaf) return;
    216230      float shift = 0;
     
    225239    }
    226240
    227     private ILayoutNode<T> Ancestor(ILayoutNode<T> u, ILayoutNode<T> v) {
     241    private LayoutNode<T> Ancestor(LayoutNode<T> u, LayoutNode<T> v) {
    228242      var ancestor = u.Ancestor;
    229243      if (ancestor == null) return null;
  • 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.csmergedeligible
      /trunk/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.csmergedeligible
      /branches/Benchmarking/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs6917-7005
      /branches/CloningRefactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs4656-4721
      /branches/DataAnalysis Refactoring/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs5471-5808
      /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs5815-6180
      /branches/DataAnalysis/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs4458-4459,​4462,​4464
      /branches/GP.Grammar.Editor/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs6284-6795
      /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs5060
      /branches/HLScript/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs10331-10358
      /branches/HeuristicLab.Crossovers/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs7343-7503
      /branches/HeuristicLab.DataAnalysis.Symbolic.LinearInterpreter/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs9271-9826
      /branches/HeuristicLab.TimeSeries/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs7098-8789
      /branches/LogResidualEvaluator/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs10202-10483
      /branches/NET40/sources/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs5138-5162
      /branches/ParallelEngine/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs5175-5192
      /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs7568-7810
      /branches/QAPAlgorithms/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs6350-6627
      /branches/Restructure trunk solution/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs6828
      /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs10204-10479
      /branches/SuccessProgressAnalysis/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs5370-5682
      /branches/Trunk/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs6829-6865
      /branches/VNS/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs5594-5752
      /branches/histogram/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs5959-6341
      /stable/HeuristicLab.Encodings.SymbolicExpressionTreeEncoding/3.4/LayoutEngines/SymbolicExpressionTreeLayoutAdapter.cs10032-10033
    r10456 r10501  
    2222using System;
    2323using System.Collections.Generic;
    24 using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.LayoutEngines;
    2524
    2625namespace HeuristicLab.Encodings.SymbolicExpressionTreeEncoding {
    2726  // adapter class that provides some conversion methods from symbolic expression trees to layout nodes (preserving the tree structure)
    2827  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) {
    3130      var layoutNode = new LayoutNode<ISymbolicExpressionTreeNode> { Content = node };
    3231      layoutNode.Ancestor = layoutNode;
     
    3433    }
    3534
    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) {
    3736      return Convert(tree.Root, convertFunc);
    3837    }
    3938    // translate the symbolic expression tree structure to a layout node tree structure
    4039    // 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);
    4342      rootLayoutNode.Ancestor = rootLayoutNode;
    4443
    4544      if (root.SubtreeCount > 0) {
    46         rootLayoutNode.Children = new List<ILayoutNode<ISymbolicExpressionTreeNode>>(root.SubtreeCount);
     45        rootLayoutNode.Children = new List<LayoutNode<ISymbolicExpressionTreeNode>>(root.SubtreeCount);
    4746        Expand(rootLayoutNode, convertFunc);
    4847      }
    4948
    50       var list = new List<ILayoutNode<ISymbolicExpressionTreeNode>> { rootLayoutNode };
     49      var list = new List<LayoutNode<ISymbolicExpressionTreeNode>> { rootLayoutNode };
    5150      int i = 0;
    5251      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);
    5653        ++i;
    5754      }
     
    5956    }
    6057
    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) {
    6259      if (layoutNode.Children == null) return;
    6360      for (int i = 0; i < layoutNode.Content.SubtreeCount; ++i) {
    6461        var subtree = layoutNode.Content.GetSubtree(i);
    65         var childLayoutNode = convertFunc == null ? DefaultConvert(subtree) : convertFunc(subtree);
     62        var childLayoutNode = convertFunc == null ? defaultConvert(subtree) : convertFunc(subtree);
    6663        childLayoutNode.Parent = layoutNode;
    6764        childLayoutNode.Number = i;
    6865        childLayoutNode.Level = layoutNode.Level + 1;
    6966        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;
    7168        layoutNode.Children.Add(childLayoutNode);
    7269        Expand(childLayoutNode, convertFunc);
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/GenealogyGraphView.cs

    r10347 r10501  
    1515    public GenealogyGraphView() {
    1616      InitializeComponent();
    17 
    18       genealogyGraphChart.GenealogyGraphNodeClicked += graphChart_GenealogyGraphNodeClicked;
    1917    }
    2018
    2119    protected override void DeregisterContentEvents() {
    2220      // TODO: Deregister your event handlers here
     21      genealogyGraphChart.GenealogyGraphNodeClicked -= graphChart_GenealogyGraphNodeClicked;
    2322      base.DeregisterContentEvents();
    2423    }
     
    2726      base.RegisterContentEvents();
    2827      // TODO: Register your event handlers here
     28      genealogyGraphChart.GenealogyGraphNodeClicked += graphChart_GenealogyGraphNodeClicked;
    2929    }
    3030
    3131    #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     }
    3932    // TODO: Put event handlers of the content here
    40     #endregion
    41 
    4233    protected override void OnContentChanged() {
    4334      base.OnContentChanged();
    44       if (Content == null) {
    45       } else {
    46         genealogyGraphChart.GenealogyGraph = Content;
    47       }
     35      if (Content != null) { genealogyGraphChart.GenealogyGraph = Content; }
    4836    }
     37    #endregion
    4938
    5039    protected override void SetEnabledStateOfControls() {
     
    5544    #region Event Handlers (child controls)
    5645    // 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    }
    5752    #endregion
    5853  }
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking.Views/3.4/HeuristicLab.EvolutionTracking.Views-3.4.csproj

    r10458 r10501  
    105105    <Compile Include="Plugin.cs" />
    106106    <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>
    112107    <Compile Include="GenealogyGraphView.cs">
    113108      <SubType>UserControl</SubType>
     
    130125    <None Include="HeuristicLab.snk" />
    131126  </ItemGroup>
    132   <ItemGroup>
    133     <EmbeddedResource Include="Properties\Resources.resx">
    134       <Generator>ResXFileCodeGenerator</Generator>
    135       <LastGenOutput>Resources.Designer.cs</LastGenOutput>
    136     </EmbeddedResource>
    137   </ItemGroup>
    138127  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    139128  <PropertyGroup>
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.EvolutionTracking/3.4/Fragment.cs

    r10347 r10501  
    55namespace HeuristicLab.EvolutionTracking {
    66  [StorableClass]
    7   [Item("Fragment", "An 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.")]
    88  public class Fragment : Item, IFragment {
    99    [Storable]
    10     private int newPos;
    11     public int NewPos { get { return newPos; } set { newPos = value; } }
     10    public int NewPos { get; set; }
    1211
    1312    [Storable]
    14     private int oldPos;
    15     public int OldPos { get { return oldPos; } set { oldPos = value; } }
     13    public int OldPos { get; set; }
    1614
    1715    [Storable]
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic

  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views

  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic.Views/3.4/InteractiveSymbolicDataAnalysisSolutionSimplifierView.cs

    r9478 r10501  
    7575      treeChart.Tree = tree.Root.SubtreeCount > 1 ? new SymbolicExpressionTree(tree.Root) : new SymbolicExpressionTree(tree.Root.GetSubtree(0).GetSubtree(0));
    7676
    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);
    7880      foreach (var pair in replacementValues.Where(pair => !(pair.Key is ConstantTreeNode))) {
    7981        foldedNodes[pair.Key] = MakeConstantTreeNode(pair.Value);
    8082      }
    81 
    82       nodeImpacts = CalculateImpactValues(tree);
    8383      PaintNodeImpacts();
    8484    }
     
    8686    protected abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateReplacementValues(ISymbolicExpressionTree tree);
    8787    protected abstract Dictionary<ISymbolicExpressionTreeNode, double> CalculateImpactValues(ISymbolicExpressionTree tree);
     88    protected abstract Dictionary<ISymbolicExpressionTreeNode, Tuple<double, double>> CalculateImpactAndReplacementValues(ISymbolicExpressionTree tree);
    8889    protected abstract void UpdateModel(ISymbolicExpressionTree tree);
    8990
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Analyzers/SymbolicDataAnalysisSingleObjectivePruningAnalyzer.cs

    r10459 r10501  
    9090    protected SymbolicDataAnalysisSingleObjectivePruningAnalyzer(SymbolicDataAnalysisSingleObjectivePruningAnalyzer original, Cloner cloner)
    9191      : 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();
    96100    }
    97101    protected SymbolicDataAnalysisSingleObjectivePruningAnalyzer() {
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Plugin.cs.frame

    r10037 r10501  
    3838  [PluginDependency("HeuristicLab.Operators", "3.3")]
    3939  [PluginDependency("HeuristicLab.Optimization", "3.3")]
     40  [PluginDependency("HeuristicLab.Optimization.Operators", "3.3")]
    4041  [PluginDependency("HeuristicLab.Parameters", "3.3")]
    4142  [PluginDependency("HeuristicLab.Persistence", "3.3")]
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SymbolicDataAnalysisExpressionPruningOperator.cs

    r10464 r10501  
    125125      var prunedTrees = 0;
    126126
    127       double quality = Evaluate((IRegressionModel)model);
     127      double quality = Evaluate(model);
    128128
    129129      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

Note: See TracChangeset for help on using the changeset viewer.