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 |
|
---|
22 | using HeuristicLab.Common;
|
---|
23 | using HeuristicLab.Core;
|
---|
24 | using HeuristicLab.Data;
|
---|
25 | using HeuristicLab.Parameters;
|
---|
26 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
27 | using HEAL.Attic;
|
---|
28 |
|
---|
29 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic {
|
---|
30 | [Item("Offspring Selection Sliding Window GP Analyzer", "Analyzer which moves a sliding window whenever the selection pressure exceeds a certain threshold.")]
|
---|
31 | [StorableType("A6424928-C98C-4166-9ABD-29934B2A0853")]
|
---|
32 | public class OffspringSelectionSlidingWindowAnalyzer : SlidingWindowAnalyzer {
|
---|
33 | private const string SelectionPressureParameterName = "SelectionPressure";
|
---|
34 | private const string SelectionPressureThresholdParameterName = "SelectionPressureThreshold";
|
---|
35 |
|
---|
36 | #region parameter properties
|
---|
37 | public ILookupParameter<DoubleValue> SelectionPressureParameter {
|
---|
38 | get { return (ILookupParameter<DoubleValue>)Parameters[SelectionPressureParameterName]; }
|
---|
39 | }
|
---|
40 | public IFixedValueParameter<DoubleValue> SelectionPressureThresholdParameter {
|
---|
41 | get { return (IFixedValueParameter<DoubleValue>)Parameters[SelectionPressureThresholdParameterName]; }
|
---|
42 | }
|
---|
43 | #endregion
|
---|
44 |
|
---|
45 | #region properties
|
---|
46 | public DoubleValue SelectionPressureThreshold {
|
---|
47 | get { return SelectionPressureThresholdParameter.Value; }
|
---|
48 | }
|
---|
49 | #endregion
|
---|
50 |
|
---|
51 |
|
---|
52 | [StorableConstructor]
|
---|
53 | protected OffspringSelectionSlidingWindowAnalyzer(StorableConstructorFlag _) : base(_) { }
|
---|
54 | protected OffspringSelectionSlidingWindowAnalyzer(OffspringSelectionSlidingWindowAnalyzer original, Cloner cloner) : base(original, cloner) { }
|
---|
55 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
56 | return new OffspringSelectionSlidingWindowAnalyzer(this, cloner);
|
---|
57 | }
|
---|
58 |
|
---|
59 | public OffspringSelectionSlidingWindowAnalyzer() {
|
---|
60 | Parameters.Add(new LookupParameter<DoubleValue>(SelectionPressureParameterName, ""));
|
---|
61 | Parameters.Add(new FixedValueParameter<DoubleValue>(SelectionPressureThresholdParameterName, "", new DoubleValue(20)));
|
---|
62 | }
|
---|
63 |
|
---|
64 | protected override bool CheckForUpdate() {
|
---|
65 | var currentSelectionPressure = SelectionPressureParameter.ActualValue.Value;
|
---|
66 | var selectionPressureThreshold = SelectionPressureThresholdParameter.Value.Value;
|
---|
67 |
|
---|
68 | return selectionPressureThreshold <= currentSelectionPressure;
|
---|
69 | }
|
---|
70 |
|
---|
71 | }
|
---|
72 | }
|
---|