Free cookie consent management tool by TermsFeed Policy Generator

Changeset 12841


Ignore:
Timestamp:
08/10/15 12:49:31 (9 years ago)
Author:
abeham
Message:

#2431:

  • Added calculation of ERT results tables
  • Added grouping by problem to avoid having different problems in one graph
  • Some restructuring to avoid duplicate code
Location:
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.Designer.cs

    r12838 r12841  
    6464      this.byTargetViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    6565      this.byCostTabPage = new System.Windows.Forms.TabPage();
     66      this.budgetLogScalingCheckBox = new System.Windows.Forms.CheckBox();
    6667      this.eachOrAllBudgetsCheckBox = new System.Windows.Forms.CheckBox();
    6768      this.generateBudgetsButton = new System.Windows.Forms.Button();
    6869      this.byCostViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    6970      this.byTableTabPage = new System.Windows.Forms.TabPage();
    70       this.dataGridView1 = new System.Windows.Forms.DataGridView();
    71       this.budgetLogScalingCheckBox = new System.Windows.Forms.CheckBox();
     71      this.ertViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     72      this.problemComboBox = new System.Windows.Forms.ComboBox();
     73      this.problemLabel = new System.Windows.Forms.Label();
    7274      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    7375      this.tabControl.SuspendLayout();
     
    7577      this.byCostTabPage.SuspendLayout();
    7678      this.byTableTabPage.SuspendLayout();
    77       ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
    7879      this.SuspendLayout();
    7980      //
     
    8485      this.dataTableComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    8586      this.dataTableComboBox.FormattingEnabled = true;
    86       this.dataTableComboBox.Location = new System.Drawing.Point(69, 30);
     87      this.dataTableComboBox.Location = new System.Drawing.Point(69, 57);
    8788      this.dataTableComboBox.Name = "dataTableComboBox";
    8889      this.dataTableComboBox.Size = new System.Drawing.Size(582, 21);
    89       this.dataTableComboBox.TabIndex = 0;
     90      this.dataTableComboBox.TabIndex = 5;
    9091      this.dataTableComboBox.SelectedIndexChanged += new System.EventHandler(this.dataTableComboBox_SelectedIndexChanged);
    9192      //
     
    9394      //
    9495      this.dataTableLabel.AutoSize = true;
    95       this.dataTableLabel.Location = new System.Drawing.Point(3, 33);
     96      this.dataTableLabel.Location = new System.Drawing.Point(3, 60);
    9697      this.dataTableLabel.Name = "dataTableLabel";
    9798      this.dataTableLabel.Size = new System.Drawing.Size(60, 13);
    98       this.dataTableLabel.TabIndex = 1;
     99      this.dataTableLabel.TabIndex = 4;
    99100      this.dataTableLabel.Text = "DataTable:";
    100101      //
     
    105106      this.groupLabel.Name = "groupLabel";
    106107      this.groupLabel.Size = new System.Drawing.Size(39, 13);
    107       this.groupLabel.TabIndex = 3;
     108      this.groupLabel.TabIndex = 0;
    108109      this.groupLabel.Text = "Group:";
    109110      //
     
    117118      this.groupComboBox.Name = "groupComboBox";
    118119      this.groupComboBox.Size = new System.Drawing.Size(582, 21);
    119       this.groupComboBox.TabIndex = 4;
     120      this.groupComboBox.TabIndex = 1;
    120121      this.groupComboBox.SelectedIndexChanged += new System.EventHandler(this.groupComboBox_SelectedIndexChanged);
    121122      //
     
    124125      this.targetLogScalingCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    125126      this.targetLogScalingCheckBox.AutoSize = true;
    126       this.targetLogScalingCheckBox.Location = new System.Drawing.Point(9, 391);
     127      this.targetLogScalingCheckBox.Location = new System.Drawing.Point(9, 364);
    127128      this.targetLogScalingCheckBox.Name = "targetLogScalingCheckBox";
    128129      this.targetLogScalingCheckBox.Size = new System.Drawing.Size(112, 17);
    129       this.targetLogScalingCheckBox.TabIndex = 5;
     130      this.targetLogScalingCheckBox.TabIndex = 6;
    130131      this.targetLogScalingCheckBox.Text = "logarithmic scaling";
    131132      this.targetLogScalingCheckBox.UseVisualStyleBackColor = true;
     
    139140      this.targetsTextBox.Name = "targetsTextBox";
    140141      this.targetsTextBox.Size = new System.Drawing.Size(320, 20);
    141       this.targetsTextBox.TabIndex = 6;
     142      this.targetsTextBox.TabIndex = 1;
    142143      this.toolTip.SetToolTip(this.targetsTextBox, "The order of the targets is important, first to-hit targets\r\nshould be given firs" +
    143144        "t. The sequence should be monotonous.\r\n\r\nTargets should be separated by semicolo" +
     
    151152      this.targetsLabel.Name = "targetsLabel";
    152153      this.targetsLabel.Size = new System.Drawing.Size(46, 13);
    153       this.targetsLabel.TabIndex = 1;
     154      this.targetsLabel.TabIndex = 0;
    154155      this.targetsLabel.Text = "Targets:";
    155156      //
     
    164165      this.addTargetsAsResultButton.Name = "addTargetsAsResultButton";
    165166      this.addTargetsAsResultButton.Size = new System.Drawing.Size(89, 23);
    166       this.addTargetsAsResultButton.TabIndex = 7;
     167      this.addTargetsAsResultButton.TabIndex = 4;
    167168      this.addTargetsAsResultButton.Text = "Add as Result";
    168169      this.addTargetsAsResultButton.UseVisualStyleBackColor = true;
     
    175176      this.generateTargetsButton.Name = "generateTargetsButton";
    176177      this.generateTargetsButton.Size = new System.Drawing.Size(89, 23);
    177       this.generateTargetsButton.TabIndex = 7;
     178      this.generateTargetsButton.TabIndex = 3;
    178179      this.generateTargetsButton.Text = "Generate...";
    179180      this.generateTargetsButton.UseVisualStyleBackColor = true;
     
    217218      this.eachOrAllTargetCheckBox.Name = "eachOrAllTargetCheckBox";
    218219      this.eachOrAllTargetCheckBox.Size = new System.Drawing.Size(36, 17);
    219       this.eachOrAllTargetCheckBox.TabIndex = 8;
     220      this.eachOrAllTargetCheckBox.TabIndex = 2;
    220221      this.eachOrAllTargetCheckBox.Text = "all";
    221222      this.eachOrAllTargetCheckBox.UseVisualStyleBackColor = true;
     
    230231      this.tabControl.Controls.Add(this.byCostTabPage);
    231232      this.tabControl.Controls.Add(this.byTableTabPage);
    232       this.tabControl.Location = new System.Drawing.Point(0, 57);
     233      this.tabControl.Location = new System.Drawing.Point(0, 84);
    233234      this.tabControl.Name = "tabControl";
    234235      this.tabControl.SelectedIndex = 0;
    235       this.tabControl.Size = new System.Drawing.Size(654, 440);
    236       this.tabControl.TabIndex = 9;
     236      this.tabControl.Size = new System.Drawing.Size(654, 413);
     237      this.tabControl.TabIndex = 6;
    237238      //
    238239      // byTargetTabPage
     
    248249      this.byTargetTabPage.Name = "byTargetTabPage";
    249250      this.byTargetTabPage.Padding = new System.Windows.Forms.Padding(3);
    250       this.byTargetTabPage.Size = new System.Drawing.Size(646, 414);
     251      this.byTargetTabPage.Size = new System.Drawing.Size(646, 387);
    251252      this.byTargetTabPage.TabIndex = 0;
    252253      this.byTargetTabPage.Text = "Performance by Target";
     
    264265      this.byTargetViewHost.Name = "byTargetViewHost";
    265266      this.byTargetViewHost.ReadOnly = false;
    266       this.byTargetViewHost.Size = new System.Drawing.Size(640, 351);
    267       this.byTargetViewHost.TabIndex = 9;
     267      this.byTargetViewHost.Size = new System.Drawing.Size(640, 324);
     268      this.byTargetViewHost.TabIndex = 5;
    268269      this.byTargetViewHost.ViewsLabelVisible = true;
    269270      this.byTargetViewHost.ViewType = null;
     
    281282      this.byCostTabPage.Name = "byCostTabPage";
    282283      this.byCostTabPage.Padding = new System.Windows.Forms.Padding(3);
    283       this.byCostTabPage.Size = new System.Drawing.Size(646, 414);
     284      this.byCostTabPage.Size = new System.Drawing.Size(646, 387);
    284285      this.byCostTabPage.TabIndex = 1;
    285286      this.byCostTabPage.Text = "Performance by Cost";
    286287      this.byCostTabPage.UseVisualStyleBackColor = true;
     288      //
     289      // budgetLogScalingCheckBox
     290      //
     291      this.budgetLogScalingCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
     292      this.budgetLogScalingCheckBox.AutoSize = true;
     293      this.budgetLogScalingCheckBox.Location = new System.Drawing.Point(9, 364);
     294      this.budgetLogScalingCheckBox.Name = "budgetLogScalingCheckBox";
     295      this.budgetLogScalingCheckBox.Size = new System.Drawing.Size(112, 17);
     296      this.budgetLogScalingCheckBox.TabIndex = 11;
     297      this.budgetLogScalingCheckBox.Text = "logarithmic scaling";
     298      this.budgetLogScalingCheckBox.UseVisualStyleBackColor = true;
     299      this.budgetLogScalingCheckBox.CheckedChanged += new System.EventHandler(this.logScalingCheckBox_CheckedChanged);
    287300      //
    288301      // eachOrAllBudgetsCheckBox
     
    320333      this.byCostViewHost.Name = "byCostViewHost";
    321334      this.byCostViewHost.ReadOnly = false;
    322       this.byCostViewHost.Size = new System.Drawing.Size(640, 351);
     335      this.byCostViewHost.Size = new System.Drawing.Size(640, 324);
    323336      this.byCostViewHost.TabIndex = 8;
    324337      this.byCostViewHost.ViewsLabelVisible = true;
     
    327340      // byTableTabPage
    328341      //
    329       this.byTableTabPage.Controls.Add(this.dataGridView1);
     342      this.byTableTabPage.Controls.Add(this.ertViewHost);
    330343      this.byTableTabPage.Location = new System.Drawing.Point(4, 22);
    331344      this.byTableTabPage.Name = "byTableTabPage";
    332345      this.byTableTabPage.Padding = new System.Windows.Forms.Padding(3);
    333       this.byTableTabPage.Size = new System.Drawing.Size(646, 388);
     346      this.byTableTabPage.Size = new System.Drawing.Size(646, 387);
    334347      this.byTableTabPage.TabIndex = 2;
    335348      this.byTableTabPage.Text = "Expected Runtime Tables";
    336349      this.byTableTabPage.UseVisualStyleBackColor = true;
    337350      //
    338       // dataGridView1
    339       //
    340       this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
    341       this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
    342       this.dataGridView1.Location = new System.Drawing.Point(3, 3);
    343       this.dataGridView1.Name = "dataGridView1";
    344       this.dataGridView1.Size = new System.Drawing.Size(640, 382);
    345       this.dataGridView1.TabIndex = 0;
    346       //
    347       // budgetLogScalingCheckBox
    348       //
    349       this.budgetLogScalingCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    350       this.budgetLogScalingCheckBox.AutoSize = true;
    351       this.budgetLogScalingCheckBox.Location = new System.Drawing.Point(9, 391);
    352       this.budgetLogScalingCheckBox.Name = "budgetLogScalingCheckBox";
    353       this.budgetLogScalingCheckBox.Size = new System.Drawing.Size(112, 17);
    354       this.budgetLogScalingCheckBox.TabIndex = 11;
    355       this.budgetLogScalingCheckBox.Text = "logarithmic scaling";
    356       this.budgetLogScalingCheckBox.UseVisualStyleBackColor = true;
     351      // ertViewHost
     352      //
     353      this.ertViewHost.Caption = "View";
     354      this.ertViewHost.Content = null;
     355      this.ertViewHost.Dock = System.Windows.Forms.DockStyle.Fill;
     356      this.ertViewHost.Enabled = false;
     357      this.ertViewHost.Location = new System.Drawing.Point(3, 3);
     358      this.ertViewHost.Name = "ertViewHost";
     359      this.ertViewHost.ReadOnly = false;
     360      this.ertViewHost.Size = new System.Drawing.Size(640, 381);
     361      this.ertViewHost.TabIndex = 0;
     362      this.ertViewHost.ViewsLabelVisible = true;
     363      this.ertViewHost.ViewType = null;
     364      //
     365      // problemComboBox
     366      //
     367      this.problemComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     368            | System.Windows.Forms.AnchorStyles.Right)));
     369      this.problemComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     370      this.problemComboBox.FormattingEnabled = true;
     371      this.problemComboBox.Location = new System.Drawing.Point(69, 30);
     372      this.problemComboBox.Name = "problemComboBox";
     373      this.problemComboBox.Size = new System.Drawing.Size(582, 21);
     374      this.problemComboBox.TabIndex = 3;
     375      this.problemComboBox.SelectedIndexChanged += new System.EventHandler(this.problemComboBox_SelectedIndexChanged);
     376      //
     377      // problemLabel
     378      //
     379      this.problemLabel.AutoSize = true;
     380      this.problemLabel.Location = new System.Drawing.Point(3, 33);
     381      this.problemLabel.Name = "problemLabel";
     382      this.problemLabel.Size = new System.Drawing.Size(48, 13);
     383      this.problemLabel.TabIndex = 2;
     384      this.problemLabel.Text = "Problem:";
    357385      //
    358386      // RunCollectionRLDView
     
    362390      this.Controls.Add(this.groupComboBox);
    363391      this.Controls.Add(this.groupLabel);
     392      this.Controls.Add(this.problemLabel);
    364393      this.Controls.Add(this.dataTableLabel);
     394      this.Controls.Add(this.problemComboBox);
    365395      this.Controls.Add(this.dataTableComboBox);
    366396      this.Name = "RunCollectionRLDView";
     
    373403      this.byCostTabPage.PerformLayout();
    374404      this.byTableTabPage.ResumeLayout(false);
    375       ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
    376405      this.ResumeLayout(false);
    377406      this.PerformLayout();
     
    401430    private System.Windows.Forms.TabPage byCostTabPage;
    402431    private System.Windows.Forms.TabPage byTableTabPage;
    403     private System.Windows.Forms.DataGridView dataGridView1;
    404432    private MainForm.WindowsForms.ViewHost byCostViewHost;
    405433    private System.Windows.Forms.CheckBox eachOrAllBudgetsCheckBox;
    406434    private System.Windows.Forms.Button generateBudgetsButton;
    407435    private System.Windows.Forms.CheckBox budgetLogScalingCheckBox;
     436    private MainForm.WindowsForms.ViewHost ertViewHost;
     437    private System.Windows.Forms.Label problemLabel;
     438    private System.Windows.Forms.ComboBox problemComboBox;
    408439  }
    409440}
  • branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs

    r12838 r12841  
    2424using System.ComponentModel;
    2525using System.Drawing;
     26using System.Globalization;
    2627using System.Linq;
    2728using System.Windows.Forms;
     
    125126        return;
    126127      }
    127       UpdateGroupComboBox();
     128      UpdateGroupAndProblemComboBox();
    128129      UpdateDataTableComboBox();
    129130      foreach (var run in e.Items)
     
    136137        return;
    137138      }
    138       UpdateGroupComboBox();
     139      UpdateGroupAndProblemComboBox();
    139140      UpdateDataTableComboBox();
    140141      foreach (var run in e.Items)
     
    147148        return;
    148149      }
    149       UpdateGroupComboBox();
     150      UpdateGroupAndProblemComboBox();
    150151      UpdateDataTableComboBox();
    151152      foreach (var run in e.OldItems)
     
    165166      if (!suppressUpdates) {
    166167        UpdateDataTableComboBox();
    167         UpdateGroupComboBox();
     168        UpdateGroupAndProblemComboBox();
    168169        UpdateRuns();
    169170      }
     
    195196      UpdateCaption();
    196197      if (Content != null) {
    197         UpdateGroupComboBox();
     198        UpdateGroupAndProblemComboBox();
    198199        UpdateDataTableComboBox();
    199200      }
     
    201202
    202203
    203     private void UpdateGroupComboBox() {
    204       string selectedItem = (string)groupComboBox.SelectedItem;
     204    private void UpdateGroupAndProblemComboBox() {
     205      var selectedGroupItem = (string)groupComboBox.SelectedItem;
    205206
    206207      var groupings = Content.ParameterNames.OrderBy(x => x).ToArray();
     
    208209      groupComboBox.Items.Add(AllRuns);
    209210      groupComboBox.Items.AddRange(groupings);
    210       if (selectedItem != null && groupComboBox.Items.Contains(selectedItem)) {
    211         groupComboBox.SelectedItem = selectedItem;
     211      if (selectedGroupItem != null && groupComboBox.Items.Contains(selectedGroupItem)) {
     212        groupComboBox.SelectedItem = selectedGroupItem;
    212213      } else if (groupComboBox.Items.Count > 0) {
    213214        groupComboBox.SelectedItem = groupComboBox.Items[0];
    214215      }
     216
     217      var problems = new HashSet<ProblemDescription>();
     218      foreach (var run in Content) {
     219        problems.Add(new ProblemDescription(run));
     220      }
     221
     222      var problemTypesDifferent = problems.Select(x => x.ProblemType).Distinct().Count() > 1;
     223      var problemNamesDifferent = problems.Select(x => x.ProblemName).Distinct().Count() > 1;
     224      var evaluatorDifferent = problems.Select(x => x.Evaluator).Distinct().Count() > 1;
     225      var allEqual = !problemTypesDifferent && !problemNamesDifferent && !evaluatorDifferent;
     226
     227      var selectedProblemItem = (ProblemDescription)problemComboBox.SelectedItem;
     228      problemComboBox.Items.Clear();
     229      foreach (var prob in problems.OrderBy(x => x.ToString()).ToList()) {
     230        prob.DisplayProblemType = problemTypesDifferent;
     231        prob.DisplayProblemName = problemNamesDifferent || allEqual;
     232        prob.DisplayEvaluator = evaluatorDifferent;
     233        problemComboBox.Items.Add(prob);
     234        if (prob.Equals(selectedProblemItem)) problemComboBox.SelectedItem = prob;
     235      }
     236      SetEnabledStateOfControls();
    215237    }
    216238
     
    235257      base.SetEnabledStateOfControls();
    236258      groupComboBox.Enabled = Content != null;
    237       dataTableComboBox.Enabled = Content != null;
     259      problemComboBox.Enabled = Content != null && problemComboBox.Items.Count > 1;
     260      dataTableComboBox.Enabled = Content != null && dataTableComboBox.Items.Count > 1;
    238261      addTargetsAsResultButton.Enabled = Content != null && targets != null && dataTableComboBox.SelectedIndex >= 0;
    239262      addBudgetsAsResultButton.Enabled = Content != null && budgets != null && dataTableComboBox.SelectedIndex >= 0;
     263    }
     264
     265    private List<Tuple<string, List<IRun>>> GroupRuns() {
     266      var groupedRuns = new List<Tuple<string, List<IRun>>>();
     267
     268      var table = (string)dataTableComboBox.SelectedItem;
     269      if (string.IsNullOrEmpty(table)) return groupedRuns;
     270
     271      var selectedGroup = (string)groupComboBox.SelectedItem;
     272      if (string.IsNullOrEmpty(selectedGroup)) return groupedRuns;
     273
     274      var selectedProblem = (ProblemDescription)problemComboBox.SelectedItem;
     275      if (selectedProblem == null) selectedProblem = ProblemDescription.MatchAll;
     276
     277      if (selectedGroup == AllRuns)
     278        groupedRuns = new List<Tuple<string, List<IRun>>> {
     279          Tuple.Create(AllRuns, Content.Where(r => selectedProblem.Match(r) && r.Results.ContainsKey(table) && r.Visible).ToList())
     280        };
     281      else
     282        groupedRuns = (from r in Content
     283                       where r.Parameters.ContainsKey(selectedGroup)
     284                             && selectedProblem.Match(r)
     285                             && r.Results.ContainsKey(table)
     286                             && r.Visible
     287                       group r by r.Parameters[selectedGroup].ToString()
     288                         into g
     289                         select Tuple.Create(g.Key, g.ToList())).ToList();
     290
     291      return groupedRuns;
    240292    }
    241293
     
    261313      if (string.IsNullOrEmpty(table)) return;
    262314
    263       var selectedGroup = (string)groupComboBox.SelectedItem;
    264       if (string.IsNullOrEmpty(selectedGroup)) return;
    265 
    266315      if (targets == null) GenerateDefaultTargets(table);
    267316
    268       List<Tuple<string, List<IRun>>> groupedRuns;
    269       if (selectedGroup == AllRuns)
    270         groupedRuns = new List<Tuple<string, List<IRun>>> {
    271           Tuple.Create(AllRuns, Content.Where(r => r.Results.ContainsKey(table) && r.Visible).ToList())
    272         };
    273       else groupedRuns = (from r in Content
    274                           where r.Results.ContainsKey(table) && r.Visible
    275                           group r by r.Parameters[selectedGroup].ToString() into g
    276                           select Tuple.Create(g.Key, g.ToList())).ToList();
     317      var groupedRuns = GroupRuns();
     318      if (groupedRuns.Count == 0) return;
    277319
    278320      var xAxisTitles = new HashSet<string>();
     
    323365      byTargetDataTable.VisualProperties.XAxisTitle = string.Join(" / ", xAxisTitles);
    324366      byTargetDataTable.VisualProperties.XAxisLogScale = byTargetDataTable.Rows.Count > 0 && targetLogScalingCheckBox.Checked;
     367
     368      UpdateErtTables(groupedRuns);
    325369    }
    326370
    327371    private void GenerateDefaultTargets(string table) {
    328       var worst = Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Select(y => y.Item2).Min()).Min();
    329       var best = Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Select(y => y.Item2).Max()).Max();
     372      var runs = GroupRuns().SelectMany(x => x.Item2).ToList();
     373      var worst = runs.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Select(y => y.Item2).Min()).Min();
     374      var best = runs.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Select(y => y.Item2).Max()).Max();
    330375      var maximization = IsMaximization();
    331376      if (!maximization) {
     
    380425      return values[j].Item1;
    381426    }
     427
     428    private void UpdateErtTables(List<Tuple<string, List<IRun>>> groupedRuns) {
     429      ertViewHost.Content = null;
     430      var columns = 1 + targets.Length + 1;
     431      var matrix = new string[groupedRuns.Count + 1, columns];
     432      var rowCount = 0;
     433      var maximization = IsMaximization();
     434
     435      var colNames = new string[columns];
     436      colNames[0] = colNames[colNames.Length - 1] = string.Empty;
     437      for (var i = 0; i < targets.Length; i++) {
     438        colNames[i + 1] = maximization ? (targets[targets.Length - 1] / targets[i] - 1).ToString("0.0%")
     439                                       : (targets[i] / targets[targets.Length - 1] - 1).ToString("0.0%");
     440        matrix[rowCount, i + 1] = targets[i].ToString(CultureInfo.CurrentCulture.NumberFormat);
     441      }
     442      matrix[rowCount, columns - 1] = "#succ";
     443      rowCount++;
     444
     445      foreach (var group in groupedRuns) {
     446        matrix[rowCount, 0] = group.Item1;
     447        var bestSucc = string.Empty;
     448        for (var i = 0; i < targets.Length; i++) {
     449          string succ;
     450          matrix[rowCount, i + 1] = CalculateExpectedRunTime(group.Item2, targets[i], maximization, out succ);
     451          if (i == targets.Length - 1) bestSucc = succ;
     452        }
     453        matrix[rowCount, columns - 1] = bestSucc;
     454        rowCount++;
     455      }
     456      ertViewHost.Content = new StringMatrix(matrix) { ColumnNames = colNames };
     457    }
     458
     459    private string CalculateExpectedRunTime(List<IRun> group, double target, bool maximization, out string successProb) {
     460      var table = (string)dataTableComboBox.SelectedItem;
     461      successProb = "-";
     462      if (string.IsNullOrEmpty(table)) return "N/A";
     463      var successful = new List<double>();
     464      var unsuccessful = new List<double>();
     465      foreach (var r in group) {
     466        var targetAchieved = false;
     467        var row = ((IndexedDataTable<double>)r.Results[table]).Rows.First();
     468        foreach (var v in row.Values) {
     469          if (maximization && v.Item2 >= target || !maximization && v.Item2 <= target) {
     470            successful.Add(v.Item1);
     471            targetAchieved = true;
     472            break;
     473          }
     474        }
     475        if (!targetAchieved) unsuccessful.Add(row.Values.Last().Item1);
     476      }
     477      successProb = successful.Count + "/" + (successful.Count + unsuccessful.Count);
     478      if (successful.Count == 0) return "\u221e"; // infinity symbol
     479      if (unsuccessful.Count == 0) return successful.Average().ToString("##,0.0", CultureInfo.CurrentCulture.NumberFormat);
     480
     481      var ps = successful.Count / (double)(successful.Count + unsuccessful.Count);
     482      return (successful.Average() + ((1.0 - ps) / ps) * unsuccessful.Average()).ToString("##,0.0", CultureInfo.CurrentCulture.NumberFormat);
     483    }
    382484    #endregion
    383485
     
    391493      if (string.IsNullOrEmpty(table)) return;
    392494
    393       var selectedGroup = (string)groupComboBox.SelectedItem;
    394       if (string.IsNullOrEmpty(selectedGroup)) return;
    395 
    396495      if (budgets == null) GenerateDefaultBudgets(table);
    397496
    398       List<Tuple<string, List<IRun>>> groupedRuns;
    399       if (selectedGroup == AllRuns)
    400         groupedRuns = new List<Tuple<string, List<IRun>>> {
    401           Tuple.Create(AllRuns, Content.Where(r => r.Results.ContainsKey(table) && r.Visible).ToList())
    402         };
    403       else groupedRuns = (from r in Content
    404                           where r.Results.ContainsKey(table) && r.Visible
    405                           group r by r.Parameters[selectedGroup].ToString() into g
    406                           select Tuple.Create(g.Key, g.ToList())).ToList();
     497      var groupedRuns = GroupRuns();
     498      if (groupedRuns.Count == 0) return;
    407499
    408500      var colorCount = 0;
     
    450542
    451543    private void GenerateDefaultBudgets(string table) {
    452       var min = Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Select(y => y.Item1).Min()).Min();
    453       var max = Content.Where(x => x.Results.ContainsKey(table)).Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Select(y => y.Item1).Max()).Max();
     544      var runs = GroupRuns().SelectMany(x => x.Item2).ToList();
     545      var min = runs.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Select(y => y.Item1).Min()).Min();
     546      var max = runs.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Select(y => y.Item1).Max()).Max();
    454547
    455548      var maxMagnitude = (int)Math.Ceiling(Math.Log10(max));
     
    525618
    526619    private void groupComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     620      UpdateRuns();
     621      SetEnabledStateOfControls();
     622    }
     623    private void problemComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     624      if (dataTableComboBox.SelectedIndex >= 0)
     625        GenerateDefaultTargets((string)dataTableComboBox.SelectedItem);
    527626      UpdateRuns();
    528627      SetEnabledStateOfControls();
     
    762861    }
    763862    #endregion
     863
     864
     865    private class ProblemDescription {
     866      private readonly bool matchAll;
     867      public static readonly ProblemDescription MatchAll = new ProblemDescription();
     868
     869      private ProblemDescription() {
     870        ProblemType = string.Empty;
     871        ProblemName = string.Empty;
     872        Evaluator = string.Empty;
     873        DisplayProblemType = false;
     874        DisplayProblemName = false;
     875        DisplayEvaluator = false;
     876        matchAll = true;
     877      }
     878
     879      public ProblemDescription(IRun run) {
     880        ProblemType = GetStringValueOrEmpty(run, "Problem Type");
     881        ProblemName = GetStringValueOrEmpty(run, "Problem Name");
     882        Evaluator = GetStringValueOrEmpty(run, "Evaluator");
     883        DisplayProblemType = !string.IsNullOrEmpty(ProblemType);
     884        DisplayProblemName = !string.IsNullOrEmpty(ProblemName);
     885        DisplayEvaluator = !string.IsNullOrEmpty(Evaluator);
     886        matchAll = false;
     887      }
     888
     889      public bool DisplayProblemType { get; set; }
     890      public string ProblemType { get; set; }
     891      public bool DisplayProblemName { get; set; }
     892      public string ProblemName { get; set; }
     893      public bool DisplayEvaluator { get; set; }
     894      public string Evaluator { get; set; }
     895
     896      public bool Match(IRun run) {
     897        return matchAll ||
     898               GetStringValueOrEmpty(run, "Problem Type") == ProblemType
     899               && GetStringValueOrEmpty(run, "Problem Name") == ProblemName
     900               && GetStringValueOrEmpty(run, "Evaluator") == Evaluator;
     901      }
     902
     903      private string GetStringValueOrEmpty(IRun run, string key) {
     904        return run.Parameters.ContainsKey(key) ? ((StringValue)run.Parameters[key]).Value : string.Empty;
     905      }
     906
     907      public override bool Equals(object obj) {
     908        var other = obj as ProblemDescription;
     909        if (other == null) return false;
     910        return ProblemType == other.ProblemType
     911               && ProblemName == other.ProblemName
     912               && Evaluator == other.Evaluator;
     913      }
     914
     915      public override int GetHashCode() {
     916        return ProblemType.GetHashCode() ^ ProblemName.GetHashCode() ^ Evaluator.GetHashCode();
     917      }
     918
     919      public override string ToString() {
     920        return string.Join("  --  ", new[] {
     921          (DisplayProblemType ? ProblemType : string.Empty),
     922          (DisplayProblemName ? ProblemName : string.Empty),
     923          (DisplayEvaluator ? Evaluator : string.Empty) }.Where(x => !string.IsNullOrEmpty(x)));
     924      }
     925    }
    764926  }
    765927}
Note: See TracChangeset for help on using the changeset viewer.