Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3040_VectorBasedGP/HeuristicLab.Problems.DataAnalysis.Views/3.4/MenuItems/ShrinkDataAnalysisRunsMenuItem.cs

Last change on this file was 18212, checked in by pfleck, 3 years ago

#3040

  • Count batch evaluation as number of evaluations for SOP manipulator.
  • Added the functionality to remove duplicate data matrices or similar to duplicated datasets to remove the size of segment optimization experiment runs.
File size: 3.3 KB
Line 
1#region License Information
2
3/* HeuristicLab
4 * Copyright (C) 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
24using System;
25using System.Collections.Generic;
26using System.Linq;
27using System.Threading.Tasks;
28using System.Windows.Forms;
29using HeuristicLab.MainForm;
30using HeuristicLab.Optimization;
31using HeuristicLab.Optimizer;
32using HeuristicLab.Problems.DataAnalysis.Symbolic.SegmentOptimization;
33using MenuItem = HeuristicLab.MainForm.WindowsForms.MenuItem;
34
35namespace HeuristicLab.Problems.DataAnalysis.Views {
36  internal sealed class ShrinkDataAnalysisRunsMenuItem : MenuItem, IOptimizerUserInterfaceItemProvider {
37    public override string Name {
38      get { return "Remove Duplicate Datasets"; }
39    }
40    public override IEnumerable<string> Structure {
41      get { return new string[] { "&Edit", "&Data Analysis" }; }
42    }
43    public override int Position {
44      get { return 5300; }
45    }
46    public override string ToolTipText {
47      get { return "This command shrinks the memory usage of data analysis optimizers by checking and unifying duplicate datasets."; }
48    }
49
50    protected override void OnToolStripItemSet(EventArgs e) {
51      ToolStripItem.Enabled = false;
52    }
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 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 = true;
72      //ToolStripItem.Enabled = runCollection.Any(run => run.Parameters.Any(p => p.Value is IDataAnalysisProblemData));
73    }
74
75    public override async void Execute() {
76      IContentView activeView = (IContentView)MainFormManager.MainForm.ActiveView;
77      var content = activeView.Content;
78      Progress.Show(content, "Removing duplicate datasets.", ProgressMode.Indeterminate);
79     
80      var results = await Task.Run(() => {
81        DatasetUtil.RemoveDuplicateDatasets(content);
82        return SegmentOptimizationProblem.RemoveDuplicateMatrices(content);
83      });
84
85      Progress.Hide(content);
86      MessageBox.Show($"DoubleMatrix-Count:{results.Item1}\nDoubleMatrix-RemovedDuplicates:{results.Item2}\nQualities-Removed:{results.Item3}");
87    }
88  }
89}
Note: See TracBrowser for help on using the repository browser.