[8313] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
| 3 | * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of HeuristicLab.
|
---|
| 6 | *
|
---|
| 7 | * HeuristicLab is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * HeuristicLab is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | */
|
---|
| 20 | #endregion
|
---|
| 21 |
|
---|
| 22 | using HeuristicLab.Common;
|
---|
| 23 | using HeuristicLab.Core;
|
---|
| 24 | using HeuristicLab.Data;
|
---|
| 25 | using HeuristicLab.Operators;
|
---|
[8379] | 26 | using HeuristicLab.Optimization;
|
---|
[8313] | 27 | using HeuristicLab.Optimization.Operators;
|
---|
| 28 | using HeuristicLab.Parameters;
|
---|
| 29 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 30 | using HeuristicLab.Selection;
|
---|
| 31 |
|
---|
| 32 | namespace HeuristicLab.Algorithms.RAPGA {
|
---|
| 33 | /// <summary>
|
---|
| 34 | /// An operator which represents the main loop of a relevant alleles preserving genetic algorithm.
|
---|
| 35 | /// </summary>
|
---|
| 36 | [Item("RAPGAMainLoop", "An operator which represents the main loop of a relevant alleles preserving genetic algorithm.")]
|
---|
| 37 | [StorableClass]
|
---|
| 38 | public sealed class RAPGAMainLoop : AlgorithmOperator {
|
---|
| 39 | #region Parameter properties
|
---|
| 40 | public ValueLookupParameter<IRandom> RandomParameter {
|
---|
| 41 | get { return (ValueLookupParameter<IRandom>)Parameters["Random"]; }
|
---|
| 42 | }
|
---|
| 43 | public ValueLookupParameter<BoolValue> MaximizationParameter {
|
---|
| 44 | get { return (ValueLookupParameter<BoolValue>)Parameters["Maximization"]; }
|
---|
| 45 | }
|
---|
| 46 | public ScopeTreeLookupParameter<DoubleValue> QualityParameter {
|
---|
| 47 | get { return (ScopeTreeLookupParameter<DoubleValue>)Parameters["Quality"]; }
|
---|
| 48 | }
|
---|
| 49 | public ValueLookupParameter<IOperator> SelectorParameter {
|
---|
| 50 | get { return (ValueLookupParameter<IOperator>)Parameters["Selector"]; }
|
---|
| 51 | }
|
---|
| 52 | public ValueLookupParameter<IOperator> CrossoverParameter {
|
---|
| 53 | get { return (ValueLookupParameter<IOperator>)Parameters["Crossover"]; }
|
---|
| 54 | }
|
---|
| 55 | public ValueLookupParameter<PercentValue> MutationProbabilityParameter {
|
---|
| 56 | get { return (ValueLookupParameter<PercentValue>)Parameters["MutationProbability"]; }
|
---|
| 57 | }
|
---|
| 58 | public ValueLookupParameter<IOperator> MutatorParameter {
|
---|
| 59 | get { return (ValueLookupParameter<IOperator>)Parameters["Mutator"]; }
|
---|
| 60 | }
|
---|
| 61 | public ValueLookupParameter<IOperator> EvaluatorParameter {
|
---|
| 62 | get { return (ValueLookupParameter<IOperator>)Parameters["Evaluator"]; }
|
---|
| 63 | }
|
---|
| 64 | public ValueLookupParameter<IntValue> ElitesParameter {
|
---|
| 65 | get { return (ValueLookupParameter<IntValue>)Parameters["Elites"]; }
|
---|
| 66 | }
|
---|
| 67 | public ValueLookupParameter<IntValue> MaximumGenerationsParameter {
|
---|
| 68 | get { return (ValueLookupParameter<IntValue>)Parameters["MaximumGenerations"]; }
|
---|
| 69 | }
|
---|
| 70 | public ValueLookupParameter<VariableCollection> ResultsParameter {
|
---|
| 71 | get { return (ValueLookupParameter<VariableCollection>)Parameters["Results"]; }
|
---|
| 72 | }
|
---|
| 73 | public ValueLookupParameter<IOperator> AnalyzerParameter {
|
---|
| 74 | get { return (ValueLookupParameter<IOperator>)Parameters["Analyzer"]; }
|
---|
| 75 | }
|
---|
| 76 | public ValueLookupParameter<IntValue> EvaluatedSolutionsParameter {
|
---|
| 77 | get { return (ValueLookupParameter<IntValue>)Parameters["EvaluatedSolutions"]; }
|
---|
| 78 | }
|
---|
| 79 | public ValueLookupParameter<IntValue> PopulationSizeParameter {
|
---|
| 80 | get { return (ValueLookupParameter<IntValue>)Parameters["PopulationSize"]; }
|
---|
| 81 | }
|
---|
[8330] | 82 | public IValueLookupParameter<IntValue> MinimumPopulationSizeParameter {
|
---|
| 83 | get { return (IValueLookupParameter<IntValue>)Parameters["MinimumPopulationSize"]; }
|
---|
| 84 | }
|
---|
| 85 | public IValueLookupParameter<IntValue> MaximumPopulationSizeParameter {
|
---|
| 86 | get { return (IValueLookupParameter<IntValue>)Parameters["MaximumPopulationSize"]; }
|
---|
| 87 | }
|
---|
| 88 | public IValueLookupParameter<DoubleValue> ComparisonFactorParameter {
|
---|
| 89 | get { return (IValueLookupParameter<DoubleValue>)Parameters["ComparisonFactor"]; }
|
---|
| 90 | }
|
---|
| 91 | public IValueLookupParameter<IntValue> EffortParameter {
|
---|
| 92 | get { return (IValueLookupParameter<IntValue>)Parameters["Effort"]; }
|
---|
| 93 | }
|
---|
[8379] | 94 | public IValueLookupParameter<IntValue> BatchSizeParameter {
|
---|
| 95 | get { return (IValueLookupParameter<IntValue>)Parameters["BatchSize"]; }
|
---|
| 96 | }
|
---|
| 97 | public IValueLookupParameter<ISolutionSimilarityCalculator> SimilarityCalculatorParameter {
|
---|
| 98 | get { return (IValueLookupParameter<ISolutionSimilarityCalculator>)Parameters["SimilarityCalculator"]; }
|
---|
| 99 | }
|
---|
[8313] | 100 | private ScopeParameter CurrentScopeParameter {
|
---|
| 101 | get { return (ScopeParameter)Parameters["CurrentScope"]; }
|
---|
| 102 | }
|
---|
| 103 |
|
---|
| 104 | public IScope CurrentScope {
|
---|
| 105 | get { return CurrentScopeParameter.ActualValue; }
|
---|
| 106 | }
|
---|
| 107 | #endregion
|
---|
| 108 |
|
---|
| 109 | [StorableConstructor]
|
---|
| 110 | private RAPGAMainLoop(bool deserializing) : base(deserializing) { }
|
---|
| 111 | private RAPGAMainLoop(RAPGAMainLoop original, Cloner cloner) : base(original, cloner) { }
|
---|
| 112 | public RAPGAMainLoop()
|
---|
| 113 | : base() {
|
---|
| 114 | Initialize();
|
---|
| 115 | }
|
---|
| 116 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 117 | return new RAPGAMainLoop(this, cloner);
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | private void Initialize() {
|
---|
| 121 | #region Create parameters
|
---|
| 122 | Parameters.Add(new ValueLookupParameter<IRandom>("Random", "A pseudo random number generator."));
|
---|
| 123 | Parameters.Add(new ValueLookupParameter<BoolValue>("Maximization", "True if the problem is a maximization problem, otherwise false."));
|
---|
| 124 | Parameters.Add(new ScopeTreeLookupParameter<DoubleValue>("Quality", "The value which represents the quality of a solution."));
|
---|
| 125 | Parameters.Add(new ValueLookupParameter<IOperator>("Selector", "The operator used to select solutions for reproduction."));
|
---|
| 126 | Parameters.Add(new ValueLookupParameter<IOperator>("Crossover", "The operator used to cross solutions."));
|
---|
| 127 | Parameters.Add(new ValueLookupParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution."));
|
---|
| 128 | Parameters.Add(new ValueLookupParameter<IOperator>("Mutator", "The operator used to mutate solutions."));
|
---|
| 129 | 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."));
|
---|
| 130 | Parameters.Add(new ValueLookupParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation."));
|
---|
| 131 | Parameters.Add(new ValueLookupParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed."));
|
---|
| 132 | Parameters.Add(new ValueLookupParameter<VariableCollection>("Results", "The variable collection where results should be stored."));
|
---|
| 133 | Parameters.Add(new ValueLookupParameter<IOperator>("Analyzer", "The operator used to analyze each generation."));
|
---|
| 134 | Parameters.Add(new ValueLookupParameter<IntValue>("EvaluatedSolutions", "The number of times solutions have been evaluated."));
|
---|
| 135 | Parameters.Add(new ValueLookupParameter<IntValue>("PopulationSize", "The size of the population."));
|
---|
[8330] | 136 | Parameters.Add(new ValueLookupParameter<IntValue>("MinimumPopulationSize", "The minimum size of the population of solutions."));
|
---|
| 137 | Parameters.Add(new ValueLookupParameter<IntValue>("MaximumPopulationSize", "The maximum size of the population of solutions."));
|
---|
| 138 | Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactor", "The comparison factor."));
|
---|
| 139 | Parameters.Add(new ValueLookupParameter<IntValue>("Effort", "The maximum number of offspring created in each generation."));
|
---|
[8400] | 140 | Parameters.Add(new ValueLookupParameter<IntValue>("BatchSize", "The number of children that should be created during one iteration of the offspring creation process."));
|
---|
[8379] | 141 | Parameters.Add(new ValueLookupParameter<ISolutionSimilarityCalculator>("SimilarityCalculator", "The operator used to calculate the similarity between two solutions."));
|
---|
[8313] | 142 | Parameters.Add(new ScopeParameter("CurrentScope", "The current scope which represents a population of solutions on which the genetic algorithm should be applied."));
|
---|
| 143 | #endregion
|
---|
| 144 |
|
---|
| 145 | #region Create operators
|
---|
| 146 | VariableCreator variableCreator = new VariableCreator();
|
---|
[8377] | 147 | Assigner assigner1 = new Assigner();
|
---|
[8359] | 148 | ResultsCollector resultsCollector = new ResultsCollector();
|
---|
[8313] | 149 | Placeholder analyzer1 = new Placeholder();
|
---|
| 150 | Placeholder selector = new Placeholder();
|
---|
| 151 | SubScopesProcessor subScopesProcessor1 = new SubScopesProcessor();
|
---|
| 152 | ChildrenCreator childrenCreator = new ChildrenCreator();
|
---|
[8377] | 153 | UniformSubScopesProcessor uniformSubScopesProcessor = new UniformSubScopesProcessor();
|
---|
[8313] | 154 | Placeholder crossover = new Placeholder();
|
---|
| 155 | StochasticBranch stochasticBranch = new StochasticBranch();
|
---|
| 156 | Placeholder mutator = new Placeholder();
|
---|
| 157 | Placeholder evaluator = new Placeholder();
|
---|
[8377] | 158 | WeightedParentsQualityComparator weightedParentsQualityComparator = new WeightedParentsQualityComparator();
|
---|
| 159 | SubScopesRemover subScopesRemover = new SubScopesRemover();
|
---|
| 160 | IntCounter intCounter1 = new IntCounter();
|
---|
[8385] | 161 | IntCounter intCounter2 = new IntCounter();
|
---|
[8330] | 162 | ConditionalSelector conditionalSelector = new ConditionalSelector();
|
---|
| 163 | RightReducer rightReducer1 = new RightReducer();
|
---|
[8377] | 164 | DuplicatesSelector duplicateSelector = new DuplicatesSelector();
|
---|
| 165 | LeftReducer leftReducer1 = new LeftReducer();
|
---|
| 166 | ProgressiveOffspringPreserver progressiveOffspringSelector = new ProgressiveOffspringPreserver();
|
---|
[8359] | 167 | SubScopesCounter subScopesCounter2 = new SubScopesCounter();
|
---|
[8642] | 168 | ExpressionCalculator calculator1 = new ExpressionCalculator();
|
---|
[8622] | 169 | ConditionalBranch conditionalBranch1 = new ConditionalBranch();
|
---|
[8377] | 170 | Comparator comparator1 = new Comparator();
|
---|
| 171 | ConditionalBranch conditionalBranch2 = new ConditionalBranch();
|
---|
| 172 | LeftReducer leftReducer2 = new LeftReducer();
|
---|
| 173 | SubScopesProcessor subScopesProcessor2 = new SubScopesProcessor();
|
---|
| 174 | BestSelector bestSelector = new BestSelector();
|
---|
[8330] | 175 | RightReducer rightReducer2 = new RightReducer();
|
---|
[8377] | 176 | ScopeCleaner scopeCleaner = new ScopeCleaner();
|
---|
[8622] | 177 | ScopeRestorer scopeRestorer = new ScopeRestorer();
|
---|
[8313] | 178 | MergingReducer mergingReducer = new MergingReducer();
|
---|
[8385] | 179 | IntCounter intCounter3 = new IntCounter();
|
---|
[8377] | 180 | SubScopesCounter subScopesCounter3 = new SubScopesCounter();
|
---|
[8642] | 181 | ExpressionCalculator calculator2 = new ExpressionCalculator();
|
---|
[8622] | 182 | Comparator comparator2 = new Comparator();
|
---|
| 183 | ConditionalBranch conditionalBranch3 = new ConditionalBranch();
|
---|
[8385] | 184 | Placeholder analyzer2 = new Placeholder();
|
---|
[8330] | 185 | Comparator comparator3 = new Comparator();
|
---|
[8622] | 186 | ConditionalBranch conditionalBranch4 = new ConditionalBranch();
|
---|
[8330] | 187 | Comparator comparator4 = new Comparator();
|
---|
[8622] | 188 | ConditionalBranch conditionalBranch5 = new ConditionalBranch();
|
---|
[8377] | 189 | Assigner assigner3 = new Assigner();
|
---|
| 190 | Assigner assigner4 = new Assigner();
|
---|
[8385] | 191 | Assigner assigner5 = new Assigner();
|
---|
[8313] | 192 |
|
---|
[8359] | 193 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Generations", new IntValue(0))); // Class RAPGA expects this to be called Generations
|
---|
[8330] | 194 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("CurrentPopulationSize", new IntValue(0)));
|
---|
[8377] | 195 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("NumberOfCreatedOffspring", new IntValue(0)));
|
---|
| 196 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("NumberOfSuccessfulOffspring", new IntValue(0)));
|
---|
| 197 | variableCreator.CollectedValues.Add(new ValueParameter<ScopeList>("OffspringList", new ScopeList()));
|
---|
[8313] | 198 |
|
---|
[8377] | 199 | assigner1.Name = "Initialize CurrentPopulationSize";
|
---|
| 200 | assigner1.LeftSideParameter.ActualName = "CurrentPopulationSize";
|
---|
| 201 | assigner1.RightSideParameter.ActualName = PopulationSizeParameter.Name;
|
---|
[8330] | 202 |
|
---|
[8359] | 203 | resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Generations"));
|
---|
| 204 | resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("CurrentPopulationSize"));
|
---|
| 205 | resultsCollector.ResultsParameter.ActualName = "Results";
|
---|
[8313] | 206 |
|
---|
| 207 | analyzer1.Name = "Analyzer";
|
---|
| 208 | analyzer1.OperatorParameter.ActualName = "Analyzer";
|
---|
| 209 |
|
---|
| 210 | selector.Name = "Selector";
|
---|
| 211 | selector.OperatorParameter.ActualName = "Selector";
|
---|
| 212 |
|
---|
| 213 | childrenCreator.ParentsPerChild = new IntValue(2);
|
---|
| 214 |
|
---|
[8377] | 215 | uniformSubScopesProcessor.Parallel.Value = true;
|
---|
| 216 |
|
---|
[8313] | 217 | crossover.Name = "Crossover";
|
---|
| 218 | crossover.OperatorParameter.ActualName = "Crossover";
|
---|
| 219 |
|
---|
| 220 | stochasticBranch.ProbabilityParameter.ActualName = "MutationProbability";
|
---|
| 221 | stochasticBranch.RandomParameter.ActualName = "Random";
|
---|
| 222 |
|
---|
| 223 | mutator.Name = "Mutator";
|
---|
| 224 | mutator.OperatorParameter.ActualName = "Mutator";
|
---|
| 225 |
|
---|
| 226 | evaluator.Name = "Evaluator";
|
---|
| 227 | evaluator.OperatorParameter.ActualName = "Evaluator";
|
---|
| 228 |
|
---|
[8377] | 229 | weightedParentsQualityComparator.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
|
---|
| 230 | weightedParentsQualityComparator.LeftSideParameter.ActualName = QualityParameter.Name;
|
---|
| 231 | weightedParentsQualityComparator.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
| 232 | weightedParentsQualityComparator.RightSideParameter.ActualName = QualityParameter.Name;
|
---|
| 233 | weightedParentsQualityComparator.ResultParameter.ActualName = "SuccessfulOffspring";
|
---|
[8313] | 234 |
|
---|
[8377] | 235 | subScopesRemover.RemoveAllSubScopes = true;
|
---|
[8359] | 236 |
|
---|
[8385] | 237 | intCounter1.Name = "Increment NumberOfCreatedOffspring";
|
---|
| 238 | intCounter1.ValueParameter.ActualName = "NumberOfCreatedOffspring";
|
---|
[8377] | 239 | intCounter1.Increment = null;
|
---|
[8385] | 240 | intCounter1.IncrementParameter.ActualName = BatchSizeParameter.Name;
|
---|
[8377] | 241 |
|
---|
[8385] | 242 | intCounter2.Name = "Increment EvaluatedSolutions";
|
---|
| 243 | intCounter2.ValueParameter.ActualName = EvaluatedSolutionsParameter.Name;
|
---|
| 244 | intCounter2.Increment = null;
|
---|
| 245 | intCounter2.IncrementParameter.ActualName = BatchSizeParameter.Name;
|
---|
| 246 |
|
---|
[8330] | 247 | conditionalSelector.ConditionParameter.ActualName = "SuccessfulOffspring";
|
---|
| 248 | conditionalSelector.ConditionParameter.Depth = 1;
|
---|
| 249 | conditionalSelector.CopySelected.Value = false;
|
---|
[8313] | 250 |
|
---|
[8349] | 251 | duplicateSelector.CopySelected.Value = false;
|
---|
| 252 |
|
---|
[8377] | 253 | progressiveOffspringSelector.OffspringListParameter.ActualName = "OffspringList";
|
---|
| 254 | progressiveOffspringSelector.ElitesParameter.ActualName = ElitesParameter.Name;
|
---|
| 255 | progressiveOffspringSelector.MaximumPopulationSizeParameter.ActualName = MaximumPopulationSizeParameter.Name;
|
---|
[8349] | 256 |
|
---|
[8359] | 257 | subScopesCounter2.Name = "Count Successful Offspring";
|
---|
| 258 | subScopesCounter2.ValueParameter.ActualName = "NumberOfSuccessfulOffspring";
|
---|
[8313] | 259 |
|
---|
[8622] | 260 | calculator1.Name = "NumberOfSuccessfulOffspring == MaximumPopulationSize - Elites";
|
---|
| 261 | calculator1.CollectedValues.Add(new ValueLookupParameter<IntValue>("NumberOfSuccessfulOffspring"));
|
---|
| 262 | calculator1.CollectedValues.Add(new ValueLookupParameter<IntValue>("MaximumPopulationSize"));
|
---|
| 263 | calculator1.CollectedValues.Add(new ValueLookupParameter<IntValue>("Elites"));
|
---|
| 264 | calculator1.ExpressionParameter.Value = new StringValue("NumberOfSuccessfulOffspring MaximumPopulationSize Elites - ==");
|
---|
| 265 | calculator1.ExpressionResultParameter.ActualName = "Break";
|
---|
[8330] | 266 |
|
---|
[8377] | 267 | conditionalBranch1.Name = "Break?";
|
---|
| 268 | conditionalBranch1.ConditionParameter.ActualName = "Break";
|
---|
[8330] | 269 |
|
---|
[8622] | 270 | comparator1.Name = "NumberOfCreatedOffspring >= Effort";
|
---|
| 271 | comparator1.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
|
---|
| 272 | comparator1.LeftSideParameter.ActualName = "NumberOfCreatedOffspring";
|
---|
| 273 | comparator1.RightSideParameter.ActualName = EffortParameter.Name;
|
---|
| 274 | comparator1.ResultParameter.ActualName = "Break";
|
---|
[8330] | 275 |
|
---|
[8377] | 276 | conditionalBranch2.Name = "Break?";
|
---|
| 277 | conditionalBranch2.ConditionParameter.ActualName = "Break";
|
---|
[8330] | 278 |
|
---|
[8377] | 279 | bestSelector.CopySelected = new BoolValue(false);
|
---|
| 280 | bestSelector.MaximizationParameter.ActualName = MaximizationParameter.Name;
|
---|
| 281 | bestSelector.NumberOfSelectedSubScopesParameter.ActualName = "Elites";
|
---|
| 282 | bestSelector.QualityParameter.ActualName = QualityParameter.Name;
|
---|
[8330] | 283 |
|
---|
[8385] | 284 | intCounter3.Name = "Increment Generations";
|
---|
| 285 | intCounter3.Increment = new IntValue(1);
|
---|
| 286 | intCounter3.ValueParameter.ActualName = "Generations";
|
---|
| 287 |
|
---|
| 288 | subScopesCounter3.Name = "Update CurrentPopulationSize";
|
---|
[8377] | 289 | subScopesCounter3.ValueParameter.ActualName = "CurrentPopulationSize";
|
---|
| 290 | subScopesCounter3.AccumulateParameter.Value = new BoolValue(false);
|
---|
| 291 |
|
---|
[8622] | 292 | calculator2.Name = "Evaluate ActualSelectionPressure";
|
---|
| 293 | calculator2.CollectedValues.Add(new ValueLookupParameter<IntValue>("NumberOfCreatedOffspring"));
|
---|
| 294 | calculator2.CollectedValues.Add(new ValueLookupParameter<IntValue>("Elites"));
|
---|
| 295 | calculator2.CollectedValues.Add(new ValueLookupParameter<IntValue>("CurrentPopulationSize"));
|
---|
| 296 | calculator2.ExpressionParameter.Value = new StringValue("NumberOfCreatedOffspring Elites + CurrentPopulationSize /");
|
---|
| 297 | calculator2.ExpressionResultParameter.ActualName = "ActualSelectionPressure";
|
---|
[8385] | 298 |
|
---|
[8622] | 299 | comparator2.Name = "CurrentPopulationSize < 1";
|
---|
| 300 | comparator2.Comparison = new Comparison(ComparisonType.Less);
|
---|
| 301 | comparator2.LeftSideParameter.ActualName = "CurrentPopulationSize";
|
---|
| 302 | comparator2.RightSideParameter.Value = new IntValue(1);
|
---|
| 303 | comparator2.ResultParameter.ActualName = "Terminate";
|
---|
| 304 |
|
---|
| 305 | conditionalBranch3.Name = "Terminate?";
|
---|
| 306 | conditionalBranch3.ConditionParameter.ActualName = "Terminate";
|
---|
| 307 |
|
---|
[8385] | 308 | analyzer2.Name = "Analyzer";
|
---|
| 309 | analyzer2.OperatorParameter.ActualName = "Analyzer";
|
---|
| 310 |
|
---|
[8377] | 311 | comparator3.Name = "Generations >= MaximumGenerations";
|
---|
[8330] | 312 | comparator3.Comparison = new Comparison(ComparisonType.GreaterOrEqual);
|
---|
| 313 | comparator3.LeftSideParameter.ActualName = "Generations";
|
---|
| 314 | comparator3.ResultParameter.ActualName = "Terminate";
|
---|
| 315 | comparator3.RightSideParameter.ActualName = MaximumGenerationsParameter.Name;
|
---|
| 316 |
|
---|
[8622] | 317 | conditionalBranch4.Name = "Terminate?";
|
---|
| 318 | conditionalBranch4.ConditionParameter.ActualName = "Terminate";
|
---|
[8330] | 319 |
|
---|
[8377] | 320 | comparator4.Name = "CurrentPopulationSize < MinimumPopulationSize";
|
---|
[8330] | 321 | comparator4.Comparison = new Comparison(ComparisonType.Less);
|
---|
| 322 | comparator4.LeftSideParameter.ActualName = "CurrentPopulationSize";
|
---|
| 323 | comparator4.RightSideParameter.ActualName = MinimumPopulationSizeParameter.Name;
|
---|
| 324 | comparator4.ResultParameter.ActualName = "Terminate";
|
---|
| 325 |
|
---|
[8622] | 326 | conditionalBranch5.Name = "Terminate?";
|
---|
| 327 | conditionalBranch5.ConditionParameter.ActualName = "Terminate";
|
---|
[8377] | 328 |
|
---|
[8385] | 329 | assigner3.Name = "Reset NumberOfCreatedOffspring";
|
---|
| 330 | assigner3.LeftSideParameter.ActualName = "NumberOfCreatedOffspring";
|
---|
[8377] | 331 | assigner3.RightSideParameter.Value = new IntValue(0);
|
---|
| 332 |
|
---|
[8385] | 333 | assigner4.Name = "Reset NumberOfSuccessfulOffspring";
|
---|
| 334 | assigner4.LeftSideParameter.ActualName = "NumberOfSuccessfulOffspring";
|
---|
| 335 | assigner4.RightSideParameter.Value = new IntValue(0);
|
---|
| 336 |
|
---|
| 337 | assigner5.Name = "Reset OffspringList";
|
---|
| 338 | assigner5.LeftSideParameter.ActualName = "OffspringList";
|
---|
| 339 | assigner5.RightSideParameter.Value = new ScopeList();
|
---|
[8313] | 340 | #endregion
|
---|
| 341 |
|
---|
| 342 | #region Create operator graph
|
---|
| 343 | OperatorGraph.InitialOperator = variableCreator;
|
---|
[8377] | 344 | variableCreator.Successor = assigner1;
|
---|
| 345 | assigner1.Successor = resultsCollector;
|
---|
[8359] | 346 | resultsCollector.Successor = analyzer1;
|
---|
[8313] | 347 | analyzer1.Successor = selector;
|
---|
| 348 | selector.Successor = subScopesProcessor1;
|
---|
| 349 | subScopesProcessor1.Operators.Add(new EmptyOperator());
|
---|
| 350 | subScopesProcessor1.Operators.Add(childrenCreator);
|
---|
[8622] | 351 | subScopesProcessor1.Successor = calculator1;
|
---|
[8377] | 352 | childrenCreator.Successor = uniformSubScopesProcessor;
|
---|
| 353 | uniformSubScopesProcessor.Operator = crossover;
|
---|
[8385] | 354 | uniformSubScopesProcessor.Successor = intCounter1;
|
---|
[8313] | 355 | crossover.Successor = stochasticBranch;
|
---|
| 356 | stochasticBranch.FirstBranch = mutator;
|
---|
| 357 | stochasticBranch.SecondBranch = null;
|
---|
| 358 | mutator.Successor = null;
|
---|
[8377] | 359 | stochasticBranch.Successor = evaluator;
|
---|
| 360 | evaluator.Successor = weightedParentsQualityComparator;
|
---|
| 361 | weightedParentsQualityComparator.Successor = subScopesRemover;
|
---|
[8385] | 362 | intCounter1.Successor = intCounter2;
|
---|
| 363 | intCounter2.Successor = conditionalSelector;
|
---|
[8330] | 364 | conditionalSelector.Successor = rightReducer1;
|
---|
[8377] | 365 | rightReducer1.Successor = duplicateSelector;
|
---|
| 366 | duplicateSelector.Successor = leftReducer1;
|
---|
| 367 | leftReducer1.Successor = progressiveOffspringSelector;
|
---|
| 368 | progressiveOffspringSelector.Successor = subScopesCounter2;
|
---|
[8622] | 369 | calculator1.Successor = conditionalBranch1;
|
---|
| 370 | conditionalBranch1.FalseBranch = comparator1;
|
---|
[8377] | 371 | conditionalBranch1.TrueBranch = subScopesProcessor2;
|
---|
[8622] | 372 | comparator1.Successor = conditionalBranch2;
|
---|
[8377] | 373 | conditionalBranch2.FalseBranch = leftReducer2;
|
---|
| 374 | conditionalBranch2.TrueBranch = subScopesProcessor2;
|
---|
| 375 | leftReducer2.Successor = selector;
|
---|
| 376 | subScopesProcessor2.Operators.Add(bestSelector);
|
---|
| 377 | subScopesProcessor2.Operators.Add(scopeCleaner);
|
---|
[8313] | 378 | subScopesProcessor2.Successor = mergingReducer;
|
---|
[8377] | 379 | bestSelector.Successor = rightReducer2;
|
---|
| 380 | rightReducer2.Successor = null;
|
---|
[8622] | 381 | scopeCleaner.Successor = scopeRestorer;
|
---|
| 382 | mergingReducer.Successor = intCounter3;
|
---|
[8385] | 383 | intCounter3.Successor = subScopesCounter3;
|
---|
[8622] | 384 | subScopesCounter3.Successor = calculator2;
|
---|
| 385 | calculator2.Successor = comparator2;
|
---|
| 386 | comparator2.Successor = conditionalBranch3;
|
---|
| 387 | conditionalBranch3.FalseBranch = analyzer2;
|
---|
| 388 | conditionalBranch3.TrueBranch = null;
|
---|
[8377] | 389 | analyzer2.Successor = comparator3;
|
---|
[8622] | 390 | comparator3.Successor = conditionalBranch4;
|
---|
| 391 | conditionalBranch4.FalseBranch = comparator4;
|
---|
[8377] | 392 | conditionalBranch4.TrueBranch = null;
|
---|
| 393 | conditionalBranch4.Successor = null;
|
---|
[8622] | 394 | comparator4.Successor = conditionalBranch5;
|
---|
| 395 | conditionalBranch5.FalseBranch = assigner3;
|
---|
| 396 | conditionalBranch5.TrueBranch = null;
|
---|
| 397 | conditionalBranch5.Successor = null;
|
---|
[8377] | 398 | assigner3.Successor = assigner4;
|
---|
[8385] | 399 | assigner4.Successor = assigner5;
|
---|
| 400 | assigner5.Successor = selector;
|
---|
[8377] | 401 |
|
---|
[8313] | 402 | #endregion
|
---|
| 403 | }
|
---|
| 404 |
|
---|
| 405 | public override IOperation Apply() {
|
---|
| 406 | if (CrossoverParameter.ActualName == null)
|
---|
| 407 | return null;
|
---|
| 408 | return base.Apply();
|
---|
| 409 | }
|
---|
| 410 | }
|
---|
| 411 | }
|
---|