Changeset 9047
- Timestamp:
- 12/13/12 10:41:22 (12 years ago)
- Location:
- branches/Sliding Window GP
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic
- Property svn:mergeinfo changed
-
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic.Views
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow/OffspringSelectionSlidingWindowAnalyzer.cs
r7849 r9047 23 23 using HeuristicLab.Core; 24 24 using HeuristicLab.Data; 25 using HeuristicLab.Optimization;26 25 using HeuristicLab.Parameters; 27 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 27 29 28 namespace HeuristicLab.Problems.DataAnalysis.Symbolic { 30 [Item(" Generational Sliding Window GP Analyzer", "Analyzer which moves a sliding window every n-th generation over the training partition.")]29 [Item("Offspring Selection Sliding Window GP Analyzer", "Analyzer which moves a sliding window whenever the selection pressure exceeds a certain threshold.")] 31 30 [StorableClass] 32 public class GenerationalSlidingWindowAnalyzer<T> : SlidingWindowAnalyzer<T>, IIterationBasedOperator31 public class OffspringSelectionSlidingWindowAnalyzer<T> : SlidingWindowAnalyzer<T> 33 32 where T : class, IDataAnalysisProblemData { 34 private const string GenerationsIntervalParameterName = "Generation Interval"; 35 private const string GenerationsIntervalStartParameterName = "Generation Interval Start"; 36 private const string IterationsParameterName = "Iterations"; 37 private const string MaximumIterationsParameterName = "Maximum Iterations"; 33 private const string SelectionPressureParameterName = "SelectionPressure"; 34 private const string SelectionPressureThresholdParameterName = "SelectionPressureThreshold"; 38 35 39 36 #region parameter properties 40 public ILookupParameter<IntValue> IterationsParameter {41 get { return (ILookupParameter<IntValue>)Parameters[ IterationsParameterName]; }37 public ILookupParameter<IntValue> SelectionPressureParameter { 38 get { return (ILookupParameter<IntValue>)Parameters[SelectionPressureParameterName]; } 42 39 } 43 public IValueLookupParameter<IntValue> MaximumIterationsParameter { 44 get { return (IValueLookupParameter<IntValue>)Parameters[MaximumIterationsParameterName]; } 45 } 46 public IFixedValueParameter<IntValue> GenerationsIntervalParameter { 47 get { return (IFixedValueParameter<IntValue>)Parameters[GenerationsIntervalParameterName]; } 48 } 49 public IFixedValueParameter<IntValue> GenerationsIntervalStartParameter { 50 get { return (IFixedValueParameter<IntValue>)Parameters[GenerationsIntervalStartParameterName]; } 40 public IFixedValueParameter<IntValue> SelectionPressureThresholdParameter { 41 get { return (IFixedValueParameter<IntValue>)Parameters[SelectionPressureThresholdParameterName]; } 51 42 } 52 43 #endregion 53 44 54 45 #region properties 55 public IntValue GenerationsInterval { 56 get { return GenerationsIntervalParameter.Value; } 57 } 58 public IntValue GenerationsIntervalStart { 59 get { return GenerationsIntervalStartParameter.Value; } 46 public IntValue SelectionPressureThreshold { 47 get { return SelectionPressureThresholdParameter.Value; } 60 48 } 61 49 #endregion … … 63 51 64 52 [StorableConstructor] 65 protected GenerationalSlidingWindowAnalyzer(bool deserializing) : base(deserializing) { }66 protected GenerationalSlidingWindowAnalyzer(GenerationalSlidingWindowAnalyzer<T> original, Cloner cloner) : base(original, cloner) { }53 protected OffspringSelectionSlidingWindowAnalyzer(bool deserializing) : base(deserializing) { } 54 protected OffspringSelectionSlidingWindowAnalyzer(OffspringSelectionSlidingWindowAnalyzer<T> original, Cloner cloner) : base(original, cloner) { } 67 55 public override IDeepCloneable Clone(Cloner cloner) { 68 return new GenerationalSlidingWindowAnalyzer<T>(this, cloner);56 return new OffspringSelectionSlidingWindowAnalyzer<T>(this, cloner); 69 57 } 70 58 71 public GenerationalSlidingWindowAnalyzer() { 72 Parameters.Add(new LookupParameter<IntValue>(IterationsParameterName, "")); 73 Parameters.Add(new ValueLookupParameter<IntValue>(MaximumIterationsParameterName, "")); 74 Parameters.Add(new FixedValueParameter<IntValue>(GenerationsIntervalParameterName, "", new IntValue(0))); 75 Parameters.Add(new FixedValueParameter<IntValue>(GenerationsIntervalStartParameterName, "", new IntValue(10))); 59 public OffspringSelectionSlidingWindowAnalyzer() { 60 Parameters.Add(new LookupParameter<IntValue>(SelectionPressureParameterName, "")); 61 Parameters.Add(new FixedValueParameter<IntValue>(SelectionPressureThresholdParameterName, "", new IntValue(20))); 76 62 } 77 63 78 64 protected override bool CheckForUpdate() { 79 var iteration = IterationsParameter.ActualValue.Value; 80 var start = GenerationsIntervalStart.Value; 81 var step = GenerationsInterval.Value; 82 if (iteration < start) return false; 65 var currentSelectionPressure = SelectionPressureParameter.ActualValue.Value; 66 var selectionPressureThreshold = SelectionPressureThresholdParameter.Value.Value; 83 67 84 if ((iteration - start) % step == 0) return true; 85 86 return false; 68 return selectionPressureThreshold <= currentSelectionPressure; 87 69 } 88 70
Note: See TracChangeset
for help on using the changeset viewer.