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