Free cookie consent management tool by TermsFeed Policy Generator

source: branches/Sliding Window GP/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/SlidingWindow/OffspringSelectionSlidingWindowAnalyzer.cs @ 9162

Last change on this file since 9162 was 9162, checked in by mkommend, 11 years ago

#1837: Refactored sliding window analyzers and updated the provided algorithm.

File size: 3.1 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using HeuristicLab.Common;
23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Parameters;
26using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
27
28namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
29  [Item("Offspring Selection Sliding Window GP Analyzer", "Analyzer which moves a sliding window whenever the selection pressure exceeds a certain threshold.")]
30  [StorableClass]
31  public class OffspringSelectionSlidingWindowAnalyzer : SlidingWindowAnalyzer {
32    private const string SelectionPressureParameterName = "SelectionPressure";
33    private const string SelectionPressureThresholdParameterName = "SelectionPressureThreshold";
34
35    #region parameter properties
36    public ILookupParameter<IntValue> SelectionPressureParameter {
37      get { return (ILookupParameter<IntValue>)Parameters[SelectionPressureParameterName]; }
38    }
39    public IFixedValueParameter<IntValue> SelectionPressureThresholdParameter {
40      get { return (IFixedValueParameter<IntValue>)Parameters[SelectionPressureThresholdParameterName]; }
41    }
42    #endregion
43
44    #region properties
45    public IntValue SelectionPressureThreshold {
46      get { return SelectionPressureThresholdParameter.Value; }
47    }
48    #endregion
49
50
51    [StorableConstructor]
52    protected OffspringSelectionSlidingWindowAnalyzer(bool deserializing) : base(deserializing) { }
53    protected OffspringSelectionSlidingWindowAnalyzer(OffspringSelectionSlidingWindowAnalyzer original, Cloner cloner) : base(original, cloner) { }
54    public override IDeepCloneable Clone(Cloner cloner) {
55      return new OffspringSelectionSlidingWindowAnalyzer(this, cloner);
56    }
57
58    public OffspringSelectionSlidingWindowAnalyzer() {
59      Parameters.Add(new LookupParameter<IntValue>(SelectionPressureParameterName, ""));
60      Parameters.Add(new FixedValueParameter<IntValue>(SelectionPressureThresholdParameterName, "", new IntValue(20)));
61    }
62
63    protected override bool CheckForUpdate() {
64      var currentSelectionPressure = SelectionPressureParameter.ActualValue.Value;
65      var selectionPressureThreshold = SelectionPressureThresholdParameter.Value.Value;
66
67      return selectionPressureThreshold <= currentSelectionPressure;
68    }
69
70  }
71}
Note: See TracBrowser for help on using the repository browser.