Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13789


Ignore:
Timestamp:
04/24/16 20:37:12 (8 years ago)
Author:
bburlacu
Message:

#2288:

  • Refactor RunCollectionVariableInteractionNetworkView improving functionality, modularity and code organisation.
  • Small tweaks to the DirectedGraphChart and DirectedGraphChartMode
Location:
branches/HeuristicLab.VariableInteractionNetworks
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/DirectedGraphChart.Designer.cs

    r13727 r13789  
    3232      // pictureBox
    3333      //
    34       this.pictureBox.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox.Image")));
     34      //this.pictureBox.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox.Image")));
    3535      //
    3636      // toolTip
  • branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/DirectedGraphChart.cs

    r13727 r13789  
    8383      this.AddChartModes(directedGraphChartMode, new PanChartMode(this), new ZoomInChartMode(this), new ZoomOutChartMode(this));
    8484      shapes = new Dictionary<Type, LabeledPrimitive>();
     85      SmoothingMode = SmoothingMode.HighQuality; // set antialiasing for nicer rendering
    8586    }
    8687
     
    110111      foreach (var v in graph.Vertices) {
    111112        var shape = CreateShape(v);
     113        shape.ToolTipText = v.Label;
    112114        vertexMap[shape] = v;
    113115        vertexShapes[v] = shape;
     
    152154        var len = points.Length; // len = 2 when no edge routingMode is performed
    153155        Pen pen;
     156        var penWidth = weight / max * 2;
    154157        if (len == 2) {
    155           pen = new Pen(Color.Black, (float)(weight / max * 3f)) { CustomEndCap = new AdjustableArrowCap(5, 3) };
     158          if (double.IsInfinity(penWidth) || double.IsNaN(penWidth)) penWidth = 1;
     159          pen = new Pen(Color.Black, (float)penWidth) { CustomEndCap = new AdjustableArrowCap(5, 3) };
    156160          var start = points[0];
    157161          var end = points[1];
     
    168172          if (intersectionPoint == default(PointD))
    169173            intersectionPoint = end;
    170           line = new Line(Chart, new PointD(start.X, start.Y), intersectionPoint, pen);
     174          line = new Line(Chart, new PointD(start.X, start.Y), intersectionPoint, pen) { ToolTipText = arc.Label };
    171175          Chart.Group.Add(line);
    172176          arcShapes[arc] = line;
     
    193197            if (intersectionPoints.Any()) {
    194198              endPoint = intersectionPoints.First();
    195               pen = new Pen(Color.Black, (float)(weight / max * 3f)) { CustomEndCap = new AdjustableArrowCap(5, 3) };
     199              pen = new Pen(Color.Black, (float)penWidth) { CustomEndCap = new AdjustableArrowCap(5, 3) };
    196200            } else {
    197201              endPoint = end;
    198               pen = new Pen(Color.Black, (float)(weight / max * 3f));
     202              pen = new Pen(Color.Black, (float)penWidth);
    199203            }
    200             line = new Line(Chart, new PointD(start.X, start.Y), endPoint, pen);
     204            line = new Line(Chart, new PointD(start.X, start.Y), endPoint, pen) { ToolTipText = arc.Label };
    201205            Chart.Group.Add(line);
    202206            if (intersectionPoints.Any()) {
  • branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/DirectedGraphChartMode.cs

    r13727 r13789  
    2525using HeuristicLab.Core;
    2626using HeuristicLab.MainForm;
    27 using HeuristicLab.Problems.DataAnalysis;
    2827using HeuristicLab.Visualization;
    2928
     
    5655                }
    5756              }
    58             } finally { chartControl.ResumeRendering(); }
     57            }
     58            finally { chartControl.ResumeRendering(); }
    5959            break;
    6060        }
    61       } finally {
     61      }
     62      finally {
    6263        base.HandleOnMouseDown(sender, e);
    6364      }
     
    6768      try {
    6869        switch (e.Button) {
    69           case MouseButtons.None:
    70             try {
    71               chartControl.SuspendRendering();
    72               var sp = chartControl.Chart.GetPrimitive(e.Location);
    73               if (sp is RectangularPrimitiveBase) {
    74                 var vertex = Control.GetVertex(sp) as IVertex<IDeepCloneable>;
    75                 var junctionNode = vertex as JunctionNetworkNode;
    76                 if (junctionNode != null) {
    77                   var solution = vertex.Data as IRegressionSolution;
    78                   if (solution != null) {
    79                     var toolTip = string.Format("Target: {0}\nQuality: {1}", solution.ProblemData.TargetVariable, solution.TrainingRSquared);
    80                     Control.ToolTip.SetToolTip(Control, toolTip);
    81                   }
    82                 }
    83               }
    84             } finally { chartControl.ResumeRendering(); }
    85             break;
    8670          case MouseButtons.Left:
    8771            var previousWorldLocation = chartControl.Chart.TransformPixelToWorld(previousLocation);
     
    119103                }
    120104              }
    121             } finally { chartControl.ResumeRendering(); }
     105            }
     106            finally { chartControl.ResumeRendering(); }
    122107            break;
    123108        }
    124       } finally {
    125         chartControl.UpdatePicture();
     109      }
     110      finally {
    126111        base.HandleOnMouseMove(sender, e);
    127112      }
  • branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/RunCollectionVariableInteractionNetworkView.Designer.cs

    r13773 r13789  
    5050      // settingsGroupBox
    5151      //
    52       this.settingsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     52      this.settingsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    5353            | System.Windows.Forms.AnchorStyles.Left)));
    5454      this.settingsGroupBox.Controls.Add(this.onlineImpactCalculationButton);
     
    169169      // layoutOptionsGroupBox
    170170      //
    171       this.layoutOptionsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     171      this.layoutOptionsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    172172            | System.Windows.Forms.AnchorStyles.Left)));
    173173      this.layoutOptionsGroupBox.Controls.Add(this.idealEdgeLengthTextBox);
     
    230230      // graphChart
    231231      //
    232       this.graphChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
    233             | System.Windows.Forms.AnchorStyles.Left) 
     232      this.graphChart.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     233            | System.Windows.Forms.AnchorStyles.Left)
    234234            | System.Windows.Forms.AnchorStyles.Right)));
    235235      this.graphChart.BackColor = System.Drawing.SystemColors.Control;
  • branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/RunCollectionVariableInteractionNetworkView.cs

    r13773 r13789  
    233233          IVertex junctionNode;
    234234          if (!nodes.TryGetValue(junctionLabel, out junctionNode)) {
    235             junctionNode = new JunctionNetworkNode { Label = string.Empty, Data = CreateEnsembleSolution(targetRuns) };
     235            var solutionsEnsemble = CreateEnsembleSolution(targetRuns);
     236            junctionNode = new JunctionNetworkNode { Label = string.Empty, Data = solutionsEnsemble };
    236237            vn.AddVertex(junctionNode);
    237238            nodes[junctionLabel] = junctionNode;
     239            junctionNode.Label = string.Format("Target quality: {0:0.000}", solutionsEnsemble.TrainingRSquared);
    238240          }
    239241          IArc arc;
     
    245247              nodes[v] = variableNode;
    246248            }
    247             arc = new Arc(variableNode, junctionNode) { Weight = impact };
     249            arc = new Arc(variableNode, junctionNode) { Weight = impact, Label = string.Format("Impact: {0:0.000}", impact) };
    248250            vn.AddArc(arc);
    249251          }
    250           arc = new Arc(junctionNode, targetNode) { Weight = junctionNode.InArcs.Sum(x => x.Weight) };
     252          var trainingR2 = ((IRegressionSolution)((JunctionNetworkNode)junctionNode).Data).TrainingRSquared;
     253          arc = new Arc(junctionNode, targetNode) { Weight = junctionNode.InArcs.Sum(x => x.Weight), Label = string.Format("Quality: {0:0.000}", trainingR2) };
    251254          vn.AddArc(arc);
    252255        } else {
     
    258261              nodes[v] = variableNode;
    259262            }
    260             var arc = new Arc(variableNode, targetNode) { Weight = impact };
     263            var arc = new Arc(variableNode, targetNode) { Weight = impact, Label = string.Format("Impact: {0:0.000}", impact) };
    261264            vn.AddArc(arc);
    262265          }
     
    380383      var filteredNetwork = new VariableInteractionNetwork();
    381384      var cloner = new Cloner();
    382       var vertices = arcs.SelectMany(x => new[] { x.Source, x.Target }).Select(cloner.Clone); // arcs are not cloned
     385      var vertices = arcs.SelectMany(x => new[] { x.Source, x.Target }).Select(cloner.Clone).Distinct(); // arcs are not cloned
    383386      filteredNetwork.AddVertices(vertices);
    384       foreach (var arc in arcs) {
    385         var source = cloner.Clone(arc.Source);
    386         var target = cloner.Clone(arc.Target);
    387         filteredNetwork.AddArc(source, target);
    388       }
     387      filteredNetwork.AddArcs(arcs.Select(x => (IArc)x.Clone(cloner)));
     388
    389389      var unusedJunctions = filteredNetwork.Vertices.Where(x => x.InDegree == 0 && x is JunctionNetworkNode).ToList();
    390390      filteredNetwork.RemoveVertices(unusedJunctions);
     
    443443        button.Enabled = false;
    444444        var impacts = CalculateVariableImpactsOnline(Content, false);
    445         var network = CreateNetwork(impacts);
     445        variableInteractionNetwork = CreateNetwork(impacts);
    446446        var threshold = double.Parse(impactThresholdTextBox.Text);
    447         graphChart.Graph = ApplyThreshold(network, threshold);
     447        graphChart.Graph = ApplyThreshold(variableInteractionNetwork, threshold);
    448448      };
    449449      worker.RunWorkerCompleted += (o, e) => button.Enabled = true;
  • branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks/3.3/HeuristicLab.VariableInteractionNetworks-3.3.csproj

    r13728 r13789  
    166166    <Compile Include="Properties\AssemblyInfo.cs" />
    167167    <Compile Include="SymbolicDataAnalysisVariableImpactsAnalyzer.cs" />
     168    <Compile Include="TinySet.cs" />
    168169    <Compile Include="VariableInteractionNetwork.cs" />
    169170  </ItemGroup>
Note: See TracChangeset for help on using the changeset viewer.