Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9420 for branches


Ignore:
Timestamp:
05/02/13 13:21:35 (11 years ago)
Author:
bburlacu
Message:

#1772: Improved the LineageExplorerView, added generation labels in the GenealogyGraphChart, added new visual component VisualGenealogyGraphTextLabel.

Location:
branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4
Files:
3 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphChart.Designer.cs

    r8213 r9420  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.components = new System.ComponentModel.Container();
    48       this.toolTip = new System.Windows.Forms.ToolTip(this.components);
     47      ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
    4948      this.SuspendLayout();
     49      //
     50      // pictureBox
     51      //
     52      this.pictureBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
     53      this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
    5054      //
    5155      // GenealogyGraphChart
     
    5458      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    5559      this.Name = "GenealogyGraphChart";
     60      this.Controls.SetChildIndex(this.pictureBox, 0);
     61      ((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
    5662      this.ResumeLayout(false);
    5763
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphChart.cs

    r9239 r9420  
    2828using HeuristicLab.Common;
    2929using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
    30 using HeuristicLab.Problems.DataAnalysis.Symbolic;
    3130using HeuristicLab.Visualization;
    3231
     
    4241    private Visualization.Rectangle targetRectangle; // provides a  rectangle mark of the currently selected genealogy graph node
    4342
     43    public bool SimpleLineages { get; set; }
     44    public bool LockGenealogy { get; set; }
     45
     46    private bool drawing;
     47
    4448    private SymbolicExpressionTreeGenealogyGraph graph;
    4549    public SymbolicExpressionTreeGenealogyGraph Graph {
     
    4852        graph = value;
    4953        if (graph == null) return;
    50         // TODO: should move the subtree sorting code out of here and int the view
    51         var canonicalSorter = new SymbolicExpressionTreeCanonicalSorter();
    52         // sort subtrees in order to improve matching
    53         foreach (var tree in graph.Nodes.Select(n => n.SymbolicExpressionTree))
    54           canonicalSorter.SortSubtrees(tree);
    5554
    5655        visualNodeMap = new Dictionary<string, VisualGenealogyGraphNode>();
     
    6867    }
    6968
     69    private VisualGenealogyGraphArc GetVisualGenealogyGraphArc(IVertex source, IVertex target) {
     70      VisualGenealogyGraphNode visualSource;
     71      VisualGenealogyGraphNode visualTarget;
     72      visualNodeMap.TryGetValue(source.Id, out visualSource);
     73      visualNodeMap.TryGetValue(target.Id, out visualTarget);
     74      if (visualSource != null && visualTarget != null) {
     75        VisualGenealogyGraphArc visualArc;
     76        visualArcMap.TryGetValue(
     77          new Tuple<VisualGenealogyGraphNode, VisualGenealogyGraphNode>(visualSource, visualTarget), out visualArc);
     78        if (visualArc != null) return visualArc;
     79      }
     80      return null;
     81    }
     82
    7083    public event MouseEventHandler GenealogyGraphNodeClicked;
    7184    private void OnGenealogyGraphNodeClicked(object sender, MouseEventArgs e) {
     
    8497      Chart.UpdateEnabled = false;
    8598
     99      drawing = true;
     100
    86101      var layers = Graph.Nodes.GroupBy(n => n.Rank).OrderBy(g => g.Key).Select(g => new { Rank = g.Key, Nodes = g.ToList() }).ToList();
    87102
     103      y = PreferredSize.Height + Cx + 2 * Diameter;
     104
    88105      for (int i = 0; i != layers.Count; ++i) {
     106        x = 0;
     107        layers[i].Nodes.Sort((b, a) => Graph.Compare(a, b));
     108        double rank = Math.Floor(layers[i].Rank);
     109        if (layers[i].Rank.IsAlmost(rank)) {
     110          var visualTextNode = new VisualGenealogyGraphTextLabel(Chart, x, y + 2, x + Diameter, y + Diameter) {
     111            Brush = new SolidBrush(Color.Black),
     112            Font = new Font("Arial", Diameter - 4, FontStyle.Regular, GraphicsUnit.Pixel),
     113            Text = String.Format("{0:0}", rank)
     114          };
     115          Chart.Group.Add(visualTextNode);
     116        }
     117
    89118        // sort descending by quality (using comparison defined in GenealogyGraphNode class)
    90         layers[i].Nodes.Sort((b, a) => Graph.Compare(a, b));
    91         x = 0; // reset horizontal coordinate
     119        x += (int)Math.Floor(1.5 * Cx); // reset horizontal coordinate
     120
    92121        foreach (var node in layers[i].Nodes) {
    93122          var pen = new Pen(Color.LightGray);
     
    95124          var visualNode = new VisualGenealogyGraphNode(Chart, x, y, x + Diameter, y + Diameter, pen, null) {
    96125            Data = node,
    97             ToolTipText = "Id: " + node.Label + nl +
    98                           "Rank: " + node.Rank + nl +
     126            ToolTipText = "Rank: " + node.Rank + nl +
    99127                          "Quality: " + String.Format("{0:0.0000}", node.Quality) + nl +
    100128                          "IsElite: " + node.IsElite
     
    135163      }
    136164
    137       Chart.UpdateEnabled = true;
    138       Chart.EnforceUpdate();
     165      // highlight the most recent common ancestor ("eve" individual)
     166      //      var eve = graph.MostRecentCommonAncestor();
     167      //      if (eve != null) {
     168      //        var visualGraphNode = GetVisualGenealogyGraphNode(eve);
     169
     170      //        var brush = new SolidBrush(Color.BlueViolet);
     171      //        visualGraphNode.Brush = brush;
     172      //      }
     173
     174      Chart.UpdateEnabled = true;
     175      Chart.EnforceUpdate();
     176
     177      drawing = false;
    139178    }
    140179
     
    150189    }
    151190
     191    protected override void pictureBox_MouseMove(object sender, MouseEventArgs e) {
     192      if (!drawing)
     193        base.pictureBox_MouseMove(sender, e);
     194    }
     195
    152196    protected override void pictureBox_MouseUp(object sender, MouseEventArgs e) {
    153197      if (Chart.Mode != ChartMode.Select) {
     
    163207      selectedGenealogyGraphNode = visualNodes[0] as VisualGenealogyGraphNode;
    164208      if (selectedGenealogyGraphNode == null) return;
    165       // new node has been selected, clean up
    166       Chart.UpdateEnabled = false;
    167       // clear colors
    168       ClearAllNodes();
    169       // use a rectangle to highlight the currently selected genealogy graph node
     209
     210      if (!LockGenealogy) {
     211        // new node has been selected, clean up
     212        Chart.UpdateEnabled = false;
     213        if (ModifierKeys != Keys.Shift)
     214          // clear colors
     215          ClearAllNodes();
     216        // use a rectangle to highlight the currently selected genealogy graph node
     217        var gNode = selectedGenealogyGraphNode.Data;
     218        var visualNode = GetVisualGenealogyGraphNode(gNode);
     219
     220        DrawLineage(visualNode, n => SimpleLineages ? n.IncomingArcs.Take(1) : n.IncomingArcs, a => a.Source);
     221        visualNode.Brush = null;
     222        DrawLineage(visualNode, n => n.OutgoingArcs, a => a.Target);
     223      }
     224
    170225      MarkSelectedNode();
    171       var gNode = selectedGenealogyGraphNode.Data;
    172       var visualNode = GetVisualGenealogyGraphNode(gNode);
    173 
    174       DrawLineage(visualNode, n => n.IncomingArcs, a => a.Source);
    175       visualNode.Brush = null;
    176       DrawLineage(visualNode, n => n.OutgoingArcs, a => a.Target);
    177226
    178227      // update
     
    185234    }
    186235
    187     private void DrawLineage(VisualGenealogyGraphNode node,
    188                              Func<VisualGenealogyGraphNode, IEnumerable<VisualGenealogyGraphArc>> arcSelector,
    189                              Func<VisualGenealogyGraphArc, VisualGenealogyGraphNode> nodeSelector) {
     236    private void DrawLineage(VisualGenealogyGraphNode node, Func<VisualGenealogyGraphNode, IEnumerable<VisualGenealogyGraphArc>> arcSelector, Func<VisualGenealogyGraphArc, VisualGenealogyGraphNode> nodeSelector) {
    190237      if (node.Brush != null) return;
    191238      node.Brush = new SolidBrush(node.Data.GetColor());
    192239      var arcs = arcSelector(node);
    193240      if (arcs == null) return;
     241
    194242      foreach (var arc in arcs) {
    195243        var source = arc.Source.Data;
     
    198246        var end = new Point((int)arc.End.X, (int)arc.End.Y);
    199247        arc.Pen.Brush = new LinearGradientBrush(start, end, source.GetColor(), target.GetColor());
     248        arc.Pen.Color = Color.Transparent;
     249        //        arc.Pen.Brush = new SolidBrush(Color.DarkGray);
    200250        DrawLineage(nodeSelector(arc), arcSelector, nodeSelector);
    201251      }
     
    231281
    232282    // TODO: optimize and reduce complexity of this method
    233     public void HighlightNodes(IEnumerable<ISymbolicExpressionTree> trees, Color color) {
     283    public void HighlightNodes(IEnumerable<ISymbolicExpressionTree> trees) {
    234284      foreach (var tree in trees) {
    235285        var graphNodes = graph.GetGraphNodes(tree);
    236286        foreach (var graphNode in graphNodes) {
    237           GetVisualGenealogyGraphNode(graphNode).Brush = new SolidBrush(color);
     287          GetVisualGenealogyGraphNode(graphNode).Brush = new SolidBrush(graphNode.GetColor());
     288        }
     289      }
     290    }
     291
     292    public void HighlightArcs(IEnumerable<IEdge> arcs, Color color) {
     293      foreach (var a in arcs) {
     294        var arc = GetVisualGenealogyGraphArc(a.Source, a.Target);
     295        if (arc != null) {
     296          var source = arc.Source.Data;
     297          var target = arc.Target.Data;
     298          var start = new Point((int)arc.Start.X, (int)arc.Start.Y);
     299          var end = new Point((int)arc.End.X, (int)arc.End.Y);
     300          arc.Pen.Brush = new LinearGradientBrush(start, end, source.GetColor(), target.GetColor());
    238301        }
    239302      }
     
    242305    public void HighlightNode(SymbolicExpressionGenealogyGraphNode graphNode, Color color) {
    243306      GetVisualGenealogyGraphNode(graphNode).Brush = new SolidBrush(color);
     307    }
     308
     309    public void HighlightAll() {
     310      Chart.UpdateEnabled = false;
     311      foreach (var visualNode in visualNodeMap.Values) {
     312        visualNode.Brush = new SolidBrush(visualNode.Data.GetColor());
     313      }
     314      foreach (var arc in visualArcMap.Values) {
     315        var source = arc.Source.Data;
     316        var target = arc.Target.Data;
     317        var start = new Point((int)arc.Start.X, (int)arc.Start.Y);
     318        var end = new Point((int)arc.End.X, (int)arc.End.Y);
     319        arc.Pen.Brush = new LinearGradientBrush(start, end, source.GetColor(), target.GetColor());
     320      }
     321      Chart.UpdateEnabled = true;
     322      Chart.EnforceUpdate();
    244323    }
    245324
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphView.Designer.cs

    r9084 r9420  
    11
     2using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
     3
    24namespace HeuristicLab.EvolutionaryTracking.Views {
    35  partial class GenealogyGraphView {
     
    2628    private void InitializeComponent() {
    2729      this.components = new System.ComponentModel.Container();
    28       this.mainTableLayout = new System.Windows.Forms.TableLayoutPanel();
    2930      this.splitContainer = new System.Windows.Forms.SplitContainer();
    30       this.genealogyTableLayout = new System.Windows.Forms.TableLayoutPanel();
    3131      this.genealogyGraphChart = new HeuristicLab.EvolutionaryTracking.Views.GenealogyGraphChart();
    3232      this.symbolicExpressionTreeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
    33       this.topControlBox = new System.Windows.Forms.GroupBox();
     33      this.topControlBox = new System.Windows.Forms.Panel();
     34      this.groupBox1 = new System.Windows.Forms.GroupBox();
     35      this.matchConstantsCheckBox = new System.Windows.Forms.CheckBox();
     36      this.matchVariableWeightsCheckBox = new System.Windows.Forms.CheckBox();
    3437      this.matchVariableNamesCheckBox = new System.Windows.Forms.CheckBox();
    35       this.matchVariableWeightsCheckBox = new System.Windows.Forms.CheckBox();
    36       this.matchConstantsCheckBox = new System.Windows.Forms.CheckBox();
    37       this.similarityLabel = new System.Windows.Forms.Label();
    38       this.graphControlsPanel = new System.Windows.Forms.Panel();
     38      this.graphControlsGroupBox = new System.Windows.Forms.GroupBox();
     39      this.lockGenealogyCheckBox = new System.Windows.Forms.CheckBox();
     40      this.highlightAllButton = new System.Windows.Forms.Button();
     41      this.simpleLineagesCheckBox = new System.Windows.Forms.CheckBox();
    3942      this.selectModeButton = new System.Windows.Forms.RadioButton();
    4043      this.moveModeButton = new System.Windows.Forms.RadioButton();
    4144      this.zoomModeButton = new System.Windows.Forms.RadioButton();
    42       this.mainTableLayout.SuspendLayout();
     45      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    4346      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    4447      this.splitContainer.Panel1.SuspendLayout();
    4548      this.splitContainer.Panel2.SuspendLayout();
    4649      this.splitContainer.SuspendLayout();
    47       this.genealogyTableLayout.SuspendLayout();
    4850      this.topControlBox.SuspendLayout();
    49       this.graphControlsPanel.SuspendLayout();
     51      this.groupBox1.SuspendLayout();
     52      this.graphControlsGroupBox.SuspendLayout();
    5053      this.SuspendLayout();
    5154      //
    52       // mainTableLayout
    53       //
    54       this.mainTableLayout.ColumnCount = 1;
    55       this.mainTableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
    56       this.mainTableLayout.Controls.Add(this.splitContainer, 0, 1);
    57       this.mainTableLayout.Controls.Add(this.topControlBox, 0, 0);
    58       this.mainTableLayout.Dock = System.Windows.Forms.DockStyle.Fill;
    59       this.mainTableLayout.Location = new System.Drawing.Point(0, 0);
    60       this.mainTableLayout.Name = "mainTableLayout";
    61       this.mainTableLayout.RowCount = 2;
    62       this.mainTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle());
    63       this.mainTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
    64       this.mainTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
    65       this.mainTableLayout.Size = new System.Drawing.Size(787, 584);
    66       this.mainTableLayout.TabIndex = 6;
    67       //
    6855      // splitContainer
    6956      //
     57      this.splitContainer.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     58            | System.Windows.Forms.AnchorStyles.Left)
     59            | System.Windows.Forms.AnchorStyles.Right)));
    7060      this.splitContainer.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    71       this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
    7261      this.splitContainer.Location = new System.Drawing.Point(3, 53);
    7362      this.splitContainer.Name = "splitContainer";
     
    7564      // splitContainer.Panel1
    7665      //
    77       this.splitContainer.Panel1.Controls.Add(this.genealogyTableLayout);
     66      this.splitContainer.Panel1.Controls.Add(this.genealogyGraphChart);
    7867      this.splitContainer.Panel1MinSize = 50;
    7968      //
     
    8271      this.splitContainer.Panel2.Controls.Add(this.symbolicExpressionTreeChart);
    8372      this.splitContainer.Panel2MinSize = 50;
    84       this.splitContainer.Size = new System.Drawing.Size(781, 528);
    85       this.splitContainer.SplitterDistance = 360;
     73      this.splitContainer.Size = new System.Drawing.Size(1066, 722);
     74      this.splitContainer.SplitterDistance = 489;
    8675      this.splitContainer.TabIndex = 7;
    87       //
    88       // genealogyTableLayout
    89       //
    90       this.genealogyTableLayout.ColumnCount = 1;
    91       this.genealogyTableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
    92       this.genealogyTableLayout.Controls.Add(this.genealogyGraphChart, 0, 1);
    93       this.genealogyTableLayout.Dock = System.Windows.Forms.DockStyle.Fill;
    94       this.genealogyTableLayout.Location = new System.Drawing.Point(0, 0);
    95       this.genealogyTableLayout.Name = "genealogyTableLayout";
    96       this.genealogyTableLayout.RowCount = 2;
    97       this.genealogyTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle());
    98       this.genealogyTableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
    99       this.genealogyTableLayout.Size = new System.Drawing.Size(358, 526);
    100       this.genealogyTableLayout.TabIndex = 4;
    10176      //
    10277      // genealogyGraphChart
     
    10479      this.genealogyGraphChart.BackColor = System.Drawing.SystemColors.Control;
    10580      this.genealogyGraphChart.Dock = System.Windows.Forms.DockStyle.Fill;
    106       this.genealogyGraphChart.Location = new System.Drawing.Point(3, 3);
     81      this.genealogyGraphChart.Location = new System.Drawing.Point(0, 0);
     82      this.genealogyGraphChart.LockGenealogy = false;
    10783      this.genealogyGraphChart.Name = "genealogyGraphChart";
    10884      this.genealogyGraphChart.ScaleOnResize = true;
    109       this.genealogyGraphChart.Size = new System.Drawing.Size(352, 520);
     85      this.genealogyGraphChart.SimpleLineages = false;
     86      this.genealogyGraphChart.Size = new System.Drawing.Size(487, 720);
    11087      this.genealogyGraphChart.TabIndex = 2;
    11188      //
     
    11794      this.symbolicExpressionTreeChart.Location = new System.Drawing.Point(0, 0);
    11895      this.symbolicExpressionTreeChart.Name = "symbolicExpressionTreeChart";
    119       this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(415, 526);
     96      this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(571, 720);
    12097      this.symbolicExpressionTreeChart.Spacing = 5;
    12198      this.symbolicExpressionTreeChart.SuspendRepaint = false;
     
    126103      // topControlBox
    127104      //
    128       this.topControlBox.Controls.Add(this.matchVariableNamesCheckBox);
    129       this.topControlBox.Controls.Add(this.matchVariableWeightsCheckBox);
    130       this.topControlBox.Controls.Add(this.matchConstantsCheckBox);
    131       this.topControlBox.Controls.Add(this.similarityLabel);
    132       this.topControlBox.Controls.Add(this.graphControlsPanel);
    133       this.topControlBox.Dock = System.Windows.Forms.DockStyle.Fill;
     105      this.topControlBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     106            | System.Windows.Forms.AnchorStyles.Right)));
     107      this.topControlBox.Controls.Add(this.groupBox1);
     108      this.topControlBox.Controls.Add(this.graphControlsGroupBox);
    134109      this.topControlBox.Location = new System.Drawing.Point(3, 3);
    135110      this.topControlBox.Name = "topControlBox";
    136       this.topControlBox.Size = new System.Drawing.Size(781, 44);
     111      this.topControlBox.Size = new System.Drawing.Size(1066, 44);
    137112      this.topControlBox.TabIndex = 6;
    138       this.topControlBox.TabStop = false;
    139       this.topControlBox.Text = "Controls";
     113      //
     114      // groupBox1
     115      //
     116      this.groupBox1.Controls.Add(this.matchConstantsCheckBox);
     117      this.groupBox1.Controls.Add(this.matchVariableWeightsCheckBox);
     118      this.groupBox1.Controls.Add(this.matchVariableNamesCheckBox);
     119      this.groupBox1.Location = new System.Drawing.Point(209, -2);
     120      this.groupBox1.Name = "groupBox1";
     121      this.groupBox1.Size = new System.Drawing.Size(325, 44);
     122      this.groupBox1.TabIndex = 12;
     123      this.groupBox1.TabStop = false;
     124      this.groupBox1.Text = "Matching constraints";
     125      //
     126      // matchConstantsCheckBox
     127      //
     128      this.matchConstantsCheckBox.AutoSize = true;
     129      this.matchConstantsCheckBox.Checked = true;
     130      this.matchConstantsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
     131      this.matchConstantsCheckBox.Location = new System.Drawing.Point(6, 19);
     132      this.matchConstantsCheckBox.Name = "matchConstantsCheckBox";
     133      this.matchConstantsCheckBox.Size = new System.Drawing.Size(102, 17);
     134      this.matchConstantsCheckBox.TabIndex = 5;
     135      this.matchConstantsCheckBox.Text = "Constant values";
     136      this.matchConstantsCheckBox.UseVisualStyleBackColor = true;
     137      this.matchConstantsCheckBox.CheckedChanged += new System.EventHandler(this.matchConstantsCheckBox_CheckedChanged);
     138      //
     139      // matchVariableWeightsCheckBox
     140      //
     141      this.matchVariableWeightsCheckBox.AutoSize = true;
     142      this.matchVariableWeightsCheckBox.Checked = true;
     143      this.matchVariableWeightsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
     144      this.matchVariableWeightsCheckBox.Location = new System.Drawing.Point(114, 19);
     145      this.matchVariableWeightsCheckBox.Name = "matchVariableWeightsCheckBox";
     146      this.matchVariableWeightsCheckBox.Size = new System.Drawing.Size(103, 17);
     147      this.matchVariableWeightsCheckBox.TabIndex = 6;
     148      this.matchVariableWeightsCheckBox.Text = "Variable weights";
     149      this.matchVariableWeightsCheckBox.UseVisualStyleBackColor = true;
     150      this.matchVariableWeightsCheckBox.CheckedChanged += new System.EventHandler(this.matchVariableWeightsCheckBox_CheckedChanged);
    140151      //
    141152      // matchVariableNamesCheckBox
     
    144155      this.matchVariableNamesCheckBox.Checked = true;
    145156      this.matchVariableNamesCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
    146       this.matchVariableNamesCheckBox.Location = new System.Drawing.Point(436, 23);
     157      this.matchVariableNamesCheckBox.Location = new System.Drawing.Point(223, 19);
    147158      this.matchVariableNamesCheckBox.Name = "matchVariableNamesCheckBox";
    148159      this.matchVariableNamesCheckBox.Size = new System.Drawing.Size(98, 17);
     
    152163      this.matchVariableNamesCheckBox.CheckedChanged += new System.EventHandler(this.matchVariableNamesCheckBox_CheckedChanged);
    153164      //
    154       // matchVariableWeightsCheckBox
    155       //
    156       this.matchVariableWeightsCheckBox.AutoSize = true;
    157       this.matchVariableWeightsCheckBox.Checked = true;
    158       this.matchVariableWeightsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
    159       this.matchVariableWeightsCheckBox.Location = new System.Drawing.Point(327, 23);
    160       this.matchVariableWeightsCheckBox.Name = "matchVariableWeightsCheckBox";
    161       this.matchVariableWeightsCheckBox.Size = new System.Drawing.Size(103, 17);
    162       this.matchVariableWeightsCheckBox.TabIndex = 6;
    163       this.matchVariableWeightsCheckBox.Text = "Variable weights";
    164       this.matchVariableWeightsCheckBox.UseVisualStyleBackColor = true;
    165       this.matchVariableWeightsCheckBox.CheckedChanged += new System.EventHandler(this.matchVariableWeightsCheckBox_CheckedChanged);
    166       //
    167       // matchConstantsCheckBox
    168       //
    169       this.matchConstantsCheckBox.AutoSize = true;
    170       this.matchConstantsCheckBox.Checked = true;
    171       this.matchConstantsCheckBox.CheckState = System.Windows.Forms.CheckState.Checked;
    172       this.matchConstantsCheckBox.Location = new System.Drawing.Point(219, 23);
    173       this.matchConstantsCheckBox.Name = "matchConstantsCheckBox";
    174       this.matchConstantsCheckBox.Size = new System.Drawing.Size(102, 17);
    175       this.matchConstantsCheckBox.TabIndex = 5;
    176       this.matchConstantsCheckBox.Text = "Constant values";
    177       this.matchConstantsCheckBox.UseVisualStyleBackColor = true;
    178       this.matchConstantsCheckBox.CheckedChanged += new System.EventHandler(this.matchConstantsCheckBox_CheckedChanged);
    179       //
    180       // similarityLabel
    181       //
    182       this.similarityLabel.AutoSize = true;
    183       this.similarityLabel.Location = new System.Drawing.Point(105, 24);
    184       this.similarityLabel.Name = "similarityLabel";
    185       this.similarityLabel.Size = new System.Drawing.Size(108, 13);
    186       this.similarityLabel.TabIndex = 3;
    187       this.similarityLabel.Text = "Matching constraints:";
    188       //
    189       // graphControlsPanel
    190       //
    191       this.graphControlsPanel.Controls.Add(this.selectModeButton);
    192       this.graphControlsPanel.Controls.Add(this.moveModeButton);
    193       this.graphControlsPanel.Controls.Add(this.zoomModeButton);
    194       this.graphControlsPanel.Location = new System.Drawing.Point(6, 14);
    195       this.graphControlsPanel.Name = "graphControlsPanel";
    196       this.graphControlsPanel.Size = new System.Drawing.Size(93, 30);
    197       this.graphControlsPanel.TabIndex = 2;
     165      // graphControlsGroupBox
     166      //
     167      this.graphControlsGroupBox.Controls.Add(this.lockGenealogyCheckBox);
     168      this.graphControlsGroupBox.Controls.Add(this.highlightAllButton);
     169      this.graphControlsGroupBox.Controls.Add(this.simpleLineagesCheckBox);
     170      this.graphControlsGroupBox.Controls.Add(this.selectModeButton);
     171      this.graphControlsGroupBox.Controls.Add(this.moveModeButton);
     172      this.graphControlsGroupBox.Controls.Add(this.zoomModeButton);
     173      this.graphControlsGroupBox.Location = new System.Drawing.Point(1, -2);
     174      this.graphControlsGroupBox.Name = "graphControlsGroupBox";
     175      this.graphControlsGroupBox.Size = new System.Drawing.Size(202, 44);
     176      this.graphControlsGroupBox.TabIndex = 11;
     177      this.graphControlsGroupBox.TabStop = false;
     178      this.graphControlsGroupBox.Text = "Graph controls";
     179      //
     180      // lockGenealogyCheckBox
     181      //
     182      this.lockGenealogyCheckBox.Appearance = System.Windows.Forms.Appearance.Button;
     183      this.lockGenealogyCheckBox.Location = new System.Drawing.Point(156, 14);
     184      this.lockGenealogyCheckBox.Name = "lockGenealogyCheckBox";
     185      this.lockGenealogyCheckBox.Size = new System.Drawing.Size(24, 24);
     186      this.lockGenealogyCheckBox.TabIndex = 17;
     187      this.toolTip.SetToolTip(this.lockGenealogyCheckBox, "Lock genealogy");
     188      this.lockGenealogyCheckBox.UseVisualStyleBackColor = true;
     189      this.lockGenealogyCheckBox.CheckedChanged += new System.EventHandler(this.lockGenealogyCheckBox_CheckedChanged);
     190      //
     191      // highlightAllButton
     192      //
     193      this.highlightAllButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
     194      this.highlightAllButton.Location = new System.Drawing.Point(96, 14);
     195      this.highlightAllButton.Name = "highlightAllButton";
     196      this.highlightAllButton.Size = new System.Drawing.Size(24, 24);
     197      this.highlightAllButton.TabIndex = 13;
     198      this.toolTip.SetToolTip(this.highlightAllButton, "Fitness gradient");
     199      this.highlightAllButton.UseVisualStyleBackColor = true;
     200      this.highlightAllButton.Click += new System.EventHandler(this.highlightAllButton_Click);
     201      //
     202      // simpleLineagesCheckBox
     203      //
     204      this.simpleLineagesCheckBox.Appearance = System.Windows.Forms.Appearance.Button;
     205      this.simpleLineagesCheckBox.Location = new System.Drawing.Point(126, 14);
     206      this.simpleLineagesCheckBox.Name = "simpleLineagesCheckBox";
     207      this.simpleLineagesCheckBox.Size = new System.Drawing.Size(24, 24);
     208      this.simpleLineagesCheckBox.TabIndex = 12;
     209      this.toolTip.SetToolTip(this.simpleLineagesCheckBox, "Simple lineages");
     210      this.simpleLineagesCheckBox.UseVisualStyleBackColor = true;
     211      this.simpleLineagesCheckBox.CheckedChanged += new System.EventHandler(this.simpleLineagesCheckBox_CheckedChanged);
    198212      //
    199213      // selectModeButton
    200214      //
    201215      this.selectModeButton.Appearance = System.Windows.Forms.Appearance.Button;
    202       this.selectModeButton.Location = new System.Drawing.Point(63, 3);
     216      this.selectModeButton.Location = new System.Drawing.Point(66, 14);
    203217      this.selectModeButton.Name = "selectModeButton";
    204218      this.selectModeButton.Size = new System.Drawing.Size(24, 24);
    205       this.selectModeButton.TabIndex = 11;
     219      this.selectModeButton.TabIndex = 16;
    206220      this.selectModeButton.TabStop = true;
     221      this.toolTip.SetToolTip(this.selectModeButton, "Select");
    207222      this.selectModeButton.UseVisualStyleBackColor = true;
    208223      this.selectModeButton.CheckedChanged += new System.EventHandler(this.selectModeButton_CheckedChanged);
     
    211226      //
    212227      this.moveModeButton.Appearance = System.Windows.Forms.Appearance.Button;
    213       this.moveModeButton.Location = new System.Drawing.Point(3, 3);
     228      this.moveModeButton.Location = new System.Drawing.Point(6, 14);
    214229      this.moveModeButton.Name = "moveModeButton";
    215230      this.moveModeButton.Size = new System.Drawing.Size(24, 24);
    216       this.moveModeButton.TabIndex = 9;
     231      this.moveModeButton.TabIndex = 14;
    217232      this.moveModeButton.TabStop = true;
     233      this.toolTip.SetToolTip(this.moveModeButton, "Move");
    218234      this.moveModeButton.UseVisualStyleBackColor = true;
    219235      this.moveModeButton.CheckedChanged += new System.EventHandler(this.moveModeButton_CheckedChanged);
     
    222238      //
    223239      this.zoomModeButton.Appearance = System.Windows.Forms.Appearance.Button;
    224       this.zoomModeButton.Location = new System.Drawing.Point(33, 3);
     240      this.zoomModeButton.Location = new System.Drawing.Point(36, 14);
    225241      this.zoomModeButton.Name = "zoomModeButton";
    226242      this.zoomModeButton.Size = new System.Drawing.Size(24, 24);
    227       this.zoomModeButton.TabIndex = 10;
     243      this.zoomModeButton.TabIndex = 15;
    228244      this.zoomModeButton.TabStop = true;
     245      this.toolTip.SetToolTip(this.zoomModeButton, "Zoom");
    229246      this.zoomModeButton.UseVisualStyleBackColor = true;
    230247      this.zoomModeButton.CheckedChanged += new System.EventHandler(this.zoomModeButton_CheckedChanged);
     
    234251      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    235252      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    236       this.Controls.Add(this.mainTableLayout);
     253      this.Controls.Add(this.splitContainer);
     254      this.Controls.Add(this.topControlBox);
    237255      this.Name = "GenealogyGraphView";
    238       this.Size = new System.Drawing.Size(787, 584);
    239       this.mainTableLayout.ResumeLayout(false);
     256      this.Size = new System.Drawing.Size(1072, 778);
    240257      this.splitContainer.Panel1.ResumeLayout(false);
    241258      this.splitContainer.Panel2.ResumeLayout(false);
    242259      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    243260      this.splitContainer.ResumeLayout(false);
    244       this.genealogyTableLayout.ResumeLayout(false);
    245261      this.topControlBox.ResumeLayout(false);
    246       this.topControlBox.PerformLayout();
    247       this.graphControlsPanel.ResumeLayout(false);
     262      this.groupBox1.ResumeLayout(false);
     263      this.groupBox1.PerformLayout();
     264      this.graphControlsGroupBox.ResumeLayout(false);
    248265      this.ResumeLayout(false);
    249266
     
    252269    #endregion
    253270
    254     private System.Windows.Forms.TableLayoutPanel mainTableLayout;
    255271    private System.Windows.Forms.SplitContainer splitContainer;
    256     private System.Windows.Forms.GroupBox topControlBox;
    257     private Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart symbolicExpressionTreeChart;
    258     private System.Windows.Forms.TableLayoutPanel genealogyTableLayout;
     272    private SymbolicExpressionTreeChart symbolicExpressionTreeChart;
     273
    259274    private GenealogyGraphChart genealogyGraphChart;
    260     private System.Windows.Forms.Panel graphControlsPanel;
     275    private System.Windows.Forms.ToolTip toolTip;
     276    private System.Windows.Forms.Panel topControlBox;
     277    private System.Windows.Forms.GroupBox groupBox1;
     278    private System.Windows.Forms.CheckBox matchConstantsCheckBox;
     279    private System.Windows.Forms.CheckBox matchVariableWeightsCheckBox;
     280    private System.Windows.Forms.CheckBox matchVariableNamesCheckBox;
     281    private System.Windows.Forms.GroupBox graphControlsGroupBox;
     282    private System.Windows.Forms.Button highlightAllButton;
     283    private System.Windows.Forms.CheckBox simpleLineagesCheckBox;
    261284    private System.Windows.Forms.RadioButton selectModeButton;
    262285    private System.Windows.Forms.RadioButton moveModeButton;
    263286    private System.Windows.Forms.RadioButton zoomModeButton;
    264     private System.Windows.Forms.Label similarityLabel;
    265     private System.Windows.Forms.CheckBox matchVariableNamesCheckBox;
    266     private System.Windows.Forms.CheckBox matchVariableWeightsCheckBox;
    267     private System.Windows.Forms.CheckBox matchConstantsCheckBox;
     287    private System.Windows.Forms.CheckBox lockGenealogyCheckBox;
    268288
    269289  }
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/GenealogyGraphView.cs

    r9250 r9420  
    5252      this.zoomModeButton.Image = Common.Resources.VSImageLibrary.Zoom;
    5353      this.selectModeButton.Image = Common.Resources.VSImageLibrary.Object;
     54      this.highlightAllButton.Image = Common.Resources.VSImageLibrary.Gradient;
     55      this.simpleLineagesCheckBox.Image = Common.Resources.VSImageLibrary.ArrowDown;
     56      this.lockGenealogyCheckBox.Image = Common.Resources.VSImageLibrary.ProtectForm;
     57
    5458      comparer = new SymbolicExpressionTreeNodeSimilarityComparer {
    5559        MatchConstantValues = true,
     
    6367      genealogyGraphChart.GenealogyGraphNodeClicked -= graphChart_GenealogyGraphNodeClicked;
    6468      symbolicExpressionTreeChart.SymbolicExpressionTreeNodeClicked -= treeChart_SymbolicExpressionTreeNodeClicked;
     69      symbolicExpressionTreeChart.SymbolicExpressionTreeNodeDoubleClicked -= treeChart_SymbolicExpressionTreeNodeDoubleClicked;
     70      Content.GraphUpdated -= genealogyGraphUpdated;
    6571      base.DeregisterContentEvents();
    6672    }
     
    7278      symbolicExpressionTreeChart.SymbolicExpressionTreeNodeClicked += treeChart_SymbolicExpressionTreeNodeClicked;
    7379      symbolicExpressionTreeChart.SymbolicExpressionTreeNodeDoubleClicked += treeChart_SymbolicExpressionTreeNodeDoubleClicked;
     80      Content.GraphUpdated += genealogyGraphUpdated;
    7481    }
    7582
     
    8289      else {
    8390        genealogyGraphChart.Graph = Content;
    84         var best = Content.Nodes.OrderByDescending(x => x.Quality).First();
    85         symbolicExpressionTreeChart.Tree = best.SymbolicExpressionTree;
     91        //        var best = Content.Nodes.OrderByDescending(x => x.Quality).First();
     92        //        symbolicExpressionTreeChart.Tree = best.SymbolicExpressionTree;
    8693      }
    8794    }
     
    105112      symbolicExpressionTreeChart.Tree = genealogyGraphNode.SymbolicExpressionTree;
    106113      if (genealogyGraphNode.InEdges == null) return;
    107       var arc = genealogyGraphNode.InEdges.First(x => x.Source != x.Target);
     114      var arc = genealogyGraphNode.InEdges.Last(x => x.Source != x.Target);
    108115      if (arc == null || arc.Data == null) return;
    109116      var fragment = (IFragment)arc.Data;
     
    113120        visualSymbExprTreeNode.LineColor = Color.OrangeRed;
    114121      }
    115       symbolicExpressionTreeChart.Repaint(); // pain orange nodes
     122      symbolicExpressionTreeChart.Repaint();
    116123    }
    117124
     
    129136      var btn = (RadioButton)sender;
    130137      if (btn.Checked) { genealogyGraphChart.Chart.Mode = ChartMode.Select; }
     138    }
     139
     140    private void genealogyGraphUpdated(object sender, EventArgs args) {
     141      genealogyGraphChart.Graph = Content;
    131142    }
    132143
     
    159170              var selectedClone = clonedNodes[selectedNode];
    160171              var parent = selectedClone.Parent;
     172              if (parent == null) break;
     173              int index = parent.IndexOfSubtree(selectedClone);
     174              if (index == -1) break;
    161175              parent.RemoveSubtree(parent.IndexOfSubtree(selectedClone));
    162176              foreach (var node in selectedNode.IterateNodesPrefix()) {
     
    179193      var fragment = new Fragment(clonedNodes[selectedVisualSymbExprTreeNode.SymbolicExpressionTreeNode]);
    180194      var fragmentLength = fragment.Length;
     195      // highlight nodes
    181196      genealogyGraphChart.HighlightNodes(from node in genealogyGraphChart.Graph.Nodes
    182197                                         let tree = node.SymbolicExpressionTree
    183198                                         where tree.Length >= fragmentLength
    184199                                         where tree.Root.ContainsFragment(fragment, comparer)
    185                                          select tree, Color.DodgerBlue);
     200                                         select tree);
     201      // highlight edges that contain a matching fragment
     202      var fragmentSimilarityComparer = new SymbolicExpressionTreeFragmentSimilarityComparer {
     203        SimilarityComparer = comparer
     204      };
     205      var matchingEdges = genealogyGraphChart.Graph.Nodes.Where(n => n.InEdges != null)
     206                           .SelectMany(n => n.InEdges).Where(edge => edge.Data != null && ((IFragment)edge.Data).Root != null)
     207                           .Where(edge => fragmentSimilarityComparer.Equals(fragment, (IFragment)edge.Data));
     208      genealogyGraphChart.HighlightArcs(matchingEdges, Color.DodgerBlue);
     209
     210
    186211      genealogyGraphChart.Chart.UpdateEnabled = true;
    187212      genealogyGraphChart.Chart.EnforceUpdate();
     
    191216    }
    192217    #endregion
     218
    193219    private void matchConstantsCheckBox_CheckedChanged(object sender, EventArgs e) {
    194220      comparer.MatchConstantValues = matchConstantsCheckBox.Checked;
     
    208234        MatchNodesAndRepaint();
    209235    }
     236
     237    private void simpleLineagesCheckBox_CheckedChanged(object sender, EventArgs e) {
     238      genealogyGraphChart.SimpleLineages = simpleLineagesCheckBox.Checked;
     239    }
     240
     241    private void highlightAllButton_Click(object sender, EventArgs e) {
     242      symbolicExpressionTreeChart.Repaint();
     243      genealogyGraphChart.HighlightAll();
     244    }
     245
     246    private void lockGenealogyCheckBox_CheckedChanged(object sender, EventArgs e) {
     247      genealogyGraphChart.LockGenealogy = lockGenealogyCheckBox.Checked;
     248    }
    210249  }
    211250}
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/HeuristicLab.EvolutionaryTracking.Views-3.4.csproj

    r9296 r9420  
    1818    <DebugType>full</DebugType>
    1919    <Optimize>false</Optimize>
    20     <OutputPath>..\..\..\..\Trunk\sources\bin\</OutputPath>
     20    <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
    2121    <DefineConstants>DEBUG;TRACE</DefineConstants>
    2222    <ErrorReport>prompt</ErrorReport>
     
    3939  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
    4040    <DebugSymbols>true</DebugSymbols>
    41     <OutputPath>bin\x64\Debug\</OutputPath>
     41    <OutputPath>..\..\..\..\trunk\sources\bin\</OutputPath>
    4242    <DefineConstants>DEBUG;TRACE</DefineConstants>
    4343    <DebugType>full</DebugType>
     
    5858    <Reference Include="HeuristicLab.Common-3.3">
    5959      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Common-3.3.dll</HintPath>
    60     </Reference>
    61     <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL" />
     60      <Private>False</Private>
     61    </Reference>
     62    <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     63      <Private>False</Private>
     64    </Reference>
    6265    <Reference Include="HeuristicLab.Core-3.3">
    6366      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core-3.3.dll</HintPath>
     67      <Private>False</Private>
    6468    </Reference>
    6569    <Reference Include="HeuristicLab.Core.Views-3.3">
    6670      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.Core.Views-3.3.dll</HintPath>
    67     </Reference>
    68     <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    69       <SpecificVersion>False</SpecificVersion>
    70       <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.dll</HintPath>
     71      <Private>False</Private>
    7172    </Reference>
    7273    <Reference Include="HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    7374      <SpecificVersion>False</SpecificVersion>
    7475      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views-3.4.dll</HintPath>
     76      <Private>False</Private>
    7577    </Reference>
    7678    <Reference Include="HeuristicLab.MainForm-3.3">
    7779      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.MainForm-3.3.dll</HintPath>
     80      <Private>False</Private>
    7881    </Reference>
    7982    <Reference Include="HeuristicLab.MainForm.WindowsForms-3.3">
    8083      <HintPath>..\..\..\trunk\sources\bin\HeuristicLab.MainForm.WindowsForms-3.3.dll</HintPath>
     84      <Private>False</Private>
    8185    </Reference>
    8286    <Reference Include="HeuristicLab.PluginInfrastructure-3.3">
    8387      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     88      <Private>False</Private>
    8489    </Reference>
    8590    <Reference Include="HeuristicLab.Problems.DataAnalysis-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    8691      <SpecificVersion>False</SpecificVersion>
    8792      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis-3.4.dll</HintPath>
     93      <Private>False</Private>
    8894    </Reference>
    8995    <Reference Include="HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4, Version=3.4.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    9096      <SpecificVersion>False</SpecificVersion>
    9197      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Problems.DataAnalysis.Symbolic.Regression-3.4.dll</HintPath>
     98      <Private>False</Private>
    9299    </Reference>
    93100    <Reference Include="HeuristicLab.Visualization-3.3, Version=3.3.0.5170, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    94101      <SpecificVersion>False</SpecificVersion>
    95102      <HintPath>..\..\..\..\trunk\sources\bin\HeuristicLab.Visualization-3.3.dll</HintPath>
     103      <Private>False</Private>
    96104    </Reference>
    97105    <Reference Include="System" />
     
    112120      <DependentUpon>FrequentFragmentsDialog.cs</DependentUpon>
    113121    </Compile>
    114     <Compile Include="GenealogyGraphChart.cs" />
     122    <Compile Include="GenealogyGraphChart.cs">
     123      <SubType>UserControl</SubType>
     124    </Compile>
    115125    <Compile Include="GenealogyGraphChart.Designer.cs">
    116126      <DependentUpon>GenealogyGraphChart.cs</DependentUpon>
     
    143153    <Compile Include="VisualGenealogyGraphArc.cs" />
    144154    <Compile Include="VisualGenealogyGraphNode.cs" />
    145   </ItemGroup>
    146   <ItemGroup>
     155    <Compile Include="VisualGenealogyGraphTextLabel.cs" />
     156  </ItemGroup>
     157  <ItemGroup>
     158    <ProjectReference Include="..\..\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding\3.4\HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4.csproj">
     159      <Project>{06d4a186-9319-48a0-bade-a2058d462eea}</Project>
     160      <Name>HeuristicLab.Encodings.SymbolicExpressionTreeEncoding-3.4</Name>
     161      <Private>False</Private>
     162    </ProjectReference>
    147163    <ProjectReference Include="..\..\HeuristicLab.EvolutionaryTracking\3.4\HeuristicLab.EvolutionaryTracking-3.4.csproj">
    148164      <Project>{1f75cea3-464f-4a6f-b2f0-04b9841ebc16}</Project>
    149165      <Name>HeuristicLab.EvolutionaryTracking-3.4</Name>
     166      <Private>False</Private>
    150167    </ProjectReference>
    151168    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis.Symbolic\3.4\HeuristicLab.Problems.DataAnalysis.Symbolic-3.4.csproj">
    152169      <Project>{3D28463F-EC96-4D82-AFEE-38BE91A0CA00}</Project>
    153170      <Name>HeuristicLab.Problems.DataAnalysis.Symbolic-3.4</Name>
     171      <Private>False</Private>
    154172    </ProjectReference>
    155173  </ItemGroup>
     
    160178    <EmbeddedResource Include="FrequentFragmentsDialog.resx">
    161179      <DependentUpon>FrequentFragmentsDialog.cs</DependentUpon>
     180    </EmbeddedResource>
     181    <EmbeddedResource Include="GenealogyGraphChart.resx">
     182      <DependentUpon>GenealogyGraphChart.cs</DependentUpon>
    162183    </EmbeddedResource>
    163184    <EmbeddedResource Include="GenealogyGraphDialog.resx">
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/LineageExplorerView.Designer.cs

    r9250 r9420  
    2525    private void InitializeComponent() {
    2626      this.components = new System.ComponentModel.Container();
     27      this.tabControl1 = new System.Windows.Forms.TabControl();
     28      this.tabPage1 = new System.Windows.Forms.TabPage();
     29      this.tabPage2 = new System.Windows.Forms.TabPage();
    2730      this.panel1 = new System.Windows.Forms.Panel();
    2831      this.qualityImprovementTreeView = new System.Windows.Forms.TreeView();
    2932      this.symbolicExpressionTreeChart = new HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart();
    3033      this.scopeListTreeView = new System.Windows.Forms.TreeView();
     34      this.calculateFragmentFrequencyButton = new System.Windows.Forms.Button();
     35      this.showGenealogyButton = new System.Windows.Forms.Button();
     36      this.button1 = new System.Windows.Forms.Button();
    3137      this.panel2 = new System.Windows.Forms.Panel();
    32       this.showGenealogyButton = new System.Windows.Forms.Button();
    33       this.calculateFragmentFrequencyButton = new System.Windows.Forms.Button();
     38      this.panel3 = new System.Windows.Forms.Panel();
     39      this.showFrequentFragmentsButton = new System.Windows.Forms.Button();
     40      this.textBox2 = new System.Windows.Forms.TextBox();
     41      this.thresholdLabel = new System.Windows.Forms.Label();
     42      this.bestNTextBox = new System.Windows.Forms.TextBox();
     43      this.consideredTrees = new System.Windows.Forms.Label();
     44      this.panel4 = new System.Windows.Forms.Panel();
     45      this.tabControl1.SuspendLayout();
     46      this.tabPage1.SuspendLayout();
     47      this.tabPage2.SuspendLayout();
    3448      this.panel1.SuspendLayout();
    3549      this.panel2.SuspendLayout();
     50      this.panel3.SuspendLayout();
    3651      this.SuspendLayout();
    3752      //
     53      // tabControl1
     54      //
     55      this.tabControl1.Controls.Add(this.tabPage1);
     56      this.tabControl1.Controls.Add(this.tabPage2);
     57      this.tabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
     58      this.tabControl1.Location = new System.Drawing.Point(0, 0);
     59      this.tabControl1.Name = "tabControl1";
     60      this.tabControl1.SelectedIndex = 0;
     61      this.tabControl1.Size = new System.Drawing.Size(1016, 669);
     62      this.tabControl1.TabIndex = 2;
     63      //
     64      // tabPage1
     65      //
     66      this.tabPage1.Controls.Add(this.panel1);
     67      this.tabPage1.Controls.Add(this.panel2);
     68      this.tabPage1.Location = new System.Drawing.Point(4, 22);
     69      this.tabPage1.Name = "tabPage1";
     70      this.tabPage1.Padding = new System.Windows.Forms.Padding(3);
     71      this.tabPage1.Size = new System.Drawing.Size(1008, 643);
     72      this.tabPage1.TabIndex = 0;
     73      this.tabPage1.Text = "Lineages";
     74      this.tabPage1.UseVisualStyleBackColor = true;
     75      //
     76      // tabPage2
     77      //
     78      this.tabPage2.Controls.Add(this.panel4);
     79      this.tabPage2.Controls.Add(this.panel3);
     80      this.tabPage2.Location = new System.Drawing.Point(4, 22);
     81      this.tabPage2.Name = "tabPage2";
     82      this.tabPage2.Padding = new System.Windows.Forms.Padding(3);
     83      this.tabPage2.Size = new System.Drawing.Size(1008, 643);
     84      this.tabPage2.TabIndex = 1;
     85      this.tabPage2.Text = "Fragments";
     86      this.tabPage2.UseVisualStyleBackColor = true;
     87      //
    3888      // panel1
    3989      //
    40       this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    41             | System.Windows.Forms.AnchorStyles.Left)
    42             | System.Windows.Forms.AnchorStyles.Right)));
    4390      this.panel1.Controls.Add(this.qualityImprovementTreeView);
    4491      this.panel1.Controls.Add(this.symbolicExpressionTreeChart);
    4592      this.panel1.Controls.Add(this.scopeListTreeView);
    46       this.panel1.Location = new System.Drawing.Point(3, 42);
     93      this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
     94      this.panel1.Location = new System.Drawing.Point(3, 36);
    4795      this.panel1.Name = "panel1";
    48       this.panel1.Size = new System.Drawing.Size(503, 624);
    49       this.panel1.TabIndex = 0;
     96      this.panel1.Size = new System.Drawing.Size(1002, 604);
     97      this.panel1.TabIndex = 1;
    5098      //
    5199      // qualityImprovementTreeView
     
    54102            | System.Windows.Forms.AnchorStyles.Right)));
    55103      this.qualityImprovementTreeView.HideSelection = false;
    56       this.qualityImprovementTreeView.Location = new System.Drawing.Point(388, 0);
     104      this.qualityImprovementTreeView.Location = new System.Drawing.Point(887, 0);
    57105      this.qualityImprovementTreeView.Name = "qualityImprovementTreeView";
    58       this.qualityImprovementTreeView.Size = new System.Drawing.Size(115, 624);
     106      this.qualityImprovementTreeView.Size = new System.Drawing.Size(115, 604);
    59107      this.qualityImprovementTreeView.TabIndex = 10;
    60108      this.qualityImprovementTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.qualityImprovementTreeView_AfterSelect);
     
    69117      this.symbolicExpressionTreeChart.Location = new System.Drawing.Point(155, 0);
    70118      this.symbolicExpressionTreeChart.Name = "symbolicExpressionTreeChart";
    71       this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(227, 624);
     119      this.symbolicExpressionTreeChart.Size = new System.Drawing.Size(726, 604);
    72120      this.symbolicExpressionTreeChart.Spacing = 5;
    73121      this.symbolicExpressionTreeChart.SuspendRepaint = false;
     
    75123      this.symbolicExpressionTreeChart.TextFont = new System.Drawing.Font("Times New Roman", 8F);
    76124      this.symbolicExpressionTreeChart.Tree = null;
    77       this.symbolicExpressionTreeChart.SymbolicExpressionTreeNodeClicked += new System.Windows.Forms.MouseEventHandler(this.symbolicExpressionTreeChart_SymbolicExpressionTreeNodeClicked);
    78125      //
    79126      // scopeListTreeView
     
    83130      this.scopeListTreeView.Location = new System.Drawing.Point(0, 0);
    84131      this.scopeListTreeView.Name = "scopeListTreeView";
    85       this.scopeListTreeView.Size = new System.Drawing.Size(155, 624);
     132      this.scopeListTreeView.Size = new System.Drawing.Size(155, 604);
    86133      this.scopeListTreeView.TabIndex = 11;
    87134      this.scopeListTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.scopeListTreeView_AfterSelect);
    88135      //
    89       // panel2
    90       //
    91       this.panel2.Controls.Add(this.showGenealogyButton);
    92       this.panel2.Controls.Add(this.calculateFragmentFrequencyButton);
    93       this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
    94       this.panel2.Location = new System.Drawing.Point(0, 0);
    95       this.panel2.Name = "panel2";
    96       this.panel2.Size = new System.Drawing.Size(509, 33);
    97       this.panel2.TabIndex = 1;
     136      // calculateFragmentFrequencyButton
     137      //
     138      this.calculateFragmentFrequencyButton.AutoSize = true;
     139      this.calculateFragmentFrequencyButton.Location = new System.Drawing.Point(4, 4);
     140      this.calculateFragmentFrequencyButton.Name = "calculateFragmentFrequencyButton";
     141      this.calculateFragmentFrequencyButton.Size = new System.Drawing.Size(119, 23);
     142      this.calculateFragmentFrequencyButton.TabIndex = 0;
     143      this.calculateFragmentFrequencyButton.Text = "Fragment frequencies";
     144      this.calculateFragmentFrequencyButton.UseVisualStyleBackColor = true;
     145      this.calculateFragmentFrequencyButton.Click += new System.EventHandler(this.calculateFragmentFrequencyButton_Click);
    98146      //
    99147      // showGenealogyButton
     
    108156      this.showGenealogyButton.Click += new System.EventHandler(this.showGenealogyButton_Click);
    109157      //
    110       // calculateFragmentFrequencyButton
    111       //
    112       this.calculateFragmentFrequencyButton.AutoSize = true;
    113       this.calculateFragmentFrequencyButton.Location = new System.Drawing.Point(4, 4);
    114       this.calculateFragmentFrequencyButton.Name = "calculateFragmentFrequencyButton";
    115       this.calculateFragmentFrequencyButton.Size = new System.Drawing.Size(119, 23);
    116       this.calculateFragmentFrequencyButton.TabIndex = 0;
    117       this.calculateFragmentFrequencyButton.Text = "Fragment frequencies";
    118       this.calculateFragmentFrequencyButton.UseVisualStyleBackColor = true;
    119       this.calculateFragmentFrequencyButton.Click += new System.EventHandler(this.calculateFragmentFrequencyButton_Click);
     158      // button1
     159      //
     160      this.button1.AutoSize = true;
     161      this.button1.Location = new System.Drawing.Point(239, 4);
     162      this.button1.Name = "button1";
     163      this.button1.Size = new System.Drawing.Size(135, 23);
     164      this.button1.TabIndex = 2;
     165      this.button1.Text = "Show frequent fragments";
     166      this.button1.UseVisualStyleBackColor = true;
     167      this.button1.Click += new System.EventHandler(this.button1_Click);
     168      //
     169      // panel2
     170      //
     171      this.panel2.Controls.Add(this.button1);
     172      this.panel2.Controls.Add(this.showGenealogyButton);
     173      this.panel2.Controls.Add(this.calculateFragmentFrequencyButton);
     174      this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
     175      this.panel2.Location = new System.Drawing.Point(3, 3);
     176      this.panel2.Name = "panel2";
     177      this.panel2.Size = new System.Drawing.Size(1002, 33);
     178      this.panel2.TabIndex = 1;
     179      //
     180      // panel3
     181      //
     182      this.panel3.Controls.Add(this.showFrequentFragmentsButton);
     183      this.panel3.Controls.Add(this.textBox2);
     184      this.panel3.Controls.Add(this.thresholdLabel);
     185      this.panel3.Controls.Add(this.bestNTextBox);
     186      this.panel3.Controls.Add(this.consideredTrees);
     187      this.panel3.Dock = System.Windows.Forms.DockStyle.Top;
     188      this.panel3.Location = new System.Drawing.Point(3, 3);
     189      this.panel3.Name = "panel3";
     190      this.panel3.Size = new System.Drawing.Size(1002, 30);
     191      this.panel3.TabIndex = 0;
     192      //
     193      // showFrequentFragmentsButton
     194      //
     195      this.showFrequentFragmentsButton.AutoSize = true;
     196      this.showFrequentFragmentsButton.Location = new System.Drawing.Point(218, 3);
     197      this.showFrequentFragmentsButton.Name = "showFrequentFragmentsButton";
     198      this.showFrequentFragmentsButton.Size = new System.Drawing.Size(135, 23);
     199      this.showFrequentFragmentsButton.TabIndex = 19;
     200      this.showFrequentFragmentsButton.Text = "Show frequent fragments";
     201      this.showFrequentFragmentsButton.UseVisualStyleBackColor = true;
     202      this.showFrequentFragmentsButton.Click += new System.EventHandler(this.showFrequentFragmentsButton_Click);
     203      //
     204      // textBox2
     205      //
     206      this.textBox2.Location = new System.Drawing.Point(173, 5);
     207      this.textBox2.Name = "textBox2";
     208      this.textBox2.Size = new System.Drawing.Size(39, 20);
     209      this.textBox2.TabIndex = 18;
     210      this.textBox2.Text = "0.2";
     211      //
     212      // thresholdLabel
     213      //
     214      this.thresholdLabel.AutoSize = true;
     215      this.thresholdLabel.Location = new System.Drawing.Point(113, 9);
     216      this.thresholdLabel.Name = "thresholdLabel";
     217      this.thresholdLabel.Size = new System.Drawing.Size(54, 13);
     218      this.thresholdLabel.TabIndex = 17;
     219      this.thresholdLabel.Text = "Threshold";
     220      //
     221      // bestNTextBox
     222      //
     223      this.bestNTextBox.Location = new System.Drawing.Point(68, 6);
     224      this.bestNTextBox.Name = "bestNTextBox";
     225      this.bestNTextBox.Size = new System.Drawing.Size(39, 20);
     226      this.bestNTextBox.TabIndex = 16;
     227      this.bestNTextBox.Text = "10";
     228      //
     229      // consideredTrees
     230      //
     231      this.consideredTrees.AutoSize = true;
     232      this.consideredTrees.Location = new System.Drawing.Point(3, 9);
     233      this.consideredTrees.Name = "consideredTrees";
     234      this.consideredTrees.Size = new System.Drawing.Size(63, 13);
     235      this.consideredTrees.TabIndex = 15;
     236      this.consideredTrees.Text = "Best n trees";
     237      //
     238      // panel4
     239      //
     240      this.panel4.Dock = System.Windows.Forms.DockStyle.Fill;
     241      this.panel4.Location = new System.Drawing.Point(3, 33);
     242      this.panel4.Name = "panel4";
     243      this.panel4.Size = new System.Drawing.Size(1002, 607);
     244      this.panel4.TabIndex = 1;
    120245      //
    121246      // LineageExplorerView
     
    123248      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    124249      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    125       this.Controls.Add(this.panel2);
    126       this.Controls.Add(this.panel1);
     250      this.Controls.Add(this.tabControl1);
    127251      this.Name = "LineageExplorerView";
    128       this.Size = new System.Drawing.Size(509, 669);
     252      this.Size = new System.Drawing.Size(1016, 669);
     253      this.tabControl1.ResumeLayout(false);
     254      this.tabPage1.ResumeLayout(false);
     255      this.tabPage2.ResumeLayout(false);
    129256      this.panel1.ResumeLayout(false);
    130257      this.panel2.ResumeLayout(false);
    131258      this.panel2.PerformLayout();
     259      this.panel3.ResumeLayout(false);
     260      this.panel3.PerformLayout();
    132261      this.ResumeLayout(false);
    133262
     
    136265    #endregion
    137266
     267    private System.Windows.Forms.TabControl tabControl1;
     268    private System.Windows.Forms.TabPage tabPage1;
    138269    private System.Windows.Forms.Panel panel1;
    139     private System.Windows.Forms.Panel panel2;
    140     private System.Windows.Forms.Button calculateFragmentFrequencyButton;
    141270    private System.Windows.Forms.TreeView qualityImprovementTreeView;
    142271    private Encodings.SymbolicExpressionTreeEncoding.Views.SymbolicExpressionTreeChart symbolicExpressionTreeChart;
    143272    private System.Windows.Forms.TreeView scopeListTreeView;
     273    private System.Windows.Forms.TabPage tabPage2;
     274    private System.Windows.Forms.Panel panel2;
     275    private System.Windows.Forms.Button button1;
    144276    private System.Windows.Forms.Button showGenealogyButton;
     277    private System.Windows.Forms.Button calculateFragmentFrequencyButton;
     278    private System.Windows.Forms.Panel panel3;
     279    private System.Windows.Forms.Button showFrequentFragmentsButton;
     280    private System.Windows.Forms.TextBox textBox2;
     281    private System.Windows.Forms.Label thresholdLabel;
     282    private System.Windows.Forms.TextBox bestNTextBox;
     283    private System.Windows.Forms.Label consideredTrees;
     284    private System.Windows.Forms.Panel panel4;
     285
    145286
    146287
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/LineageExplorerView.cs

    r9250 r9420  
    77using HeuristicLab.Core.Views;
    88using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding;
     9using HeuristicLab.Encodings.SymbolicExpressionTreeEncoding.Views;
    910using HeuristicLab.MainForm;
    1011using HeuristicLab.Problems.DataAnalysis.Symbolic;
     
    1718    private List<SymbolicExpressionGenealogyGraphNode> lineage;
    1819
     20    private Dictionary<ISymbolicExpressionTree, Dictionary<ISymbolicExpressionTreeNode, double>> fragmentFrequencies;
     21
    1922    public new LineageExplorer Content {
    2023      get { return (LineageExplorer)base.Content; }
     
    6669      var treeNode = scopeListTreeView.SelectedNode;
    6770      var symbExprTree = treeMap[treeNode];
     71
     72      fragmentFrequencies = fragmentFrequencies ?? new Dictionary<ISymbolicExpressionTree, Dictionary<ISymbolicExpressionTreeNode, double>>();
     73
     74      if (fragmentFrequencies.ContainsKey(symbExprTree) && false) {
     75        // colorize tree nodes according to fragment frequencies
     76        symbolicExpressionTreeChart.SuspendRepaint = true;
     77        var frequencies = fragmentFrequencies[symbExprTree];
     78
     79        foreach (var node in symbExprTree.IterateNodesBreadth()) {
     80          double freq = frequencies[node];
     81          int index = (int)Math.Floor(freq * ColorGradient.Colors.Count / scopeListTreeView.GetNodeCount(false));
     82          if (index == ColorGradient.Colors.Count) index--;
     83          var color = ColorGradient.Colors[index];
     84          var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
     85          visualNode.FillColor = Color.FromArgb(200, color);
     86        }
     87        symbolicExpressionTreeChart.SuspendRepaint = false;
     88        symbolicExpressionTreeChart.Repaint();
     89      }
     90      // highlight crossover fragment
    6891      HighlightFragment(symbExprTree);
    6992
    70       var graphNode = Content.GenealogyGraph.GetGraphNodes(symbExprTree).First();
     93      var graphNode = Content.GenealogyGraph.GetGraphNodes(symbExprTree).Last();
    7194      lineage = lineage ?? new List<SymbolicExpressionGenealogyGraphNode>();
    7295      lineage.Clear();
     
    78101        lineage.Add(gn);
    79102      }
    80       lineage.Reverse(); // incresing order by generation
     103      lineage.Reverse(); // increasing order by generation
    81104
    82105      // update the righthand side tree view
     
    108131        return;
    109132      }
    110       var fragment = (IFragment)graphNode.InEdges[0].Data;
     133      var fragment = graphNode.InEdges.Count == 1 ? (IFragment)graphNode.InEdges[0].Data : (IFragment)graphNode.InEdges[1].Data;
    111134      if (fragment.Root == null) {
    112135        symbolicExpressionTreeChart.SuspendRepaint = false;
     
    130153      // the individual can occur multiple times in the graph if it is(was) elite. we take the first occurence.
    131154      var graphNode = Content.GenealogyGraph.GetGraphNodes(symbolicExpressionTreeChart.Tree).First();
     155      var trees = Content.GenealogyGraph.Nodes.Where(x => x.Rank.IsAlmost(graphNode.Rank)).Select(x => x.SymbolicExpressionTree).ToList();
     156
    132157      var fragments = graphNode.SymbolicExpressionTree.IterateNodesBreadth().Select(n => new Fragment(n));
    133       var trees = Content.Trees.Select(t => t.Item1).ToList();
    134       var hashset = new HashSet<ISymbolicExpressionTree>();
    135158
    136159      var similarityComparer = new SymbolicExpressionTreeNodeSimilarityComparer {
     
    140163      };
    141164
     165      var canonicalSorter = new SymbolicExpressionTreeCanonicalSorter();
     166
     167      fragmentFrequencies = fragmentFrequencies ?? new Dictionary<ISymbolicExpressionTree, Dictionary<ISymbolicExpressionTreeNode, double>>();
     168
     169      if (!fragmentFrequencies.ContainsKey(graphNode.SymbolicExpressionTree)) {
     170        fragmentFrequencies[graphNode.SymbolicExpressionTree] = new Dictionary<ISymbolicExpressionTreeNode, double>();
     171      }
     172
     173      fragmentFrequencies[graphNode.SymbolicExpressionTree].Clear();
     174
    142175      symbolicExpressionTreeChart.SuspendRepaint = true;
    143176      foreach (var f in fragments) {
    144177        double freq = 0;
     178
    145179        foreach (var t in trees) {
    146180          if (t.Root.ContainsFragment(f, similarityComparer)) ++freq;
    147           int index = (int)Math.Floor(freq * ColorGradient.Colors.Count / trees.Count);
    148           if (index == ColorGradient.Colors.Count) index--;
    149           var color = ColorGradient.Colors[index];
    150           foreach (var node in f.Root.IterateNodesBreadth()) {
    151             var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
    152             visualNode.FillColor = Color.FromArgb(200, color);
    153           }
    154         }
    155       }
     181        }
     182
     183        fragmentFrequencies[graphNode.SymbolicExpressionTree].Add(f.Root, freq);
     184
     185        // colorize tree nodes according to fragment frequencies
     186        int index = (int)Math.Floor(freq * ColorGradient.Colors.Count / trees.Count);
     187        if (index == ColorGradient.Colors.Count) index--;
     188        var color = ColorGradient.Colors[index];
     189        foreach (var node in f.Root.IterateNodesBreadth()) {
     190          var visualNode = symbolicExpressionTreeChart.GetVisualSymbolicExpressionTreeNode(node);
     191          visualNode.FillColor = Color.FromArgb(200, color);
     192        }
     193      }
     194
    156195      symbolicExpressionTreeChart.SuspendRepaint = false;
    157196      symbolicExpressionTreeChart.Repaint();
     
    172211      }
    173212      using (var dialog = new GenealogyGraphDialog { Graph = graph }) {
     213        dialog.ShowDialog(this);
     214      }
     215    }
     216
     217    private void button1_Click(object sender, EventArgs e) {
     218      using (var dialog = new FrequentFragmentsDialog()) {
     219        var panel = new Panel { Dock = DockStyle.Left, Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom };
     220
     221        panel.Controls.Add(new SymbolicExpressionTreeChart() { Tree = treeMap.Values.First() });
     222        panel.Controls.Add(new Label { Text = "Fragment frequency." });
     223
     224        dialog.fragmentsPanel.Controls.Add(panel);
     225
     226        dialog.ShowDialog(this);
     227      }
     228    }
     229
     230    private void showFrequentFragmentsButton_Click(object sender, EventArgs e) {
     231      int bestN;
     232      bool success = int.TryParse(bestNTextBox.Text, out bestN);
     233      if (!success) bestN = 10;
     234      var tuples = Content.Trees.Select(t => new { Tree = t.Item1, Quality = t.Item2 }).OrderByDescending(x => x.Quality).ToList();
     235      var bestTrees = tuples.Take(bestN).Select(x => x.Tree).ToList();
     236
     237      var similarityComparer = new SymbolicExpressionTreeNodeSimilarityComparer {
     238        MatchConstantValues = false,
     239        MatchVariableNames = true,
     240        MatchVariableWeights = false
     241      };
     242
     243      var fragments = bestTrees.SelectMany(t => t.IterateNodesBreadth()).Where(n => n.GetLength() >= 3).Distinct(similarityComparer).Select(n => new Fragment(n));
     244
     245      double bestNQuality = tuples.Take(bestN).Sum(x => x.Quality); // average quality of best N individuals in the population
     246
     247      using (var dialog = new FrequentFragmentsDialog()) {
     248        foreach (var fragment in fragments.Take(20)) {
     249          double avgQuality = bestNQuality;
     250          double frequency = bestN;
     251          foreach (var t in tuples.Skip(bestN)) {
     252            var tree = t.Tree;
     253            if (tree.Root.ContainsFragment(fragment, similarityComparer)) {
     254              avgQuality += t.Quality;
     255              frequency++;
     256            }
     257          }
     258          if (frequency > 0.2) {
     259            var panel = new Panel {
     260              Dock = DockStyle.Left,
     261              Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Bottom
     262            };
     263
     264            panel.Controls.Add(new SymbolicExpressionTreeChart() { Tree = treeMap.Values.First() });
     265            panel.Controls.Add(new Label { Text = "Fragment frequency." });
     266
     267            dialog.fragmentsPanel.Controls.Add(panel);
     268          }
     269        }
    174270        dialog.ShowDialog(this);
    175271      }
  • branches/HeuristicLab.EvolutionaryTracking/HeuristicLab.EvolutionaryTracking.Views/3.4/VisualGenealogyGraphNode.cs

    r9084 r9420  
    3838      get { return outgoingArcs; }
    3939      set { outgoingArcs = value; }
     40    }
     41
     42    public float LineWidth {
     43      get { return Pen.Width; }
     44      set { Pen.Width = value; }
    4045    }
    4146
Note: See TracChangeset for help on using the changeset viewer.