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