Changeset 13893 for branches/HeuristicLab.VariableInteractionNetworks
- Timestamp:
- 06/14/16 17:12:51 (9 years ago)
- Location:
- branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/DirectedGraphChart.Designer.cs
r13874 r13893 30 30 this.SuspendLayout(); 31 31 // 32 // pictureBox33 //34 this.pictureBox.Image = ((System.Drawing.Image)(resources.GetObject("pictureBox.Image")));35 //36 32 // toolTip 37 33 // -
branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/DirectedGraphChart.cs
r13874 r13893 159 159 Pen pen; 160 160 var penWidth = weight / max * 3; 161 //var penColor = colors[(int)Math.Min(255, weight / max * 255)]; 162 var penColor = Color.Black; 161 var colorIndex = (int)Math.Min(255, weight / max * 255); 162 if (colorIndex < 0) colorIndex = 0; 163 if (colorIndex > 255) colorIndex = 255; 164 var penColor = colors[colorIndex]; 163 165 if (len == 2) { 164 if (double.IsInfinity(penWidth) || double.IsNaN(penWidth)) penWidth = 1; 166 if (double.IsInfinity(penWidth) || double.IsNaN(penWidth)) 167 penWidth = 1; 168 165 169 pen = new Pen(penColor, (float)penWidth) { CustomEndCap = new AdjustableArrowCap(5, 3) }; 166 170 var start = points[0]; … … 169 173 var rect = target.Primitive as Rectangle; 170 174 var ell = target.Primitive as Ellipse; 175 176 // calculate intersection point 171 177 PointD intersectionPoint; 172 178 if (rect != null) … … 176 182 else 177 183 throw new InvalidOperationException("Unknown vertex shape."); 184 178 185 if (intersectionPoint == default(PointD)) 179 186 intersectionPoint = end; 187 180 188 line = new Line(Chart, new PointD(start.X, start.Y), intersectionPoint, pen) { ToolTipText = arc.Label }; 181 189 Chart.Group.Add(line); … … 184 192 } else { 185 193 for (int i = 0; i < points.Length - 1; ++i) { 186 Line line;187 194 var start = points[i]; 188 195 var end = points[i + 1]; … … 208 215 pen = new Pen(penColor, (float)penWidth); 209 216 } 210 line = new Line(Chart, new PointD(start.X, start.Y), endPoint, pen) { ToolTipText = arc.Label }; 217 var startPoint = new PointD(start.X, start.Y); 218 var line = new Line(Chart, startPoint, endPoint, pen) { ToolTipText = arc.Label }; 211 219 Chart.Group.Add(line); 212 220 if (intersectionPoints.Any()) { … … 248 256 var rectangle = p as Rectangle; 249 257 var ellipse = p as Ellipse; 250 var brush = (SolidBrush)shape.Brush; 258 var pen = new Pen(shape.Pen.Color); 259 var brush = new SolidBrush(((SolidBrush)shape.Brush).Color); 251 260 252 261 if (rectangle != null) { 253 var r = new Rectangle(this.Chart, shape.LowerLeft, shape.UpperRight, new Pen(shape.Pen.Color), new SolidBrush(brush.Color));262 var r = new Rectangle(this.Chart, shape.LowerLeft, shape.UpperRight, pen, brush); 254 263 return new LabeledPrimitive(r, v.Label, shape.Font); 255 264 } 256 265 if (ellipse != null) { 257 var e = new Ellipse(this.Chart, shape.LowerLeft, shape.UpperRight, new Pen(shape.Pen.Color), new SolidBrush(brush.Color));266 var e = new Ellipse(this.Chart, shape.LowerLeft, shape.UpperRight, pen, brush); 258 267 return new LabeledPrimitive(e, v.Label, shape.Font); 259 268 } -
branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/HeuristicLab.VariableInteractionNetworks.Views-3.3.csproj
r13727 r13893 171 171 <None Include="Plugin.cs.frame" /> 172 172 </ItemGroup> 173 <ItemGroup> 174 <EmbeddedResource Include="RunCollectionVariableInteractionNetworkView.resx"> 175 <DependentUpon>RunCollectionVariableInteractionNetworkView.cs</DependentUpon> 176 </EmbeddedResource> 177 </ItemGroup> 173 178 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 174 179 <PropertyGroup> -
branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/Layout/ConstrainedForceDirectedLayout.cs
r13821 r13893 25 25 using System.Linq; 26 26 using Cola; 27 using HeuristicLab.Common;28 27 using HeuristicLab.Core; 29 28 using HeuristicLab.Random; … … 180 179 181 180 private static IEnumerable<Cluster> IdentifyClusters(RectanglePtrs rectangles, ColaEdges edges) { 182 var vertices = rectangles.Select(x => new Vertex()).ToList(); 181 // build a graph using the rectangles and the edges 182 var vertices = new List<IVertex>(rectangles.Select(x => new Vertex())); 183 183 foreach (var e in edges) { 184 184 var i = (int)e.first; … … 188 188 vertices[j].AddArc(arc); 189 189 } 190 while (vertices.Min(x => x.Weight).IsAlmost(0)) { 191 foreach (var v in vertices) { 192 if (v.Weight > 0) continue; 193 v.Weight = vertices.Max(x => x.Weight) + 1; 190 // group vertices into clusters 191 var clusters = new List<RectangularCluster>(); 192 for (int i = 0; i < vertices.Count; ++i) { 193 var v = vertices[i]; 194 if (v.Weight > 0) { 195 clusters[(int)Math.Round(v.Weight) - 1].addChildNode((uint)i); 196 } else { 197 var cluster = new RectangularCluster(); 198 cluster.addChildNode((uint)i); 199 clusters.Add(cluster); 200 v.Weight = clusters.Count; 194 201 ColourNeighbours(v); 195 202 } 196 203 } 197 var colors = vertices.Select(x => (int)Math.Round(x.Weight)).ToList(); 198 foreach (var i in colors.Distinct()) { 199 var cluster = new RectangularCluster(); 200 for (int j = 0; j < colors.Count; ++j) { 201 if (colors[j] == i) cluster.addChildNode((uint)j); 202 } 203 yield return cluster; 204 } 204 return clusters; 205 205 } 206 206 -
branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/RunCollectionVariableInteractionNetworkView.Designer.cs
r13874 r13893 26 26 this.components = new System.ComponentModel.Container(); 27 27 this.settingsGroupBox = new System.Windows.Forms.GroupBox(); 28 this.impactThresholdTrackBar = new System.Windows.Forms.TrackBar(); 29 this.exportImpactsMatrixButton = new System.Windows.Forms.Button(); 28 30 this.onlineImpactCalculationButton = new System.Windows.Forms.Button(); 29 31 this.maximizationCheckBox = new System.Windows.Forms.CheckBox(); 30 32 this.qualityResultNameComboBox = new System.Windows.Forms.ComboBox(); 31 33 this.qualityResultNameLabel = new System.Windows.Forms.Label(); 32 this.impactThresholdTextBox = new System.Windows.Forms.TextBox();33 34 this.impactAggregationComboBox = new System.Windows.Forms.ComboBox(); 34 35 this.impactResultNameComboBox = new System.Windows.Forms.ComboBox(); … … 42 43 this.label3 = new System.Windows.Forms.Label(); 43 44 this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); 45 this.impactThresholdLabel = new System.Windows.Forms.Label(); 46 this.relayoutGraphButton = new System.Windows.Forms.Button(); 44 47 this.graphChart = new HeuristicLab.VariableInteractionNetworks.Views.DirectedGraphChart(); 45 48 this.settingsGroupBox.SuspendLayout(); 49 ((System.ComponentModel.ISupportInitialize)(this.impactThresholdTrackBar)).BeginInit(); 46 50 this.layoutOptionsGroupBox.SuspendLayout(); 47 51 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); … … 52 56 this.settingsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 53 57 | System.Windows.Forms.AnchorStyles.Left))); 58 this.settingsGroupBox.Controls.Add(this.impactThresholdLabel); 59 this.settingsGroupBox.Controls.Add(this.impactThresholdTrackBar); 60 this.settingsGroupBox.Controls.Add(this.exportImpactsMatrixButton); 54 61 this.settingsGroupBox.Controls.Add(this.onlineImpactCalculationButton); 55 62 this.settingsGroupBox.Controls.Add(this.maximizationCheckBox); 56 63 this.settingsGroupBox.Controls.Add(this.qualityResultNameComboBox); 57 64 this.settingsGroupBox.Controls.Add(this.qualityResultNameLabel); 58 this.settingsGroupBox.Controls.Add(this.impactThresholdTextBox);59 65 this.settingsGroupBox.Controls.Add(this.impactAggregationComboBox); 60 66 this.settingsGroupBox.Controls.Add(this.impactResultNameComboBox); … … 64 70 this.settingsGroupBox.Location = new System.Drawing.Point(4, 4); 65 71 this.settingsGroupBox.Name = "settingsGroupBox"; 66 this.settingsGroupBox.Size = new System.Drawing.Size(331, 23 0);72 this.settingsGroupBox.Size = new System.Drawing.Size(331, 235); 67 73 this.settingsGroupBox.TabIndex = 1; 68 74 this.settingsGroupBox.TabStop = false; 69 75 this.settingsGroupBox.Text = "Network Configuration"; 70 76 // 77 // impactThresholdTrackBar 78 // 79 this.impactThresholdTrackBar.AutoSize = false; 80 this.impactThresholdTrackBar.LargeChange = 1; 81 this.impactThresholdTrackBar.Location = new System.Drawing.Point(10, 118); 82 this.impactThresholdTrackBar.Maximum = 1000; 83 this.impactThresholdTrackBar.Name = "impactThresholdTrackBar"; 84 this.impactThresholdTrackBar.Size = new System.Drawing.Size(312, 23); 85 this.impactThresholdTrackBar.TabIndex = 7; 86 this.impactThresholdTrackBar.ValueChanged += new System.EventHandler(this.impactThresholdTrackBar_ValueChanged); 87 // 88 // exportImpactsMatrixButton 89 // 90 this.exportImpactsMatrixButton.Location = new System.Drawing.Point(10, 203); 91 this.exportImpactsMatrixButton.Name = "exportImpactsMatrixButton"; 92 this.exportImpactsMatrixButton.Size = new System.Drawing.Size(149, 23); 93 this.exportImpactsMatrixButton.TabIndex = 6; 94 this.exportImpactsMatrixButton.Text = "Export Impacts Matrix"; 95 this.exportImpactsMatrixButton.UseVisualStyleBackColor = true; 96 this.exportImpactsMatrixButton.Click += new System.EventHandler(this.exportImpactsMatrixButton_Click); 97 // 71 98 // onlineImpactCalculationButton 72 99 // 73 this.onlineImpactCalculationButton.Location = new System.Drawing.Point(10, 201);100 this.onlineImpactCalculationButton.Location = new System.Drawing.Point(10, 174); 74 101 this.onlineImpactCalculationButton.Name = "onlineImpactCalculationButton"; 75 102 this.onlineImpactCalculationButton.Size = new System.Drawing.Size(149, 23); … … 108 135 this.qualityResultNameLabel.Text = "Quality result name"; 109 136 // 110 // impactThresholdTextBox111 //112 this.impactThresholdTextBox.Location = new System.Drawing.Point(121, 94);113 this.impactThresholdTextBox.Name = "impactThresholdTextBox";114 this.impactThresholdTextBox.Size = new System.Drawing.Size(201, 20);115 this.impactThresholdTextBox.TabIndex = 2;116 this.impactThresholdTextBox.Text = "0.2";117 this.impactThresholdTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.TextBoxValidating);118 this.impactThresholdTextBox.Validated += new System.EventHandler(this.ImpactThresholdTextBoxValidated);119 //120 137 // impactAggregationComboBox 121 138 // … … 124 141 "Best run", 125 142 "Runs average"}); 126 this.impactAggregationComboBox.Location = new System.Drawing.Point(121, 1 20);143 this.impactAggregationComboBox.Location = new System.Drawing.Point(121, 147); 127 144 this.impactAggregationComboBox.Name = "impactAggregationComboBox"; 128 145 this.impactAggregationComboBox.Size = new System.Drawing.Size(201, 21); … … 143 160 // 144 161 this.weightAggregationLabel.AutoSize = true; 145 this.weightAggregationLabel.Location = new System.Drawing.Point(7, 1 23);162 this.weightAggregationLabel.Location = new System.Drawing.Point(7, 150); 146 163 this.weightAggregationLabel.Name = "weightAggregationLabel"; 147 164 this.weightAggregationLabel.Size = new System.Drawing.Size(98, 13); … … 171 188 this.layoutOptionsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 172 189 | System.Windows.Forms.AnchorStyles.Left))); 190 this.layoutOptionsGroupBox.Controls.Add(this.relayoutGraphButton); 173 191 this.layoutOptionsGroupBox.Controls.Add(this.idealEdgeLengthTextBox); 174 192 this.layoutOptionsGroupBox.Controls.Add(this.edgeRoutingComboBox); 175 193 this.layoutOptionsGroupBox.Controls.Add(this.label4); 176 194 this.layoutOptionsGroupBox.Controls.Add(this.label3); 177 this.layoutOptionsGroupBox.Location = new System.Drawing.Point(4, 24 0);195 this.layoutOptionsGroupBox.Location = new System.Drawing.Point(4, 245); 178 196 this.layoutOptionsGroupBox.Name = "layoutOptionsGroupBox"; 179 this.layoutOptionsGroupBox.Size = new System.Drawing.Size(331, 2 22);197 this.layoutOptionsGroupBox.Size = new System.Drawing.Size(331, 217); 180 198 this.layoutOptionsGroupBox.TabIndex = 2; 181 199 this.layoutOptionsGroupBox.TabStop = false; … … 227 245 // 228 246 this.errorProvider.ContainerControl = this; 247 // 248 // impactThresholdLabel 249 // 250 this.impactThresholdLabel.Location = new System.Drawing.Point(118, 92); 251 this.impactThresholdLabel.Name = "impactThresholdLabel"; 252 this.impactThresholdLabel.Size = new System.Drawing.Size(204, 23); 253 this.impactThresholdLabel.TabIndex = 8; 254 this.impactThresholdLabel.Text = "0"; 255 this.impactThresholdLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight; 256 // 257 // relayoutGraphButton 258 // 259 this.relayoutGraphButton.Location = new System.Drawing.Point(10, 69); 260 this.relayoutGraphButton.Name = "relayoutGraphButton"; 261 this.relayoutGraphButton.Size = new System.Drawing.Size(149, 23); 262 this.relayoutGraphButton.TabIndex = 4; 263 this.relayoutGraphButton.Text = "Recalculate Layout"; 264 this.relayoutGraphButton.UseVisualStyleBackColor = true; 265 this.relayoutGraphButton.Click += new System.EventHandler(this.relayoutGraphButton_Click); 229 266 // 230 267 // graphChart … … 256 293 this.settingsGroupBox.ResumeLayout(false); 257 294 this.settingsGroupBox.PerformLayout(); 295 ((System.ComponentModel.ISupportInitialize)(this.impactThresholdTrackBar)).EndInit(); 258 296 this.layoutOptionsGroupBox.ResumeLayout(false); 259 297 this.layoutOptionsGroupBox.PerformLayout(); … … 270 308 private System.Windows.Forms.Label label2; 271 309 private System.Windows.Forms.ComboBox impactResultNameComboBox; 272 private System.Windows.Forms.TextBox impactThresholdTextBox;273 310 private System.Windows.Forms.GroupBox layoutOptionsGroupBox; 274 311 private System.Windows.Forms.Label label3; … … 283 320 private System.Windows.Forms.CheckBox maximizationCheckBox; 284 321 private System.Windows.Forms.Button onlineImpactCalculationButton; 322 private System.Windows.Forms.Button exportImpactsMatrixButton; 323 private System.Windows.Forms.TrackBar impactThresholdTrackBar; 324 private System.Windows.Forms.Label impactThresholdLabel; 325 private System.Windows.Forms.Button relayoutGraphButton; 285 326 } 286 327 } -
branches/HeuristicLab.VariableInteractionNetworks/HeuristicLab.VariableInteractionNetworks.Views/3.3/RunCollectionVariableInteractionNetworkView.cs
r13874 r13893 322 322 foreach (var run in runs) { 323 323 var impactsMatrix = (DoubleMatrix)run.Results[resultName]; 324 325 324 int i = 0; 326 325 foreach (var v in impactsMatrix.RowNames) { … … 412 411 private void NetworkConfigurationChanged(object sender, EventArgs e) { 413 412 var useBest = impactAggregationComboBox.SelectedIndex <= 0; 414 var threshold = double.Parse(impactThresholdTextBox.Text);413 var threshold = impactThresholdTrackBar.Value / 100.0; 415 414 var qualityResultName = qualityResultNameComboBox.Text; 416 415 var impactsResultName = impactResultNameComboBox.Text; … … 451 450 = impactResultNameComboBox.Enabled 452 451 = impactAggregationComboBox.Enabled 453 = impactThresholdT extBox.Enabled452 = impactThresholdTrackBar.Enabled 454 453 = onlineImpactCalculationButton.Enabled 455 454 = edgeRoutingComboBox.Enabled 456 = idealEdgeLengthTextBox.Enabled = enabled; 455 = idealEdgeLengthTextBox.Enabled 456 = maximizationCheckBox.Enabled = enabled; 457 457 } 458 458 … … 463 463 var impacts = CalculateVariableImpactsOnline(Content, false); 464 464 variableInteractionNetwork = CreateNetwork(impacts); 465 var threshold = double.Parse(impactThresholdTextBox.Text);465 var threshold = impactThresholdTrackBar.Minimum + (double)impactThresholdTrackBar.Value / impactThresholdTrackBar.Maximum; 466 466 graphChart.Graph = ApplyThreshold(variableInteractionNetwork, threshold); 467 467 }; … … 469 469 worker.RunWorkerAsync(); 470 470 } 471 472 private void relayoutGraphButton_Click(object sender, EventArgs e) { 473 graphChart.Draw(); 474 } 471 475 #endregion 476 477 private void exportImpactsMatrixButton_Click(object sender, EventArgs e) { 478 var graph = graphChart.Graph; 479 var labels = graph.Vertices.OfType<VariableNetworkNode>().Select(x => x.Label).ToList(); 480 labels.Sort(); // sort variables alphabetically 481 var matrix = new DoubleMatrix(labels.Count, labels.Count) { RowNames = labels, ColumnNames = labels }; 482 var indexes = labels.Select((x, i) => new { Label = x, Index = i }).ToDictionary(x => x.Label, x => x.Index); 483 var junctions = graph.Vertices.OfType<JunctionNetworkNode>().ToList(); 484 foreach (var jn in junctions) { 485 var target = jn.OutArcs.First().Target.Label; 486 var targetIndex = indexes[target]; 487 foreach (var input in jn.InArcs) { 488 var inputIndex = indexes[input.Source.Label]; 489 var inputImpact = input.Weight; 490 matrix[targetIndex, inputIndex] = inputImpact; 491 } 492 } 493 for (int i = 0; i < labels.Count; ++i) matrix[i, i] = 1; 494 MainFormManager.MainForm.ShowContent(matrix); 495 } 496 497 private void impactThresholdTrackBar_ValueChanged(object sender, EventArgs e) { 498 var impact = impactThresholdTrackBar.Minimum + (double)impactThresholdTrackBar.Value / impactThresholdTrackBar.Maximum; 499 impactThresholdLabel.Text = impact.ToString("N3", CultureInfo.CurrentCulture); 500 var network = ApplyThreshold(variableInteractionNetwork, impact); 501 graphChart.Graph = network; 502 } 503 504 472 505 } 473 506 }
Note: See TracChangeset
for help on using the changeset viewer.