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