Free cookie consent management tool by TermsFeed Policy Generator

Changeset 8725


Ignore:
Timestamp:
10/03/12 17:13:31 (12 years ago)
Author:
epitzer
Message:

improve information analysis #1696

  • fixed a bug in quality delta filtering
  • report finer-grained results
  • add total entropy
  • add peak values to results
Location:
branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/Analysis
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/Analysis/InformationAnalysis.cs

    r7128 r8725  
    1919    public List<double> PartialInformationContent { get; private set; }
    2020    public List<double> DensityBasinInformation { get; private set; }
     21    public List<double> TotalEntropy { get; private set; }
    2122    public List<double> QualityDelta { get; private set; }
    2223    public double InformationStability { get; private set; }
    2324    public int Regularity { get; private set; }
     25    public int Diversity { get; private set; }
    2426    public Peak PeakInformationContent { get; private set; }
    2527    public Peak PeakPartialInformationContent { get; private set; }
    2628    public Peak PeakDensityBasinInformation { get; private set; }
     29    public Peak PeakTotalEntropy { get; private set; }
    2730
    28     public InformationAnalysis(IEnumerable<double> qualities, int nQuantiles) {
     31    public InformationAnalysis(IList<double> qualities, int nQuantiles) {
    2932      InformationContent = new List<double>();
    3033      PartialInformationContent = new List<double>();
    3134      DensityBasinInformation = new List<double>();
     35      TotalEntropy = new List<double>();
    3236      QualityDelta = new List<double>();
    3337      PerformAnalysis(qualities, nQuantiles);
    3438    }
    3539
    36     private void PerformAnalysis(IEnumerable<double> qualities, int nQuantiles) {
     40    private void PerformAnalysis(IList<double> qualities, int nQuantiles) {
    3741      var differences = Differences(qualities).ToList();
    3842      InformationStability = differences.Select(d => Math.Abs(d)).Max();
    3943      Regularity = new HashSet<double>(differences).Count;
    40       var thresholds = UniqueThresholdCalculator.DetermineThresholds(differences, nQuantiles).ToList();
     44      Diversity = new HashSet<double>(qualities).Count;
     45      //var thresholds = UniqueThresholdCalculator.DetermineThresholds(differences, nQuantiles).ToList();
     46      var thresholds = differences.Select(d => Math.Abs(d)).OrderBy(d => d);
    4147      foreach (var eps in thresholds) {
    4248        var shapes = Shapes(eps, differences).ToList();
    43         int[] shape_counts = CountShapes(shapes);
     49        int[] shapeCounts = CountShapes(shapes);
    4450        QualityDelta.Add(eps);
    45         InformationContent.Add(CalculateInformationContent(shape_counts, shapes.Count));
     51        InformationContent.Add(CalculateInformationContent(shapeCounts, shapes.Count));
    4652        PartialInformationContent.Add(CalculatePartialInformationContent(eps, differences));
    47         DensityBasinInformation.Add(CalculateDensityBasinInformation(shape_counts, shapes.Count));
     53        DensityBasinInformation.Add(CalculateDensityBasinInformation(shapeCounts, shapes.Count));
     54        TotalEntropy.Add(CalculateTotalEntropy(shapeCounts, shapes.Count));
    4855      }
    49       PeakDensityBasinInformation = GetPeak(QualityDelta, InformationContent);
     56      PeakInformationContent = GetPeak(QualityDelta, InformationContent);
     57      PeakDensityBasinInformation = GetPeak(QualityDelta, DensityBasinInformation);
    5058      PeakPartialInformationContent = GetPeak(QualityDelta, PartialInformationContent);
    51       PeakDensityBasinInformation = GetPeak(QualityDelta, DensityBasinInformation);
     59      PeakTotalEntropy = GetPeak(QualityDelta, TotalEntropy);
    5260    }
    5361
     
    7280      return Utils.Delta(differences, (x, y) =>
    7381        (Shape)
    74           ((x >= eps ? 1 : (x <= -eps ? -1 : 0)) +
    75            (y >= eps ? 3 : (y <= -eps ? -3 : 0))));
     82          ((x > eps ? 1 : (x < -eps ? -1 : 0)) +
     83           (y > eps ? 3 : (y < -eps ? -3 : 0))));
    7684    }
    7785
    78     private static double CalculateInformationContent(int[] shape_counts, int total_n_shapes) {
     86    private static double CalculateInformationContent(int[] shapeCounts, int totalNShapes) {
    7987      return
    80         -Entropy(shape_counts[(int)Shape.EquDec + 4], total_n_shapes, 6)
    81         - Entropy(shape_counts[(int)Shape.IncDec + 4], total_n_shapes, 6)
    82         - Entropy(shape_counts[(int)Shape.DecEqu + 4], total_n_shapes, 6)
    83         - Entropy(shape_counts[(int)Shape.IncEqu + 4], total_n_shapes, 6)
    84         - Entropy(shape_counts[(int)Shape.DecInc + 4], total_n_shapes, 6)
    85         - Entropy(shape_counts[(int)Shape.EquInc + 4], total_n_shapes, 6);
     88        -Entropy(shapeCounts[(int)Shape.EquDec + 4], totalNShapes, 6)
     89        - Entropy(shapeCounts[(int)Shape.IncDec + 4], totalNShapes, 6)
     90        - Entropy(shapeCounts[(int)Shape.DecEqu + 4], totalNShapes, 6)
     91        - Entropy(shapeCounts[(int)Shape.IncEqu + 4], totalNShapes, 6)
     92        - Entropy(shapeCounts[(int)Shape.DecInc + 4], totalNShapes, 6)
     93        - Entropy(shapeCounts[(int)Shape.EquInc + 4], totalNShapes, 6);
    8694    }
    8795
    88     private static double CalculateDensityBasinInformation(int[] shape_counts, int total_n_shapes) {
     96    private static double CalculateDensityBasinInformation(int[] shapeCounts, int totalNShapes) {
    8997      return
    90         -Entropy(shape_counts[(int)Shape.DecDec + 4], total_n_shapes, 3)
    91         - Entropy(shape_counts[(int)Shape.EquEqu + 4], total_n_shapes, 3)
    92         - Entropy(shape_counts[(int)Shape.IncInc + 4], total_n_shapes, 3);
     98        -Entropy(shapeCounts[(int)Shape.DecDec + 4], totalNShapes, 3)
     99        - Entropy(shapeCounts[(int)Shape.EquEqu + 4], totalNShapes, 3)
     100        - Entropy(shapeCounts[(int)Shape.IncInc + 4], totalNShapes, 3);
    93101    }
    94102
    95     private static double CalculatePartialInformationContent(double eps, List<double> differences) {
     103    private static double CalculateTotalEntropy(int[] shapeCounts, int totalNShapes) {
     104      return shapeCounts.Aggregate(0.0, (current, t) => current - Entropy(t, totalNShapes, 9));
     105    }
     106
     107    private static double CalculatePartialInformationContent(double eps, ICollection<double> differences) {
    96108      int slope = 0;
    97109      int nPeaks = 0;
    98110      foreach (var d in differences) {
    99         if (d >= eps) {
     111        if (d > eps) {
    100112          if (slope < 0) nPeaks++;
    101113          slope = +1;
    102         } else if (d <= -eps) {
     114        } else if (d < -eps) {
    103115          if (slope > 0) nPeaks++;
    104116          slope = -1;
     
    109121
    110122    private static int[] CountShapes(IEnumerable<Shape> shapes) {
    111       int[] shape_counts = new int[9];
     123      int[] shapeCounts = new int[9];
    112124      foreach (var s in shapes) {
    113         shape_counts[(int)s + 4]++;
     125        shapeCounts[(int)s + 4]++;
    114126      }
    115       return shape_counts;
     127      return shapeCounts;
    116128    }
    117129
    118     private static double Entropy(int count, int total, int n_cases) {
     130    private static double Entropy(int count, int total, int nCases) {
    119131      if (count == 0)
    120132        return 0;
    121133      double freq = 1.0 * count / total;
    122       return freq * Math.Log(freq, n_cases);
     134      return freq * Math.Log(freq, nCases);
    123135    }
    124136
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/Analysis/InformationAnalysisCalculator.cs

    r7128 r8725  
    2525      get { return (LookupParameter<IntValue>)Parameters["Regularity"]; }
    2626    }
     27    public LookupParameter<IntValue> DiversityParameter {
     28      get { return (LookupParameter<IntValue>)Parameters["Diversity"]; }
     29    }
    2730    public LookupParameter<DoubleArray> InformationContentParameter {
    2831      get { return (LookupParameter<DoubleArray>)Parameters["InformationContent"]; }
     
    3437      get { return (LookupParameter<DoubleArray>)Parameters["DensityBasinInformation"]; }
    3538    }
     39    public LookupParameter<DoubleArray> TotalEntropyParameter {
     40      get { return (LookupParameter<DoubleArray>)Parameters["TotalEntropy"]; }
     41    }
    3642    public LookupParameter<DoubleArray> EpsilonQuantilesParameter {
    3743      get { return (LookupParameter<DoubleArray>)Parameters["EpsilonQuantiles"]; }
     
    4248    [StorableConstructor]
    4349    protected InformationAnalysisCalculator(bool deserializing) : base(deserializing) { }
    44     public InformationAnalysisCalculator()
    45       : base() {
     50    public InformationAnalysisCalculator() {
    4651      Parameters.Add(new LookupParameter<DataTable>("QualityTrail", "Historical quality trail of a walk over a fitness landscape."));
    4752      Parameters.Add(new ValueLookupParameter<IntValue>("NQuantiles", "Number of epsilon quantiles to calculate information analysis."));
    4853      Parameters.Add(new LookupParameter<DoubleValue>("InformationStability"));
    4954      Parameters.Add(new LookupParameter<IntValue>("Regularity"));
     55      Parameters.Add(new LookupParameter<IntValue>("Diversity"));
    5056      Parameters.Add(new LookupParameter<DoubleArray>("InformationContent"));
    5157      Parameters.Add(new LookupParameter<DoubleArray>("PartialInformationContent"));
    5258      Parameters.Add(new LookupParameter<DoubleArray>("DensityBasinInformation"));
     59      Parameters.Add(new LookupParameter<DoubleArray>("TotalEntropy"));
    5360      Parameters.Add(new LookupParameter<DoubleArray>("EpsilonQuantiles", "Considered values of epsilon, selected as quantiles of actual quality differences"));
    5461    }
     
    6673        NQuantilesParameter.ActualValue.Value);
    6774      RegularityParameter.ActualValue = new IntValue(analysis.Regularity);
     75      DiversityParameter.ActualValue = new IntValue(analysis.Diversity);
    6876      InformationStabilityParameter.ActualValue = new DoubleValue(analysis.InformationStability);
    6977      InformationContentParameter.ActualValue = new DoubleArray(analysis.InformationContent.ToArray());
    7078      PartialInformationContentParameter.ActualValue = new DoubleArray(analysis.PartialInformationContent.ToArray());
    7179      DensityBasinInformationParameter.ActualValue = new DoubleArray(analysis.DensityBasinInformation.ToArray());
     80      TotalEntropyParameter.ActualValue = new DoubleArray(analysis.TotalEntropy.ToArray());
    7281      EpsilonQuantilesParameter.ActualValue = new DoubleArray(analysis.QualityDelta.ToArray());
    7382      return base.Apply();
  • branches/FitnessLandscapeAnalysis/HeuristicLab.Analysis.FitnessLandscape/Analysis/InformationAnalyzer.cs

    r7176 r8725  
    6262      get { return (LookupParameter<DoubleValue>)Parameters["DensityBasinInformationValue"]; }
    6363    }
     64    public LookupParameter<DoubleValue> TotalEntropyValueParameter {
     65      get { return (LookupParameter<DoubleValue>)Parameters["TotalEntropyValue"]; }
     66    }
    6467    public LookupParameter<DoubleValue> InformationStabilityValueParameter {
    6568      get { return (LookupParameter<DoubleValue>)Parameters["InformationStabilityValue"]; }
     
    6871      get { return (LookupParameter<IntValue>)Parameters["RegularityValue"]; }
    6972    }
     73    public LookupParameter<IntValue> DiversityValueParameter {
     74      get { return (LookupParameter<IntValue>)Parameters["DiversityValue"]; }
     75    }
     76
     77    #region Peaks
     78    public LookupParameter<DoubleValue> PeakInformationContentParameter {
     79      get { return (LookupParameter<DoubleValue>) Parameters["PeakInformationContent"]; }
     80    }
     81    public LookupParameter<DoubleValue> PeakInformationContentQualityDeltaParameter {
     82      get { return (LookupParameter<DoubleValue>) Parameters["PeakInformationContentQualityDelta"]; }
     83    }
     84    public LookupParameter<DoubleValue> PeakDensityBasinInformationParameter {
     85      get { return (LookupParameter<DoubleValue>) Parameters["PeakDensityBasinInformation"]; }
     86    }
     87    public LookupParameter<DoubleValue> PeakDensityBasinInformationQualityDeltaParameter {
     88      get { return (LookupParameter<DoubleValue>) Parameters["PeakDensityBasinInformationQualityDelta"]; }
     89    }
     90
     91
     92    #endregion
     93
    7094    #endregion
    7195
     
    82106      set { DensityBasinInformationValueParameter.ActualValue = new DoubleValue(value); }
    83107    }
     108    private double TotalEntropyValue {
     109      set { TotalEntropyValueParameter.ActualValue = new DoubleValue(value); }
     110    }
    84111    private double InformationStabilityValue {
    85112      set { InformationStabilityValueParameter.ActualValue = new DoubleValue(value); }
    86113    }
    87 
    88114
    89115    [StorableConstructor]
     
    100126      Parameters.Add(new LookupParameter<DoubleValue>("PartialInformationContentValue", "Partial information content M(0) at eps = 0"));
    101127      Parameters.Add(new LookupParameter<DoubleValue>("DensityBasinInformationValue", "Density Basin Information h(0) at eps = 0"));
     128      Parameters.Add(new LookupParameter<DoubleValue>("TotalEntropyValue", "The overall disorder in the trajectory"));
    102129      Parameters.Add(new LookupParameter<DoubleValue>("InformationStabilityValue", "Information Stability Value"));
    103130      Parameters.Add(new LookupParameter<IntValue>("RegularityValue", "The number of different quality differences"));
     131      Parameters.Add(new LookupParameter<IntValue>("DiversityValue", "The number of different quality values"));
     132      Parameters.Add(new LookupParameter<DoubleValue>("PeakInformationContent", "Maximum information content at any quality delta."));
     133      Parameters.Add(new LookupParameter<DoubleValue>("PeakInformationContentQualityDelta", "Quality delta with maximum information content."));
     134      Parameters.Add(new LookupParameter<DoubleValue>("PeakDensityBasinInformation", "Maximum density basin information at any quality delta."));
     135      Parameters.Add(new LookupParameter<DoubleValue>("PeakDensityBasinInformationQualityDelta", "Quality delta with maximum density basin information."));
    104136
    105137      var resultsCollector = new ResultsCollector();
     
    109141      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>(PartialInformationContentValueParameter.Name));
    110142      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>(DensityBasinInformationValueParameter.Name));
     143      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>(TotalEntropyValueParameter.Name));
    111144      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>(InformationStabilityValueParameter.Name));
    112145      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>(RegularityValueParameter.Name));
    113 
     146      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>(DiversityValueParameter.Name));
     147      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>(PeakInformationContentParameter.Name));
     148      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>(PeakInformationContentQualityDeltaParameter.Name));
     149      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>(PeakDensityBasinInformationParameter.Name));
     150      resultsCollector.CollectedValues.Add(new LookupParameter<DoubleValue>(PeakDensityBasinInformationQualityDeltaParameter.Name));
    114151
    115152      OperatorGraph.InitialOperator = resultsCollector;
     
    139176        var partialInformationContent = informationTable.Rows["Partial Information Content"].Values;
    140177        var densityBasinInformation = informationTable.Rows["Density Basin Information"].Values;
     178        var totalEntropy = informationTable.Rows["Total Entropy"].Values;
    141179        var qualityDelta = informationTable.Rows["Quality Delta"].Values;
    142180        var analysis = new InformationAnalysis(qualities, nQuantiles);
    143181        InformationStability.Rows["Regularity"].Values.Add(analysis.Regularity);
     182        InformationStability.Rows["Diversity"].Values.Add(analysis.Diversity);
    144183        InformationStability.Rows["Relative Regularity"].Values.Add(1.0 * analysis.Regularity / qualities.Count);
     184        InformationStability.Rows["Relative Diversity"].Values.Add(1.0 * analysis.Diversity / qualities.Count);
    145185        InformationStability.Rows["Information Stability"].Values.Add(analysis.InformationStability);
    146186        informationContent.Clear();
     
    150190        densityBasinInformation.Clear();
    151191        densityBasinInformation.AddRange(analysis.DensityBasinInformation);
     192        totalEntropy.Clear();
     193        totalEntropy.AddRange(analysis.TotalEntropy);
    152194        qualityDelta.Clear();
    153195        qualityDelta.AddRange(analysis.QualityDelta);
     
    157199        InformationStabilityValue = analysis.InformationStability;
    158200        RegularityValueParameter.ActualValue = new IntValue(analysis.Regularity);
     201        DiversityValueParameter.ActualValue = new IntValue(analysis.Diversity);
     202        PeakInformationContentParameter.ActualValue = new DoubleValue(analysis.PeakInformationContent.Value);
     203        PeakDensityBasinInformationParameter.ActualValue = new DoubleValue(analysis.PeakDensityBasinInformation.Value);
     204        PeakInformationContentQualityDeltaParameter.ActualValue = new DoubleValue(analysis.PeakInformationContent.QualityDelta);
     205        PeakDensityBasinInformationQualityDeltaParameter.ActualValue = new DoubleValue(analysis.PeakDensityBasinInformation.QualityDelta);
    159206      }
    160207    }
     
    167214        information.Rows.Add(new DataRow("Partial Information Content"));
    168215        information.Rows.Add(new DataRow("Density Basin Information"));
    169         var row = new DataRow("Quality Delta");
    170         row.VisualProperties.SecondYAxis = true;
    171         information.Rows.Add(row);
     216        information.Rows.Add(new DataRow("Total Entropy"));
     217        information.Rows.Add(new DataRow("Quality Delta") {VisualProperties = {SecondYAxis = true}});
    172218        InformationParameter.ActualValue = information;
    173219      }
     
    180226        informationStability.Rows.Add(new DataRow("Information Stability"));
    181227        informationStability.Rows.Add(new DataRow("Relative Regularity"));
    182         var row = new DataRow("Regularity");
    183         row.VisualProperties.SecondYAxis = true;
    184         informationStability.Rows.Add(row);
     228        informationStability.Rows.Add(new DataRow("Relative Diversity"));
     229        informationStability.Rows.Add(new DataRow("Regularity") {VisualProperties = {SecondYAxis = true}});
     230        informationStability.Rows.Add(new DataRow("Diversity") {VisualProperties = {SecondYAxis = true}});
    185231        InformationStabilityParameter.ActualValue = informationStability;
    186232      }
Note: See TracChangeset for help on using the changeset viewer.