Changeset 16096 for branches/2457_ExpertSystem/HeuristicLab.Analysis.FitnessLandscape/3.3/Analysis/RuggednessAnalyzer.cs
 Timestamp:
 08/29/18 18:16:05 (23 months ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

branches/2457_ExpertSystem/HeuristicLab.Analysis.FitnessLandscape/3.3/Analysis/RuggednessAnalyzer.cs
r13583 r16096 20 20 #endregion 21 21 22 using System.Linq; 22 23 using HeuristicLab.Common; 23 24 using HeuristicLab.Core; … … 27 28 using HeuristicLab.Parameters; 28 29 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 29 using System.Linq;30 30 31 31 namespace HeuristicLab.Analysis.FitnessLandscape { 32 [Item("Ruggedness Analyzer", "Analyzes autocorrelation for one mutation step and correlation length. ")]32 [Item("Ruggedness Analyzer", "Analyzes autocorrelation for one mutation step and correlation length. Correlation length is calculated according to the statistical correlation length defined by Hordijk, W., 1996. A measure of landscapes. Evolutionary computation, 4(4), pp.335360.")] 33 33 [StorableClass] 34 34 public class RuggednessAnalyzer : SingleSuccessorOperator, IQualityTrailAnalyzer { … … 50 50 get { return (LookupParameter<IntValue>)Parameters["CorrelationLength"]; } 51 51 } 52 public ValueLookupParameter<DoubleValue> LimitParameter { 53 get { return (ValueLookupParameter<DoubleValue>)Parameters["Limit"]; } 54 } 52 55 #endregion 53 56 … … 60 63 Parameters.Add(new LookupParameter<DoubleValue>("AutoCorrelation1", "Autocorrelation for one mutation step.")); 61 64 Parameters.Add(new LookupParameter<IntValue>("CorrelationLength", "The correlation length.")); 65 Parameters.Add(new ValueLookupParameter<DoubleValue>("Limit", "The limit for the statistical correlation length, if left empty 2 / sqrt(n), where n = length of walk will be used, as defined by Hordijk 1996.")); 62 66 } 63 67 … … 70 74 if (qualityTrail == null  qualityTrail.Rows.Count <= 0) return base.Apply(); 71 75 var results = ResultsParameter.ActualValue; 76 var limit = LimitParameter.ActualValue?.Value; 72 77 double[] autocorrelationValues; 73 var correlationLength = RuggednessCalculator.CalculateCorrelationLength(qualityTrail.Rows.First().Values.ToArray(), out autocorrelationValues );78 var correlationLength = RuggednessCalculator.CalculateCorrelationLength(qualityTrail.Rows.First().Values.ToArray(), out autocorrelationValues, limit); 74 79 var cl = new IntValue(correlationLength); 75 80 CorrelationLengthParameter.ActualValue = cl; 76 AddOrUpdateResult(results,CorrelationLengthParameter.Name, cl);81 results.AddOrUpdateResult(CorrelationLengthParameter.Name, cl); 77 82 var ac1 = new DoubleValue(autocorrelationValues.Length > 1 ? autocorrelationValues[1] : 0.0); 78 83 AutoCorrelation1Parameter.ActualValue = ac1; 79 AddOrUpdateResult(results,AutoCorrelation1Parameter.Name, ac1);84 results.AddOrUpdateResult(AutoCorrelation1Parameter.Name, ac1); 80 85 return base.Apply(); 81 }82 83 private static void AddOrUpdateResult(ResultCollection results, string name, IItem item, bool clone = false) {84 IResult r;85 if (!results.TryGetValue(name, out r)) {86 results.Add(new Result(name, clone ? (IItem)item.Clone() : item));87 } else r.Value = clone ? (IItem)item.Clone() : item;88 86 } 89 87 }
Note: See TracChangeset
for help on using the changeset viewer.