using System.Linq; using HeuristicLab.Common; using HeuristicLab.Core; using HeuristicLab.Data; using HeuristicLab.Operators; using HeuristicLab.Parameters; using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; namespace HeuristicLab.Analysis.FitnessLandscape.Analysis { [Item("InformationAnalysisCalculator", "Performs an information analysis on a quality trail as described in Vassilev et al. (2000) Evol Comput 8:31–60")] [StorableClass] public class InformationAnalysisCalculator : SingleSuccessorOperator { #region Parameter Properties public LookupParameter QualityTrailParameter { get { return (LookupParameter)Parameters["QualityTrail"]; } } public ValueLookupParameter NQuantilesParameter { get { return (ValueLookupParameter)Parameters["NQuantiles"]; } } public ValueLookupParameter ShapeSizeParameter { get { return (ValueLookupParameter) Parameters["ShapeSize"]; } } public LookupParameter InformationStabilityParameter { get { return (LookupParameter)Parameters["InformationStability"]; } } public LookupParameter RegularityParameter { get { return (LookupParameter)Parameters["Regularity"]; } } public LookupParameter DiversityParameter { get { return (LookupParameter)Parameters["Diversity"]; } } public LookupParameter InformationContentParameter { get { return (LookupParameter)Parameters["InformationContent"]; } } public LookupParameter PartialInformationContentParameter { get { return (LookupParameter)Parameters["PartialInformationContent"]; } } public LookupParameter DensityBasinInformationParameter { get { return (LookupParameter)Parameters["DensityBasinInformation"]; } } public LookupParameter TotalEntropyParameter { get { return (LookupParameter)Parameters["TotalEntropy"]; } } public LookupParameter EpsilonQuantilesParameter { get { return (LookupParameter)Parameters["EpsilonQuantiles"]; } } #endregion #region Constructors & Cloning [StorableConstructor] protected InformationAnalysisCalculator(bool deserializing) : base(deserializing) { } public InformationAnalysisCalculator() { Parameters.Add(new LookupParameter("QualityTrail", "Historical quality trail of a walk over a fitness landscape.")); Parameters.Add(new ValueLookupParameter("NQuantiles", "Number of epsilon quantiles to calculate information analysis.")); Parameters.Add(new ValueLookupParameter("ShapeSize", "The number of consecutive slopes to consider as shape.", new IntValue(2))); Parameters.Add(new LookupParameter("InformationStability")); Parameters.Add(new LookupParameter("Regularity")); Parameters.Add(new LookupParameter("Diversity")); Parameters.Add(new LookupParameter("InformationContent")); Parameters.Add(new LookupParameter("PartialInformationContent")); Parameters.Add(new LookupParameter("DensityBasinInformation")); Parameters.Add(new LookupParameter("TotalEntropy")); Parameters.Add(new LookupParameter("EpsilonQuantiles", "Considered values of epsilon, selected as quantiles of actual quality differences")); } protected InformationAnalysisCalculator(InformationAnalysisCalculator original, Cloner cloner) : base(original, cloner) { } public override IDeepCloneable Clone(Cloner cloner) { return new InformationAnalysisCalculator(this, cloner); } #endregion public override IOperation Apply() { var analysis = new InformationAnalysis( QualityTrailParameter.ActualValue.Rows.First().Values, NQuantilesParameter.ActualValue.Value, ShapeSizeParameter.ActualValue.Value); RegularityParameter.ActualValue = new IntValue(analysis.Regularity); DiversityParameter.ActualValue = new IntValue(analysis.Diversity); InformationStabilityParameter.ActualValue = new DoubleValue(analysis.InformationStability); InformationContentParameter.ActualValue = new DoubleArray(analysis.InformationContent.ToArray()); PartialInformationContentParameter.ActualValue = new DoubleArray(analysis.PartialInformationContent.ToArray()); DensityBasinInformationParameter.ActualValue = new DoubleArray(analysis.DensityBasinInformation.ToArray()); TotalEntropyParameter.ActualValue = new DoubleArray(analysis.TotalEntropy.ToArray()); EpsilonQuantilesParameter.ActualValue = new DoubleArray(analysis.QualityDelta.ToArray()); return base.Apply(); } } }