Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Benchmarking/sources/HeuristicLab.Algorithms.Benchmarks.Views/3.3/BenchmarkView.cs @ 6920

Last change on this file since 6920 was 6920, checked in by ascheibe, 13 years ago

#1659 added benchmarking algorithms

File size: 9.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Linq;
25using System.Windows.Forms;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Core.Views;
29using HeuristicLab.MainForm;
30using HeuristicLab.PluginInfrastructure;
31using HeuristicLab.Optimization;
32using HeuristicLab.Optimization.Views;
33
34namespace HeuristicLab.Algorithms.Benchmarks.Views {
35  [View("Benchmark View")]
36  [Content(typeof(Whetstone), true)]
37  [Content(typeof(Dhrystone), true)]
38  [Content(typeof(Linpack), true)]
39  public partial class BenchmarkView : AlgorithmView {
40    //private TypeSelectorDialog problemTypeSelectorDialog;
41    public BenchmarkView() {
42      InitializeComponent();
43      tabControl.TabPages.Remove(this.problemTabPage);
44      tabControl.TabPages.Remove(this.parametersTabPage);
45    }
46
47    //public new IAlgorithm Content {
48    //  get { return (IAlgorithm)base.Content; }
49    //  set { base.Content = value; }
50    //}
51
52    //protected override void Dispose(bool disposing) {
53    //  if (disposing) {
54    //    if (problemTypeSelectorDialog != null) problemTypeSelectorDialog.Dispose();
55    //    if (components != null) components.Dispose();
56    //  }
57    //  base.Dispose(disposing);
58    //}
59
60    //protected override void OnInitialized(EventArgs e) {
61    //  // Set order of tab pages according to z order.
62    //  // NOTE: This is required due to a bug in the VS designer.
63    //  List<Control> tabPages = new List<Control>();
64    //  for (int i = 0; i < tabControl.Controls.Count; i++) {
65    //    tabPages.Add(tabControl.Controls[i]);
66    //  }
67    //  tabControl.Controls.Clear();
68    //  foreach (Control control in tabPages)
69    //    tabControl.Controls.Add(control);
70
71    //  base.OnInitialized(e);
72    //}
73
74    //protected override void DeregisterContentEvents() {
75    //  Content.ProblemChanged -= new EventHandler(Content_ProblemChanged);
76    //  Content.StoreAlgorithmInEachRunChanged -= new EventHandler(Content_StoreAlgorithmInEachRunChanged);
77    //  base.DeregisterContentEvents();
78    //}
79    //protected override void RegisterContentEvents() {
80    //  base.RegisterContentEvents();
81    //  Content.ProblemChanged += new EventHandler(Content_ProblemChanged);
82    //  Content.StoreAlgorithmInEachRunChanged += new EventHandler(Content_StoreAlgorithmInEachRunChanged);
83    //}
84
85    //protected override void OnContentChanged() {
86    //  base.OnContentChanged();
87    //  if (Content == null) {
88    //    parameterCollectionView.Content = null;
89    //    problemViewHost.Content = null;
90    //    resultsView.Content = null;
91    //    runsView.Content = null;
92    //    storeAlgorithmInEachRunCheckBox.Checked = true;
93    //  } else {
94    //    parameterCollectionView.Content = Content.Parameters;
95    //    problemViewHost.ViewType = null;
96    //    problemViewHost.Content = Content.Problem;
97    //    resultsView.Content = Content.Results.AsReadOnly();
98    //    runsView.Content = Content.Runs;
99    //    storeAlgorithmInEachRunCheckBox.Checked = Content.StoreAlgorithmInEachRun;
100    //  }
101    //}
102
103    //protected override void SetEnabledStateOfControls() {
104    //  base.SetEnabledStateOfControls();
105    //  parameterCollectionView.Enabled = Content != null;
106    //  newProblemButton.Enabled = Content != null && !ReadOnly;
107    //  openProblemButton.Enabled = Content != null && !ReadOnly;
108    //  problemViewHost.Enabled = Content != null;
109    //  resultsView.Enabled = Content != null;
110    //  runsView.Enabled = Content != null;
111    //  storeAlgorithmInEachRunCheckBox.Enabled = Content != null && !ReadOnly;
112    //}
113
114    //protected override void OnClosed(FormClosedEventArgs e) {
115    //  if ((Content != null) && (Content.ExecutionState == ExecutionState.Started)) {
116    //    //The content must be stopped if no other view showing the content is available
117    //    var optimizers = MainFormManager.MainForm.Views.OfType<IContentView>().Where(v => v != this).Select(v => v.Content).OfType<IOptimizer>();
118    //    if (!optimizers.Contains(Content)) {
119    //      var nestedOptimizers = optimizers.SelectMany(opt => opt.NestedOptimizers);
120    //      if (!nestedOptimizers.Contains(Content)) Content.Stop();
121    //    }
122    //  }
123    //  base.OnClosed(e);
124    //}
125
126    //#region Content Events
127    //protected override void Content_Prepared(object sender, EventArgs e) {
128    //  if (InvokeRequired)
129    //    Invoke(new EventHandler(Content_Prepared), sender, e);
130    //  else {
131    //    base.Content_Prepared(sender, e);
132    //    resultsView.Content = Content.Results.AsReadOnly();
133    //  }
134    //}
135
136    //protected virtual void Content_ProblemChanged(object sender, EventArgs e) {
137    //  if (InvokeRequired)
138    //    Invoke(new EventHandler(Content_ProblemChanged), sender, e);
139    //  else {
140    //    problemViewHost.ViewType = null;
141    //    problemViewHost.Content = Content.Problem;
142    //  }
143    //}
144    //protected virtual void Content_StoreAlgorithmInEachRunChanged(object sender, EventArgs e) {
145    //  if (InvokeRequired)
146    //    Invoke(new EventHandler(Content_StoreAlgorithmInEachRunChanged), sender, e);
147    //  else
148    //    storeAlgorithmInEachRunCheckBox.Checked = Content.StoreAlgorithmInEachRun;
149    //}
150    //#endregion
151
152    //#region Control Events
153    //protected virtual void newProblemButton_Click(object sender, EventArgs e) {
154    //  if (problemTypeSelectorDialog == null) {
155    //    problemTypeSelectorDialog = new TypeSelectorDialog();
156    //    problemTypeSelectorDialog.Caption = "Select Problem";
157    //    problemTypeSelectorDialog.TypeSelector.Caption = "Available Problems";
158    //    problemTypeSelectorDialog.TypeSelector.Configure(Content.ProblemType, false, true);
159    //  }
160    //  if (problemTypeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
161    //    try {
162    //      Content.Problem = (IProblem)problemTypeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType();
163    //    }
164    //    catch (Exception ex) {
165    //      ErrorHandling.ShowErrorDialog(this, ex);
166    //    }
167    //  }
168    //}
169    //protected virtual void openProblemButton_Click(object sender, EventArgs e) {
170    //  openFileDialog.Title = "Open Problem";
171    //  if (openFileDialog.ShowDialog(this) == DialogResult.OK) {
172    //    newProblemButton.Enabled = openProblemButton.Enabled = false;
173    //    problemViewHost.Enabled = false;
174
175    //    ContentManager.LoadAsync(openFileDialog.FileName, delegate(IStorableContent content, Exception error) {
176    //      try {
177    //        if (error != null) throw error;
178    //        IProblem problem = content as IProblem;
179    //        if (problem == null)
180    //          Invoke(new Action(() =>
181    //            MessageBox.Show(this, "The selected file does not contain a problem.", "Invalid File", MessageBoxButtons.OK, MessageBoxIcon.Error)));
182    //        else if (!Content.ProblemType.IsInstanceOfType(problem))
183    //          Invoke(new Action(() =>
184    //            MessageBox.Show(this, "The selected file contains a problem type which is not supported by this algorithm.", "Invalid Problem Type", MessageBoxButtons.OK, MessageBoxIcon.Error)));
185    //        else
186    //          Content.Problem = problem;
187    //      }
188    //      catch (Exception ex) {
189    //        Invoke(new Action(() => ErrorHandling.ShowErrorDialog(this, ex)));
190    //      }
191    //      finally {
192    //        Invoke(new Action(delegate() {
193    //          problemViewHost.Enabled = true;
194    //          newProblemButton.Enabled = openProblemButton.Enabled = true;
195    //        }));
196    //      }
197    //    });
198    //  }
199    //}
200    //protected virtual void storeAlgorithmInEachRunCheckBox_CheckedChanged(object sender, EventArgs e) {
201    //  if (Content != null) Content.StoreAlgorithmInEachRun = storeAlgorithmInEachRunCheckBox.Checked;
202    //}
203    //protected virtual void problemTabPage_DragEnterOver(object sender, DragEventArgs e) {
204    //  e.Effect = DragDropEffects.None;
205    //  if (!ReadOnly && (e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) != null) && Content.ProblemType.IsAssignableFrom(e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat).GetType())) {
206    //    if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
207    //    else if ((e.KeyState & 4) == 4) e.Effect = DragDropEffects.Move;  // SHIFT key
208    //    else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
209    //    else if (e.AllowedEffect.HasFlag(DragDropEffects.Move)) e.Effect = DragDropEffects.Move;
210    //    else if (e.AllowedEffect.HasFlag(DragDropEffects.Link)) e.Effect = DragDropEffects.Link;
211    //  }
212    //}
213    //protected virtual void problemTabPage_DragDrop(object sender, DragEventArgs e) {
214    //  if (e.Effect != DragDropEffects.None) {
215    //    IProblem problem = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as IProblem;
216    //    if (e.Effect.HasFlag(DragDropEffects.Copy)) problem = (IProblem)problem.Clone();
217    //    Content.Problem = problem;
218    //  }
219    //}
220    //#endregion
221  }
222}
Note: See TracBrowser for help on using the repository browser.