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 |
|
---|
21 | #endregion
|
---|
22 |
|
---|
23 | using System;
|
---|
24 | using System.Collections.Generic;
|
---|
25 | using HeuristicLab.PluginInfrastructure;
|
---|
26 |
|
---|
27 | namespace HeuristicLab.Problems.DataAnalysis.Views {
|
---|
28 | [NonDiscoverableType]
|
---|
29 | internal class FeatureCorrelationTimeframeCache : Object {
|
---|
30 | private Dictionary<FeatureCorrelationEnums.CorrelationCalculators, Dictionary<FeatureCorrelationEnums.Partitions, Dictionary<string, double[,]>>> timeFrameCorrelationsCache;
|
---|
31 |
|
---|
32 | public FeatureCorrelationTimeframeCache()
|
---|
33 | : base() {
|
---|
34 | InitializeCaches();
|
---|
35 | }
|
---|
36 |
|
---|
37 | private void InitializeCaches() {
|
---|
38 | timeFrameCorrelationsCache = new Dictionary<FeatureCorrelationEnums.CorrelationCalculators, Dictionary<FeatureCorrelationEnums.Partitions, Dictionary<string, double[,]>>>();
|
---|
39 | foreach (var calc in FeatureCorrelationEnums.EnumToList<FeatureCorrelationEnums.CorrelationCalculators>()) {
|
---|
40 | timeFrameCorrelationsCache.Add(calc, new Dictionary<FeatureCorrelationEnums.Partitions, Dictionary<string, double[,]>>());
|
---|
41 | foreach (var part in FeatureCorrelationEnums.EnumToList<FeatureCorrelationEnums.Partitions>()) {
|
---|
42 | timeFrameCorrelationsCache[calc].Add(part, new Dictionary<string, double[,]>());
|
---|
43 | }
|
---|
44 | }
|
---|
45 | }
|
---|
46 |
|
---|
47 | public void Reset() {
|
---|
48 | InitializeCaches();
|
---|
49 | }
|
---|
50 |
|
---|
51 | public double[,] GetTimeframeCorrelation(FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitions partition, string variable) {
|
---|
52 | double[,] corr;
|
---|
53 | timeFrameCorrelationsCache[calc][partition].TryGetValue(variable, out corr);
|
---|
54 | return corr;
|
---|
55 | }
|
---|
56 |
|
---|
57 | public void SetTimeframeCorrelation(FeatureCorrelationEnums.CorrelationCalculators calc, FeatureCorrelationEnums.Partitions partition, string variable, double[,] correlation) {
|
---|
58 | timeFrameCorrelationsCache[calc][partition][variable] = correlation;
|
---|
59 | }
|
---|
60 | }
|
---|
61 | }
|
---|