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 FeatureCorrelationCache : Object {
|
---|
31 | private Dictionary<FCE.CorrelationCalculators, Dictionary<FCE.Partitions, double[,]>> correlationsCache;
|
---|
32 |
|
---|
33 | public FeatureCorrelationCache()
|
---|
34 | : base() {
|
---|
35 | InitializeCaches();
|
---|
36 | }
|
---|
37 |
|
---|
38 | private void InitializeCaches() {
|
---|
39 | correlationsCache = new Dictionary<FCE.CorrelationCalculators, Dictionary<FCE.Partitions, double[,]>>();
|
---|
40 | foreach (var calc in FCE.EnumToList<FCE.CorrelationCalculators>()) {
|
---|
41 | correlationsCache.Add(calc, new Dictionary<FCE.Partitions, double[,]>());
|
---|
42 | }
|
---|
43 | }
|
---|
44 |
|
---|
45 | public void Reset() {
|
---|
46 | InitializeCaches();
|
---|
47 | }
|
---|
48 |
|
---|
49 | public double[,] GetCorrelation(FCE.CorrelationCalculators calc, FCE.Partitions partition) {
|
---|
50 | double[,] corr;
|
---|
51 | correlationsCache[calc].TryGetValue(partition, out corr);
|
---|
52 | return corr;
|
---|
53 | }
|
---|
54 |
|
---|
55 | public void SetCorrelation(FCE.CorrelationCalculators calc, FCE.Partitions partition, double[,] correlation) {
|
---|
56 | correlationsCache[calc][partition] = correlation;
|
---|
57 | }
|
---|
58 | }
|
---|
59 | }
|
---|