Changeset 13745


Ignore:
Timestamp:
04/07/16 14:24:44 (6 years ago)
Author:
abeham
Message:

#2457: added line annotations to the network visu to highlight close solutions

Location:
branches/PerformanceComparison
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.Analysis.Views/3.3/IndexedDataTableView.cs

    r12865 r13745  
    2020#endregion
    2121
     22using HeuristicLab.Collections;
     23using HeuristicLab.Core.Views;
     24using HeuristicLab.MainForm;
    2225using System;
    2326using System.Collections.Generic;
     
    2629using System.Windows.Forms;
    2730using System.Windows.Forms.DataVisualization.Charting;
    28 using HeuristicLab.Collections;
    29 using HeuristicLab.Core.Views;
    30 using HeuristicLab.MainForm;
    3131
    3232namespace HeuristicLab.Analysis.Views {
     
    164164
    165165      series.SmartLabelStyle.Enabled = true;
    166       series.SmartLabelStyle.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.Yes;
     166      series.SmartLabelStyle.AllowOutsidePlotArea = LabelOutsidePlotAreaStyle.No;
    167167      series.SmartLabelStyle.CalloutLineAnchorCapStyle = LineAnchorCapStyle.None;
    168168      series.SmartLabelStyle.CalloutLineColor = series.Color;
     
    262262      area.AxisX2.IsMarginVisible = false;
    263263
     264      area.AxisX.IsStartedFromZero = Content.Rows.Where(x => !x.VisualProperties.SecondXAxis).Any(x => x.VisualProperties.StartIndexZero);
     265      area.AxisX2.IsStartedFromZero = Content.Rows.Where(x => x.VisualProperties.SecondXAxis).Any(x => x.VisualProperties.StartIndexZero);
     266
    264267      if (!Content.VisualProperties.XAxisMinimumAuto && !double.IsNaN(Content.VisualProperties.XAxisMinimumFixedValue)) area.AxisX.Minimum = Content.VisualProperties.XAxisMinimumFixedValue;
    265268      if (!Content.VisualProperties.XAxisMaximumAuto && !double.IsNaN(Content.VisualProperties.XAxisMaximumFixedValue)) area.AxisX.Maximum = Content.VisualProperties.XAxisMaximumFixedValue;
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs

    r13736 r13745  
    357357              LineWidth = 2,
    358358              Color = colors[colorCount],
    359               LineStyle = lineStyles[lineStyleCount]
     359              LineStyle = lineStyles[lineStyleCount],
     360              StartIndexZero = false
    360361            }
    361362          };
     
    549550              LineWidth = 2,
    550551              Color = colors[colorCount],
    551               LineStyle = lineStyles[lineStyleCount]
     552              LineStyle = lineStyles[lineStyleCount],
     553              StartIndexZero = false
    552554            }
    553555          };
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Views/UnderstandingSolutionsView.Designer.cs

    r13743 r13745  
    6969      this.solutionsFdcViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    7070      this.solutionsNetworkTabPage = new System.Windows.Forms.TabPage();
     71      this.solutionsNetworkChart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart();
     72      this.linesCheckBox = new System.Windows.Forms.CheckBox();
    7173      this.solutionNetworkProjectionLabel = new System.Windows.Forms.Label();
    7274      this.solutionNetworkProjectionComboBox = new System.Windows.Forms.ComboBox();
    73       this.solutionsNetworkChart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart();
     75      this.contrastTrackBar = new System.Windows.Forms.TrackBar();
     76      this.minimumTrackBar = new System.Windows.Forms.TrackBar();
     77      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    7478      this.solutionsTabControl.SuspendLayout();
    7579      this.solutionsQualityTabPage.SuspendLayout();
     
    7983      this.solutionsNetworkTabPage.SuspendLayout();
    8084      ((System.ComponentModel.ISupportInitialize)(this.solutionsNetworkChart)).BeginInit();
     85      ((System.ComponentModel.ISupportInitialize)(this.contrastTrackBar)).BeginInit();
     86      ((System.ComponentModel.ISupportInitialize)(this.minimumTrackBar)).BeginInit();
    8187      this.SuspendLayout();
    8288      //
     
    294300      // solutionsNetworkTabPage
    295301      //
     302      this.solutionsNetworkTabPage.Controls.Add(this.solutionsNetworkChart);
     303      this.solutionsNetworkTabPage.Controls.Add(this.linesCheckBox);
    296304      this.solutionsNetworkTabPage.Controls.Add(this.solutionNetworkProjectionLabel);
    297305      this.solutionsNetworkTabPage.Controls.Add(this.solutionNetworkProjectionComboBox);
    298       this.solutionsNetworkTabPage.Controls.Add(this.solutionsNetworkChart);
     306      this.solutionsNetworkTabPage.Controls.Add(this.contrastTrackBar);
     307      this.solutionsNetworkTabPage.Controls.Add(this.minimumTrackBar);
    299308      this.solutionsNetworkTabPage.Location = new System.Drawing.Point(4, 22);
    300309      this.solutionsNetworkTabPage.Name = "solutionsNetworkTabPage";
     
    304313      this.solutionsNetworkTabPage.Text = "Network Analysis";
    305314      this.solutionsNetworkTabPage.UseVisualStyleBackColor = true;
    306       //
    307       // solutionNetworkProjectionLabel
    308       //
    309       this.solutionNetworkProjectionLabel.AutoSize = true;
    310       this.solutionNetworkProjectionLabel.Location = new System.Drawing.Point(6, 9);
    311       this.solutionNetworkProjectionLabel.Name = "solutionNetworkProjectionLabel";
    312       this.solutionNetworkProjectionLabel.Size = new System.Drawing.Size(57, 13);
    313       this.solutionNetworkProjectionLabel.TabIndex = 4;
    314       this.solutionNetworkProjectionLabel.Text = "Projection:";
    315       //
    316       // solutionNetworkProjectionComboBox
    317       //
    318       this.solutionNetworkProjectionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    319       this.solutionNetworkProjectionComboBox.FormattingEnabled = true;
    320       this.solutionNetworkProjectionComboBox.Items.AddRange(new object[] {
    321             "SOM",
    322             "MDS"});
    323       this.solutionNetworkProjectionComboBox.Location = new System.Drawing.Point(69, 6);
    324       this.solutionNetworkProjectionComboBox.Name = "solutionNetworkProjectionComboBox";
    325       this.solutionNetworkProjectionComboBox.Size = new System.Drawing.Size(180, 21);
    326       this.solutionNetworkProjectionComboBox.TabIndex = 3;
    327       this.solutionNetworkProjectionComboBox.SelectedIndexChanged += new System.EventHandler(this.SolutionNetworkProjectionComboBoxOnSelectedIndexChanged);
    328315      //
    329316      // solutionsNetworkChart
     
    373360      this.solutionsNetworkChart.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.SolutionsNetworkChartOnMouseDoubleClick);
    374361      //
     362      // linesCheckBox
     363      //
     364      this.linesCheckBox.AutoSize = true;
     365      this.linesCheckBox.Location = new System.Drawing.Point(263, 8);
     366      this.linesCheckBox.Name = "linesCheckBox";
     367      this.linesCheckBox.Size = new System.Drawing.Size(54, 17);
     368      this.linesCheckBox.TabIndex = 6;
     369      this.linesCheckBox.Text = "Lines:";
     370      this.linesCheckBox.UseVisualStyleBackColor = true;
     371      this.linesCheckBox.CheckedChanged += new System.EventHandler(this.LinesCheckBoxOnCheckedChanged);
     372      //
     373      // solutionNetworkProjectionLabel
     374      //
     375      this.solutionNetworkProjectionLabel.AutoSize = true;
     376      this.solutionNetworkProjectionLabel.Location = new System.Drawing.Point(6, 9);
     377      this.solutionNetworkProjectionLabel.Name = "solutionNetworkProjectionLabel";
     378      this.solutionNetworkProjectionLabel.Size = new System.Drawing.Size(57, 13);
     379      this.solutionNetworkProjectionLabel.TabIndex = 4;
     380      this.solutionNetworkProjectionLabel.Text = "Projection:";
     381      //
     382      // solutionNetworkProjectionComboBox
     383      //
     384      this.solutionNetworkProjectionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     385      this.solutionNetworkProjectionComboBox.FormattingEnabled = true;
     386      this.solutionNetworkProjectionComboBox.Items.AddRange(new object[] {
     387            "SOM",
     388            "MDS"});
     389      this.solutionNetworkProjectionComboBox.Location = new System.Drawing.Point(69, 6);
     390      this.solutionNetworkProjectionComboBox.Name = "solutionNetworkProjectionComboBox";
     391      this.solutionNetworkProjectionComboBox.Size = new System.Drawing.Size(180, 21);
     392      this.solutionNetworkProjectionComboBox.TabIndex = 3;
     393      this.solutionNetworkProjectionComboBox.SelectedIndexChanged += new System.EventHandler(this.SolutionNetworkProjectionComboBoxOnSelectedIndexChanged);
     394      //
     395      // contrastTrackBar
     396      //
     397      this.contrastTrackBar.LargeChange = 3;
     398      this.contrastTrackBar.Location = new System.Drawing.Point(323, 6);
     399      this.contrastTrackBar.Maximum = 17;
     400      this.contrastTrackBar.Minimum = 3;
     401      this.contrastTrackBar.Name = "contrastTrackBar";
     402      this.contrastTrackBar.Size = new System.Drawing.Size(148, 45);
     403      this.contrastTrackBar.TabIndex = 5;
     404      this.contrastTrackBar.TickStyle = System.Windows.Forms.TickStyle.None;
     405      this.toolTip.SetToolTip(this.contrastTrackBar, "Adjusts the contrast of the lines");
     406      this.contrastTrackBar.Value = 10;
     407      this.contrastTrackBar.Scroll += new System.EventHandler(this.ContrastTrackBarOnScroll);
     408      //
     409      // minimumTrackBar
     410      //
     411      this.minimumTrackBar.LargeChange = 10;
     412      this.minimumTrackBar.Location = new System.Drawing.Point(477, 6);
     413      this.minimumTrackBar.Maximum = 100;
     414      this.minimumTrackBar.Minimum = 1;
     415      this.minimumTrackBar.Name = "minimumTrackBar";
     416      this.minimumTrackBar.Size = new System.Drawing.Size(148, 45);
     417      this.minimumTrackBar.TabIndex = 5;
     418      this.minimumTrackBar.TickStyle = System.Windows.Forms.TickStyle.None;
     419      this.toolTip.SetToolTip(this.minimumTrackBar, "Adjusts the minimum");
     420      this.minimumTrackBar.Value = 50;
     421      this.minimumTrackBar.Scroll += new System.EventHandler(this.MinimumTrackBarOnScroll);
     422      //
    375423      // UnderstandingSolutionsView
    376424      //
     
    393441      this.solutionsNetworkTabPage.PerformLayout();
    394442      ((System.ComponentModel.ISupportInitialize)(this.solutionsNetworkChart)).EndInit();
     443      ((System.ComponentModel.ISupportInitialize)(this.contrastTrackBar)).EndInit();
     444      ((System.ComponentModel.ISupportInitialize)(this.minimumTrackBar)).EndInit();
    395445      this.ResumeLayout(false);
    396446      this.PerformLayout();
     
    422472    private System.Windows.Forms.Label solutionNetworkProjectionLabel;
    423473    private System.Windows.Forms.ComboBox solutionNetworkProjectionComboBox;
     474    private System.Windows.Forms.TrackBar contrastTrackBar;
     475    private System.Windows.Forms.CheckBox linesCheckBox;
     476    private System.Windows.Forms.TrackBar minimumTrackBar;
     477    private System.Windows.Forms.ToolTip toolTip;
    424478  }
    425479}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Views/UnderstandingSolutionsView.cs

    r13743 r13745  
    3131using System;
    3232using System.Collections.Generic;
     33using System.Drawing;
    3334using System.Linq;
    3435using System.Windows.Forms;
     
    6869    protected override void OnSolutionSeedingPoolChanged() {
    6970      base.OnSolutionSeedingPoolChanged();
    70       UpdateSolutionNetworkAnalysis(similarityComboBox.SelectedItem as ISolutionSimilarityCalculator, (string)solutionNetworkProjectionComboBox.SelectedItem);
     71      UpdateSolutionNetworkAnalysis(similarityComboBox.SelectedItem as ISolutionSimilarityCalculator, (string)solutionNetworkProjectionComboBox.SelectedItem, linesCheckBox.Checked, contrastTrackBar.Value, minimumTrackBar.Value);
    7172    }
    7273
     
    109110        UpdateSolutionFdcAnalysis(calculator, fdcBetweenBestCheckBox.Checked);
    110111        UpdateSolutionLengthScaleAnalysis(calculator);
    111         UpdateSolutionNetworkAnalysis(calculator, (string)solutionNetworkProjectionComboBox.SelectedItem);
     112        UpdateSolutionNetworkAnalysis(calculator, (string)solutionNetworkProjectionComboBox.SelectedItem, linesCheckBox.Checked, contrastTrackBar.Value, minimumTrackBar.Value);
    112113      } else {
    113114        solutionsDiversityViewHost.Content = null;
     
    223224    }
    224225
    225     private void UpdateSolutionNetworkAnalysis(ISolutionSimilarityCalculator calculator, string projection) {
     226    private void UpdateSolutionNetworkAnalysis(ISolutionSimilarityCalculator calculator, string projection, bool lines, double contrast, double minimum) {
    226227      var series = solutionsNetworkChart.Series["SolutionSeries"];
    227228      var seedingSeries = solutionsNetworkChart.Series["SeedingSolutionSeries"];
    228229      try {
     230        solutionsNetworkChart.Annotations.Clear();
    229231        series.Points.Clear();
    230232        seedingSeries.Points.Clear();
     
    241243          coords = Som(dissimilarities, new MersenneTwister(42), jittering: true);
    242244        else coords = MultidimensionalScaling.KruskalShepard(dissimilarities);
     245        var dataPoints = new List<DataPoint>();
    243246        for (var i = 0; i < coords.Rows; i++) {
    244247          var quality = GetQuality(solutionScopes[i], calculator.QualityVariableName) ?? double.NaN;
     
    250253            Tag = solutionScopes[i]
    251254          };
     255          dataPoints.Add(dataPoint);
    252256          if (Content.SolutionSeedingPool.Contains(solutionScopes[i]) && Content.SolutionSeedingPool.ItemChecked(solutionScopes[i]))
    253257            seedingSeries.Points.Add(dataPoint);
    254258          else series.Points.Add(dataPoint);
     259        }
     260        if (lines) {
     261          for (var i = 0; i < dataPoints.Count - 1; i++) {
     262            for (var j = i + 1; j < dataPoints.Count; j++) {
     263              if (dissimilarities[i, j].IsAlmost(1.0)) continue;
     264              // s-shaped curve for mapping dissimilarities to alpha values
     265              var alpha = (int)Math.Round(255.0 / (1.0 + Math.Exp(-contrast * ((1.0 - dissimilarities[i, j]) - (minimum / 100.0)))));
     266              var lw = (int)Math.Round((1 - dissimilarities[i, j]) * 3.0 + 1.0); // linewidth of 1 to 4
     267              var an = new LineAnnotation();
     268              an.SetAnchor(dataPoints[i], dataPoints[j]);
     269              an.LineColor = Color.FromArgb(alpha, Color.DarkGray);
     270              an.LineWidth = lw;
     271              solutionsNetworkChart.Annotations.Add(an);
     272            }
     273          }
    255274        }
    256275      } catch {
     
    271290      UpdateSolutionFdcAnalysis(calculator, fdcBetweenBestCheckBox.Checked);
    272291      UpdateSolutionLengthScaleAnalysis(calculator);
    273       UpdateSolutionNetworkAnalysis(calculator, (string)solutionNetworkProjectionComboBox.SelectedItem);
     292      UpdateSolutionNetworkAnalysis(calculator, (string)solutionNetworkProjectionComboBox.SelectedItem, linesCheckBox.Checked, contrastTrackBar.Value, minimumTrackBar.Value);
    274293    }
    275294
     
    284303      UpdateSolutionFdcAnalysis(calculator, fdcBetweenBestCheckBox.Checked);
    285304      UpdateSolutionLengthScaleAnalysis(calculator);
    286       UpdateSolutionNetworkAnalysis(calculator, (string)solutionNetworkProjectionComboBox.SelectedItem);
     305      UpdateSolutionNetworkAnalysis(calculator, (string)solutionNetworkProjectionComboBox.SelectedItem, linesCheckBox.Checked, contrastTrackBar.Value, minimumTrackBar.Value);
    287306    }
    288307
     
    299318        calculator.QualityVariableName = Content.Problem.Problem.Evaluator.QualityParameter.ActualName;
    300319      }
    301       UpdateSolutionNetworkAnalysis(calculator, (string)solutionNetworkProjectionComboBox.SelectedItem);
     320      UpdateSolutionNetworkAnalysis(calculator, (string)solutionNetworkProjectionComboBox.SelectedItem, linesCheckBox.Checked, contrastTrackBar.Value, minimumTrackBar.Value);
     321    }
     322
     323    private void LinesCheckBoxOnCheckedChanged(object sender, EventArgs e) {
     324      if (InvokeRequired) { Invoke((Action<object, EventArgs>)LinesCheckBoxOnCheckedChanged, sender, e); return; }
     325      var calculator = (ISolutionSimilarityCalculator)similarityComboBox.SelectedItem;
     326      if (calculator != null) {
     327        calculator.SolutionVariableName = (string)solutionNameComboBox.SelectedItem;
     328        calculator.QualityVariableName = Content.Problem.Problem.Evaluator.QualityParameter.ActualName;
     329      }
     330      UpdateSolutionNetworkAnalysis(calculator, (string)solutionNetworkProjectionComboBox.SelectedItem, linesCheckBox.Checked, contrastTrackBar.Value, minimumTrackBar.Value);
     331    }
     332
     333    private void ContrastTrackBarOnScroll(object sender, EventArgs e) {
     334      if (InvokeRequired) { Invoke((Action<object, EventArgs>)ContrastTrackBarOnScroll, sender, e); return; }
     335      var calculator = (ISolutionSimilarityCalculator)similarityComboBox.SelectedItem;
     336      if (calculator != null) {
     337        calculator.SolutionVariableName = (string)solutionNameComboBox.SelectedItem;
     338        calculator.QualityVariableName = Content.Problem.Problem.Evaluator.QualityParameter.ActualName;
     339      }
     340      UpdateSolutionNetworkAnalysis(calculator, (string)solutionNetworkProjectionComboBox.SelectedItem, linesCheckBox.Checked, contrastTrackBar.Value, minimumTrackBar.Value);
     341    }
     342
     343    private void MinimumTrackBarOnScroll(object sender, EventArgs e) {
     344      if (InvokeRequired) { Invoke((Action<object, EventArgs>)MinimumTrackBarOnScroll, sender, e); return; }
     345      var calculator = (ISolutionSimilarityCalculator)similarityComboBox.SelectedItem;
     346      if (calculator != null) {
     347        calculator.SolutionVariableName = (string)solutionNameComboBox.SelectedItem;
     348        calculator.QualityVariableName = Content.Problem.Problem.Evaluator.QualityParameter.ActualName;
     349      }
     350      UpdateSolutionNetworkAnalysis(calculator, (string)solutionNetworkProjectionComboBox.SelectedItem, linesCheckBox.Checked, contrastTrackBar.Value, minimumTrackBar.Value);
    302351    }
    303352
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/Views/UnderstandingSolutionsView.resx

    r13722 r13745  
    118118    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
    119119  </resheader>
     120  <metadata name="toolTip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     121    <value>17, 17</value>
     122  </metadata>
    120123</root>
Note: See TracChangeset for help on using the changeset viewer.