Free cookie consent management tool by TermsFeed Policy Generator

source: branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/Analysis/InformationAnalysisCalculator.cs @ 10349

Last change on this file since 10349 was 8744, checked in by epitzer, 12 years ago

Improve Information Analyzer #1696

  • Configurable discretized or full quantile analysis
  • Configurable shape size
  • Include peak information values and deltas in results
File size: 4.9 KB
Line 
1using System.Linq;
2using HeuristicLab.Common;
3using HeuristicLab.Core;
4using HeuristicLab.Data;
5using HeuristicLab.Operators;
6using HeuristicLab.Parameters;
7using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
8
9namespace HeuristicLab.Analysis.FitnessLandscape.Analysis {
10  [Item("InformationAnalysisCalculator", "Performs an information analysis on a quality trail as described in Vassilev et al. (2000) Evol Comput 8:31–60")]
11  [StorableClass]
12  public class InformationAnalysisCalculator : SingleSuccessorOperator {
13
14    #region Parameter Properties
15    public LookupParameter<DataTable> QualityTrailParameter {
16      get { return (LookupParameter<DataTable>)Parameters["QualityTrail"]; }
17    }
18    public ValueLookupParameter<IntValue> NQuantilesParameter {
19      get { return (ValueLookupParameter<IntValue>)Parameters["NQuantiles"]; }
20    }
21    public ValueLookupParameter<IntValue> ShapeSizeParameter {
22      get { return (ValueLookupParameter<IntValue>) Parameters["ShapeSize"]; }
23    }
24    public LookupParameter<DoubleValue> InformationStabilityParameter {
25      get { return (LookupParameter<DoubleValue>)Parameters["InformationStability"]; }
26    }
27    public LookupParameter<IntValue> RegularityParameter {
28      get { return (LookupParameter<IntValue>)Parameters["Regularity"]; }
29    }
30    public LookupParameter<IntValue> DiversityParameter {
31      get { return (LookupParameter<IntValue>)Parameters["Diversity"]; }
32    }
33    public LookupParameter<DoubleArray> InformationContentParameter {
34      get { return (LookupParameter<DoubleArray>)Parameters["InformationContent"]; }
35    }
36    public LookupParameter<DoubleArray> PartialInformationContentParameter {
37      get { return (LookupParameter<DoubleArray>)Parameters["PartialInformationContent"]; }
38    }
39    public LookupParameter<DoubleArray> DensityBasinInformationParameter {
40      get { return (LookupParameter<DoubleArray>)Parameters["DensityBasinInformation"]; }
41    }
42    public LookupParameter<DoubleArray> TotalEntropyParameter {
43      get { return (LookupParameter<DoubleArray>)Parameters["TotalEntropy"]; }
44    }
45    public LookupParameter<DoubleArray> EpsilonQuantilesParameter {
46      get { return (LookupParameter<DoubleArray>)Parameters["EpsilonQuantiles"]; }
47    }
48    #endregion
49
50    #region Constructors & Cloning
51    [StorableConstructor]
52    protected InformationAnalysisCalculator(bool deserializing) : base(deserializing) { }
53    public InformationAnalysisCalculator() {
54      Parameters.Add(new LookupParameter<DataTable>("QualityTrail", "Historical quality trail of a walk over a fitness landscape."));
55
56      Parameters.Add(new ValueLookupParameter<IntValue>("NQuantiles", "Number of epsilon quantiles to calculate information analysis."));
57      Parameters.Add(new ValueLookupParameter<IntValue>("ShapeSize", "The number of consecutive slopes to consider as shape.", new IntValue(2)));
58
59      Parameters.Add(new LookupParameter<DoubleValue>("InformationStability"));
60      Parameters.Add(new LookupParameter<IntValue>("Regularity"));
61      Parameters.Add(new LookupParameter<IntValue>("Diversity"));
62      Parameters.Add(new LookupParameter<DoubleArray>("InformationContent"));
63      Parameters.Add(new LookupParameter<DoubleArray>("PartialInformationContent"));
64      Parameters.Add(new LookupParameter<DoubleArray>("DensityBasinInformation"));
65      Parameters.Add(new LookupParameter<DoubleArray>("TotalEntropy"));
66      Parameters.Add(new LookupParameter<DoubleArray>("EpsilonQuantiles", "Considered values of epsilon, selected as quantiles of actual quality differences"));
67    }
68    protected InformationAnalysisCalculator(InformationAnalysisCalculator original, Cloner cloner)
69      : base(original, cloner) {
70    }
71    public override IDeepCloneable Clone(Cloner cloner) {
72      return new InformationAnalysisCalculator(this, cloner);
73    }
74    #endregion
75
76    public override IOperation Apply() {
77      var analysis = new InformationAnalysis(
78        QualityTrailParameter.ActualValue.Rows.First().Values,
79        NQuantilesParameter.ActualValue.Value,
80        ShapeSizeParameter.ActualValue.Value);
81      RegularityParameter.ActualValue = new IntValue(analysis.Regularity);
82      DiversityParameter.ActualValue = new IntValue(analysis.Diversity);
83      InformationStabilityParameter.ActualValue = new DoubleValue(analysis.InformationStability);
84      InformationContentParameter.ActualValue = new DoubleArray(analysis.InformationContent.ToArray());
85      PartialInformationContentParameter.ActualValue = new DoubleArray(analysis.PartialInformationContent.ToArray());
86      DensityBasinInformationParameter.ActualValue = new DoubleArray(analysis.DensityBasinInformation.ToArray());
87      TotalEntropyParameter.ActualValue = new DoubleArray(analysis.TotalEntropy.ToArray());
88      EpsilonQuantilesParameter.ActualValue = new DoubleArray(analysis.QualityDelta.ToArray());
89      return base.Apply();
90    }
91  }
92}
Note: See TracBrowser for help on using the repository browser.