Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Algorithms.ALPS/3.3/ReseedingController.cs @ 13689

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

#2269 Fixed typos and renamed some stuff suggested by ascheibe and adapted project for mono.

  • The initialization of layer 0 is done similar to other algorithms where general initialization is done in the algorithm itself and variables used and produced during the main-loop is initialized in the main-loop-operator.
  • The GeneralizedRankSelector is used as default selector because it generally works the best (rank compensates the large quality range of multiple layers and high selection pressure via pressure-parameter). Proportional selection performs very badly because the selection pressure is too low for ALPS.
  • Concerning ReduceToPopulationSize in the EldersEmigrator, the behavior it is not completely clear in the original paper. Reducing the population to the population size seems the more logical way, therefore it is default. An empty layer could happen in extremely rare situations, but it never happens to me so far.
  • Concerning opening a new layer, when taking a closer look at the ages, all individual tends to be as old as possible, in the standard version with AgeInheritance==1. That means they usually get too old in exactly after the generation the AgeLimits for the current last layer states. This way it is not necessary to check if any individual becomes too old for the current last layer. For AgeInheritance<1 it can happen that there would actually be no need to open a new layer; however, it will be opened anyway.
File size: 3.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.Operators;
26using HeuristicLab.Parameters;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace HeuristicLab.Algorithms.ALPS {
30  [Item("ReseedingController", "An operator that controls if reseeding is needed.")]
31  [StorableClass]
32  public sealed class ReseedingController : SingleSuccessorOperator {
33    public ILookupParameter<IntValue> GenerationsParameter {
34      get { return (ILookupParameter<IntValue>)Parameters["Generations"]; }
35    }
36    public ILookupParameter<IntValue> AgeGapParameter {
37      get { return (ILookupParameter<IntValue>)Parameters["AgeGap"]; }
38    }
39    public OperatorParameter FirstLayerOperatorParameter {
40      get { return (OperatorParameter)Parameters["FirstLayerOperator"]; }
41    }
42
43    public IOperator FirstLayerOperator {
44      get { return FirstLayerOperatorParameter.Value; }
45      set { FirstLayerOperatorParameter.Value = value; }
46    }
47
48    [StorableConstructor]
49    private ReseedingController(bool deserializing)
50      : base(deserializing) { }
51
52    private ReseedingController(ReseedingController original, Cloner cloner)
53      : base(original, cloner) {
54    }
55    public override IDeepCloneable Clone(Cloner cloner) {
56      return new ReseedingController(this, cloner);
57    }
58
59    public ReseedingController()
60      : base() {
61      Parameters.Add(new LookupParameter<IntValue>("Generations", "The current number of generations."));
62      Parameters.Add(new ValueLookupParameter<IntValue>("AgeGap", "The frequency of reseeding the lowest layer and scaling factor for the age-limits for the layers."));
63      Parameters.Add(new OperatorParameter("FirstLayerOperator", "The operator that is performed on the first layer if reseeding is required."));
64    }
65
66    public override IOperation Apply() {
67      int generations = GenerationsParameter.ActualValue.Value;
68      int ageGap = AgeGapParameter.ActualValue.Value;
69
70      var next = new OperationCollection(base.Apply());
71      if (generations % ageGap == 0) {
72        var layerZeroScope = ExecutionContext.Scope.SubScopes[0];
73        if (FirstLayerOperator != null)
74          next.Insert(0, ExecutionContext.CreateChildOperation(FirstLayerOperator, layerZeroScope));
75      }
76      return next;
77    }
78  }
79}
Note: See TracBrowser for help on using the repository browser.