Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ALPS/HeuristicLab.Algorithms.ALPS.SteadyState/3.3/AlpsSsGeneticAlgorithmMainOperator.cs @ 12571

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

#2350

  • Fixed Plugin dependencies.
  • Added missing Hook.
  • Sealed some classes and fixed some access modifier.
File size: 3.6 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.Persistence.Default.CompositeSerializers.Storable;
27using HeuristicLab.Selection;
28
29namespace HeuristicLab.Algorithms.ALPS.SteadyState {
30  [Item("AlpsSsGeneticAlgorithmMainOperator", "")]
31  [StorableClass]
32  public sealed class AlpsSsGeneticAlgorithmMainOperator : AlgorithmOperator {
33    [StorableConstructor]
34    private AlpsSsGeneticAlgorithmMainOperator(bool deserializing)
35      : base(deserializing) { }
36    private AlpsSsGeneticAlgorithmMainOperator(AlpsSsGeneticAlgorithmMainOperator original, Cloner cloner)
37      : base(original, cloner) { }
38    public override IDeepCloneable Clone(Cloner cloner) {
39      return new AlpsSsGeneticAlgorithmMainOperator(this, cloner);
40    }
41
42    public AlpsSsGeneticAlgorithmMainOperator()
43      : base() {
44      var selector = new Placeholder() { Name = "Selector (Placeholder)" };
45      var reducer = new RightReducer();
46      var crossover = new Placeholder() { Name = "Crossover (Placeholder)" };
47      var mutationBranch = new StochasticBranch();
48      var mutator = new Placeholder() { Name = "Mutator (Placeholder)" };
49      var ageReducer = new DataReducer() { Name = "Calculate EvalsCreated" };
50      var lastMoveAssigner = new Assigner() { Name = "Set LastMove" };
51      var subScopesRemover = new SubScopesRemover();
52      var evaluator = new Placeholder() { Name = "Evaluator (Placeholder)" };
53
54
55      OperatorGraph.InitialOperator = selector;
56
57      selector.OperatorParameter.ActualName = "Selector";
58      selector.Successor = reducer;
59
60      reducer.Successor = crossover;
61
62      crossover.OperatorParameter.ActualName = "Crossover";
63      crossover.Successor = mutationBranch;
64
65      mutationBranch.ProbabilityParameter.ActualName = "MutationProbability";
66      mutationBranch.RandomParameter.ActualName = "Random";
67      mutationBranch.FirstBranch = mutator;
68      mutationBranch.Successor = ageReducer;
69
70      mutator.OperatorParameter.ActualName = "Mutator";
71
72      ageReducer.ParameterToReduce.ActualName = "EvalsCreated";
73      ageReducer.ReductionOperation.ActualName = "AgeInheritanceReduction";
74      ageReducer.ReductionOperation.Value = null;
75      ageReducer.TargetParameter.ActualName = "EvalsCreated";
76      ageReducer.TargetOperation.Value = new ReductionOperation(ReductionOperations.Assign);
77      ageReducer.Successor = lastMoveAssigner;
78
79      lastMoveAssigner.LeftSideParameter.ActualName = "LastMove";
80      lastMoveAssigner.RightSideParameter.ActualName = "EvaluatedSolutions";
81      lastMoveAssigner.Successor = subScopesRemover;
82
83      subScopesRemover.Successor = evaluator;
84
85      evaluator.OperatorParameter.ActualName = "Evaluator";
86    }
87  }
88}
Note: See TracBrowser for help on using the repository browser.