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 |
|
---|
23 | using System;
|
---|
24 | using System.Collections.Generic;
|
---|
25 | using HeuristicLab.PluginInfrastructure;
|
---|
26 | using FCE = HeuristicLab.Problems.DataAnalysis.FeatureCorrelationEnums;
|
---|
27 |
|
---|
28 | namespace 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 | }
|
---|