Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/FeatureCorrelationTimeframeCache.cs @ 8578

Last change on this file since 8578 was 8578, checked in by sforsten, 12 years ago

#1292:

  • added ProblemDataView which has a button to open the feature correlation
  • added abstract base class for feature correlations
  • added caches for the feature correlation
  • created own class for calculation of feature correlation
  • changed SelectedItemChanged to SelectionChangeCommitted events, so the correlation is only calculated if the user changes the selection
File size: 2.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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
21#endregion
22
23using System;
24using System.Collections.Generic;
25using HeuristicLab.PluginInfrastructure;
26using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;
27
28namespace HeuristicLab.Problems.DataAnalysis.Views {
29  [NonDiscoverableType]
30  internal class FeatureCorrelationTimeframeCache : Object {
31    private Dictionary<FCE.CorrelationCalculators, Dictionary<FCE.Partitions, Dictionary<string, double[,]>>> timeFrameCorrelationsCache;
32
33    public FeatureCorrelationTimeframeCache()
34      : base() {
35      InitializeCaches();
36    }
37
38    private void InitializeCaches() {
39      timeFrameCorrelationsCache = new Dictionary<FCE.CorrelationCalculators, Dictionary<FCE.Partitions, Dictionary<string, double[,]>>>();
40      foreach (var calc in FCE.EnumToList<FCE.CorrelationCalculators>()) {
41        timeFrameCorrelationsCache.Add(calc, new Dictionary<FCE.Partitions, Dictionary<string, double[,]>>());
42        foreach (var part in FCE.EnumToList<FCE.Partitions>()) {
43          timeFrameCorrelationsCache[calc].Add(part, new Dictionary<string, double[,]>());
44        }
45      }
46    }
47
48    public void Reset() {
49      InitializeCaches();
50    }
51
52    public double[,] GetTimeframeCorrelation(FCE.CorrelationCalculators calc, FCE.Partitions partition, string variable) {
53      double[,] corr;
54      timeFrameCorrelationsCache[calc][partition].TryGetValue(variable, out corr);
55      return corr;
56    }
57
58    public void SetTimeframeCorrelation(FCE.CorrelationCalculators calc, FCE.Partitions partition, string variable, double[,] correlation) {
59      timeFrameCorrelationsCache[calc][partition][variable] = correlation;
60    }
61  }
62}
Note: See TracBrowser for help on using the repository browser.