Changeset 12806
- Timestamp:
- 07/27/15 16:10:23 (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
r12804 r12806 46 46 this.components = new System.ComponentModel.Container(); 47 47 this.dataTableComboBox = new System.Windows.Forms.ComboBox(); 48 this. label1= new System.Windows.Forms.Label();48 this.dataTableLabel = new System.Windows.Forms.Label(); 49 49 this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 50 this. label2= new System.Windows.Forms.Label();50 this.groupLabel = new System.Windows.Forms.Label(); 51 51 this.groupComboBox = new System.Windows.Forms.ComboBox(); 52 52 this.logScalingCheckBox = new System.Windows.Forms.CheckBox(); 53 53 this.targetsTextBox = new System.Windows.Forms.TextBox(); 54 this. label3= new System.Windows.Forms.Label();54 this.targetsLabel = new System.Windows.Forms.Label(); 55 55 this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); 56 this.fixedTargetButton = new System.Windows.Forms.Button(); 57 this.generateTargetsButton = new System.Windows.Forms.Button(); 58 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 59 this.budgetsLabel = new System.Windows.Forms.Label(); 60 this.budgetsTextBox = new System.Windows.Forms.TextBox(); 61 this.fixedCostButton = new System.Windows.Forms.Button(); 56 62 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); 57 63 this.SuspendLayout(); … … 69 75 this.dataTableComboBox.SelectedIndexChanged += new System.EventHandler(this.dataTableComboBox_SelectedIndexChanged); 70 76 // 71 // label172 // 73 this. label1.AutoSize = true;74 this. label1.Location = new System.Drawing.Point(3, 33);75 this. label1.Name = "label1";76 this. label1.Size = new System.Drawing.Size(60, 13);77 this. label1.TabIndex = 1;78 this. label1.Text = "DataTable:";77 // dataTableLabel 78 // 79 this.dataTableLabel.AutoSize = true; 80 this.dataTableLabel.Location = new System.Drawing.Point(3, 33); 81 this.dataTableLabel.Name = "dataTableLabel"; 82 this.dataTableLabel.Size = new System.Drawing.Size(60, 13); 83 this.dataTableLabel.TabIndex = 1; 84 this.dataTableLabel.Text = "DataTable:"; 79 85 // 80 86 // viewHost … … 94 100 this.viewHost.ViewType = null; 95 101 // 96 // label297 // 98 this. label2.AutoSize = true;99 this. label2.Location = new System.Drawing.Point(3, 6);100 this. label2.Name = "label2";101 this. label2.Size = new System.Drawing.Size(39, 13);102 this. label2.TabIndex = 3;103 this. label2.Text = "Group:";102 // groupLabel 103 // 104 this.groupLabel.AutoSize = true; 105 this.groupLabel.Location = new System.Drawing.Point(3, 6); 106 this.groupLabel.Name = "groupLabel"; 107 this.groupLabel.Size = new System.Drawing.Size(39, 13); 108 this.groupLabel.TabIndex = 3; 109 this.groupLabel.Text = "Group:"; 104 110 // 105 111 // groupComboBox … … 133 139 this.targetsTextBox.Location = new System.Drawing.Point(69, 57); 134 140 this.targetsTextBox.Name = "targetsTextBox"; 135 this.targetsTextBox.Size = new System.Drawing.Size( 455, 20);141 this.targetsTextBox.Size = new System.Drawing.Size(265, 20); 136 142 this.targetsTextBox.TabIndex = 6; 143 this.toolTip.SetToolTip(this.targetsTextBox, "The order of the targets is important, first to-hit targets\r\nshould be given firs" + 144 "t. The sequence should be monotonous.\r\n\r\nTargets should be separated by semicolo" + 145 "n, tab or space."); 137 146 this.targetsTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.targetsTextBox_Validating); 138 147 // 139 // label3140 // 141 this. label3.AutoSize = true;142 this. label3.Location = new System.Drawing.Point(3, 60);143 this. label3.Name = "label3";144 this. label3.Size = new System.Drawing.Size(46, 13);145 this. label3.TabIndex = 1;146 this. label3.Text = "Targets:";148 // targetsLabel 149 // 150 this.targetsLabel.AutoSize = true; 151 this.targetsLabel.Location = new System.Drawing.Point(3, 60); 152 this.targetsLabel.Name = "targetsLabel"; 153 this.targetsLabel.Size = new System.Drawing.Size(46, 13); 154 this.targetsLabel.TabIndex = 1; 155 this.targetsLabel.Text = "Targets:"; 147 156 // 148 157 // errorProvider … … 150 159 this.errorProvider.ContainerControl = this; 151 160 // 161 // fixedTargetButton 162 // 163 this.fixedTargetButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 164 this.fixedTargetButton.Location = new System.Drawing.Point(435, 54); 165 this.fixedTargetButton.Name = "fixedTargetButton"; 166 this.fixedTargetButton.Size = new System.Drawing.Size(89, 23); 167 this.fixedTargetButton.TabIndex = 7; 168 this.fixedTargetButton.Text = "Add as Result"; 169 this.fixedTargetButton.UseVisualStyleBackColor = true; 170 this.fixedTargetButton.Click += new System.EventHandler(this.fixedTargetButton_Click); 171 // 172 // generateTargetsButton 173 // 174 this.generateTargetsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 175 this.generateTargetsButton.Location = new System.Drawing.Point(340, 54); 176 this.generateTargetsButton.Name = "generateTargetsButton"; 177 this.generateTargetsButton.Size = new System.Drawing.Size(89, 23); 178 this.generateTargetsButton.TabIndex = 7; 179 this.generateTargetsButton.Text = "Generate..."; 180 this.generateTargetsButton.UseVisualStyleBackColor = true; 181 this.generateTargetsButton.Click += new System.EventHandler(this.generateTargetsButton_Click); 182 // 183 // budgetsLabel 184 // 185 this.budgetsLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 186 this.budgetsLabel.AutoSize = true; 187 this.budgetsLabel.Location = new System.Drawing.Point(235, 353); 188 this.budgetsLabel.Name = "budgetsLabel"; 189 this.budgetsLabel.Size = new System.Drawing.Size(49, 13); 190 this.budgetsLabel.TabIndex = 1; 191 this.budgetsLabel.Text = "Budgets:"; 192 // 193 // budgetsTextBox 194 // 195 this.budgetsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 196 | System.Windows.Forms.AnchorStyles.Right))); 197 this.budgetsTextBox.Location = new System.Drawing.Point(290, 350); 198 this.budgetsTextBox.Name = "budgetsTextBox"; 199 this.budgetsTextBox.Size = new System.Drawing.Size(139, 20); 200 this.budgetsTextBox.TabIndex = 6; 201 this.budgetsTextBox.Text = "1e2 ; 1e3 ; 1e4 ; 1e5 ; 1e6"; 202 this.budgetsTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.targetsTextBox_Validating); 203 // 204 // fixedCostButton 205 // 206 this.fixedCostButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 207 this.fixedCostButton.Location = new System.Drawing.Point(435, 348); 208 this.fixedCostButton.Name = "fixedCostButton"; 209 this.fixedCostButton.Size = new System.Drawing.Size(89, 23); 210 this.fixedCostButton.TabIndex = 7; 211 this.fixedCostButton.Text = "Add as Result"; 212 this.fixedCostButton.UseVisualStyleBackColor = true; 213 this.fixedCostButton.Click += new System.EventHandler(this.fixedCostButton_Click); 214 // 152 215 // RunCollectionRLDView 153 216 // 154 217 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 218 this.Controls.Add(this.generateTargetsButton); 219 this.Controls.Add(this.fixedCostButton); 220 this.Controls.Add(this.fixedTargetButton); 221 this.Controls.Add(this.budgetsTextBox); 155 222 this.Controls.Add(this.targetsTextBox); 156 223 this.Controls.Add(this.logScalingCheckBox); 157 224 this.Controls.Add(this.groupComboBox); 158 this.Controls.Add(this.label2); 225 this.Controls.Add(this.groupLabel); 226 this.Controls.Add(this.budgetsLabel); 159 227 this.Controls.Add(this.viewHost); 160 this.Controls.Add(this. label3);161 this.Controls.Add(this. label1);228 this.Controls.Add(this.targetsLabel); 229 this.Controls.Add(this.dataTableLabel); 162 230 this.Controls.Add(this.dataTableComboBox); 163 231 this.Name = "RunCollectionRLDView"; … … 172 240 173 241 private System.Windows.Forms.ComboBox dataTableComboBox; 174 private System.Windows.Forms.Label label1;242 private System.Windows.Forms.Label dataTableLabel; 175 243 private MainForm.WindowsForms.ViewHost viewHost; 176 private System.Windows.Forms.Label label2;244 private System.Windows.Forms.Label groupLabel; 177 245 private System.Windows.Forms.ComboBox groupComboBox; 178 246 private System.Windows.Forms.CheckBox logScalingCheckBox; 179 247 private System.Windows.Forms.TextBox targetsTextBox; 180 private System.Windows.Forms.Label label3;248 private System.Windows.Forms.Label targetsLabel; 181 249 protected System.Windows.Forms.ErrorProvider errorProvider; 250 private System.Windows.Forms.Button fixedTargetButton; 251 private System.Windows.Forms.Button generateTargetsButton; 252 private System.Windows.Forms.ToolTip toolTip; 253 private System.Windows.Forms.Button fixedCostButton; 254 private System.Windows.Forms.TextBox budgetsTextBox; 255 private System.Windows.Forms.Label budgetsLabel; 182 256 } 183 257 } -
branches/PerformanceComparison/HeuristicLab.Optimization.Views/3.3/RunCollectionViews/RunCollectionRLDView.cs
r12804 r12806 29 29 using HeuristicLab.Common; 30 30 using HeuristicLab.Core.Views; 31 using HeuristicLab.Data; 31 32 using HeuristicLab.MainForm; 33 using HeuristicLab.MainForm.WindowsForms; 32 34 33 35 namespace HeuristicLab.Optimization.Views { … … 156 158 UpdateDataTableComboBox(); 157 159 } 160 } 161 162 protected override void SetEnabledStateOfControls() { 163 base.SetEnabledStateOfControls(); 164 groupComboBox.Enabled = Content != null; 165 dataTableComboBox.Enabled = Content != null; 166 fixedTargetButton.Enabled = Content != null && levels != null && dataTableComboBox.SelectedIndex >= 0; 158 167 } 159 168 … … 172 181 var worst = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Max(y => y.Item2)).First(); 173 182 var best = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Min(y => y.Item2)).Last(); 174 levels = Enumerable.Range(0, 51).Select(x => worst + (x / 50.0) * (best - worst)).ToArray();183 levels = Enumerable.Range(0, 11).Select(x => worst + (x / 10.0) * (best - worst)).ToArray(); 175 184 suppressTargetsEvents = true; 176 185 targetsTextBox.Text = string.Join(" ; ", levels); … … 263 272 private void groupComboBox_SelectedIndexChanged(object sender, EventArgs e) { 264 273 UpdateRuns(); 274 SetEnabledStateOfControls(); 265 275 } 266 276 private void dataTableComboBox_SelectedIndexChanged(object sender, EventArgs e) { 267 277 UpdateRuns(); 278 SetEnabledStateOfControls(); 268 279 } 269 280 … … 294 305 errorProvider.SetError(targetsTextBox, null); 295 306 levels = targetList.ToArray(); 307 UpdateRuns(); 308 SetEnabledStateOfControls(); 309 } 310 311 private void generateTargetsButton_Click(object sender, EventArgs e) { 312 decimal max = 1, min = 0, count = 10; 313 if (levels != null) { 314 max = (decimal)Math.Max(levels.First(), levels.Last()); 315 min = (decimal)Math.Min(levels.First(), levels.Last()); 316 count = levels.Length; 317 } else if (Content.Count > 0 && dataTableComboBox.SelectedIndex >= 0) { 318 var table = (string)dataTableComboBox.SelectedItem; 319 var worst = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Max(y => y.Item2)).First(); 320 var best = Content.Select(x => ((IndexedDataTable<double>)x.Results[table]).Rows.First().Values.Min(y => y.Item2)).Last(); 321 max = (decimal)Math.Max(best, worst); 322 min = (decimal)Math.Min(best, worst); 323 count = 10; 324 } 325 using (var dialog = new DefineArithmeticProgressionDialog(false, min, max, (max - min) / count)) { 326 if (dialog.ShowDialog() == DialogResult.OK) { 327 if (dialog.Values.Any()) { 328 var maximization = true; 329 if (Content.Count > 0 && Content.First().Parameters.ContainsKey("Maximization")) 330 maximization = ((BoolValue)Content.First().Parameters["Maximization"]).Value; 331 332 levels = maximization ? dialog.Values.Select(x => (double)x).ToArray() 333 : dialog.Values.Reverse().Select(x => (double)x).ToArray(); 334 UpdateRuns(); 335 SetEnabledStateOfControls(); 336 } 337 } 338 } 339 } 340 341 private void fixedTargetButton_Click(object sender, EventArgs e) { 342 var table = (string)dataTableComboBox.SelectedItem; 343 foreach (var run in Content) { 344 var resultsTable = (IndexedDataTable<double>)run.Results[table]; 345 var values = resultsTable.Rows.First().Values; 346 var maximization = values.First().Item2 < values.Last().Item2; 347 var i = 0; 348 var j = 0; 349 var current = values[j]; 350 var prev = Tuple.Create(-1.0, double.NaN); 351 while (i < levels.Length) { 352 if (prev.Item2 != current.Item2 353 && (maximization && current.Item2 >= levels[i] 354 || !maximization && current.Item2 <= levels[i])) { 355 run.Results[table + ".Target" + levels[i]] = new DoubleValue(current.Item1); 356 i++; 357 } else { 358 j++; 359 if (j >= values.Count) break; 360 prev = current; 361 current = values[j]; 362 } 363 } 364 } 365 } 366 367 private void fixedCostButton_Click(object sender, EventArgs e) { 368 var table = (string)dataTableComboBox.SelectedItem; 369 var budgetStrings = budgetsTextBox.Text.Split(new[] { ';', '\t', ' ' }, StringSplitOptions.RemoveEmptyEntries); 370 if (budgetStrings.Length == 0) { 371 MessageBox.Show("Define a number of budgets."); 372 return; 373 } 374 var budgetList = new List<double>(); 375 foreach (var bs in budgetStrings) { 376 double v; 377 if (!double.TryParse(bs, out v)) { 378 MessageBox.Show("Budgets must be a valid number: " + bs); 379 return; 380 } 381 budgetList.Add(v); 382 } 383 budgetList.Sort(); 384 385 foreach (var run in Content) { 386 var resultsTable = (IndexedDataTable<double>)run.Results[table]; 387 var values = resultsTable.Rows.First().Values; 388 var i = 0; 389 var j = 0; 390 var current = values[j]; 391 var prev = Tuple.Create(-1.0, double.NaN); 392 while (i < budgetList.Count) { 393 if (prev.Item2 != current.Item2 && current.Item1 >= budgetList[i]) { 394 run.Results[table + ".Cost" + budgetList[i]] = new DoubleValue(double.IsNaN(prev.Item2) || current.Item1 == budgetList[i] ? current.Item2 : prev.Item2); 395 i++; 396 } else { 397 j++; 398 if (j >= values.Count) break; 399 prev = current; 400 current = values[j]; 401 } 402 } 403 } 296 404 } 297 405 }
Note: See TracChangeset
for help on using the changeset viewer.