Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SASEGASAMainLoop.cs @ 6716

Last change on this file since 6716 was 6630, checked in by abeham, 13 years ago

#1054

  • Added description
File size: 28.3 KB
RevLine 
[3479]1#region License Information
2/* HeuristicLab
[5445]3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[3479]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
[4722]22using HeuristicLab.Common;
[3479]23using HeuristicLab.Core;
24using HeuristicLab.Data;
25using HeuristicLab.Operators;
26using HeuristicLab.Optimization;
27using HeuristicLab.Optimization.Operators;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30
31namespace HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm {
32  /// <summary>
33  /// A SASEGASA main loop operator.
34  /// </summary>
35  [Item("SASEGASAMainLoop", "A SASEGASA main loop operator.")]
36  [StorableClass]
37  public sealed class SASEGASAMainLoop : AlgorithmOperator {
38    #region Parameter Properties
39    public ValueLookupParameter<IRandom> RandomParameter {
40      get { return (ValueLookupParameter<IRandom>)Parameters["Random"]; }
41    }
42    public ValueLookupParameter<IntValue> NumberOfVillagesParameter {
43      get { return (ValueLookupParameter<IntValue>)Parameters["NumberOfVillages"]; }
44    }
45    public ValueLookupParameter<IntValue> MigrationIntervalParameter {
46      get { return (ValueLookupParameter<IntValue>)Parameters["MigrationInterval"]; }
47    }
48    public ValueLookupParameter<BoolValue> MaximizationParameter {
49      get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
50    }
[3659]51    public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
52      get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
[3479]53    }
54    public ValueLookupParameter<DoubleValue> BestKnownQualityParameter {
55      get { return (ValueLookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
56    }
57    public ValueLookupParameter<IOperator> SelectorParameter {
58      get { return (ValueLookupParameter<IOperator>)Parameters["Selector"]; }
59    }
60    public ValueLookupParameter<IOperator> CrossoverParameter {
61      get { return (ValueLookupParameter<IOperator>)Parameters["Crossover"]; }
62    }
63    public ValueLookupParameter<PercentValue> MutationProbabilityParameter {
64      get { return (ValueLookupParameter<PercentValue>)Parameters["MutationProbability"]; }
65    }
66    public ValueLookupParameter<IOperator> MutatorParameter {
67      get { return (ValueLookupParameter<IOperator>)Parameters["Mutator"]; }
68    }
69    public ValueLookupParameter<IOperator> EvaluatorParameter {
70      get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
71    }
72    public ValueLookupParameter<IntValue> ElitesParameter {
73      get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; }
74    }
75    public ValueLookupParameter<ResultCollection> ResultsParameter {
76      get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
77    }
[3656]78    public ValueLookupParameter<IOperator> AnalyzerParameter {
79      get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
[3479]80    }
[3656]81    public ValueLookupParameter<IOperator> VillageAnalyzerParameter {
82      get { return (ValueLookupParameter<IOperator>)Parameters["VillageAnalyzer"]; }
[3479]83    }
84    public ValueLookupParameter<DoubleValue> SuccessRatioParameter {
85      get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
86    }
[3615]87    public LookupParameter<DoubleValue> ComparisonFactorParameter {
88      get { return (LookupParameter<DoubleValue>)Parameters["ComparisonFactor"]; }
89    }
[3744]90    public ValueLookupParameter<DoubleValue> ComparisonFactorStartParameter {
91      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorStart"]; }
[3479]92    }
93    public ValueLookupParameter<IOperator> ComparisonFactorModifierParameter {
94      get { return (ValueLookupParameter<IOperator>)Parameters["ComparisonFactorModifier"]; }
95    }
96    public ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
97      get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
98    }
[3490]99    public ValueLookupParameter<DoubleValue> FinalMaximumSelectionPressureParameter {
100      get { return (ValueLookupParameter<DoubleValue>)Parameters["FinalMaximumSelectionPressure"]; }
101    }
[3479]102    public ValueLookupParameter<IntValue> MaximumGenerationsParameter {
103      get { return (ValueLookupParameter<IntValue>)Parameters["MaximumGenerations"]; }
104    }
105    public ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
106      get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
107    }
[5356]108    public LookupParameter<IntValue> EvaluatedSolutionsParameter {
109      get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
110    }
[3479]111    #endregion
112
113    [StorableConstructor]
[4722]114    private SASEGASAMainLoop(bool deserializing) : base(deserializing) { }
115    private SASEGASAMainLoop(SASEGASAMainLoop original, Cloner cloner)
116      : base(original, cloner) {
117    }
118    public override IDeepCloneable Clone(Cloner cloner) {
119      return new SASEGASAMainLoop(this, cloner);
120    }
[3479]121    public SASEGASAMainLoop()
122      : base() {
123      #region Create parameters
124      Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
125      Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
[3659]126      Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
[3479]127      Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
128      Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfVillages", "The initial number of villages."));
129      Parameters.Add(new ValueLookupParameter<IntValue>("MigrationInterval", "The fixed period after which migration occurs."));
130      Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction."));
131      Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
132      Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
133      Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
[5208]134      Parameters.Add(new ValueLookupParameter<IOperator>("Evaluator", "The operator used to evaluate solutions. This operator is executed in parallel, if an engine is used which supports parallelization."));
[3479]135      Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
136      Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection to store the results."));
[3656]137      Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to the analyze the villages."));
138      Parameters.Add(new ValueLookupParameter<IOperator>("VillageAnalyzer", "The operator used to analyze each village."));
[3479]139      Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved."));
[3615]140      Parameters.Add(new LookupParameter<DoubleValue>("ComparisonFactor", "The comparison factor is used to determine whether the offspring should be compared to the better parent, the worse parent or a quality value linearly interpolated between them. It is in the range [0;1]."));
[3744]141      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorStart", "The lower bound of the comparison factor (start)."));
[3479]142      Parameters.Add(new ValueLookupParameter<IOperator>("ComparisonFactorModifier", "The operator used to modify the comparison factor."));
143      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm."));
[3490]144      Parameters.Add(new ValueLookupParameter<DoubleValue>("FinalMaximumSelectionPressure", "The maximum selection pressure used when there is only one village left."));
[3479]145      Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum genreation that terminates the algorithm."));
146      Parameters.Add(new ValueLookupParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation."));
[5356]147      Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
[3479]148      #endregion
149
150      #region Create operators
151      VariableCreator variableCreator = new VariableCreator();
[3490]152      Assigner maxSelPressAssigner = new Assigner();
[3479]153      Assigner villageCountAssigner = new Assigner();
154      Assigner comparisonFactorInitializer = new Assigner();
[3615]155      UniformSubScopesProcessor uniformSubScopesProcessor0 = new UniformSubScopesProcessor();
156      VariableCreator villageVariableCreator = new VariableCreator();
[3656]157      Placeholder villageAnalyzer1 = new Placeholder();
158      ResultsCollector villageResultsCollector1 = new ResultsCollector();
159      Placeholder analyzer1 = new Placeholder();
160      ResultsCollector resultsCollector1 = new ResultsCollector();
[3615]161      UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
162      ConditionalBranch villageTerminatedBySelectionPressure1 = new ConditionalBranch();
163      OffspringSelectionGeneticAlgorithmMainOperator mainOperator = new OffspringSelectionGeneticAlgorithmMainOperator();
[3656]164      Placeholder villageAnalyzer2 = new Placeholder();
165      ResultsCollector villageResultsCollector2 = new ResultsCollector();
[3615]166      Comparator villageSelectionPressureComparator = new Comparator();
167      ConditionalBranch villageTerminatedBySelectionPressure2 = new ConditionalBranch();
168      IntCounter terminatedVillagesCounter = new IntCounter();
169      IntCounter generationsCounter = new IntCounter();
170      IntCounter generationsSinceLastReunificationCounter = new IntCounter();
171      Comparator reunificationComparator1 = new Comparator();
172      ConditionalBranch reunificationConditionalBranch1 = new ConditionalBranch();
173      Comparator reunificationComparator2 = new Comparator();
174      ConditionalBranch reunificationConditionalBranch2 = new ConditionalBranch();
175      Comparator reunificationComparator3 = new Comparator();
176      ConditionalBranch reunificationConditionalBranch3 = new ConditionalBranch();
177      Assigner resetTerminatedVillagesAssigner = new Assigner();
178      Assigner resetGenerationsSinceLastReunificationAssigner = new Assigner();
[3479]179      SASEGASAReunificator reunificator = new SASEGASAReunificator();
180      IntCounter reunificationCounter = new IntCounter();
181      Placeholder comparisonFactorModifier = new Placeholder();
[3615]182      UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
183      Assigner villageReviver = new Assigner();
184      Comparator villageCountComparator = new Comparator();
185      ConditionalBranch villageCountConditionalBranch = new ConditionalBranch();
[3490]186      Assigner finalMaxSelPressAssigner = new Assigner();
[3479]187      Comparator maximumGenerationsComparator = new Comparator();
[3891]188      Comparator maximumEvaluatedSolutionsComparator = new Comparator();
[3656]189      Placeholder analyzer2 = new Placeholder();
[3615]190      ConditionalBranch terminationCondition = new ConditionalBranch();
[3479]191      ConditionalBranch maximumGenerationsTerminationCondition = new ConditionalBranch();
[3891]192      ConditionalBranch maximumEvaluatedSolutionsTerminationCondition = new ConditionalBranch();
[3479]193
[3615]194      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Reunifications", new IntValue(0)));
[3750]195      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class SASEGASA expects this to be called Generations
[3615]196      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("GenerationsSinceLastReunification", new IntValue(0)));
197      variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("TerminatedVillages", new IntValue(0)));
[3479]198
199      villageCountAssigner.LeftSideParameter.ActualName = "VillageCount";
200      villageCountAssigner.RightSideParameter.ActualName = NumberOfVillagesParameter.Name;
201
[3490]202      maxSelPressAssigner.LeftSideParameter.ActualName = "CurrentMaximumSelectionPressure";
203      maxSelPressAssigner.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
204
[3744]205      comparisonFactorInitializer.LeftSideParameter.ActualName = ComparisonFactorParameter.Name;
206      comparisonFactorInitializer.RightSideParameter.ActualName = ComparisonFactorStartParameter.Name;
[3479]207
[3656]208      villageVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>("Results", new ResultCollection()));
[3615]209      villageVariableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("TerminateSelectionPressure", new BoolValue(false)));
210      villageVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
211      villageVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("CurrentSuccessRatio", new DoubleValue(0)));
[3479]212
[3656]213      villageAnalyzer1.Name = "Village Analyzer (placeholder)";
214      villageAnalyzer1.OperatorParameter.ActualName = VillageAnalyzerParameter.Name;
[3479]215
[6630]216      villageResultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", "Indicates how many successful children were already found during a generation (relative to the population size).", "CurrentSuccessRatio"));
217      villageResultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", "Displays the rising selection pressure during a generation.", "SelectionPressure"));
[3656]218      villageResultsCollector1.ResultsParameter.ActualName = "Results";
[3615]219
[3656]220      analyzer1.Name = "Analyzer (placeholder)";
221      analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name;
[3615]222
[3673]223      resultsCollector1.CopyValue = new BoolValue(false);
[3656]224      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
[3744]225      resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("ComparisonFactor", null, ComparisonFactorParameter.Name));
[3656]226      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Terminated Villages", null, "TerminatedVillages"));
227      resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Total Active Villages", null, "VillageCount"));
[3673]228      resultsCollector1.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("VillageResults", "Result set for each village", "Results"));
[3656]229      resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
[3615]230
231      villageTerminatedBySelectionPressure1.Name = "Village Terminated ?";
232      villageTerminatedBySelectionPressure1.ConditionParameter.ActualName = "TerminateSelectionPressure";
[3489]233
[3615]234      mainOperator.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
235      mainOperator.CrossoverParameter.ActualName = CrossoverParameter.Name;
236      mainOperator.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
237      mainOperator.ElitesParameter.ActualName = ElitesParameter.Name;
[5356]238      mainOperator.EvaluatedSolutionsParameter.ActualName = EvaluatedSolutionsParameter.Name;
[3615]239      mainOperator.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
240      mainOperator.MaximizationParameter.ActualName = MaximizationParameter.Name;
241      mainOperator.MaximumSelectionPressureParameter.ActualName = "CurrentMaximumSelectionPressure";
242      mainOperator.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
243      mainOperator.MutatorParameter.ActualName = MutatorParameter.Name;
244      mainOperator.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
245      mainOperator.QualityParameter.ActualName = QualityParameter.Name;
246      mainOperator.RandomParameter.ActualName = RandomParameter.Name;
247      mainOperator.SelectionPressureParameter.ActualName = "SelectionPressure";
248      mainOperator.SelectorParameter.ActualName = SelectorParameter.Name;
249      mainOperator.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
[3479]250
[3656]251      villageAnalyzer2.Name = "Village Analyzer (placeholder)";
252      villageAnalyzer2.OperatorParameter.ActualName = VillageAnalyzerParameter.Name;
[3479]253
[6630]254      villageResultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Success Ratio", "Indicates how many successful children were already found during a generation (relative to the population size).", "CurrentSuccessRatio"));
255      villageResultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", "Displays the rising selection pressure during a generation.", "SelectionPressure"));
[3656]256      villageResultsCollector2.ResultsParameter.ActualName = "Results";
[3479]257
[3615]258      villageSelectionPressureComparator.Name = "SelectionPressure >= MaximumSelectionPressure ?";
259      villageSelectionPressureComparator.LeftSideParameter.ActualName = "SelectionPressure";
260      villageSelectionPressureComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
261      villageSelectionPressureComparator.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
262      villageSelectionPressureComparator.ResultParameter.ActualName = "TerminateSelectionPressure";
[3489]263
[3615]264      villageTerminatedBySelectionPressure2.Name = "Village Terminated ?";
265      villageTerminatedBySelectionPressure2.ConditionParameter.ActualName = "TerminateSelectionPressure";
[3479]266
[3615]267      terminatedVillagesCounter.Name = "TerminatedVillages + 1";
268      terminatedVillagesCounter.ValueParameter.ActualName = "TerminatedVillages";
269      terminatedVillagesCounter.Increment = new IntValue(1);
[3489]270
[3615]271      generationsCounter.Name = "Generations + 1";
272      generationsCounter.ValueParameter.ActualName = "Generations";
273      generationsCounter.Increment = new IntValue(1);
[3479]274
[3615]275      generationsSinceLastReunificationCounter.Name = "GenerationsSinceLastReunification + 1";
276      generationsSinceLastReunificationCounter.ValueParameter.ActualName = "GenerationsSinceLastReunification";
277      generationsSinceLastReunificationCounter.Increment = new IntValue(1);
[3479]278
[3615]279      reunificationComparator1.Name = "TerminatedVillages = VillageCount ?";
280      reunificationComparator1.LeftSideParameter.ActualName = "TerminatedVillages";
281      reunificationComparator1.Comparison = new Comparison(ComparisonType.Equal);
282      reunificationComparator1.RightSideParameter.ActualName = "VillageCount";
283      reunificationComparator1.ResultParameter.ActualName = "Reunificate";
284
285      reunificationConditionalBranch1.Name = "Reunificate ?";
286      reunificationConditionalBranch1.ConditionParameter.ActualName = "Reunificate";
287
288      reunificationComparator2.Name = "GenerationsSinceLastReunification = MigrationInterval ?";
289      reunificationComparator2.LeftSideParameter.ActualName = "GenerationsSinceLastReunification";
290      reunificationComparator2.Comparison = new Comparison(ComparisonType.Equal);
291      reunificationComparator2.RightSideParameter.ActualName = "MigrationInterval";
292      reunificationComparator2.ResultParameter.ActualName = "Reunificate";
293
294      reunificationConditionalBranch2.Name = "Reunificate ?";
295      reunificationConditionalBranch2.ConditionParameter.ActualName = "Reunificate";
296
297      // if there's just one village left and we're getting to this point SASEGASA terminates
298      reunificationComparator3.Name = "VillageCount <= 1 ?";
299      reunificationComparator3.LeftSideParameter.ActualName = "VillageCount";
300      reunificationComparator3.RightSideParameter.Value = new IntValue(1);
301      reunificationComparator3.Comparison.Value = ComparisonType.LessOrEqual;
302      reunificationComparator3.ResultParameter.ActualName = "TerminateSASEGASA";
303
304      reunificationConditionalBranch3.Name = "Skip reunification?";
305      reunificationConditionalBranch3.ConditionParameter.ActualName = "TerminateSASEGASA";
306
307      resetTerminatedVillagesAssigner.Name = "Reset TerminatedVillages";
308      resetTerminatedVillagesAssigner.LeftSideParameter.ActualName = "TerminatedVillages";
309      resetTerminatedVillagesAssigner.RightSideParameter.Value = new IntValue(0);
310
311      resetGenerationsSinceLastReunificationAssigner.Name = "Reset GenerationsSinceLastReunification";
312      resetGenerationsSinceLastReunificationAssigner.LeftSideParameter.ActualName = "GenerationsSinceLastReunification";
313      resetGenerationsSinceLastReunificationAssigner.RightSideParameter.Value = new IntValue(0);
314
[3479]315      reunificator.VillageCountParameter.ActualName = "VillageCount";
316
317      reunificationCounter.ValueParameter.ActualName = "Reunifications"; // this variable is referenced in SASEGASA, do not change!
318      reunificationCounter.IncrementParameter.Value = new IntValue(1);
319
[3744]320      comparisonFactorModifier.Name = "Update comparison factor (placeholder)";
[3479]321      comparisonFactorModifier.OperatorParameter.ActualName = ComparisonFactorModifierParameter.Name;
322
[3615]323      villageReviver.Name = "Village Reviver";
324      villageReviver.LeftSideParameter.ActualName = "TerminateSelectionPressure";
325      villageReviver.RightSideParameter.Value = new BoolValue(false);
[3490]326
[3615]327      villageCountComparator.Name = "VillageCount == 1 ?";
328      villageCountComparator.LeftSideParameter.ActualName = "VillageCount";
329      villageCountComparator.RightSideParameter.Value = new IntValue(1);
330      villageCountComparator.Comparison.Value = ComparisonType.Equal;
331      villageCountComparator.ResultParameter.ActualName = "ChangeMaxSelPress";
[3490]332
[3615]333      villageCountConditionalBranch.Name = "Change max selection pressure?";
334      villageCountConditionalBranch.ConditionParameter.ActualName = "ChangeMaxSelPress";
335
[3490]336      finalMaxSelPressAssigner.LeftSideParameter.ActualName = "CurrentMaximumSelectionPressure";
337      finalMaxSelPressAssigner.RightSideParameter.ActualName = FinalMaximumSelectionPressureParameter.Name;
338
[3615]339      // if Generations is reaching MaximumGenerations we're also terminating
340      maximumGenerationsComparator.LeftSideParameter.ActualName = "Generations";
[3479]341      maximumGenerationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
342      maximumGenerationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
343      maximumGenerationsComparator.ResultParameter.ActualName = "TerminateMaximumGenerations";
344
[3891]345      maximumEvaluatedSolutionsComparator.Name = "EvaluatedSolutions >= MaximumEvaluatedSolutions";
346      maximumEvaluatedSolutionsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
[5356]347      maximumEvaluatedSolutionsComparator.LeftSideParameter.ActualName = EvaluatedSolutionsParameter.Name;
[3891]348      maximumEvaluatedSolutionsComparator.ResultParameter.ActualName = "TerminateEvaluatedSolutions";
349      maximumEvaluatedSolutionsComparator.RightSideParameter.ActualName = "MaximumEvaluatedSolutions";
350
[3656]351      analyzer2.Name = "Analyzer (placeholder)";
352      analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name;
[3479]353
[3615]354      terminationCondition.ConditionParameter.ActualName = "TerminateSASEGASA";
355      maximumGenerationsTerminationCondition.ConditionParameter.ActualName = "TerminateMaximumGenerations";
[3891]356      maximumEvaluatedSolutionsTerminationCondition.ConditionParameter.ActualName = "TerminateEvaluatedSolutions";
[3479]357      #endregion
358
359      #region Create operator graph
360      OperatorGraph.InitialOperator = variableCreator;
[3615]361      variableCreator.Successor = maxSelPressAssigner;
362      maxSelPressAssigner.Successor = villageCountAssigner;
363      villageCountAssigner.Successor = comparisonFactorInitializer;
364      comparisonFactorInitializer.Successor = uniformSubScopesProcessor0;
365      uniformSubScopesProcessor0.Operator = villageVariableCreator;
[3656]366      uniformSubScopesProcessor0.Successor = analyzer1;
367      villageVariableCreator.Successor = villageAnalyzer1;
368      villageAnalyzer1.Successor = villageResultsCollector1;
369      analyzer1.Successor = resultsCollector1;
[5356]370      resultsCollector1.Successor = uniformSubScopesProcessor1;
[3615]371      uniformSubScopesProcessor1.Operator = villageTerminatedBySelectionPressure1;
372      uniformSubScopesProcessor1.Successor = generationsCounter;
373      villageTerminatedBySelectionPressure1.TrueBranch = null;
374      villageTerminatedBySelectionPressure1.FalseBranch = mainOperator;
375      villageTerminatedBySelectionPressure1.Successor = null;
[3656]376      mainOperator.Successor = villageAnalyzer2;
377      villageAnalyzer2.Successor = villageResultsCollector2;
[5356]378      villageResultsCollector2.Successor = villageSelectionPressureComparator;
[3615]379      villageSelectionPressureComparator.Successor = villageTerminatedBySelectionPressure2;
380      villageTerminatedBySelectionPressure2.TrueBranch = terminatedVillagesCounter;
381      villageTerminatedBySelectionPressure2.FalseBranch = null;
382      villageTerminatedBySelectionPressure2.Successor = null;
383      terminatedVillagesCounter.Successor = null;
384      generationsCounter.Successor = generationsSinceLastReunificationCounter;
385      generationsSinceLastReunificationCounter.Successor = reunificationComparator1;
386      reunificationComparator1.Successor = reunificationConditionalBranch1;
387      reunificationConditionalBranch1.TrueBranch = reunificationComparator3;
388      reunificationConditionalBranch1.FalseBranch = reunificationComparator2;
389      reunificationConditionalBranch1.Successor = maximumGenerationsComparator;
390      reunificationComparator2.Successor = reunificationConditionalBranch2;
391      reunificationConditionalBranch2.TrueBranch = reunificationComparator3;
392      reunificationConditionalBranch2.FalseBranch = null;
393      reunificationConditionalBranch2.Successor = null;
394      reunificationComparator3.Successor = reunificationConditionalBranch3;
395      reunificationConditionalBranch3.TrueBranch = null;
396      reunificationConditionalBranch3.FalseBranch = resetTerminatedVillagesAssigner;
397      reunificationConditionalBranch3.Successor = null;
398      resetTerminatedVillagesAssigner.Successor = resetGenerationsSinceLastReunificationAssigner;
399      resetGenerationsSinceLastReunificationAssigner.Successor = reunificator;
[3479]400      reunificator.Successor = reunificationCounter;
401      reunificationCounter.Successor = comparisonFactorModifier;
[3615]402      comparisonFactorModifier.Successor = uniformSubScopesProcessor2;
403      uniformSubScopesProcessor2.Operator = villageReviver;
404      uniformSubScopesProcessor2.Successor = villageCountComparator;
405      villageReviver.Successor = null;
406      villageCountComparator.Successor = villageCountConditionalBranch;
407      villageCountConditionalBranch.TrueBranch = finalMaxSelPressAssigner;
408      villageCountConditionalBranch.FalseBranch = null;
409      villageCountConditionalBranch.Successor = null;
[3490]410      finalMaxSelPressAssigner.Successor = null;
[3891]411      maximumGenerationsComparator.Successor = maximumEvaluatedSolutionsComparator;
412      maximumEvaluatedSolutionsComparator.Successor = analyzer2;
[5356]413      analyzer2.Successor = terminationCondition;
[3615]414      terminationCondition.TrueBranch = null;
415      terminationCondition.FalseBranch = maximumGenerationsTerminationCondition;
416      terminationCondition.Successor = null;
[3479]417      maximumGenerationsTerminationCondition.TrueBranch = null;
[3891]418      maximumGenerationsTerminationCondition.FalseBranch = maximumEvaluatedSolutionsTerminationCondition;
[3479]419      maximumGenerationsTerminationCondition.Successor = null;
[3891]420      maximumEvaluatedSolutionsTerminationCondition.TrueBranch = null;
421      maximumEvaluatedSolutionsTerminationCondition.FalseBranch = uniformSubScopesProcessor1;
422      maximumEvaluatedSolutionsTerminationCondition.Successor = null;
[3479]423      #endregion
424    }
[3715]425
426    public override IOperation Apply() {
427      if (CrossoverParameter.ActualValue == null)
428        return null;
429      return base.Apply();
430    }
[3479]431  }
432}
Note: See TracBrowser for help on using the repository browser.