Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13561


Ignore:
Timestamp:
01/21/16 11:15:23 (8 years ago)
Author:
abeham
Message:

#2457:

  • added two types of problem instance mappings: PCA and MDS
Location:
branches/PerformanceComparison
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.Optimization

  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.Designer.cs

    r13551 r13561  
    3434    /// </summary>
    3535    private void InitializeComponent() {
     36      this.components = new System.ComponentModel.Container();
     37      System.Windows.Forms.DataVisualization.Charting.ChartArea chartArea1 = new System.Windows.Forms.DataVisualization.Charting.ChartArea();
     38      System.Windows.Forms.DataVisualization.Charting.Legend legend1 = new System.Windows.Forms.DataVisualization.Charting.Legend();
     39      System.Windows.Forms.DataVisualization.Charting.Series series1 = new System.Windows.Forms.DataVisualization.Charting.Series();
     40      System.Windows.Forms.DataVisualization.Charting.Series series2 = new System.Windows.Forms.DataVisualization.Charting.Series();
    3641      this.evaluationsLimitabel = new System.Windows.Forms.Label();
    3742      this.maxEvaluationsTextBox = new System.Windows.Forms.TextBox();
     
    4045      this.problemViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    4146      this.algorithmTabPage = new System.Windows.Forms.TabPage();
     47      this.algorithmStartButton = new System.Windows.Forms.Button();
    4248      this.algorithmViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    4349      this.algorithmSuggestionLabel = new System.Windows.Forms.Label();
     
    4854      this.kbViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    4955      this.problemInstancesTabPage = new System.Windows.Forms.TabPage();
     56      this.label1 = new System.Windows.Forms.Label();
     57      this.projectionComboBox = new System.Windows.Forms.ComboBox();
     58      this.problemInstancesTabControl = new System.Windows.Forms.TabControl();
     59      this.instancesTabPage = new System.Windows.Forms.TabPage();
    5060      this.problemInstancesView = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    51       this.instancesDropPanel = new System.Windows.Forms.Panel();
    52       this.dragFLAHereLabel = new System.Windows.Forms.Label();
     61      this.mapTabPage = new System.Windows.Forms.TabPage();
     62      this.instanceMapChart = new HeuristicLab.Visualization.ChartControlsExtensions.EnhancedChart();
    5363      this.refreshMapButton = new System.Windows.Forms.Button();
    5464      this.progressPanel = new System.Windows.Forms.Panel();
    5565      this.okbDownloadButton = new System.Windows.Forms.Button();
    5666      this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
    57       this.algorithmStartButton = new System.Windows.Forms.Button();
    5867      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5968      this.tabControl.SuspendLayout();
     
    6372      this.okbTabPage.SuspendLayout();
    6473      this.problemInstancesTabPage.SuspendLayout();
    65       this.instancesDropPanel.SuspendLayout();
     74      this.problemInstancesTabControl.SuspendLayout();
     75      this.instancesTabPage.SuspendLayout();
     76      this.mapTabPage.SuspendLayout();
     77      ((System.ComponentModel.ISupportInitialize)(this.instanceMapChart)).BeginInit();
    6678      this.SuspendLayout();
    6779      //
     
    88100      // maxEvaluationsTextBox
    89101      //
    90       this.maxEvaluationsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     102      this.maxEvaluationsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    91103            | System.Windows.Forms.AnchorStyles.Right)));
    92104      this.maxEvaluationsTextBox.Location = new System.Drawing.Point(75, 26);
     
    94106      this.maxEvaluationsTextBox.Size = new System.Drawing.Size(449, 20);
    95107      this.maxEvaluationsTextBox.TabIndex = 6;
    96       this.maxEvaluationsTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.maxEvaluationsTextBox_Validating);
     108      this.maxEvaluationsTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.MaxEvaluationsTextBoxOnValidating);
    97109      //
    98110      // tabControl
    99111      //
    100112      this.tabControl.AllowDrop = true;
    101       this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    102             | System.Windows.Forms.AnchorStyles.Left)
     113      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     114            | System.Windows.Forms.AnchorStyles.Left) 
    103115            | System.Windows.Forms.AnchorStyles.Right)));
    104116      this.tabControl.Controls.Add(this.problemTabPage);
     
    153165      this.algorithmTabPage.UseVisualStyleBackColor = true;
    154166      //
     167      // algorithmStartButton
     168      //
     169      this.algorithmStartButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
     170      this.algorithmStartButton.Location = new System.Drawing.Point(506, 5);
     171      this.algorithmStartButton.Name = "algorithmStartButton";
     172      this.algorithmStartButton.Size = new System.Drawing.Size(26, 23);
     173      this.algorithmStartButton.TabIndex = 3;
     174      this.algorithmStartButton.Text = "Start";
     175      this.algorithmStartButton.UseVisualStyleBackColor = true;
     176      this.algorithmStartButton.Click += new System.EventHandler(this.AlgorithmStartButtonOnClick);
     177      //
    155178      // algorithmViewHost
    156179      //
    157       this.algorithmViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    158             | System.Windows.Forms.AnchorStyles.Left)
     180      this.algorithmViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     181            | System.Windows.Forms.AnchorStyles.Left) 
    159182            | System.Windows.Forms.AnchorStyles.Right)));
    160183      this.algorithmViewHost.Caption = "View";
     
    180203      // suggestedInstancesComboBox
    181204      //
    182       this.suggestedInstancesComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     205      this.suggestedInstancesComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    183206            | System.Windows.Forms.AnchorStyles.Right)));
    184207      this.suggestedInstancesComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     
    238261      // problemInstancesTabPage
    239262      //
    240       this.problemInstancesTabPage.Controls.Add(this.problemInstancesView);
    241       this.problemInstancesTabPage.Controls.Add(this.instancesDropPanel);
     263      this.problemInstancesTabPage.Controls.Add(this.label1);
     264      this.problemInstancesTabPage.Controls.Add(this.projectionComboBox);
     265      this.problemInstancesTabPage.Controls.Add(this.problemInstancesTabControl);
    242266      this.problemInstancesTabPage.Controls.Add(this.refreshMapButton);
    243267      this.problemInstancesTabPage.Location = new System.Drawing.Point(4, 22);
     
    249273      this.problemInstancesTabPage.UseVisualStyleBackColor = true;
    250274      //
     275      // label1
     276      //
     277      this.label1.AutoSize = true;
     278      this.label1.Location = new System.Drawing.Point(35, 11);
     279      this.label1.Name = "label1";
     280      this.label1.Size = new System.Drawing.Size(57, 13);
     281      this.label1.TabIndex = 6;
     282      this.label1.Text = "Projection:";
     283      //
     284      // projectionComboBox
     285      //
     286      this.projectionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     287      this.projectionComboBox.FormattingEnabled = true;
     288      this.projectionComboBox.Location = new System.Drawing.Point(98, 8);
     289      this.projectionComboBox.Name = "projectionComboBox";
     290      this.projectionComboBox.Size = new System.Drawing.Size(158, 21);
     291      this.projectionComboBox.TabIndex = 5;
     292      this.projectionComboBox.SelectedIndexChanged += new System.EventHandler(this.ProjectionComboBoxOnSelectedIndexChanged);
     293      //
     294      // problemInstancesTabControl
     295      //
     296      this.problemInstancesTabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     297            | System.Windows.Forms.AnchorStyles.Left)
     298            | System.Windows.Forms.AnchorStyles.Right)));
     299      this.problemInstancesTabControl.Controls.Add(this.instancesTabPage);
     300      this.problemInstancesTabControl.Controls.Add(this.mapTabPage);
     301      this.problemInstancesTabControl.Location = new System.Drawing.Point(3, 35);
     302      this.problemInstancesTabControl.Name = "problemInstancesTabControl";
     303      this.problemInstancesTabControl.SelectedIndex = 0;
     304      this.problemInstancesTabControl.Size = new System.Drawing.Size(532, 268);
     305      this.problemInstancesTabControl.TabIndex = 4;
     306      //
     307      // instancesTabPage
     308      //
     309      this.instancesTabPage.Controls.Add(this.problemInstancesView);
     310      this.instancesTabPage.Location = new System.Drawing.Point(4, 22);
     311      this.instancesTabPage.Name = "instancesTabPage";
     312      this.instancesTabPage.Padding = new System.Windows.Forms.Padding(3);
     313      this.instancesTabPage.Size = new System.Drawing.Size(524, 242);
     314      this.instancesTabPage.TabIndex = 0;
     315      this.instancesTabPage.Text = "Instances";
     316      this.instancesTabPage.UseVisualStyleBackColor = true;
     317      //
    251318      // problemInstancesView
    252319      //
    253       this.problemInstancesView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    254             | System.Windows.Forms.AnchorStyles.Left)
    255             | System.Windows.Forms.AnchorStyles.Right)));
    256320      this.problemInstancesView.Caption = "View";
    257321      this.problemInstancesView.Content = null;
     322      this.problemInstancesView.Dock = System.Windows.Forms.DockStyle.Fill;
    258323      this.problemInstancesView.Enabled = false;
    259       this.problemInstancesView.Location = new System.Drawing.Point(3, 34);
     324      this.problemInstancesView.Location = new System.Drawing.Point(3, 3);
    260325      this.problemInstancesView.Name = "problemInstancesView";
    261326      this.problemInstancesView.ReadOnly = false;
    262       this.problemInstancesView.Size = new System.Drawing.Size(532, 269);
    263       this.problemInstancesView.TabIndex = 3;
     327      this.problemInstancesView.Size = new System.Drawing.Size(518, 236);
     328      this.problemInstancesView.TabIndex = 0;
    264329      this.problemInstancesView.ViewsLabelVisible = true;
    265330      this.problemInstancesView.ViewType = null;
    266331      //
    267       // instancesDropPanel
    268       //
    269       this.instancesDropPanel.AllowDrop = true;
    270       this.instancesDropPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    271             | System.Windows.Forms.AnchorStyles.Right)));
    272       this.instancesDropPanel.BackColor = System.Drawing.Color.LightYellow;
    273       this.instancesDropPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
    274       this.instancesDropPanel.Controls.Add(this.dragFLAHereLabel);
    275       this.instancesDropPanel.Location = new System.Drawing.Point(35, 7);
    276       this.instancesDropPanel.Name = "instancesDropPanel";
    277       this.instancesDropPanel.Size = new System.Drawing.Size(500, 21);
    278       this.instancesDropPanel.TabIndex = 2;
    279       this.instancesDropPanel.DragDrop += new System.Windows.Forms.DragEventHandler(this.instancesDropPanel_DragDrop);
    280       this.instancesDropPanel.DragEnter += new System.Windows.Forms.DragEventHandler(this.instancesDropPanel_DragEnter);
    281       this.instancesDropPanel.DragOver += new System.Windows.Forms.DragEventHandler(this.instancesDropPanel_DragOver);
    282       //
    283       // dragFLAHereLabel
    284       //
    285       this.dragFLAHereLabel.Anchor = System.Windows.Forms.AnchorStyles.None;
    286       this.dragFLAHereLabel.AutoSize = true;
    287       this.dragFLAHereLabel.ForeColor = System.Drawing.SystemColors.ControlDarkDark;
    288       this.dragFLAHereLabel.Location = new System.Drawing.Point(155, 3);
    289       this.dragFLAHereLabel.Name = "dragFLAHereLabel";
    290       this.dragFLAHereLabel.Size = new System.Drawing.Size(175, 13);
    291       this.dragFLAHereLabel.TabIndex = 0;
    292       this.dragFLAHereLabel.Text = "Drag and drop runs with FLA here...";
     332      // mapTabPage
     333      //
     334      this.mapTabPage.Controls.Add(this.instanceMapChart);
     335      this.mapTabPage.Location = new System.Drawing.Point(4, 22);
     336      this.mapTabPage.Name = "mapTabPage";
     337      this.mapTabPage.Padding = new System.Windows.Forms.Padding(3);
     338      this.mapTabPage.Size = new System.Drawing.Size(524, 242);
     339      this.mapTabPage.TabIndex = 1;
     340      this.mapTabPage.Text = "Map";
     341      this.mapTabPage.UseVisualStyleBackColor = true;
     342      //
     343      // instanceMapChart
     344      //
     345      chartArea1.AxisX.MajorGrid.LineColor = System.Drawing.Color.LightGray;
     346      chartArea1.AxisX.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
     347      chartArea1.AxisY.MajorGrid.LineColor = System.Drawing.Color.LightGray;
     348      chartArea1.AxisY.MajorGrid.LineDashStyle = System.Windows.Forms.DataVisualization.Charting.ChartDashStyle.Dash;
     349      chartArea1.Name = "Default";
     350      this.instanceMapChart.ChartAreas.Add(chartArea1);
     351      this.instanceMapChart.Dock = System.Windows.Forms.DockStyle.Fill;
     352      legend1.Docking = System.Windows.Forms.DataVisualization.Charting.Docking.Top;
     353      legend1.Enabled = false;
     354      legend1.Name = "Legend";
     355      this.instanceMapChart.Legends.Add(legend1);
     356      this.instanceMapChart.Location = new System.Drawing.Point(3, 3);
     357      this.instanceMapChart.Name = "instanceMapChart";
     358      series1.ChartArea = "Default";
     359      series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
     360      series1.Legend = "Legend";
     361      series1.MarkerSize = 10;
     362      series1.Name = "InstancesSeries";
     363      series2.ChartArea = "Default";
     364      series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
     365      series2.Legend = "Legend";
     366      series2.MarkerColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))));
     367      series2.MarkerSize = 15;
     368      series2.MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Cross;
     369      series2.Name = "CurrentInstanceSeries";
     370      this.instanceMapChart.Series.Add(series1);
     371      this.instanceMapChart.Series.Add(series2);
     372      this.instanceMapChart.Size = new System.Drawing.Size(518, 236);
     373      this.instanceMapChart.TabIndex = 0;
    293374      //
    294375      // refreshMapButton
     
    300381      this.refreshMapButton.Text = "Refresh";
    301382      this.refreshMapButton.UseVisualStyleBackColor = true;
    302       this.refreshMapButton.Click += new System.EventHandler(this.refreshMapButton_Click);
     383      this.refreshMapButton.Click += new System.EventHandler(this.RefreshMapButtonOnClick);
    303384      //
    304385      // progressPanel
    305386      //
    306       this.progressPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    307             | System.Windows.Forms.AnchorStyles.Left)
     387      this.progressPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     388            | System.Windows.Forms.AnchorStyles.Left) 
    308389            | System.Windows.Forms.AnchorStyles.Right)));
    309390      this.progressPanel.Location = new System.Drawing.Point(0, 81);
     
    315396      // okbDownloadButton
    316397      //
    317       this.okbDownloadButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     398      this.okbDownloadButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    318399            | System.Windows.Forms.AnchorStyles.Right)));
    319400      this.okbDownloadButton.Location = new System.Drawing.Point(6, 52);
     
    323404      this.okbDownloadButton.Text = "Download from OKB";
    324405      this.okbDownloadButton.UseVisualStyleBackColor = true;
    325       this.okbDownloadButton.Click += new System.EventHandler(this.okbDownloadButton_Click);
     406      this.okbDownloadButton.Click += new System.EventHandler(this.OkbDownloadButtonOnClick);
    326407      //
    327408      // openFileDialog
     
    331412      this.openFileDialog.Filter = "HeuristicLab Files|*.hl|All Files|*.*";
    332413      this.openFileDialog.Title = "Open Optimizer";
    333       //
    334       // algorithmStartButton
    335       //
    336       this.algorithmStartButton.Location = new System.Drawing.Point(506, 5);
    337       this.algorithmStartButton.Name = "algorithmStartButton";
    338       this.algorithmStartButton.Size = new System.Drawing.Size(26, 23);
    339       this.algorithmStartButton.TabIndex = 3;
    340       this.algorithmStartButton.Text = "Start";
    341       this.algorithmStartButton.UseVisualStyleBackColor = true;
    342       this.algorithmStartButton.Click += new System.EventHandler(this.algorithmStartButton_Click);
    343414      //
    344415      // ExpertSystemView
     
    368439      this.okbTabPage.ResumeLayout(false);
    369440      this.problemInstancesTabPage.ResumeLayout(false);
    370       this.instancesDropPanel.ResumeLayout(false);
    371       this.instancesDropPanel.PerformLayout();
     441      this.problemInstancesTabPage.PerformLayout();
     442      this.problemInstancesTabControl.ResumeLayout(false);
     443      this.instancesTabPage.ResumeLayout(false);
     444      this.mapTabPage.ResumeLayout(false);
     445      ((System.ComponentModel.ISupportInitialize)(this.instanceMapChart)).EndInit();
    372446      this.ResumeLayout(false);
    373447      this.PerformLayout();
     
    391465    private System.Windows.Forms.TabPage okbTabPage;
    392466    private System.Windows.Forms.TabPage problemInstancesTabPage;
    393     private System.Windows.Forms.Panel instancesDropPanel;
    394467    private System.Windows.Forms.Button refreshMapButton;
    395     private System.Windows.Forms.Label dragFLAHereLabel;
    396     private MainForm.WindowsForms.ViewHost problemInstancesView;
    397468    private System.Windows.Forms.Button okbDownloadButton;
    398469    private System.Windows.Forms.Panel progressPanel;
    399470    private MainForm.WindowsForms.ViewHost kbViewHost;
    400471    private System.Windows.Forms.Button algorithmStartButton;
     472    private System.Windows.Forms.TabControl problemInstancesTabControl;
     473    private System.Windows.Forms.TabPage instancesTabPage;
     474    private MainForm.WindowsForms.ViewHost problemInstancesView;
     475    private System.Windows.Forms.TabPage mapTabPage;
     476    private Visualization.ChartControlsExtensions.EnhancedChart instanceMapChart;
     477    private System.Windows.Forms.Label label1;
     478    private System.Windows.Forms.ComboBox projectionComboBox;
    401479  }
    402480}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/ExpertSystemView.cs

    r13551 r13561  
    2121
    2222using System;
    23 using System.Collections;
    2423using System.ComponentModel;
    2524using System.Linq;
     25using System.Text.RegularExpressions;
    2626using System.Windows.Forms;
    27 using HeuristicLab.Common;
     27using System.Windows.Forms.DataVisualization.Charting;
    2828using HeuristicLab.Common.Resources;
    2929using HeuristicLab.Core.Views;
     
    172172
    173173    #region Control events
    174     private void maxEvaluationsTextBox_Validating(object sender, CancelEventArgs e) {
     174    private void MaxEvaluationsTextBoxOnValidating(object sender, CancelEventArgs e) {
    175175      if (SuppressEvents) return;
    176176      if (InvokeRequired) {
    177         Invoke((Action<object, CancelEventArgs>)maxEvaluationsTextBox_Validating, sender, e);
     177        Invoke((Action<object, CancelEventArgs>)MaxEvaluationsTextBoxOnValidating, sender, e);
    178178        return;
    179179      }
     
    189189    }
    190190    #endregion
    191 
    192     private bool validDragOperation;
    193     private void instancesDropPanel_DragEnter(object sender, DragEventArgs e) {
    194       validDragOperation = false;
    195       if (!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IRun)) {
    196         validDragOperation = true;
    197       } else if (!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable)) {
    198         validDragOperation = true;
    199         var items = (IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    200         foreach (object item in items)
    201           validDragOperation = validDragOperation && (item is IRun);
    202       }
    203     }
    204     private void instancesDropPanel_DragOver(object sender, DragEventArgs e) {
    205       e.Effect = DragDropEffects.None;
    206       if (!validDragOperation) return;
    207       if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
    208       else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
    209       else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
    210       else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move;
    211       else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link;
    212     }
    213     private void instancesDropPanel_DragDrop(object sender, DragEventArgs e) {
    214       if (e.Effect == DragDropEffects.None) return;
    215       if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IRun) {
    216         var item = (IRun)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    217         Content.ProblemInstances.Add(e.Effect.HasFlag(DragDropEffects.Copy) ? (IRun)item.Clone() : item);
    218       } else if (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) is IEnumerable) {
    219         var items = ((IEnumerable)e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat)).Cast<IRun>();
    220         if (e.Effect.HasFlag(DragDropEffects.Copy)) {
    221           var cloner = new Cloner();
    222           items = items.Select(x => cloner.Clone(x));
    223         }
    224         Content.ProblemInstances.AddRange(items);
    225       }
    226     }
    227191    #endregion
    228192
    229     private void refreshMapButton_Click(object sender, EventArgs e) {
    230       Content.UpdateInstanceMap();
    231     }
    232 
    233     private void okbDownloadButton_Click(object sender, EventArgs e) {
     193    private void RefreshMapButtonOnClick(object sender, EventArgs e) {
     194      Content.UpdateInstanceProjection();
     195      UpdateProjectionComboBox();
     196    }
     197
     198    private void UpdateProjectionComboBox() {
     199      projectionComboBox.Items.Clear();
     200      var projStrings = Content.ProblemInstances
     201        .SelectMany(x => x.Results.Where(y => Regex.IsMatch(y.Key, "^Projection[.].*[.][XY]$")))
     202        .Select(x => Regex.Match(x.Key, "Projection[.](?<g>.*)[.][XY]").Groups["g"].Value)
     203        .Distinct();
     204      foreach (var str in projStrings) {
     205        projectionComboBox.Items.Add(str);
     206      }
     207    }
     208
     209    private void OkbDownloadButtonOnClick(object sender, EventArgs e) {
    234210      if (Content.Problem.ProblemId < 0) {
    235211        MessageBox.Show("Please select a problem instance first.");
     
    254230    }
    255231
    256     private void algorithmStartButton_Click(object sender, EventArgs e) {
     232    private void AlgorithmStartButtonOnClick(object sender, EventArgs e) {
    257233      var selectedInstance = (IAlgorithm)suggestedInstancesComboBox.SelectedItem;
    258234      var clone = (IAlgorithm)selectedInstance.Clone();
     
    261237      algorithmViewHost.Content = clone.Results;
    262238    }
     239
     240    private void ProjectionComboBoxOnSelectedIndexChanged(object sender, EventArgs e) {
     241      if (projectionComboBox.SelectedIndex < 0) return;
     242      var projection = (string)projectionComboBox.SelectedItem;
     243      var instancesSeries = instanceMapChart.Series["InstancesSeries"];
     244      var currentInstanceSeries = instanceMapChart.Series["CurrentInstanceSeries"];
     245
     246      instancesSeries.Points.Clear();
     247      currentInstanceSeries.Points.Clear();
     248
     249      foreach (var run in Content.ProblemInstances) {
     250        var xKey = "Projection." + projection + ".X";
     251        var yKey = "Projection." + projection + ".Y";
     252        if (!run.Results.ContainsKey(xKey) || !run.Results.ContainsKey(yKey)
     253          || !(run.Results[xKey] is Data.DoubleValue) || !(run.Results[yKey] is Data.DoubleValue)) continue;
     254        var x = ((Data.DoubleValue)run.Results[xKey]).Value;
     255        var y = ((Data.DoubleValue)run.Results[yKey]).Value;
     256        var dataPoint = new DataPoint(x, y) {
     257          Label = run.Name
     258        };
     259        instancesSeries.Points.Add(dataPoint);
     260      }
     261
     262      var curPoint = Content.ProjectCurrentInstance(projection);
     263      if (curPoint != null) {
     264        var dp = new DataPoint(curPoint.Item1, curPoint.Item2) {
     265          Label = Content.Problem.Problem.Name
     266        };
     267        currentInstanceSeries.Points.Add(dp);
     268      }
     269    }
    263270  }
    264271}
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem.Views/3.3/HeuristicLab.OptimizationExpertSystem.Views-3.3.csproj

    r13475 r13561  
    148148    <Reference Include="System.Runtime.Serialization" />
    149149    <Reference Include="System.Windows.Forms" />
     150    <Reference Include="System.Windows.Forms.DataVisualization" />
    150151    <Reference Include="System.Xml.Linq" />
    151152    <Reference Include="System.Data.DataSetExtensions" />
  • branches/PerformanceComparison/HeuristicLab.OptimizationExpertSystem/3.3/ExpertSystem.cs

    r13551 r13561  
    116116    private BidirectionalDictionary<long, IAlgorithm> algorithmId2AlgorithmInstanceMapping;
    117117
     118    [Storable]
     119    private Run currentInstance;
     120
    118121    private bool Maximization {
    119122      get {
     
    140143        algorithmId2AlgorithmInstanceMapping.Add(kvp.Key, cloner.Clone(kvp.Value));
    141144      }
     145      currentInstance = cloner.Clone(original.currentInstance);
    142146      RegisterEventHandlers();
    143147    }
     
    188192    }
    189193
    190     public void UpdateInstanceMap() {
    191       var flaValues = ProblemInstances.ResultNames
    192                       .Where(x => x.StartsWith("Characteristic.")
    193                         && ProblemInstances.All(y => y.Results.ContainsKey(x) && y.Results[x] is DoubleValue))
    194                       .Select(x => x).ToList();
    195       var ds = new double[ProblemInstances.Count, flaValues.Count];
    196       var instanceCounter = 0;
    197       foreach (var instance in ProblemInstances) {
    198         for (var feature = 0; feature < flaValues.Count; feature++)
    199           ds[instanceCounter, feature] = ((DoubleValue)instance.Results[flaValues[feature]]).Value;
    200         instanceCounter++;
     194    public void UpdateInstanceProjection() {
     195      currentInstance = null;
     196      var filter = new HashSet<string>();
     197
     198      if (Problem.ProblemId != -1) {
     199        currentInstance = new Run { Name = Problem.Name };
     200        Problem.Problem.CollectParameterValues(currentInstance.Parameters);
     201        foreach (var c in RunCreationClient.GetCharacteristicValues(Problem.ProblemId)) {
     202          var key = "Characteristic." + c.Name;
     203          currentInstance.Results.Add(key, RunCreationClient.Instance.ConvertToItem(c));
     204          filter.Add(key);
     205        }
     206      }
     207      // TODO: There is a problem with missing values that has to be solved
     208      // The common set of characteristics among all problems may be too small to be useful
     209      // It has to be decided somehow which problem instances to include in order to obtain the set of features that is expressive and available
     210      var allCharacteristics = ProblemInstances.Select(x => new HashSet<string>(x.Results.Where(y => y.Key.StartsWith("Characteristic.", StringComparison.Ordinal)).Select(y => y.Key))).ToList();
     211      var commonCharacteristics = filter.Count > 0 ? filter : allCharacteristics[0];
     212      for (var i = 0; i < allCharacteristics.Count; i++)
     213        commonCharacteristics.IntersectWith(allCharacteristics[i]);
     214
     215      if (commonCharacteristics.Count == 0) return;
     216
     217      var instances = new Dictionary<string, double[]>();
     218      foreach (var i in ProblemInstances)
     219        instances[i.Name] = i.Results.Where(x => commonCharacteristics.Contains(x.Key)).OrderBy(x => x.Key).Select(x => (double)((dynamic)x.Value).Value).ToArray();
     220      if (currentInstance != null)
     221        instances[currentInstance.Name] = currentInstance.Results.Where(x => commonCharacteristics.Contains(x.Key)).OrderBy(x => x.Key).Select(x => (double)((dynamic)x.Value).Value).ToArray();
     222
     223      var allValues = instances.SelectMany(x => x.Value).ToList();
     224      var avg = allValues.Average();
     225      var stdev = allValues.StandardDeviation();
     226
     227      // normalize characteristic values by transforming them to their z-score
     228      foreach (var key in instances.Keys.ToList()) {
     229        var arr = instances[key];
     230        for (var i = 0; i < arr.Length; i++) {
     231          arr[i] = (arr[i] - avg) / stdev;
     232        }
     233      }
     234
     235      var key2Idx = new BidirectionalDictionary<string, int>();
     236      foreach (var kvp in instances.Select((k, i) => new { Index = i, Key = k.Key }))
     237        key2Idx.Add(kvp.Key, kvp.Index);
     238
     239      #region MDS
     240      Func<double[], double[], double> euclid = (a, b) => Math.Sqrt(a.Zip(b, (x, y) => (x - y)).Sum(x => x * x));
     241      var num = instances.Count;
     242      var matrix = new DoubleMatrix(num, num);
     243      for (var i = 0; i < num - 1; i++) {
     244        for (var j = i + 1; j < num; j++) {
     245          matrix[i, j] = matrix[j, i] = euclid(instances[key2Idx.GetBySecond(i)], instances[key2Idx.GetBySecond(j)]);
     246        }
     247      }
     248
     249      var coords = MultidimensionalScaling.KruskalShepard(matrix);
     250      #endregion
     251      #region PCA
     252      var ds = new double[instances.Count, commonCharacteristics.Count];
     253      foreach (var instance in instances) {
     254        var arr = instance.Value;
     255        for (var feature = 0; feature < arr.Length; feature++)
     256          ds[key2Idx.GetByFirst(instance.Key), feature] = arr[feature];
    201257      }
    202258
     
    204260      double[] s2;
    205261      double[,] v;
    206       alglib.pcabuildbasis(ds, instanceCounter, flaValues.Count, out info, out s2, out v);
     262      alglib.pcabuildbasis(ds, ds.GetLength(0), ds.GetLength(1), out info, out s2, out v);
     263      #endregion
    207264
    208265      ProblemInstances.UpdateOfRunsInProgress = true;
    209266      try {
    210         instanceCounter = 0;
    211267        foreach (var instance in ProblemInstances) {
    212268          double x = 0, y = 0;
    213           for (var feature = 0; feature < flaValues.Count; feature++) {
    214             x += ds[instanceCounter, feature] * v[feature, 0];
    215             y += ds[instanceCounter, feature] * v[feature, 1];
     269          for (var feature = 0; feature < ds.GetLength(1); feature++) {
     270            x += ds[key2Idx.GetByFirst(instance.Name), feature] * v[feature, 0];
     271            y += ds[key2Idx.GetByFirst(instance.Name), feature] * v[feature, 1];
    216272          }
     273
    217274          IItem item;
    218           if (instance.Results.TryGetValue("Projection.PCA1", out item)) {
     275          if (instance.Results.TryGetValue("Projection.PCA.X", out item)) {
    219276            ((DoubleValue)item).Value = x;
    220           } else instance.Results.Add("Projection.PCA1", new DoubleValue(x));
    221           if (instance.Results.TryGetValue("Projection.PCA2", out item)) {
     277          } else instance.Results.Add("Projection.PCA.X", new DoubleValue(x));
     278          if (instance.Results.TryGetValue("Projection.PCA.Y", out item)) {
    222279            ((DoubleValue)item).Value = y;
    223           } else instance.Results.Add("Projection.PCA2", new DoubleValue(y));
    224 
    225           instanceCounter++;
     280          } else instance.Results.Add("Projection.PCA.Y", new DoubleValue(y));
     281
     282          if (instance.Results.TryGetValue("Projection.MDS.X", out item)) {
     283            ((DoubleValue)item).Value = coords[key2Idx.GetByFirst(instance.Name), 0];
     284          } else instance.Results.Add("Projection.MDS.X", new DoubleValue(coords[key2Idx.GetByFirst(instance.Name), 0]));
     285          if (instance.Results.TryGetValue("Projection.MDS.Y", out item)) {
     286            ((DoubleValue)item).Value = coords[key2Idx.GetByFirst(instance.Name), 1];
     287          } else instance.Results.Add("Projection.MDS.Y", new DoubleValue(coords[key2Idx.GetByFirst(instance.Name), 1]));
    226288        }
    227289      } finally { ProblemInstances.UpdateOfRunsInProgress = false; }
     290
     291      if (currentInstance != null) {
     292        double x = 0, y = 0;
     293        for (var feature = 0; feature < ds.GetLength(1); feature++) {
     294          x += ds[key2Idx.GetByFirst(currentInstance.Name), feature] * v[feature, 0];
     295          y += ds[key2Idx.GetByFirst(currentInstance.Name), feature] * v[feature, 1];
     296        }
     297
     298        IItem item;
     299        if (currentInstance.Results.TryGetValue("Projection.PCA.X", out item)) {
     300          ((DoubleValue)item).Value = x;
     301        } else currentInstance.Results.Add("Projection.PCA.X", new DoubleValue(x));
     302        if (currentInstance.Results.TryGetValue("Projection.PCA.Y", out item)) {
     303          ((DoubleValue)item).Value = y;
     304        } else currentInstance.Results.Add("Projection.PCA.Y", new DoubleValue(y));
     305
     306        if (currentInstance.Results.TryGetValue("Projection.MDS.X", out item)) {
     307          ((DoubleValue)item).Value = coords[key2Idx.GetByFirst(currentInstance.Name), 0];
     308        } else currentInstance.Results.Add("Projection.MDS.X", new DoubleValue(coords[key2Idx.GetByFirst(currentInstance.Name), 0]));
     309        if (currentInstance.Results.TryGetValue("Projection.MDS.Y", out item)) {
     310          ((DoubleValue)item).Value = coords[key2Idx.GetByFirst(currentInstance.Name), 1];
     311        } else currentInstance.Results.Add("Projection.MDS.Y", new DoubleValue(coords[key2Idx.GetByFirst(currentInstance.Name), 1]));
     312      }
     313    }
     314
     315    public Tuple<double, double> ProjectCurrentInstance(string projection) {
     316      if (currentInstance == null) return null;
     317      var xKey = "Projection." + projection + ".X";
     318      var yKey = "Projection." + projection + ".Y";
     319      if (!currentInstance.Results.ContainsKey(xKey) || !currentInstance.Results.ContainsKey(yKey))
     320        return null;
     321      var x = ((DoubleValue)currentInstance.Results[xKey]).Value;
     322      var y = ((DoubleValue)currentInstance.Results[yKey]).Value;
     323      return Tuple.Create(x, y);
    228324    }
    229325
Note: See TracChangeset for help on using the changeset viewer.