Changeset 12841 for branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews
- Timestamp:
- 08/10/15 12:49:31 (9 years ago)
- 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 64 64 this.byTargetViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 65 65 this.byCostTabPage = new System.Windows.Forms.TabPage(); 66 this.budgetLogScalingCheckBox = new System.Windows.Forms.CheckBox(); 66 67 this.eachOrAllBudgetsCheckBox = new System.Windows.Forms.CheckBox(); 67 68 this.generateBudgetsButton = new System.Windows.Forms.Button(); 68 69 this.byCostViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 69 70 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(); 72 74 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 73 75 this.tabControl.SuspendLayout(); … … 75 77 this.byCostTabPage.SuspendLayout(); 76 78 this.byTableTabPage.SuspendLayout(); 77 ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();78 79 this.SuspendLayout(); 79 80 // … … 84 85 this.dataTableComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 85 86 this.dataTableComboBox.FormattingEnabled = true; 86 this.dataTableComboBox.Location = new System.Drawing.Point(69, 30);87 this.dataTableComboBox.Location = new System.Drawing.Point(69, 57); 87 88 this.dataTableComboBox.Name = "dataTableComboBox"; 88 89 this.dataTableComboBox.Size = new System.Drawing.Size(582, 21); 89 this.dataTableComboBox.TabIndex = 0;90 this.dataTableComboBox.TabIndex = 5; 90 91 this.dataTableComboBox.SelectedIndexChanged += new System.EventHandler(this.dataTableComboBox_SelectedIndexChanged); 91 92 // … … 93 94 // 94 95 this.dataTableLabel.AutoSize = true; 95 this.dataTableLabel.Location = new System.Drawing.Point(3, 33);96 this.dataTableLabel.Location = new System.Drawing.Point(3, 60); 96 97 this.dataTableLabel.Name = "dataTableLabel"; 97 98 this.dataTableLabel.Size = new System.Drawing.Size(60, 13); 98 this.dataTableLabel.TabIndex = 1;99 this.dataTableLabel.TabIndex = 4; 99 100 this.dataTableLabel.Text = "DataTable:"; 100 101 // … … 105 106 this.groupLabel.Name = "groupLabel"; 106 107 this.groupLabel.Size = new System.Drawing.Size(39, 13); 107 this.groupLabel.TabIndex = 3;108 this.groupLabel.TabIndex = 0; 108 109 this.groupLabel.Text = "Group:"; 109 110 // … … 117 118 this.groupComboBox.Name = "groupComboBox"; 118 119 this.groupComboBox.Size = new System.Drawing.Size(582, 21); 119 this.groupComboBox.TabIndex = 4;120 this.groupComboBox.TabIndex = 1; 120 121 this.groupComboBox.SelectedIndexChanged += new System.EventHandler(this.groupComboBox_SelectedIndexChanged); 121 122 // … … 124 125 this.targetLogScalingCheckBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 125 126 this.targetLogScalingCheckBox.AutoSize = true; 126 this.targetLogScalingCheckBox.Location = new System.Drawing.Point(9, 3 91);127 this.targetLogScalingCheckBox.Location = new System.Drawing.Point(9, 364); 127 128 this.targetLogScalingCheckBox.Name = "targetLogScalingCheckBox"; 128 129 this.targetLogScalingCheckBox.Size = new System.Drawing.Size(112, 17); 129 this.targetLogScalingCheckBox.TabIndex = 5;130 this.targetLogScalingCheckBox.TabIndex = 6; 130 131 this.targetLogScalingCheckBox.Text = "logarithmic scaling"; 131 132 this.targetLogScalingCheckBox.UseVisualStyleBackColor = true; … … 139 140 this.targetsTextBox.Name = "targetsTextBox"; 140 141 this.targetsTextBox.Size = new System.Drawing.Size(320, 20); 141 this.targetsTextBox.TabIndex = 6;142 this.targetsTextBox.TabIndex = 1; 142 143 this.toolTip.SetToolTip(this.targetsTextBox, "The order of the targets is important, first to-hit targets\r\nshould be given firs" + 143 144 "t. The sequence should be monotonous.\r\n\r\nTargets should be separated by semicolo" + … … 151 152 this.targetsLabel.Name = "targetsLabel"; 152 153 this.targetsLabel.Size = new System.Drawing.Size(46, 13); 153 this.targetsLabel.TabIndex = 1;154 this.targetsLabel.TabIndex = 0; 154 155 this.targetsLabel.Text = "Targets:"; 155 156 // … … 164 165 this.addTargetsAsResultButton.Name = "addTargetsAsResultButton"; 165 166 this.addTargetsAsResultButton.Size = new System.Drawing.Size(89, 23); 166 this.addTargetsAsResultButton.TabIndex = 7;167 this.addTargetsAsResultButton.TabIndex = 4; 167 168 this.addTargetsAsResultButton.Text = "Add as Result"; 168 169 this.addTargetsAsResultButton.UseVisualStyleBackColor = true; … … 175 176 this.generateTargetsButton.Name = "generateTargetsButton"; 176 177 this.generateTargetsButton.Size = new System.Drawing.Size(89, 23); 177 this.generateTargetsButton.TabIndex = 7;178 this.generateTargetsButton.TabIndex = 3; 178 179 this.generateTargetsButton.Text = "Generate..."; 179 180 this.generateTargetsButton.UseVisualStyleBackColor = true; … … 217 218 this.eachOrAllTargetCheckBox.Name = "eachOrAllTargetCheckBox"; 218 219 this.eachOrAllTargetCheckBox.Size = new System.Drawing.Size(36, 17); 219 this.eachOrAllTargetCheckBox.TabIndex = 8;220 this.eachOrAllTargetCheckBox.TabIndex = 2; 220 221 this.eachOrAllTargetCheckBox.Text = "all"; 221 222 this.eachOrAllTargetCheckBox.UseVisualStyleBackColor = true; … … 230 231 this.tabControl.Controls.Add(this.byCostTabPage); 231 232 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); 233 234 this.tabControl.Name = "tabControl"; 234 235 this.tabControl.SelectedIndex = 0; 235 this.tabControl.Size = new System.Drawing.Size(654, 4 40);236 this.tabControl.TabIndex = 9;236 this.tabControl.Size = new System.Drawing.Size(654, 413); 237 this.tabControl.TabIndex = 6; 237 238 // 238 239 // byTargetTabPage … … 248 249 this.byTargetTabPage.Name = "byTargetTabPage"; 249 250 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); 251 252 this.byTargetTabPage.TabIndex = 0; 252 253 this.byTargetTabPage.Text = "Performance by Target"; … … 264 265 this.byTargetViewHost.Name = "byTargetViewHost"; 265 266 this.byTargetViewHost.ReadOnly = false; 266 this.byTargetViewHost.Size = new System.Drawing.Size(640, 3 51);267 this.byTargetViewHost.TabIndex = 9;267 this.byTargetViewHost.Size = new System.Drawing.Size(640, 324); 268 this.byTargetViewHost.TabIndex = 5; 268 269 this.byTargetViewHost.ViewsLabelVisible = true; 269 270 this.byTargetViewHost.ViewType = null; … … 281 282 this.byCostTabPage.Name = "byCostTabPage"; 282 283 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); 284 285 this.byCostTabPage.TabIndex = 1; 285 286 this.byCostTabPage.Text = "Performance by Cost"; 286 287 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); 287 300 // 288 301 // eachOrAllBudgetsCheckBox … … 320 333 this.byCostViewHost.Name = "byCostViewHost"; 321 334 this.byCostViewHost.ReadOnly = false; 322 this.byCostViewHost.Size = new System.Drawing.Size(640, 3 51);335 this.byCostViewHost.Size = new System.Drawing.Size(640, 324); 323 336 this.byCostViewHost.TabIndex = 8; 324 337 this.byCostViewHost.ViewsLabelVisible = true; … … 327 340 // byTableTabPage 328 341 // 329 this.byTableTabPage.Controls.Add(this. dataGridView1);342 this.byTableTabPage.Controls.Add(this.ertViewHost); 330 343 this.byTableTabPage.Location = new System.Drawing.Point(4, 22); 331 344 this.byTableTabPage.Name = "byTableTabPage"; 332 345 this.byTableTabPage.Padding = new System.Windows.Forms.Padding(3); 333 this.byTableTabPage.Size = new System.Drawing.Size(646, 38 8);346 this.byTableTabPage.Size = new System.Drawing.Size(646, 387); 334 347 this.byTableTabPage.TabIndex = 2; 335 348 this.byTableTabPage.Text = "Expected Runtime Tables"; 336 349 this.byTableTabPage.UseVisualStyleBackColor = true; 337 350 // 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:"; 357 385 // 358 386 // RunCollectionRLDView … … 362 390 this.Controls.Add(this.groupComboBox); 363 391 this.Controls.Add(this.groupLabel); 392 this.Controls.Add(this.problemLabel); 364 393 this.Controls.Add(this.dataTableLabel); 394 this.Controls.Add(this.problemComboBox); 365 395 this.Controls.Add(this.dataTableComboBox); 366 396 this.Name = "RunCollectionRLDView"; … … 373 403 this.byCostTabPage.PerformLayout(); 374 404 this.byTableTabPage.ResumeLayout(false); 375 ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();376 405 this.ResumeLayout(false); 377 406 this.PerformLayout(); … … 401 430 private System.Windows.Forms.TabPage byCostTabPage; 402 431 private System.Windows.Forms.TabPage byTableTabPage; 403 private System.Windows.Forms.DataGridView dataGridView1;404 432 private MainForm.WindowsForms.ViewHost byCostViewHost; 405 433 private System.Windows.Forms.CheckBox eachOrAllBudgetsCheckBox; 406 434 private System.Windows.Forms.Button generateBudgetsButton; 407 435 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; 408 439 } 409 440 } -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs
r12838 r12841 24 24 using System.ComponentModel; 25 25 using System.Drawing; 26 using System.Globalization; 26 27 using System.Linq; 27 28 using System.Windows.Forms; … … 125 126 return; 126 127 } 127 UpdateGroup ComboBox();128 UpdateGroupAndProblemComboBox(); 128 129 UpdateDataTableComboBox(); 129 130 foreach (var run in e.Items) … … 136 137 return; 137 138 } 138 UpdateGroup ComboBox();139 UpdateGroupAndProblemComboBox(); 139 140 UpdateDataTableComboBox(); 140 141 foreach (var run in e.Items) … … 147 148 return; 148 149 } 149 UpdateGroup ComboBox();150 UpdateGroupAndProblemComboBox(); 150 151 UpdateDataTableComboBox(); 151 152 foreach (var run in e.OldItems) … … 165 166 if (!suppressUpdates) { 166 167 UpdateDataTableComboBox(); 167 UpdateGroup ComboBox();168 UpdateGroupAndProblemComboBox(); 168 169 UpdateRuns(); 169 170 } … … 195 196 UpdateCaption(); 196 197 if (Content != null) { 197 UpdateGroup ComboBox();198 UpdateGroupAndProblemComboBox(); 198 199 UpdateDataTableComboBox(); 199 200 } … … 201 202 202 203 203 private void UpdateGroup ComboBox() {204 string selectedItem = (string)groupComboBox.SelectedItem;204 private void UpdateGroupAndProblemComboBox() { 205 var selectedGroupItem = (string)groupComboBox.SelectedItem; 205 206 206 207 var groupings = Content.ParameterNames.OrderBy(x => x).ToArray(); … … 208 209 groupComboBox.Items.Add(AllRuns); 209 210 groupComboBox.Items.AddRange(groupings); 210 if (selected Item != null && groupComboBox.Items.Contains(selectedItem)) {211 groupComboBox.SelectedItem = selected Item;211 if (selectedGroupItem != null && groupComboBox.Items.Contains(selectedGroupItem)) { 212 groupComboBox.SelectedItem = selectedGroupItem; 212 213 } else if (groupComboBox.Items.Count > 0) { 213 214 groupComboBox.SelectedItem = groupComboBox.Items[0]; 214 215 } 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(); 215 237 } 216 238 … … 235 257 base.SetEnabledStateOfControls(); 236 258 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; 238 261 addTargetsAsResultButton.Enabled = Content != null && targets != null && dataTableComboBox.SelectedIndex >= 0; 239 262 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; 240 292 } 241 293 … … 261 313 if (string.IsNullOrEmpty(table)) return; 262 314 263 var selectedGroup = (string)groupComboBox.SelectedItem;264 if (string.IsNullOrEmpty(selectedGroup)) return;265 266 315 if (targets == null) GenerateDefaultTargets(table); 267 316 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; 277 319 278 320 var xAxisTitles = new HashSet<string>(); … … 323 365 byTargetDataTable.VisualProperties.XAxisTitle = string.Join(" / ", xAxisTitles); 324 366 byTargetDataTable.VisualProperties.XAxisLogScale = byTargetDataTable.Rows.Count > 0 && targetLogScalingCheckBox.Checked; 367 368 UpdateErtTables(groupedRuns); 325 369 } 326 370 327 371 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(); 330 375 var maximization = IsMaximization(); 331 376 if (!maximization) { … … 380 425 return values[j].Item1; 381 426 } 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 } 382 484 #endregion 383 485 … … 391 493 if (string.IsNullOrEmpty(table)) return; 392 494 393 var selectedGroup = (string)groupComboBox.SelectedItem;394 if (string.IsNullOrEmpty(selectedGroup)) return;395 396 495 if (budgets == null) GenerateDefaultBudgets(table); 397 496 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; 407 499 408 500 var colorCount = 0; … … 450 542 451 543 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(); 454 547 455 548 var maxMagnitude = (int)Math.Ceiling(Math.Log10(max)); … … 525 618 526 619 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); 527 626 UpdateRuns(); 528 627 SetEnabledStateOfControls(); … … 762 861 } 763 862 #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 } 764 926 } 765 927 }
Note: See TracChangeset
for help on using the changeset viewer.