1 | #region License Information
|
---|
2 |
|
---|
3 | /* HeuristicLab
|
---|
4 | * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
5 | *
|
---|
6 | * This file is part of HeuristicLab.
|
---|
7 | *
|
---|
8 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
9 | * it under the terms of the GNU General Public License as published by
|
---|
10 | * the Free Software Foundation, either version 3 of the License, or
|
---|
11 | * (at your option) any later version.
|
---|
12 | *
|
---|
13 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | * GNU General Public License for more details.
|
---|
17 | *
|
---|
18 | * You should have received a copy of the GNU General Public License
|
---|
19 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
20 | */
|
---|
21 |
|
---|
22 | #endregion
|
---|
23 |
|
---|
24 | using System;
|
---|
25 | using System.Collections.Generic;
|
---|
26 | using System.Linq;
|
---|
27 | using HeuristicLab.MainForm;
|
---|
28 | using HeuristicLab.Optimization;
|
---|
29 | using HeuristicLab.Optimizer;
|
---|
30 |
|
---|
31 | using MenuItem = HeuristicLab.MainForm.WindowsForms.MenuItem;
|
---|
32 |
|
---|
33 | namespace HeuristicLab.Problems.DataAnalysis.Views {
|
---|
34 | public abstract class OptimizeDataAnalysisRunsMenuItem : MenuItem, IOptimizerUserInterfaceItemProvider {
|
---|
35 | public override string Name {
|
---|
36 | get { return "Optimize Runs"; }
|
---|
37 | }
|
---|
38 | public override IEnumerable<string> Structure {
|
---|
39 | get { return new string[] { "&Data Analysis" }; }
|
---|
40 | }
|
---|
41 | public override int Position {
|
---|
42 | get { return 5400; }
|
---|
43 | }
|
---|
44 | public override string ToolTipText {
|
---|
45 | get {
|
---|
46 | return "This command tries to optimize each run by performing a pruning and a constant optimization step on the solution models.";
|
---|
47 | }
|
---|
48 | }
|
---|
49 | protected override void OnToolStripItemSet(EventArgs e) {
|
---|
50 | ToolStripItem.Enabled = false;
|
---|
51 | }
|
---|
52 | protected RunCollection runCollection;
|
---|
53 |
|
---|
54 | protected override void OnActiveViewChanged(object sender, EventArgs e) {
|
---|
55 | IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView;
|
---|
56 | if (activeView == null) {
|
---|
57 | ToolStripItem.Enabled = false;
|
---|
58 | return;
|
---|
59 | }
|
---|
60 |
|
---|
61 | var content = activeView.Content;
|
---|
62 | runCollection = content as RunCollection;
|
---|
63 | if (runCollection == null && content is IOptimizer)
|
---|
64 | runCollection = ((IOptimizer)content).Runs;
|
---|
65 |
|
---|
66 | if (runCollection == null) {
|
---|
67 | ToolStripItem.Enabled = false;
|
---|
68 | return;
|
---|
69 | }
|
---|
70 |
|
---|
71 | ToolStripItem.Enabled = runCollection.Any(run => run.Results.ContainsKey("Best training solution"));
|
---|
72 | }
|
---|
73 | }
|
---|
74 | }
|
---|