Free cookie consent management tool by TermsFeed Policy Generator

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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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;
Note: See TracChangeset for help on using the changeset viewer.