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