1 | #region License Information
|
---|
2 | /* HeuristicLab
|
---|
3 | * Copyright (C) 2002-2014 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 |
|
---|
22 | using HeuristicLab.Common;
|
---|
23 | using HeuristicLab.Core;
|
---|
24 | using HeuristicLab.Data;
|
---|
25 | using HeuristicLab.Operators;
|
---|
26 | using HeuristicLab.Optimization.Operators;
|
---|
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]
|
---|
34 | public class EldersEmigrator : AlgorithmOperator {
|
---|
35 |
|
---|
36 | [StorableConstructor]
|
---|
37 | private EldersEmigrator(bool deserializing)
|
---|
38 | : base(deserializing) { }
|
---|
39 | private EldersEmigrator(EldersEmigrator original, Cloner cloner)
|
---|
40 | : base(original, cloner) { }
|
---|
41 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
42 | return new EldersEmigrator(this, cloner);
|
---|
43 | }
|
---|
44 | public EldersEmigrator()
|
---|
45 | : base() {
|
---|
46 | var selectorProsessor = new UniformSubScopesProcessor();
|
---|
47 | var eldersSelector = new EldersSelector();
|
---|
48 | var shiftToRightMigrator = new ShiftToRightMigrator();
|
---|
49 | var mergingProsessor = new UniformSubScopesProcessor();
|
---|
50 | var mergingReducer = new MergingReducer();
|
---|
51 | var subScopesCounter = new SubScopesCounter();
|
---|
52 | var countCalculator = new ExpressionCalculator() { Name = "Count = Min(NumSubScopes, PopulationSize)" };
|
---|
53 | var bestSelector = new BestSelector();
|
---|
54 | var rightReducer = new RightReducer();
|
---|
55 |
|
---|
56 |
|
---|
57 | OperatorGraph.InitialOperator = selectorProsessor;
|
---|
58 |
|
---|
59 | selectorProsessor.Operator = eldersSelector;
|
---|
60 | selectorProsessor.Successor = shiftToRightMigrator;
|
---|
61 |
|
---|
62 | eldersSelector.Successor = null;
|
---|
63 |
|
---|
64 | shiftToRightMigrator.Successor = mergingProsessor;
|
---|
65 |
|
---|
66 | mergingProsessor.Operator = mergingReducer;
|
---|
67 | mergingProsessor.Successor = null;
|
---|
68 |
|
---|
69 | mergingReducer.Successor = subScopesCounter;
|
---|
70 |
|
---|
71 | subScopesCounter.ValueParameter.ActualName = "NumSubScopes";
|
---|
72 | subScopesCounter.AccumulateParameter.Value = new BoolValue(false);
|
---|
73 | subScopesCounter.Successor = countCalculator;
|
---|
74 |
|
---|
75 | countCalculator.CollectedValues.Add(new LookupParameter<IntValue>("PopulationSize"));
|
---|
76 | countCalculator.CollectedValues.Add(new LookupParameter<IntValue>("NumSubScopes"));
|
---|
77 | countCalculator.ExpressionParameter.Value = new StringValue("NumSubScopes PopulationSize NumSubScopes < PopulationSize if");
|
---|
78 | countCalculator.ExpressionResultParameter.ActualName = "Count";
|
---|
79 | countCalculator.Successor = bestSelector;
|
---|
80 |
|
---|
81 | bestSelector.NumberOfSelectedSubScopesParameter.ActualName = "Count";
|
---|
82 | bestSelector.Successor = rightReducer;
|
---|
83 |
|
---|
84 | rightReducer.Successor = null;
|
---|
85 | }
|
---|
86 | }
|
---|
87 | } |
---|