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
RevLine 
[5829]1#region License Information
2/* HeuristicLab
[12012]3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[5829]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
[13766]22using System;
23using System.Linq;
24using System.Threading.Tasks;
[5829]25using System.Windows.Forms;
[6666]26using HeuristicLab.Core;
[13766]27using HeuristicLab.Data;
28using HeuristicLab.Data.Views;
[5829]29using HeuristicLab.MainForm;
[13766]30using HeuristicLab.MainForm.WindowsForms;
[5829]31
32namespace HeuristicLab.Problems.DataAnalysis.Views {
[5834]33  [View("RegressionSolution View")]
[6652]34  [Content(typeof(RegressionSolutionBase), false)]
[5829]35  public partial class RegressionSolutionView : DataAnalysisSolutionView {
36    public RegressionSolutionView() {
37      InitializeComponent();
38    }
39
[6597]40    public new RegressionSolutionBase Content {
41      get { return (RegressionSolutionBase)base.Content; }
[5829]42      set { base.Content = value; }
43    }
[6653]44
[13766]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
[6653]66    #region drag and drop
67    protected override void itemsListView_DragEnter(object sender, DragEventArgs e) {
68      validDragOperation = false;
[6666]69      if (ReadOnly) return;
70
71      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
[10173]72      if (dropData is IRegressionProblemData) validDragOperation = true;
73      else if (dropData is IRegressionProblem) validDragOperation = true;
[6666]74      else if (dropData is IValueParameter) {
75        var param = (IValueParameter)dropData;
76        if (param.Value is RegressionProblemData) validDragOperation = true;
[6653]77      }
78    }
79    #endregion
[5829]80  }
81}
Note: See TracBrowser for help on using the repository browser.