[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 |
|
---|
| 22 | using HeuristicLab.Common;
|
---|
| 23 | using HeuristicLab.Core;
|
---|
| 24 | using HeuristicLab.Data;
|
---|
| 25 | using HeuristicLab.Operators;
|
---|
[12092] | 26 | using HeuristicLab.Optimization.Operators;
|
---|
[11585] | 27 | using HeuristicLab.Parameters;
|
---|
| 28 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 29 | using HeuristicLab.Selection;
|
---|
| 30 |
|
---|
| 31 | namespace 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();
|
---|
[12035] | 48 | var mergingProsessor = new LayerUniformSubScopesProcessor();
|
---|
[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 |
|
---|
[11590] | 61 | eldersSelector.CopySelected = new BoolValue(false);
|
---|
[11585] | 62 | eldersSelector.Successor = null;
|
---|
| 63 |
|
---|
| 64 | shiftToRightMigrator.Successor = mergingProsessor;
|
---|
| 65 |
|
---|
| 66 | mergingProsessor.Operator = mergingReducer;
|
---|
| 67 | mergingProsessor.Successor = null;
|
---|
| 68 |
|
---|
| 69 | mergingReducer.Successor = subScopesCounter;
|
---|
| 70 |
|
---|
[11676] | 71 | subScopesCounter.ValueParameter.ActualName = "LayerPopulationSize";
|
---|
[11585] | 72 | subScopesCounter.AccumulateParameter.Value = new BoolValue(false);
|
---|
| 73 | subScopesCounter.Successor = countCalculator;
|
---|
| 74 |
|
---|
[12092] | 75 | countCalculator.CollectedValues.Add(new LookupParameter<IntValue>("PopulationSize"));
|
---|
| 76 | countCalculator.CollectedValues.Add(new LookupParameter<IntValue>("LayerPopulationSize"));
|
---|
| 77 | countCalculator.ExpressionParameter.Value = new StringValue("LayerPopulationSize PopulationSize LayerPopulationSize PopulationSize < if toint");
|
---|
| 78 | countCalculator.ExpressionResultParameter.ActualName = "LayerPopulationSize";
|
---|
[11585] | 79 | countCalculator.Successor = bestSelector;
|
---|
| 80 |
|
---|
[11676] | 81 | bestSelector.NumberOfSelectedSubScopesParameter.ActualName = "LayerPopulationSize";
|
---|
[11590] | 82 | bestSelector.CopySelected = new BoolValue(false);
|
---|
[11585] | 83 | bestSelector.Successor = rightReducer;
|
---|
| 84 |
|
---|
| 85 | rightReducer.Successor = null;
|
---|
| 86 | }
|
---|
| 87 | }
|
---|
| 88 | } |
---|