[3429] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[9456] | 3 | * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[3429] | 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;
|
---|
[3429] | 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>
|
---|
[3479] | 33 | /// An island offspring selection genetic algorithm main loop operator.
|
---|
[3429] | 34 | /// </summary>
|
---|
[3479] | 35 | [Item("IslandOffspringSelectionGeneticAlgorithmMainLoop", "An island offspring selection genetic algorithm main loop operator.")]
|
---|
[3429] | 36 | [StorableClass]
|
---|
[3479] | 37 | public sealed class IslandOffspringSelectionGeneticAlgorithmMainLoop : AlgorithmOperator {
|
---|
[3429] | 38 | #region Parameter Properties
|
---|
| 39 | public ValueLookupParameter<IRandom> RandomParameter {
|
---|
| 40 | get { return (ValueLookupParameter<IRandom>)Parameters["Random"]; }
|
---|
| 41 | }
|
---|
| 42 | public ValueLookupParameter<BoolValue> MaximizationParameter {
|
---|
| 43 | get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
|
---|
| 44 | }
|
---|
[3659] | 45 | public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
|
---|
| 46 | get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
|
---|
[3429] | 47 | }
|
---|
| 48 | public ValueLookupParameter<DoubleValue> BestKnownQualityParameter {
|
---|
| 49 | get { return (ValueLookupParameter<DoubleValue>)Parameters["BestKnownQuality"]; }
|
---|
| 50 | }
|
---|
| 51 | public ValueLookupParameter<IntValue> NumberOfIslandsParameter {
|
---|
| 52 | get { return (ValueLookupParameter<IntValue>)Parameters["NumberOfIslands"]; }
|
---|
| 53 | }
|
---|
| 54 | public ValueLookupParameter<IntValue> MigrationIntervalParameter {
|
---|
| 55 | get { return (ValueLookupParameter<IntValue>)Parameters["MigrationInterval"]; }
|
---|
| 56 | }
|
---|
| 57 | public ValueLookupParameter<PercentValue> MigrationRateParameter {
|
---|
| 58 | get { return (ValueLookupParameter<PercentValue>)Parameters["MigrationRate"]; }
|
---|
| 59 | }
|
---|
| 60 | public ValueLookupParameter<IOperator> MigratorParameter {
|
---|
| 61 | get { return (ValueLookupParameter<IOperator>)Parameters["Migrator"]; }
|
---|
| 62 | }
|
---|
| 63 | public ValueLookupParameter<IOperator> EmigrantsSelectorParameter {
|
---|
| 64 | get { return (ValueLookupParameter<IOperator>)Parameters["EmigrantsSelector"]; }
|
---|
| 65 | }
|
---|
[3611] | 66 | public ValueLookupParameter<IOperator> ImmigrationReplacerParameter {
|
---|
| 67 | get { return (ValueLookupParameter<IOperator>)Parameters["ImmigrationReplacer"]; }
|
---|
[3429] | 68 | }
|
---|
| 69 | public ValueLookupParameter<IntValue> PopulationSizeParameter {
|
---|
| 70 | get { return (ValueLookupParameter<IntValue>)Parameters["PopulationSize"]; }
|
---|
| 71 | }
|
---|
[3611] | 72 | public ValueLookupParameter<IntValue> MaximumGenerationsParameter {
|
---|
| 73 | get { return (ValueLookupParameter<IntValue>)Parameters["MaximumGenerations"]; }
|
---|
[3429] | 74 | }
|
---|
| 75 | public ValueLookupParameter<IOperator> SelectorParameter {
|
---|
| 76 | get { return (ValueLookupParameter<IOperator>)Parameters["Selector"]; }
|
---|
| 77 | }
|
---|
| 78 | public ValueLookupParameter<IOperator> CrossoverParameter {
|
---|
| 79 | get { return (ValueLookupParameter<IOperator>)Parameters["Crossover"]; }
|
---|
| 80 | }
|
---|
| 81 | public ValueLookupParameter<PercentValue> MutationProbabilityParameter {
|
---|
| 82 | get { return (ValueLookupParameter<PercentValue>)Parameters["MutationProbability"]; }
|
---|
| 83 | }
|
---|
| 84 | public ValueLookupParameter<IOperator> MutatorParameter {
|
---|
| 85 | get { return (ValueLookupParameter<IOperator>)Parameters["Mutator"]; }
|
---|
| 86 | }
|
---|
| 87 | public ValueLookupParameter<IOperator> EvaluatorParameter {
|
---|
| 88 | get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
|
---|
| 89 | }
|
---|
| 90 | public ValueLookupParameter<IntValue> ElitesParameter {
|
---|
| 91 | get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; }
|
---|
| 92 | }
|
---|
[9569] | 93 | public IValueLookupParameter<BoolValue> ReevaluateElitesParameter {
|
---|
| 94 | get { return (IValueLookupParameter<BoolValue>)Parameters["ReevaluateElites"]; }
|
---|
| 95 | }
|
---|
[3429] | 96 | public ValueLookupParameter<ResultCollection> ResultsParameter {
|
---|
| 97 | get { return (ValueLookupParameter<ResultCollection>)Parameters["Results"]; }
|
---|
| 98 | }
|
---|
| 99 | public ValueLookupParameter<IOperator> VisualizerParameter {
|
---|
| 100 | get { return (ValueLookupParameter<IOperator>)Parameters["Visualizer"]; }
|
---|
| 101 | }
|
---|
| 102 | public LookupParameter<IItem> VisualizationParameter {
|
---|
| 103 | get { return (LookupParameter<IItem>)Parameters["Visualization"]; }
|
---|
| 104 | }
|
---|
| 105 | public ValueLookupParameter<DoubleValue> SuccessRatioParameter {
|
---|
| 106 | get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
|
---|
| 107 | }
|
---|
[3611] | 108 | public LookupParameter<DoubleValue> ComparisonFactorParameter {
|
---|
| 109 | get { return (LookupParameter<DoubleValue>)Parameters["ComparisonFactor"]; }
|
---|
| 110 | }
|
---|
[3744] | 111 | public ValueLookupParameter<DoubleValue> ComparisonFactorStartParameter {
|
---|
| 112 | get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorStart"]; }
|
---|
| 113 | }
|
---|
[3429] | 114 | public ValueLookupParameter<IOperator> ComparisonFactorModifierParameter {
|
---|
| 115 | get { return (ValueLookupParameter<IOperator>)Parameters["ComparisonFactorModifier"]; }
|
---|
| 116 | }
|
---|
| 117 | public ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
|
---|
| 118 | get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
|
---|
| 119 | }
|
---|
| 120 | public ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
|
---|
| 121 | get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
|
---|
| 122 | }
|
---|
[3654] | 123 | public ValueLookupParameter<IOperator> AnalyzerParameter {
|
---|
| 124 | get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
|
---|
| 125 | }
|
---|
| 126 | public ValueLookupParameter<IOperator> IslandAnalyzerParameter {
|
---|
| 127 | get { return (ValueLookupParameter<IOperator>)Parameters["IslandAnalyzer"]; }
|
---|
| 128 | }
|
---|
[5356] | 129 | public LookupParameter<IntValue> EvaluatedSolutionsParameter {
|
---|
| 130 | get { return (LookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
|
---|
| 131 | }
|
---|
[3429] | 132 | #endregion
|
---|
| 133 |
|
---|
| 134 | [StorableConstructor]
|
---|
[4722] | 135 | private IslandOffspringSelectionGeneticAlgorithmMainLoop(bool deserializing) : base(deserializing) { }
|
---|
| 136 | private IslandOffspringSelectionGeneticAlgorithmMainLoop(IslandOffspringSelectionGeneticAlgorithmMainLoop original, Cloner cloner)
|
---|
| 137 | : base(original, cloner) {
|
---|
| 138 | }
|
---|
| 139 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 140 | return new IslandOffspringSelectionGeneticAlgorithmMainLoop(this, cloner);
|
---|
| 141 | }
|
---|
[3479] | 142 | public IslandOffspringSelectionGeneticAlgorithmMainLoop()
|
---|
[3429] | 143 | : base() {
|
---|
| 144 | #region Create parameters
|
---|
| 145 | Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
|
---|
| 146 | Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
|
---|
[3659] | 147 | Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
|
---|
[3429] | 148 | Parameters.Add(new ValueLookupParameter<DoubleValue>("BestKnownQuality", "The best known quality value found so far."));
|
---|
| 149 | Parameters.Add(new ValueLookupParameter<IntValue>("NumberOfIslands", "The number of islands."));
|
---|
| 150 | Parameters.Add(new ValueLookupParameter<IntValue>("MigrationInterval", "The number of generations that should pass between migration phases."));
|
---|
| 151 | Parameters.Add(new ValueLookupParameter<PercentValue>("MigrationRate", "The proportion of individuals that should migrate between the islands."));
|
---|
| 152 | Parameters.Add(new ValueLookupParameter<IOperator>("Migrator", "The migration strategy."));
|
---|
| 153 | Parameters.Add(new ValueLookupParameter<IOperator>("EmigrantsSelector", "Selects the individuals that will be migrated."));
|
---|
[3611] | 154 | Parameters.Add(new ValueLookupParameter<IOperator>("ImmigrationReplacer", "Replaces part of the original population with the immigrants."));
|
---|
[3429] | 155 | Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population of solutions."));
|
---|
[3611] | 156 | Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations that should be processed."));
|
---|
[3429] | 157 | Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction."));
|
---|
| 158 | Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
|
---|
| 159 | Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
|
---|
| 160 | Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
|
---|
[5208] | 161 | 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."));
|
---|
[3429] | 162 | Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
|
---|
[9569] | 163 | Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)"));
|
---|
[3429] | 164 | Parameters.Add(new ValueLookupParameter<ResultCollection>("Results", "The results collection to store the results."));
|
---|
| 165 | Parameters.Add(new ValueLookupParameter<IOperator>("Visualizer", "The operator used to visualize solutions."));
|
---|
| 166 | Parameters.Add(new LookupParameter<IItem>("Visualization", "The item which represents the visualization of solutions."));
|
---|
| 167 | Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved."));
|
---|
[3611] | 168 | 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] | 169 | Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorStart", "The initial value for the comparison factor."));
|
---|
[3429] | 170 | Parameters.Add(new ValueLookupParameter<IOperator>("ComparisonFactorModifier", "The operator used to modify the comparison factor."));
|
---|
| 171 | Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm."));
|
---|
| 172 | 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."));
|
---|
[3654] | 173 | Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to the analyze the islands."));
|
---|
| 174 | Parameters.Add(new ValueLookupParameter<IOperator>("IslandAnalyzer", "The operator used to analyze each island."));
|
---|
[5356] | 175 | Parameters.Add(new LookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
|
---|
[3429] | 176 | #endregion
|
---|
| 177 |
|
---|
| 178 | #region Create operators
|
---|
| 179 | VariableCreator variableCreator = new VariableCreator();
|
---|
[3611] | 180 | UniformSubScopesProcessor uniformSubScopesProcessor0 = new UniformSubScopesProcessor();
|
---|
[3429] | 181 | VariableCreator islandVariableCreator = new VariableCreator();
|
---|
[3654] | 182 | Placeholder islandAnalyzer1 = new Placeholder();
|
---|
| 183 | ResultsCollector islandResultsCollector1 = new ResultsCollector();
|
---|
[3744] | 184 | Assigner comparisonFactorInitializer = new Assigner();
|
---|
[3654] | 185 | Placeholder analyzer1 = new Placeholder();
|
---|
| 186 | ResultsCollector resultsCollector1 = new ResultsCollector();
|
---|
[3611] | 187 | UniformSubScopesProcessor uniformSubScopesProcessor1 = new UniformSubScopesProcessor();
|
---|
| 188 | ConditionalBranch islandTerminatedBySelectionPressure1 = new ConditionalBranch();
|
---|
| 189 | OffspringSelectionGeneticAlgorithmMainOperator mainOperator = new OffspringSelectionGeneticAlgorithmMainOperator();
|
---|
[3654] | 190 | Placeholder islandAnalyzer2 = new Placeholder();
|
---|
| 191 | ResultsCollector islandResultsCollector2 = new ResultsCollector();
|
---|
[3611] | 192 | Comparator islandSelectionPressureComparator = new Comparator();
|
---|
| 193 | ConditionalBranch islandTerminatedBySelectionPressure2 = new ConditionalBranch();
|
---|
| 194 | IntCounter terminatedIslandsCounter = new IntCounter();
|
---|
| 195 | IntCounter generationsCounter = new IntCounter();
|
---|
| 196 | IntCounter generationsSinceLastMigrationCounter = new IntCounter();
|
---|
| 197 | Comparator migrationComparator = new Comparator();
|
---|
| 198 | ConditionalBranch migrationBranch = new ConditionalBranch();
|
---|
| 199 | Assigner resetTerminatedIslandsAssigner = new Assigner();
|
---|
| 200 | Assigner resetGenerationsSinceLastMigrationAssigner = new Assigner();
|
---|
| 201 | IntCounter migrationsCounter = new IntCounter();
|
---|
| 202 | UniformSubScopesProcessor uniformSubScopesProcessor2 = new UniformSubScopesProcessor();
|
---|
| 203 | Assigner reviveIslandAssigner = new Assigner();
|
---|
[3429] | 204 | Placeholder emigrantsSelector = new Placeholder();
|
---|
| 205 | Placeholder migrator = new Placeholder();
|
---|
[3611] | 206 | UniformSubScopesProcessor uniformSubScopesProcessor3 = new UniformSubScopesProcessor();
|
---|
| 207 | Placeholder immigrationReplacer = new Placeholder();
|
---|
| 208 | Comparator generationsComparator = new Comparator();
|
---|
| 209 | Comparator terminatedIslandsComparator = new Comparator();
|
---|
[3891] | 210 | Comparator maxEvaluatedSolutionsComparator = new Comparator();
|
---|
[3744] | 211 | Placeholder comparisonFactorModifier = new Placeholder();
|
---|
[3654] | 212 | Placeholder analyzer2 = new Placeholder();
|
---|
[3611] | 213 | ConditionalBranch generationsTerminationCondition = new ConditionalBranch();
|
---|
| 214 | ConditionalBranch terminatedIslandsCondition = new ConditionalBranch();
|
---|
[3891] | 215 | ConditionalBranch evaluatedSolutionsTerminationCondition = new ConditionalBranch();
|
---|
[3429] | 216 |
|
---|
| 217 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Migrations", new IntValue(0)));
|
---|
[3750] | 218 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class IslandOffspringSelectionGeneticAlgorithm expects this to be called Generations
|
---|
[3611] | 219 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("GenerationsSinceLastMigration", new IntValue(0)));
|
---|
| 220 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("TerminatedIslands", new IntValue(0)));
|
---|
| 221 |
|
---|
[3744] | 222 | islandVariableCreator.CollectedValues.Add(new ValueParameter<ResultCollection>(ResultsParameter.Name, new ResultCollection()));
|
---|
[3611] | 223 | islandVariableCreator.CollectedValues.Add(new ValueParameter<BoolValue>("TerminateSelectionPressure", new BoolValue(false)));
|
---|
| 224 | islandVariableCreator.CollectedValues.Add(new ValueParameter<DoubleValue>("SelectionPressure", new DoubleValue(0)));
|
---|
[3429] | 225 |
|
---|
[3654] | 226 | islandAnalyzer1.Name = "Island Analyzer (placeholder)";
|
---|
| 227 | islandAnalyzer1.OperatorParameter.ActualName = IslandAnalyzerParameter.Name;
|
---|
[3429] | 228 |
|
---|
[6630] | 229 | islandResultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", "Displays the rising selection pressure during a generation.", "SelectionPressure"));
|
---|
| 230 | islandResultsCollector1.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"));
|
---|
[3744] | 231 | islandResultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
|
---|
[3611] | 232 |
|
---|
[3744] | 233 | comparisonFactorInitializer.Name = "Initialize Comparison Factor";
|
---|
| 234 | comparisonFactorInitializer.LeftSideParameter.ActualName = ComparisonFactorParameter.Name;
|
---|
| 235 | comparisonFactorInitializer.RightSideParameter.ActualName = ComparisonFactorStartParameter.Name;
|
---|
[3698] | 236 |
|
---|
[3654] | 237 | analyzer1.Name = "Analyzer (placeholder)";
|
---|
| 238 | analyzer1.OperatorParameter.ActualName = AnalyzerParameter.Name;
|
---|
[3611] | 239 |
|
---|
[3673] | 240 | resultsCollector1.CopyValue = new BoolValue(false);
|
---|
[3654] | 241 | resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Migrations"));
|
---|
| 242 | resultsCollector1.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
|
---|
[3744] | 243 | resultsCollector1.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Comparison Factor", null, ComparisonFactorParameter.Name));
|
---|
| 244 | resultsCollector1.CollectedValues.Add(new ScopeTreeLookupParameter<ResultCollection>("IslandResults", "Result set for each island", ResultsParameter.Name));
|
---|
[3654] | 245 | resultsCollector1.ResultsParameter.ActualName = ResultsParameter.Name;
|
---|
[3611] | 246 |
|
---|
| 247 | islandTerminatedBySelectionPressure1.Name = "Island Terminated ?";
|
---|
| 248 | islandTerminatedBySelectionPressure1.ConditionParameter.ActualName = "TerminateSelectionPressure";
|
---|
[3429] | 249 |
|
---|
[3611] | 250 | mainOperator.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
|
---|
| 251 | mainOperator.CrossoverParameter.ActualName = CrossoverParameter.Name;
|
---|
| 252 | mainOperator.CurrentSuccessRatioParameter.ActualName = "CurrentSuccessRatio";
|
---|
| 253 | mainOperator.ElitesParameter.ActualName = ElitesParameter.Name;
|
---|
[9569] | 254 | mainOperator.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
|
---|
[5356] | 255 | mainOperator.EvaluatedSolutionsParameter.ActualName = EvaluatedSolutionsParameter.Name;
|
---|
[3611] | 256 | mainOperator.EvaluatorParameter.ActualName = EvaluatorParameter.Name;
|
---|
| 257 | mainOperator.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
| 258 | mainOperator.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
|
---|
| 259 | mainOperator.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
|
---|
| 260 | mainOperator.MutatorParameter.ActualName = MutatorParameter.Name;
|
---|
| 261 | mainOperator.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
|
---|
| 262 | mainOperator.QualityParameter.ActualName = QualityParameter.Name;
|
---|
| 263 | mainOperator.RandomParameter.ActualName = RandomParameter.Name;
|
---|
| 264 | mainOperator.SelectionPressureParameter.ActualName = "SelectionPressure";
|
---|
| 265 | mainOperator.SelectorParameter.ActualName = SelectorParameter.Name;
|
---|
| 266 | mainOperator.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
|
---|
| 267 |
|
---|
[3654] | 268 | islandAnalyzer2.Name = "Island Analyzer (placeholder)";
|
---|
| 269 | islandAnalyzer2.OperatorParameter.ActualName = IslandAnalyzerParameter.Name;
|
---|
[3611] | 270 |
|
---|
[6630] | 271 | islandResultsCollector2.CollectedValues.Add(new LookupParameter<DoubleValue>("Current Selection Pressure", "Displays the rising selection pressure during a generation.", "SelectionPressure"));
|
---|
| 272 | islandResultsCollector2.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"));
|
---|
[3654] | 273 | islandResultsCollector2.ResultsParameter.ActualName = "Results";
|
---|
[3611] | 274 |
|
---|
| 275 | islandSelectionPressureComparator.Name = "SelectionPressure >= MaximumSelectionPressure ?";
|
---|
| 276 | islandSelectionPressureComparator.LeftSideParameter.ActualName = "SelectionPressure";
|
---|
| 277 | islandSelectionPressureComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
|
---|
| 278 | islandSelectionPressureComparator.RightSideParameter.ActualName = MaximumSelectionPressureParameter.Name;
|
---|
| 279 | islandSelectionPressureComparator.ResultParameter.ActualName = "TerminateSelectionPressure";
|
---|
| 280 |
|
---|
| 281 | islandTerminatedBySelectionPressure2.Name = "Island Terminated ?";
|
---|
| 282 | islandTerminatedBySelectionPressure2.ConditionParameter.ActualName = "TerminateSelectionPressure";
|
---|
| 283 |
|
---|
| 284 | terminatedIslandsCounter.Name = "TerminatedIslands + 1";
|
---|
| 285 | terminatedIslandsCounter.ValueParameter.ActualName = "TerminatedIslands";
|
---|
| 286 | terminatedIslandsCounter.Increment = new IntValue(1);
|
---|
| 287 |
|
---|
| 288 | generationsCounter.Name = "Generations + 1";
|
---|
| 289 | generationsCounter.ValueParameter.ActualName = "Generations";
|
---|
| 290 | generationsCounter.Increment = new IntValue(1);
|
---|
| 291 |
|
---|
| 292 | generationsSinceLastMigrationCounter.Name = "GenerationsSinceLastMigration + 1";
|
---|
| 293 | generationsSinceLastMigrationCounter.ValueParameter.ActualName = "GenerationsSinceLastMigration";
|
---|
| 294 | generationsSinceLastMigrationCounter.Increment = new IntValue(1);
|
---|
| 295 |
|
---|
| 296 | migrationComparator.Name = "GenerationsSinceLastMigration = MigrationInterval ?";
|
---|
| 297 | migrationComparator.LeftSideParameter.ActualName = "GenerationsSinceLastMigration";
|
---|
| 298 | migrationComparator.Comparison = new Comparison(ComparisonType.Equal);
|
---|
| 299 | migrationComparator.RightSideParameter.ActualName = MigrationIntervalParameter.Name;
|
---|
| 300 | migrationComparator.ResultParameter.ActualName = "Migrate";
|
---|
| 301 |
|
---|
| 302 | migrationBranch.Name = "Migrate?";
|
---|
| 303 | migrationBranch.ConditionParameter.ActualName = "Migrate";
|
---|
| 304 |
|
---|
| 305 | resetTerminatedIslandsAssigner.Name = "Reset TerminatedIslands";
|
---|
| 306 | resetTerminatedIslandsAssigner.LeftSideParameter.ActualName = "TerminatedIslands";
|
---|
| 307 | resetTerminatedIslandsAssigner.RightSideParameter.Value = new IntValue(0);
|
---|
| 308 |
|
---|
| 309 | resetGenerationsSinceLastMigrationAssigner.Name = "Reset GenerationsSinceLastMigration";
|
---|
| 310 | resetGenerationsSinceLastMigrationAssigner.LeftSideParameter.ActualName = "GenerationsSinceLastMigration";
|
---|
| 311 | resetGenerationsSinceLastMigrationAssigner.RightSideParameter.Value = new IntValue(0);
|
---|
| 312 |
|
---|
| 313 | migrationsCounter.Name = "Migrations + 1";
|
---|
| 314 | migrationsCounter.IncrementParameter.Value = new IntValue(1);
|
---|
| 315 | migrationsCounter.ValueParameter.ActualName = "Migrations";
|
---|
| 316 |
|
---|
| 317 | reviveIslandAssigner.Name = "Revive Island";
|
---|
| 318 | reviveIslandAssigner.LeftSideParameter.ActualName = "TerminateSelectionPressure";
|
---|
| 319 | reviveIslandAssigner.RightSideParameter.Value = new BoolValue(false);
|
---|
| 320 |
|
---|
[3429] | 321 | emigrantsSelector.Name = "Emigrants Selector (placeholder)";
|
---|
| 322 | emigrantsSelector.OperatorParameter.ActualName = EmigrantsSelectorParameter.Name;
|
---|
| 323 |
|
---|
| 324 | migrator.Name = "Migrator (placeholder)";
|
---|
| 325 | migrator.OperatorParameter.ActualName = MigratorParameter.Name;
|
---|
| 326 |
|
---|
[3611] | 327 | immigrationReplacer.Name = "Immigration Replacer (placeholder)";
|
---|
| 328 | immigrationReplacer.OperatorParameter.ActualName = ImmigrationReplacerParameter.Name;
|
---|
[3429] | 329 |
|
---|
[3611] | 330 | generationsComparator.Name = "Generations >= MaximumGenerations ?";
|
---|
| 331 | generationsComparator.LeftSideParameter.ActualName = "Generations";
|
---|
| 332 | generationsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
|
---|
| 333 | generationsComparator.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
|
---|
| 334 | generationsComparator.ResultParameter.ActualName = "TerminateGenerations";
|
---|
[3429] | 335 |
|
---|
[3611] | 336 | terminatedIslandsComparator.Name = "All Islands terminated ?";
|
---|
| 337 | terminatedIslandsComparator.LeftSideParameter.ActualName = "TerminatedIslands";
|
---|
| 338 | terminatedIslandsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
|
---|
| 339 | terminatedIslandsComparator.RightSideParameter.ActualName = NumberOfIslandsParameter.Name;
|
---|
| 340 | terminatedIslandsComparator.ResultParameter.ActualName = "TerminateTerminatedIslands";
|
---|
[3429] | 341 |
|
---|
[3891] | 342 | maxEvaluatedSolutionsComparator.Name = "EvaluatedSolutions >= MaximumEvaluatedSolutions ?";
|
---|
| 343 | maxEvaluatedSolutionsComparator.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
|
---|
[5356] | 344 | maxEvaluatedSolutionsComparator.LeftSideParameter.ActualName = EvaluatedSolutionsParameter.Name;
|
---|
[3891] | 345 | maxEvaluatedSolutionsComparator.ResultParameter.ActualName = "TerminateEvaluatedSolutions";
|
---|
| 346 | maxEvaluatedSolutionsComparator.RightSideParameter.ActualName = "MaximumEvaluatedSolutions";
|
---|
| 347 |
|
---|
[3744] | 348 | comparisonFactorModifier.Name = "Update Comparison Factor (Placeholder)";
|
---|
| 349 | comparisonFactorModifier.OperatorParameter.ActualName = ComparisonFactorModifierParameter.Name;
|
---|
[3698] | 350 |
|
---|
[3654] | 351 | analyzer2.Name = "Analyzer (placeholder)";
|
---|
| 352 | analyzer2.OperatorParameter.ActualName = AnalyzerParameter.Name;
|
---|
[3429] | 353 |
|
---|
[3611] | 354 | generationsTerminationCondition.Name = "Terminate (MaxGenerations) ?";
|
---|
| 355 | generationsTerminationCondition.ConditionParameter.ActualName = "TerminateGenerations";
|
---|
| 356 |
|
---|
| 357 | terminatedIslandsCondition.Name = "Terminate (TerminatedIslands) ?";
|
---|
| 358 | terminatedIslandsCondition.ConditionParameter.ActualName = "TerminateTerminatedIslands";
|
---|
[3891] | 359 |
|
---|
| 360 | evaluatedSolutionsTerminationCondition.Name = "Terminate (EvaluatedSolutions) ?";
|
---|
| 361 | evaluatedSolutionsTerminationCondition.ConditionParameter.ActualName = "TerminateEvaluatedSolutions";
|
---|
[3429] | 362 | #endregion
|
---|
| 363 |
|
---|
| 364 | #region Create operator graph
|
---|
| 365 | OperatorGraph.InitialOperator = variableCreator;
|
---|
[3611] | 366 | variableCreator.Successor = uniformSubScopesProcessor0;
|
---|
| 367 | uniformSubScopesProcessor0.Operator = islandVariableCreator;
|
---|
[3744] | 368 | uniformSubScopesProcessor0.Successor = comparisonFactorInitializer;
|
---|
[3654] | 369 | islandVariableCreator.Successor = islandAnalyzer1;
|
---|
| 370 | islandAnalyzer1.Successor = islandResultsCollector1;
|
---|
| 371 | islandResultsCollector1.Successor = null;
|
---|
[3744] | 372 | comparisonFactorInitializer.Successor = analyzer1;
|
---|
[3654] | 373 | analyzer1.Successor = resultsCollector1;
|
---|
[5356] | 374 | resultsCollector1.Successor = uniformSubScopesProcessor1;
|
---|
[3611] | 375 | uniformSubScopesProcessor1.Operator = islandTerminatedBySelectionPressure1;
|
---|
| 376 | uniformSubScopesProcessor1.Successor = generationsCounter;
|
---|
| 377 | islandTerminatedBySelectionPressure1.TrueBranch = null;
|
---|
| 378 | islandTerminatedBySelectionPressure1.FalseBranch = mainOperator;
|
---|
| 379 | islandTerminatedBySelectionPressure1.Successor = null;
|
---|
[3654] | 380 | mainOperator.Successor = islandAnalyzer2;
|
---|
| 381 | islandAnalyzer2.Successor = islandResultsCollector2;
|
---|
[5356] | 382 | islandResultsCollector2.Successor = islandSelectionPressureComparator;
|
---|
[3611] | 383 | islandSelectionPressureComparator.Successor = islandTerminatedBySelectionPressure2;
|
---|
| 384 | islandTerminatedBySelectionPressure2.TrueBranch = terminatedIslandsCounter;
|
---|
| 385 | islandTerminatedBySelectionPressure2.FalseBranch = null;
|
---|
| 386 | islandTerminatedBySelectionPressure2.Successor = null;
|
---|
| 387 | generationsCounter.Successor = generationsSinceLastMigrationCounter;
|
---|
| 388 | generationsSinceLastMigrationCounter.Successor = migrationComparator;
|
---|
| 389 | migrationComparator.Successor = migrationBranch;
|
---|
| 390 | migrationBranch.TrueBranch = resetTerminatedIslandsAssigner;
|
---|
| 391 | migrationBranch.FalseBranch = null;
|
---|
| 392 | migrationBranch.Successor = generationsComparator;
|
---|
| 393 | resetTerminatedIslandsAssigner.Successor = resetGenerationsSinceLastMigrationAssigner;
|
---|
| 394 | resetGenerationsSinceLastMigrationAssigner.Successor = migrationsCounter;
|
---|
| 395 | migrationsCounter.Successor = uniformSubScopesProcessor2;
|
---|
| 396 | uniformSubScopesProcessor2.Operator = reviveIslandAssigner;
|
---|
| 397 | uniformSubScopesProcessor2.Successor = migrator;
|
---|
| 398 | reviveIslandAssigner.Successor = emigrantsSelector;
|
---|
[3429] | 399 | emigrantsSelector.Successor = null;
|
---|
[3611] | 400 | migrator.Successor = uniformSubScopesProcessor3;
|
---|
| 401 | uniformSubScopesProcessor3.Operator = immigrationReplacer;
|
---|
| 402 | uniformSubScopesProcessor3.Successor = null;
|
---|
| 403 | immigrationReplacer.Successor = null;
|
---|
| 404 | generationsComparator.Successor = terminatedIslandsComparator;
|
---|
[3891] | 405 | terminatedIslandsComparator.Successor = maxEvaluatedSolutionsComparator;
|
---|
| 406 | maxEvaluatedSolutionsComparator.Successor = comparisonFactorModifier;
|
---|
[3744] | 407 | comparisonFactorModifier.Successor = analyzer2;
|
---|
[5356] | 408 | analyzer2.Successor = generationsTerminationCondition;
|
---|
[3611] | 409 | generationsTerminationCondition.TrueBranch = null;
|
---|
| 410 | generationsTerminationCondition.FalseBranch = terminatedIslandsCondition;
|
---|
| 411 | generationsTerminationCondition.Successor = null;
|
---|
| 412 | terminatedIslandsCondition.TrueBranch = null;
|
---|
[3891] | 413 | terminatedIslandsCondition.FalseBranch = evaluatedSolutionsTerminationCondition;
|
---|
[3611] | 414 | terminatedIslandsCondition.Successor = null;
|
---|
[3891] | 415 | evaluatedSolutionsTerminationCondition.TrueBranch = null;
|
---|
| 416 | evaluatedSolutionsTerminationCondition.FalseBranch = uniformSubScopesProcessor1;
|
---|
| 417 | evaluatedSolutionsTerminationCondition.Successor = null;
|
---|
[3429] | 418 | #endregion
|
---|
| 419 | }
|
---|
[3715] | 420 |
|
---|
[9569] | 421 | [StorableHook(HookType.AfterDeserialization)]
|
---|
| 422 | private void AfterDeserialization() {
|
---|
[9592] | 423 | // BackwardsCompatibility3.3
|
---|
[9591] | 424 | #region Backwards compatible code, remove with 3.4
|
---|
[9569] | 425 | if (!Parameters.ContainsKey("ReevaluateElites")) {
|
---|
| 426 | Parameters.Add(new ValueLookupParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)"));
|
---|
| 427 | }
|
---|
[9591] | 428 | #endregion
|
---|
[9569] | 429 | }
|
---|
| 430 |
|
---|
[3715] | 431 | public override IOperation Apply() {
|
---|
| 432 | if (CrossoverParameter.ActualValue == null)
|
---|
| 433 | return null;
|
---|
| 434 | return base.Apply();
|
---|
| 435 | }
|
---|
[3429] | 436 | }
|
---|
| 437 | }
|
---|