[5144] | 1 | using System;
|
---|
| 2 | using System.Linq;
|
---|
[5654] | 3 | using System.Windows.Forms;
|
---|
[6017] | 4 | using HeuristicLab.Common;
|
---|
[5654] | 5 | using HeuristicLab.Core;
|
---|
[5144] | 6 | using HeuristicLab.MainForm;
|
---|
[5654] | 7 | using HeuristicLab.Optimization;
|
---|
[5144] | 8 | using HeuristicLab.Optimization.Views;
|
---|
[5654] | 9 | using HeuristicLab.PluginInfrastructure;
|
---|
[5144] | 10 |
|
---|
| 11 | namespace HeuristicLab.Problems.MetaOptimization.Views {
|
---|
| 12 | [View("MetaOptimization View")]
|
---|
| 13 | [Content(typeof(MetaOptimizationProblem), IsDefaultView = true)]
|
---|
| 14 | public sealed partial class MetaOptimizationProblemView : ProblemView {
|
---|
| 15 | public new MetaOptimizationProblem Content {
|
---|
| 16 | get { return (MetaOptimizationProblem)base.Content; }
|
---|
| 17 | set { base.Content = value; }
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | public MetaOptimizationProblemView() {
|
---|
| 21 | InitializeComponent();
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | protected override void DeregisterContentEvents() {
|
---|
| 25 | // TODO: Deregister your event handlers here
|
---|
| 26 | base.DeregisterContentEvents();
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | protected override void RegisterContentEvents() {
|
---|
| 30 | base.RegisterContentEvents();
|
---|
| 31 | // TODO: Register your event handlers here
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | #region Event Handlers (Content)
|
---|
| 35 | // TODO: Put event handlers of the content here
|
---|
| 36 | #endregion
|
---|
| 37 |
|
---|
| 38 | protected override void OnContentChanged() {
|
---|
| 39 | base.OnContentChanged();
|
---|
| 40 | if (Content == null) {
|
---|
| 41 | // TODO: Add code when content has been changed and is null
|
---|
| 42 | } else {
|
---|
| 43 | // TODO: Add code when content has been changed and is not null
|
---|
| 44 | }
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | protected override void SetEnabledStateOfControls() {
|
---|
| 48 | base.SetEnabledStateOfControls();
|
---|
| 49 | // TODO: Enable or disable controls based on whether the content is null or the view is set readonly
|
---|
| 50 | }
|
---|
| 51 |
|
---|
| 52 | #region Event Handlers (child controls)
|
---|
| 53 |
|
---|
| 54 | private void createExperimentButton_Click(object sender, EventArgs e) {
|
---|
| 55 | if (Content != null) {
|
---|
[5328] | 56 | long max = 100000;
|
---|
| 57 | long count = Content.ParameterConfigurationTree.GetCombinationCount(max);
|
---|
[5144] | 58 |
|
---|
| 59 | System.Windows.Forms.DialogResult result = System.Windows.Forms.DialogResult.OK;
|
---|
| 60 | if (count > 512) {
|
---|
[5328] | 61 | if (count == max) {
|
---|
| 62 | result = System.Windows.Forms.MessageBox.Show(string.Format("Do you really want to create more than {0}+ optimizers? Be aware that this might take a significant amount of time and memory.", count), "Create Experiment", System.Windows.Forms.MessageBoxButtons.OKCancel);
|
---|
| 63 | } else {
|
---|
| 64 | result = System.Windows.Forms.MessageBox.Show(string.Format("Do you really want to create {0} optimizers? Be aware that this might take a significant amount of time and memory.", count), "Create Experiment", System.Windows.Forms.MessageBoxButtons.OKCancel);
|
---|
| 65 | }
|
---|
[5144] | 66 | }
|
---|
| 67 | if (result == System.Windows.Forms.DialogResult.OK) {
|
---|
[5654] | 68 | CreateExperimentDialog dlg = new CreateExperimentDialog(ApplicationManager.Manager.GetInstances<IEngine>(), typeof(SequentialEngine.SequentialEngine));
|
---|
[5313] | 69 | DialogResult dlgResult = dlg.ShowDialog();
|
---|
| 70 |
|
---|
| 71 | if (dlgResult == DialogResult.OK) {
|
---|
[5654] | 72 | var algorithm = (EngineAlgorithm)Content.Algorithm.Clone();
|
---|
[5313] | 73 | if(Content.Problems.Count > 0) algorithm.Problem = Content.Problems.First();
|
---|
[5654] | 74 | algorithm.Engine = (IEngine)dlg.Engine.Clone();
|
---|
[5313] | 75 | Experiment experiment;
|
---|
| 76 |
|
---|
| 77 | if (dlg.CreateBatchRuns) {
|
---|
| 78 | experiment = Content.ParameterConfigurationTree.GenerateExperiment(algorithm, true, dlg.Repetitions);
|
---|
| 79 | } else {
|
---|
| 80 | experiment = Content.ParameterConfigurationTree.GenerateExperiment(algorithm);
|
---|
| 81 | }
|
---|
| 82 | MainFormManager.MainForm.ShowContent(experiment);
|
---|
[5184] | 83 | }
|
---|
[5144] | 84 | }
|
---|
| 85 | }
|
---|
| 86 | }
|
---|
| 87 |
|
---|
| 88 | #endregion
|
---|
[5313] | 89 |
|
---|
[5654] | 90 | private void parameterCollectionView_DragEnterOver(object sender, System.Windows.Forms.DragEventArgs e) {
|
---|
[5313] | 91 | e.Effect = DragDropEffects.None;
|
---|
[6017] | 92 | var type = e.Data.GetData(Constants.DragDropDataFormat).GetType();
|
---|
| 93 | if (!ReadOnly && (Content.AlgorithmType.ValidTypes.Contains(type))) {
|
---|
| 94 | IAlgorithm algorithm = e.Data.GetData(Constants.DragDropDataFormat) as IAlgorithm;
|
---|
[5337] | 95 | if (algorithm != null && algorithm.Problem == null || Content.ProblemType.ValidTypes.Contains(algorithm.Problem.GetType())) {
|
---|
[5313] | 96 | e.Effect = DragDropEffects.Copy;
|
---|
| 97 | }
|
---|
| 98 | }
|
---|
| 99 | }
|
---|
[5654] | 100 | private void parameterCollectionView_DragDrop(object sender, System.Windows.Forms.DragEventArgs e) {
|
---|
[5313] | 101 | if (e.Effect != DragDropEffects.None) {
|
---|
[6017] | 102 | IAlgorithm algorithm = e.Data.GetData(Constants.DragDropDataFormat) as IAlgorithm;
|
---|
[5313] | 103 | Content.ImportAlgorithm(algorithm);
|
---|
| 104 | }
|
---|
| 105 | }
|
---|
[5144] | 106 | }
|
---|
| 107 | }
|
---|