Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3057_DynamicALPS/TestProblems/oesr-alps-master/HeuristicLab.Algorithms.OESRALPS/Analyzers/GenerationalSlidingWindowAnalyzer.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.2 KB
Line 
1using HEAL.Attic;
2using HeuristicLab.Algorithms.OESRALPS.SlidingWindow.Operator;
3using HeuristicLab.Common;
4using HeuristicLab.Core;
5using HeuristicLab.Data;
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("GenerationalSlidingWindowAnalyzer", "Analyzer which moves a sliding window every n-th generation over the training partition.")]
18    [StorableType("3E8EA052-3A86-4610-BA18-E3FE78DAD22F")]
19    public abstract class GenerationalSlidingWindowAnalyzer<T, U> : SlidingWindowAnalyzer<T, U>, IGenerationalSlidingWindowOperator
20        where T : class, ISymbolicDataAnalysisSingleObjectiveEvaluator<U>
21        where U : class, IDataAnalysisProblemData
22    {
23        private const string GenerationsIntervalParameterName = "GenerationInterval";
24        private const string GenerationsIntervalStartParameterName = "GenerationIntervalStart";
25
26        #region parameter properties
27        public IFixedValueParameter<IntValue> GenerationsIntervalParameter {
28            get { return (IFixedValueParameter<IntValue>)Parameters[GenerationsIntervalParameterName]; }
29        }
30        public IFixedValueParameter<IntValue> GenerationsIntervalStartParameter {
31            get { return (IFixedValueParameter<IntValue>)Parameters[GenerationsIntervalStartParameterName]; }
32        }
33        #endregion
34
35        #region properties
36        public IntValue GenerationsInterval { get { return GenerationsIntervalParameter.Value; } }
37        public IntValue GenerationsIntervalStart { get { return GenerationsIntervalStartParameter.Value; } }
38        #endregion
39
40        [StorableConstructor]
41        protected GenerationalSlidingWindowAnalyzer(StorableConstructorFlag _) : base(_) { }
42        protected GenerationalSlidingWindowAnalyzer(GenerationalSlidingWindowAnalyzer<T, U> original, Cloner cloner) : base(original, cloner) { }
43        public GenerationalSlidingWindowAnalyzer()
44          : base()
45        {
46            Parameters.Add(new FixedValueParameter<IntValue>(GenerationsIntervalParameterName, "The number of generations to pass for a window move.", new IntValue(1)));
47            Parameters.Add(new FixedValueParameter<IntValue>(GenerationsIntervalStartParameterName, "The number of generations to pass before the first window move.", new IntValue(0)));
48
49            MinimumIterationsUntilNextMoveParameter.Value = GenerationsIntervalParameter.Value;
50            MinimumIterationsUntilNextMoveParameter.Hidden = true;
51        }
52       
53        public override IOperation Apply()
54        {
55            if (TrainingPartitionParameter.ActualValue == null
56                || IsIterationIntervalPassed())
57                return OnMoveWindow();
58
59            return base.Apply();
60        }
61
62        protected IOperation GetBaseOperation()
63        {
64            return base.Apply();
65        }
66
67        protected bool IsIterationIntervalPassed() {
68            return (IterationsParameter.ActualValue.Value - GenerationsIntervalStart.Value) % GenerationsInterval.Value == 0;
69        }
70    }
71}
Note: See TracBrowser for help on using the repository browser.