Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ALPS/HeuristicLab.Algorithms.ALPS/3.3/EldersEmigrator.cs @ 13046

Last change on this file since 13046 was 13046, checked in by pfleck, 9 years ago

#2269

  • Changed the age type from int to double.
  • Changed EldersSelector to make use of a ScopeTreeLookupParameter.
  • Removed unused operators in LayerUpdator.
File size: 3.6 KB
RevLine 
[11585]1#region License Information
2/* HeuristicLab
[12018]3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[11585]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.Operators;
[12092]26using HeuristicLab.Optimization.Operators;
[11585]27using HeuristicLab.Parameters;
28using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
29using HeuristicLab.Selection;
30
31namespace HeuristicLab.Algorithms.ALPS {
32  [Item("EldersEmigrator", "Moves Individuals which are too old for its current layer up to the next layer.")]
33  [StorableClass]
[11586]34  public sealed class EldersEmigrator : AlgorithmOperator {
[11585]35    [StorableConstructor]
36    private EldersEmigrator(bool deserializing)
37      : base(deserializing) { }
38    private EldersEmigrator(EldersEmigrator original, Cloner cloner)
39      : base(original, cloner) { }
40    public override IDeepCloneable Clone(Cloner cloner) {
41      return new EldersEmigrator(this, cloner);
42    }
43    public EldersEmigrator()
44      : base() {
45      var selectorProsessor = new UniformSubScopesProcessor();
46      var eldersSelector = new EldersSelector();
47      var shiftToRightMigrator = new ShiftToRightMigrator();
[12992]48      var mergingProsessor = new UniformSubScopesProcessor();
[11585]49      var mergingReducer = new MergingReducer();
50      var subScopesCounter = new SubScopesCounter();
[12092]51      var countCalculator = new ExpressionCalculator() { Name = "LayerPopulationSize = Min(LayerPopulationSize, PopulationSize)" };
[11585]52      var bestSelector = new BestSelector();
53      var rightReducer = new RightReducer();
54
55
56      OperatorGraph.InitialOperator = selectorProsessor;
57
58      selectorProsessor.Operator = eldersSelector;
59      selectorProsessor.Successor = shiftToRightMigrator;
60
61      eldersSelector.Successor = null;
62
63      shiftToRightMigrator.Successor = mergingProsessor;
64
65      mergingProsessor.Operator = mergingReducer;
66      mergingProsessor.Successor = null;
67
68      mergingReducer.Successor = subScopesCounter;
69
[11676]70      subScopesCounter.ValueParameter.ActualName = "LayerPopulationSize";
[11585]71      subScopesCounter.AccumulateParameter.Value = new BoolValue(false);
72      subScopesCounter.Successor = countCalculator;
73
[12092]74      countCalculator.CollectedValues.Add(new LookupParameter<IntValue>("PopulationSize"));
75      countCalculator.CollectedValues.Add(new LookupParameter<IntValue>("LayerPopulationSize"));
76      countCalculator.ExpressionParameter.Value = new StringValue("LayerPopulationSize PopulationSize LayerPopulationSize PopulationSize < if toint");
77      countCalculator.ExpressionResultParameter.ActualName = "LayerPopulationSize";
[11585]78      countCalculator.Successor = bestSelector;
79
[11676]80      bestSelector.NumberOfSelectedSubScopesParameter.ActualName = "LayerPopulationSize";
[11590]81      bestSelector.CopySelected = new BoolValue(false);
[11585]82      bestSelector.Successor = rightReducer;
83
84      rightReducer.Successor = null;
85    }
86  }
87}
Note: See TracBrowser for help on using the repository browser.