Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3057_DynamicALPS/TestProblems/oesr-alps-master/HeuristicLab.Algorithms.OESRALPS/Analyzers/OffspringSelectionSlidingWindowAnalyzer.cs @ 17479

Last change on this file since 17479 was 17479, checked in by kyang, 4 years ago

#3057

  1. upload the latest version of ALPS with SMS-EMOA
  2. upload the related dynamic test problems (dynamic, single-objective symbolic regression), written by David Daninel.
File size: 3.6 KB
Line 
1using HEAL.Attic;
2using HeuristicLab.Common;
3using HeuristicLab.Core;
4using HeuristicLab.Data;
5using HeuristicLab.Optimization;
6using HeuristicLab.Parameters;
7using HeuristicLab.Problems.DataAnalysis;
8using HeuristicLab.Problems.DataAnalysis.Symbolic;
9using System;
10using System.Collections.Generic;
11using System.Linq;
12using System.Text;
13using System.Threading.Tasks;
14
15namespace HeuristicLab.Algorithms.OESRALPS.Analyzers
16{
17    [Item("OffspringSelectionSlidingWindowAnalyzer", "An operator that analyzes the offspring selection pressure and moves a sliding window if the threshold is exceeded.")]
18    [StorableType("75E112AA-95B2-4BA4-8544-CF2025A65822")]
19    public abstract class OffspringSelectionSlidingWindowAnalyzer<T, U> : SlidingWindowAnalyzer<T, U>
20        where T : class, ISymbolicDataAnalysisSingleObjectiveEvaluator<U>
21        where U : class, IDataAnalysisProblemData
22    {
23        private const string SelectionPressureParameterName = "SelectionPressure";
24        private const string SelectionPressureThresholdParameterName = "SelectionPressureThreshold";
25
26        #region parameter properties
27        public IScopeTreeLookupParameter<DoubleValue> SelectionPressureParameter {
28            get { return (IScopeTreeLookupParameter<DoubleValue>)Parameters[SelectionPressureParameterName]; }
29        }
30        public IFixedValueParameter<DoubleValue> SelectionPressureThresholdParameter {
31            get { return (IFixedValueParameter<DoubleValue>)Parameters[SelectionPressureThresholdParameterName]; }
32        }
33        #endregion
34
35        #region properties
36        public DoubleValue SelectionPressureThreshold {
37            get { return SelectionPressureThresholdParameter.Value; }
38        }
39        public ItemArray<DoubleValue> SelectionPressure {
40            get { return SelectionPressureParameter.ActualValue; }
41        }
42        #endregion
43
44        [StorableConstructor]
45        protected OffspringSelectionSlidingWindowAnalyzer(StorableConstructorFlag _) : base(_) { }
46        protected OffspringSelectionSlidingWindowAnalyzer(OffspringSelectionSlidingWindowAnalyzer<T, U> original, Cloner cloner) : base(original, cloner) { }
47        public OffspringSelectionSlidingWindowAnalyzer()
48        {
49            Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>(SelectionPressureParameterName, "Offspring selection pressure."));
50            Parameters.Add(new FixedValueParameter<DoubleValue>(SelectionPressureThresholdParameterName, "Offspring selection pressure threshold.", new DoubleValue(20)));
51        }
52
53        public override IOperation Apply()
54        {
55            if (TrainingPartitionParameter.ActualValue == null
56                || IsSelectionPressureThresholdExceeded())
57                return OnMoveWindow();
58             
59            return base.Apply();
60        }
61
62        private bool IsSelectionPressureThresholdExceeded()
63        {
64            // Selection pressure on each layer higher
65            // TODO consider maximum Selection Pressure
66            var AgeLimits =
67                AgingScheme
68                .Linear
69                .CalculateAgeLimits((int)SelectionPressureThreshold.Value, SelectionPressure.Count());
70
71            // TODO think of a suitable strategy,
72            // leave out first layer or check only last iterations before moving to next layer
73            for (int i = 0; i < SelectionPressure.Count(); i++)
74            {
75                if (SelectionPressure[i].Value > AgeLimits[i])
76                    return true;               
77            }
78
79            return false;   
80        }
81    }
82}
Note: See TracBrowser for help on using the repository browser.