Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs @ 13848

Last change on this file since 13848 was 13766, checked in by mkommend, 9 years ago

#2595: First version of impact calculation for regression solution.

File size: 3.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.Linq;
24using System.Threading.Tasks;
25using System.Windows.Forms;
26using HeuristicLab.Core;
27using HeuristicLab.Data;
28using HeuristicLab.Data.Views;
29using HeuristicLab.MainForm;
30using HeuristicLab.MainForm.WindowsForms;
31
32namespace HeuristicLab.Problems.DataAnalysis.Views {
33  [View("RegressionSolution View")]
34  [Content(typeof(RegressionSolutionBase), false)]
35  public partial class RegressionSolutionView : DataAnalysisSolutionView {
36    public RegressionSolutionView() {
37      InitializeComponent();
38    }
39
40    public new RegressionSolutionBase Content {
41      get { return (RegressionSolutionBase)base.Content; }
42      set { base.Content = value; }
43    }
44
45    protected virtual void btnImpactCalculation_Click(object sender, EventArgs e) {
46      var mainForm = (MainForm.WindowsForms.MainForm)MainFormManager.MainForm;
47      var view = new StringConvertibleArrayView();
48      view.Caption = Content.Name + " Variable Impacts";
49      view.Show();
50
51      Task.Factory.StartNew(() => {
52        try {
53          mainForm.AddOperationProgressToView(view, "Calculating variable impacts for " + Content.Name);
54
55          var impacts = RegressionSolutionVariableImpactsCalculator.CalculateImpacts(Content);
56          var impactArray = new DoubleArray(impacts.Select(i => i.Item2).ToArray());
57          impactArray.ElementNames = impacts.Select(i => i.Item1);
58          view.Content = (DoubleArray)impactArray.AsReadOnly();
59        }
60        finally {
61          mainForm.RemoveOperationProgressFromView(view);
62        }
63      });
64    }
65
66    #region drag and drop
67    protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
68      validDragOperation = false;
69      if (ReadOnly) return;
70
71      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
72      if (dropData is IRegressionProblemData) validDragOperation = true;
73      else if (dropData is IRegressionProblem) validDragOperation = true;
74      else if (dropData is IValueParameter) {
75        var param = (IValueParameter)dropData;
76        if (param.Value is RegressionProblemData) validDragOperation = true;
77      }
78    }
79    #endregion
80  }
81}
Note: See TracBrowser for help on using the repository browser.