[3429] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[7259] | 3 | * Copyright (C) 2002-2012 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using System.Linq;
|
---|
[3654] | 24 | using HeuristicLab.Analysis;
|
---|
[3429] | 25 | using HeuristicLab.Common;
|
---|
| 26 | using HeuristicLab.Core;
|
---|
| 27 | using HeuristicLab.Data;
|
---|
| 28 | using HeuristicLab.Operators;
|
---|
| 29 | using HeuristicLab.Optimization;
|
---|
| 30 | using HeuristicLab.Optimization.Operators;
|
---|
| 31 | using HeuristicLab.Parameters;
|
---|
| 32 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
| 33 | using HeuristicLab.PluginInfrastructure;
|
---|
| 34 | using HeuristicLab.Random;
|
---|
| 35 |
|
---|
| 36 | namespace HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm {
|
---|
| 37 | /// <summary>
|
---|
| 38 | /// An offspring selection island genetic algorithm.
|
---|
| 39 | /// </summary>
|
---|
[3479] | 40 | [Item("Island Offspring Selection Genetic Algorithm", "An island offspring selection genetic algorithm.")]
|
---|
[3429] | 41 | [Creatable("Algorithms")]
|
---|
| 42 | [StorableClass]
|
---|
[5809] | 43 | public sealed class IslandOffspringSelectionGeneticAlgorithm : HeuristicOptimizationEngineAlgorithm, IStorableContent {
|
---|
[4437] | 44 | public string Filename { get; set; }
|
---|
[3429] | 45 |
|
---|
| 46 | #region Problem Properties
|
---|
| 47 | public override Type ProblemType {
|
---|
[5809] | 48 | get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); }
|
---|
[3429] | 49 | }
|
---|
[5809] | 50 | public new ISingleObjectiveHeuristicOptimizationProblem Problem {
|
---|
| 51 | get { return (ISingleObjectiveHeuristicOptimizationProblem)base.Problem; }
|
---|
[3429] | 52 | set { base.Problem = value; }
|
---|
| 53 | }
|
---|
| 54 | #endregion
|
---|
| 55 |
|
---|
| 56 | #region Parameter Properties
|
---|
| 57 | private ValueParameter<IntValue> SeedParameter {
|
---|
| 58 | get { return (ValueParameter<IntValue>)Parameters["Seed"]; }
|
---|
| 59 | }
|
---|
| 60 | private ValueParameter<BoolValue> SetSeedRandomlyParameter {
|
---|
| 61 | get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
|
---|
| 62 | }
|
---|
| 63 | private ValueParameter<IntValue> NumberOfIslandsParameter {
|
---|
| 64 | get { return (ValueParameter<IntValue>)Parameters["NumberOfIslands"]; }
|
---|
| 65 | }
|
---|
| 66 | private ValueParameter<IntValue> MigrationIntervalParameter {
|
---|
| 67 | get { return (ValueParameter<IntValue>)Parameters["MigrationInterval"]; }
|
---|
| 68 | }
|
---|
| 69 | private ValueParameter<PercentValue> MigrationRateParameter {
|
---|
| 70 | get { return (ValueParameter<PercentValue>)Parameters["MigrationRate"]; }
|
---|
| 71 | }
|
---|
| 72 | private ConstrainedValueParameter<IMigrator> MigratorParameter {
|
---|
| 73 | get { return (ConstrainedValueParameter<IMigrator>)Parameters["Migrator"]; }
|
---|
| 74 | }
|
---|
| 75 | private ConstrainedValueParameter<ISelector> EmigrantsSelectorParameter {
|
---|
| 76 | get { return (ConstrainedValueParameter<ISelector>)Parameters["EmigrantsSelector"]; }
|
---|
| 77 | }
|
---|
[3611] | 78 | private ConstrainedValueParameter<IReplacer> ImmigrationReplacerParameter {
|
---|
| 79 | get { return (ConstrainedValueParameter<IReplacer>)Parameters["ImmigrationReplacer"]; }
|
---|
[3429] | 80 | }
|
---|
| 81 | private ValueParameter<IntValue> PopulationSizeParameter {
|
---|
| 82 | get { return (ValueParameter<IntValue>)Parameters["PopulationSize"]; }
|
---|
| 83 | }
|
---|
[3611] | 84 | private ValueParameter<IntValue> MaximumGenerationsParameter {
|
---|
| 85 | get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; }
|
---|
[3429] | 86 | }
|
---|
| 87 | private ConstrainedValueParameter<ISelector> SelectorParameter {
|
---|
| 88 | get { return (ConstrainedValueParameter<ISelector>)Parameters["Selector"]; }
|
---|
| 89 | }
|
---|
| 90 | private ConstrainedValueParameter<ICrossover> CrossoverParameter {
|
---|
| 91 | get { return (ConstrainedValueParameter<ICrossover>)Parameters["Crossover"]; }
|
---|
| 92 | }
|
---|
| 93 | private ValueParameter<PercentValue> MutationProbabilityParameter {
|
---|
| 94 | get { return (ValueParameter<PercentValue>)Parameters["MutationProbability"]; }
|
---|
| 95 | }
|
---|
| 96 | private OptionalConstrainedValueParameter<IManipulator> MutatorParameter {
|
---|
| 97 | get { return (OptionalConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }
|
---|
| 98 | }
|
---|
| 99 | private ValueParameter<IntValue> ElitesParameter {
|
---|
| 100 | get { return (ValueParameter<IntValue>)Parameters["Elites"]; }
|
---|
| 101 | }
|
---|
| 102 | private ValueLookupParameter<DoubleValue> SuccessRatioParameter {
|
---|
| 103 | get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
|
---|
| 104 | }
|
---|
| 105 | private ValueLookupParameter<DoubleValue> ComparisonFactorLowerBoundParameter {
|
---|
| 106 | get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorLowerBound"]; }
|
---|
| 107 | }
|
---|
| 108 | private ValueLookupParameter<DoubleValue> ComparisonFactorUpperBoundParameter {
|
---|
| 109 | get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorUpperBound"]; }
|
---|
| 110 | }
|
---|
| 111 | private OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier> ComparisonFactorModifierParameter {
|
---|
| 112 | get { return (OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters["ComparisonFactorModifier"]; }
|
---|
| 113 | }
|
---|
| 114 | private ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
|
---|
| 115 | get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
|
---|
| 116 | }
|
---|
| 117 | private ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
|
---|
| 118 | get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
|
---|
| 119 | }
|
---|
[3700] | 120 | private ValueLookupParameter<IntValue> SelectedParentsParameter {
|
---|
| 121 | get { return (ValueLookupParameter<IntValue>)Parameters["SelectedParents"]; }
|
---|
| 122 | }
|
---|
[3658] | 123 | private ValueParameter<MultiAnalyzer> AnalyzerParameter {
|
---|
| 124 | get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
|
---|
[3654] | 125 | }
|
---|
[3658] | 126 | private ValueParameter<MultiAnalyzer> IslandAnalyzerParameter {
|
---|
| 127 | get { return (ValueParameter<MultiAnalyzer>)Parameters["IslandAnalyzer"]; }
|
---|
[3654] | 128 | }
|
---|
[3891] | 129 | private ValueParameter<IntValue> MaximumEvaluatedSolutionsParameter {
|
---|
| 130 | get { return (ValueParameter<IntValue>)Parameters["MaximumEvaluatedSolutions"]; }
|
---|
| 131 | }
|
---|
[3429] | 132 | #endregion
|
---|
| 133 |
|
---|
| 134 | #region Properties
|
---|
| 135 | public IntValue Seed {
|
---|
| 136 | get { return SeedParameter.Value; }
|
---|
| 137 | set { SeedParameter.Value = value; }
|
---|
| 138 | }
|
---|
| 139 | public BoolValue SetSeedRandomly {
|
---|
| 140 | get { return SetSeedRandomlyParameter.Value; }
|
---|
| 141 | set { SetSeedRandomlyParameter.Value = value; }
|
---|
| 142 | }
|
---|
| 143 | public IntValue NumberOfIslands {
|
---|
| 144 | get { return NumberOfIslandsParameter.Value; }
|
---|
| 145 | set { NumberOfIslandsParameter.Value = value; }
|
---|
| 146 | }
|
---|
| 147 | public IntValue MigrationInterval {
|
---|
| 148 | get { return MigrationIntervalParameter.Value; }
|
---|
| 149 | set { MigrationIntervalParameter.Value = value; }
|
---|
| 150 | }
|
---|
| 151 | public PercentValue MigrationRate {
|
---|
| 152 | get { return MigrationRateParameter.Value; }
|
---|
| 153 | set { MigrationRateParameter.Value = value; }
|
---|
| 154 | }
|
---|
| 155 | public IMigrator Migrator {
|
---|
| 156 | get { return MigratorParameter.Value; }
|
---|
| 157 | set { MigratorParameter.Value = value; }
|
---|
| 158 | }
|
---|
| 159 | public ISelector EmigrantsSelector {
|
---|
| 160 | get { return EmigrantsSelectorParameter.Value; }
|
---|
| 161 | set { EmigrantsSelectorParameter.Value = value; }
|
---|
| 162 | }
|
---|
[3611] | 163 | public IReplacer ImmigrationReplacer {
|
---|
| 164 | get { return ImmigrationReplacerParameter.Value; }
|
---|
| 165 | set { ImmigrationReplacerParameter.Value = value; }
|
---|
[3429] | 166 | }
|
---|
| 167 | public IntValue PopulationSize {
|
---|
| 168 | get { return PopulationSizeParameter.Value; }
|
---|
| 169 | set { PopulationSizeParameter.Value = value; }
|
---|
| 170 | }
|
---|
[3611] | 171 | public IntValue MaximumGenerations {
|
---|
| 172 | get { return MaximumGenerationsParameter.Value; }
|
---|
| 173 | set { MaximumGenerationsParameter.Value = value; }
|
---|
[3429] | 174 | }
|
---|
| 175 | public ISelector Selector {
|
---|
| 176 | get { return SelectorParameter.Value; }
|
---|
| 177 | set { SelectorParameter.Value = value; }
|
---|
| 178 | }
|
---|
| 179 | public ICrossover Crossover {
|
---|
| 180 | get { return CrossoverParameter.Value; }
|
---|
| 181 | set { CrossoverParameter.Value = value; }
|
---|
| 182 | }
|
---|
| 183 | public PercentValue MutationProbability {
|
---|
| 184 | get { return MutationProbabilityParameter.Value; }
|
---|
| 185 | set { MutationProbabilityParameter.Value = value; }
|
---|
| 186 | }
|
---|
| 187 | public IManipulator Mutator {
|
---|
| 188 | get { return MutatorParameter.Value; }
|
---|
| 189 | set { MutatorParameter.Value = value; }
|
---|
| 190 | }
|
---|
| 191 | public IntValue Elites {
|
---|
| 192 | get { return ElitesParameter.Value; }
|
---|
| 193 | set { ElitesParameter.Value = value; }
|
---|
| 194 | }
|
---|
| 195 | private DoubleValue SuccessRatio {
|
---|
| 196 | get { return SuccessRatioParameter.Value; }
|
---|
| 197 | set { SuccessRatioParameter.Value = value; }
|
---|
| 198 | }
|
---|
| 199 | private DoubleValue ComparisonFactorLowerBound {
|
---|
| 200 | get { return ComparisonFactorLowerBoundParameter.Value; }
|
---|
| 201 | set { ComparisonFactorLowerBoundParameter.Value = value; }
|
---|
| 202 | }
|
---|
| 203 | private DoubleValue ComparisonFactorUpperBound {
|
---|
| 204 | get { return ComparisonFactorUpperBoundParameter.Value; }
|
---|
| 205 | set { ComparisonFactorUpperBoundParameter.Value = value; }
|
---|
| 206 | }
|
---|
| 207 | private IDiscreteDoubleValueModifier ComparisonFactorModifier {
|
---|
| 208 | get { return ComparisonFactorModifierParameter.Value; }
|
---|
| 209 | set { ComparisonFactorModifierParameter.Value = value; }
|
---|
| 210 | }
|
---|
| 211 | private DoubleValue MaximumSelectionPressure {
|
---|
| 212 | get { return MaximumSelectionPressureParameter.Value; }
|
---|
| 213 | set { MaximumSelectionPressureParameter.Value = value; }
|
---|
| 214 | }
|
---|
| 215 | private BoolValue OffspringSelectionBeforeMutation {
|
---|
| 216 | get { return OffspringSelectionBeforeMutationParameter.Value; }
|
---|
| 217 | set { OffspringSelectionBeforeMutationParameter.Value = value; }
|
---|
| 218 | }
|
---|
[3658] | 219 | public MultiAnalyzer Analyzer {
|
---|
[3654] | 220 | get { return AnalyzerParameter.Value; }
|
---|
| 221 | set { AnalyzerParameter.Value = value; }
|
---|
| 222 | }
|
---|
[3658] | 223 | public MultiAnalyzer IslandAnalyzer {
|
---|
[3654] | 224 | get { return IslandAnalyzerParameter.Value; }
|
---|
| 225 | set { IslandAnalyzerParameter.Value = value; }
|
---|
| 226 | }
|
---|
[3891] | 227 | public IntValue MaximumEvaluatedSolutions {
|
---|
| 228 | get { return MaximumEvaluatedSolutionsParameter.Value; }
|
---|
| 229 | set { MaximumEvaluatedSolutionsParameter.Value = value; }
|
---|
| 230 | }
|
---|
[3429] | 231 | private RandomCreator RandomCreator {
|
---|
| 232 | get { return (RandomCreator)OperatorGraph.InitialOperator; }
|
---|
| 233 | }
|
---|
| 234 | private UniformSubScopesProcessor IslandProcessor {
|
---|
| 235 | get { return ((RandomCreator.Successor as SubScopesCreator).Successor as UniformSubScopesProcessor); }
|
---|
| 236 | }
|
---|
| 237 | private SolutionsCreator SolutionsCreator {
|
---|
| 238 | get { return (SolutionsCreator)IslandProcessor.Operator; }
|
---|
| 239 | }
|
---|
[3479] | 240 | private IslandOffspringSelectionGeneticAlgorithmMainLoop MainLoop {
|
---|
[5366] | 241 | get { return FindMainLoop(IslandProcessor.Successor); }
|
---|
[3429] | 242 | }
|
---|
[3689] | 243 | [Storable]
|
---|
[3662] | 244 | private BestAverageWorstQualityAnalyzer islandQualityAnalyzer;
|
---|
[3689] | 245 | [Storable]
|
---|
[3673] | 246 | private BestAverageWorstQualityAnalyzer qualityAnalyzer;
|
---|
[3689] | 247 | [Storable]
|
---|
[3673] | 248 | private ValueAnalyzer islandSelectionPressureAnalyzer;
|
---|
[3689] | 249 | [Storable]
|
---|
[3673] | 250 | private ValueAnalyzer selectionPressureAnalyzer;
|
---|
[5683] | 251 | [Storable]
|
---|
| 252 | private SuccessfulOffspringAnalyzer successfulOffspringAnalyzer;
|
---|
[3429] | 253 | #endregion
|
---|
| 254 |
|
---|
| 255 | [StorableConstructor]
|
---|
[3479] | 256 | private IslandOffspringSelectionGeneticAlgorithm(bool deserializing) : base(deserializing) { }
|
---|
[4722] | 257 | [StorableHook(HookType.AfterDeserialization)]
|
---|
| 258 | private void AfterDeserialization() {
|
---|
[5683] | 259 | #region Backwards Compatibility
|
---|
| 260 | if (successfulOffspringAnalyzer == null)
|
---|
| 261 | successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();
|
---|
| 262 | #endregion
|
---|
[7172] | 263 |
|
---|
[4722] | 264 | Initialize();
|
---|
| 265 | }
|
---|
| 266 | private IslandOffspringSelectionGeneticAlgorithm(IslandOffspringSelectionGeneticAlgorithm original, Cloner cloner)
|
---|
| 267 | : base(original, cloner) {
|
---|
| 268 | islandQualityAnalyzer = cloner.Clone(original.islandQualityAnalyzer);
|
---|
| 269 | qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
|
---|
| 270 | islandSelectionPressureAnalyzer = cloner.Clone(original.islandSelectionPressureAnalyzer);
|
---|
| 271 | selectionPressureAnalyzer = cloner.Clone(original.selectionPressureAnalyzer);
|
---|
[5683] | 272 | successfulOffspringAnalyzer = cloner.Clone(original.successfulOffspringAnalyzer);
|
---|
[4722] | 273 | Initialize();
|
---|
| 274 | }
|
---|
| 275 | public override IDeepCloneable Clone(Cloner cloner) {
|
---|
| 276 | return new IslandOffspringSelectionGeneticAlgorithm(this, cloner);
|
---|
| 277 | }
|
---|
[3479] | 278 | public IslandOffspringSelectionGeneticAlgorithm()
|
---|
[3429] | 279 | : base() {
|
---|
| 280 | Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
|
---|
| 281 | Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
|
---|
| 282 | Parameters.Add(new ValueParameter<IntValue>("NumberOfIslands", "The number of islands.", new IntValue(5)));
|
---|
| 283 | Parameters.Add(new ValueParameter<IntValue>("MigrationInterval", "The number of generations that should pass between migration phases.", new IntValue(20)));
|
---|
| 284 | Parameters.Add(new ValueParameter<PercentValue>("MigrationRate", "The proportion of individuals that should migrate between the islands.", new PercentValue(0.15)));
|
---|
| 285 | Parameters.Add(new ConstrainedValueParameter<IMigrator>("Migrator", "The migration strategy."));
|
---|
| 286 | Parameters.Add(new ConstrainedValueParameter<ISelector>("EmigrantsSelector", "Selects the individuals that will be migrated."));
|
---|
[3698] | 287 | Parameters.Add(new ConstrainedValueParameter<IReplacer>("ImmigrationReplacer", "Replaces part of the original population with the immigrants."));
|
---|
[3479] | 288 | Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions of each island.", new IntValue(100)));
|
---|
[3611] | 289 | Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations that should be processed.", new IntValue(100)));
|
---|
[3429] | 290 | Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
|
---|
| 291 | Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
|
---|
| 292 | Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
|
---|
| 293 | Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
|
---|
| 294 | Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
|
---|
| 295 | Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1)));
|
---|
| 296 | Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start).", new DoubleValue(0)));
|
---|
| 297 | Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorUpperBound", "The upper bound of the comparison factor (end).", new DoubleValue(1)));
|
---|
| 298 | Parameters.Add(new OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>("ComparisonFactorModifier", "The operator used to modify the comparison factor.", new ItemSet<IDiscreteDoubleValueModifier>(new IDiscreteDoubleValueModifier[] { new LinearDiscreteDoubleValueModifier() }), new LinearDiscreteDoubleValueModifier()));
|
---|
| 299 | Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100)));
|
---|
| 300 | 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.", new BoolValue(false)));
|
---|
[3735] | 301 | Parameters.Add(new ValueLookupParameter<IntValue>("SelectedParents", "How much parents should be selected each time the offspring selection step is performed until the population is filled. This parameter should be about the same or twice the size of PopulationSize for smaller problems, and less for large problems.", new IntValue(200)));
|
---|
[3658] | 302 | Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the islands.", new MultiAnalyzer()));
|
---|
| 303 | Parameters.Add(new ValueParameter<MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer()));
|
---|
[3891] | 304 | Parameters.Add(new ValueParameter<IntValue>("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions (approximately).", new IntValue(int.MaxValue)));
|
---|
| 305 |
|
---|
[3429] | 306 | RandomCreator randomCreator = new RandomCreator();
|
---|
| 307 | SubScopesCreator populationCreator = new SubScopesCreator();
|
---|
| 308 | UniformSubScopesProcessor ussp1 = new UniformSubScopesProcessor();
|
---|
| 309 | SolutionsCreator solutionsCreator = new SolutionsCreator();
|
---|
[5356] | 310 | VariableCreator variableCreator = new VariableCreator();
|
---|
| 311 | UniformSubScopesProcessor ussp2 = new UniformSubScopesProcessor();
|
---|
| 312 | SubScopesCounter subScopesCounter = new SubScopesCounter();
|
---|
| 313 | ResultsCollector resultsCollector = new ResultsCollector();
|
---|
[3479] | 314 | IslandOffspringSelectionGeneticAlgorithmMainLoop mainLoop = new IslandOffspringSelectionGeneticAlgorithmMainLoop();
|
---|
[3429] | 315 | OperatorGraph.InitialOperator = randomCreator;
|
---|
| 316 |
|
---|
| 317 | randomCreator.RandomParameter.ActualName = "Random";
|
---|
| 318 | randomCreator.SeedParameter.ActualName = SeedParameter.Name;
|
---|
| 319 | randomCreator.SeedParameter.Value = null;
|
---|
| 320 | randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
|
---|
| 321 | randomCreator.SetSeedRandomlyParameter.Value = null;
|
---|
| 322 | randomCreator.Successor = populationCreator;
|
---|
| 323 |
|
---|
| 324 | populationCreator.NumberOfSubScopesParameter.ActualName = NumberOfIslandsParameter.Name;
|
---|
| 325 | populationCreator.Successor = ussp1;
|
---|
| 326 |
|
---|
| 327 | ussp1.Operator = solutionsCreator;
|
---|
[5356] | 328 | ussp1.Successor = variableCreator;
|
---|
[3429] | 329 |
|
---|
| 330 | solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
|
---|
| 331 | solutionsCreator.Successor = null;
|
---|
| 332 |
|
---|
[5356] | 333 | variableCreator.Name = "Initialize EvaluatedSolutions";
|
---|
| 334 | variableCreator.CollectedValues.Add(new ValueParameter<IntValue>("EvaluatedSolutions", new IntValue()));
|
---|
| 335 | variableCreator.Successor = ussp2;
|
---|
| 336 |
|
---|
| 337 | ussp2.Operator = subScopesCounter;
|
---|
| 338 | ussp2.Successor = resultsCollector;
|
---|
| 339 |
|
---|
| 340 | subScopesCounter.Name = "Increment EvaluatedSolutions";
|
---|
| 341 | subScopesCounter.ValueParameter.ActualName = "EvaluatedSolutions";
|
---|
| 342 |
|
---|
| 343 | resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", "", "EvaluatedSolutions"));
|
---|
| 344 | resultsCollector.ResultsParameter.ActualName = "Results";
|
---|
| 345 | resultsCollector.Successor = mainLoop;
|
---|
| 346 |
|
---|
[3429] | 347 | mainLoop.EmigrantsSelectorParameter.ActualName = EmigrantsSelectorParameter.Name;
|
---|
[3611] | 348 | mainLoop.ImmigrationReplacerParameter.ActualName = ImmigrationReplacerParameter.Name;
|
---|
| 349 | mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
|
---|
[3429] | 350 | mainLoop.MigrationIntervalParameter.ActualName = MigrationIntervalParameter.Name;
|
---|
| 351 | mainLoop.MigrationRateParameter.ActualName = MigrationRateParameter.Name;
|
---|
| 352 | mainLoop.MigratorParameter.ActualName = MigratorParameter.Name;
|
---|
| 353 | mainLoop.NumberOfIslandsParameter.ActualName = NumberOfIslandsParameter.Name;
|
---|
| 354 | mainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
|
---|
| 355 | mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
|
---|
| 356 | mainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
|
---|
| 357 | mainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
|
---|
| 358 | mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
|
---|
| 359 | mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName;
|
---|
| 360 | mainLoop.ResultsParameter.ActualName = "Results";
|
---|
| 361 | mainLoop.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
|
---|
[3611] | 362 | mainLoop.ComparisonFactorParameter.ActualName = "ComparisonFactor";
|
---|
[3744] | 363 | mainLoop.ComparisonFactorStartParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
|
---|
[3429] | 364 | mainLoop.ComparisonFactorModifierParameter.ActualName = ComparisonFactorModifierParameter.Name;
|
---|
| 365 | mainLoop.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
|
---|
| 366 | mainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
|
---|
[5356] | 367 | mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
|
---|
[3429] | 368 | mainLoop.Successor = null;
|
---|
| 369 |
|
---|
[3689] | 370 | foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name))
|
---|
| 371 | SelectorParameter.ValidValues.Add(selector);
|
---|
| 372 | ISelector proportionalSelector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("ProportionalSelector"));
|
---|
| 373 | if (proportionalSelector != null) SelectorParameter.Value = proportionalSelector;
|
---|
| 374 |
|
---|
| 375 | foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name))
|
---|
| 376 | EmigrantsSelectorParameter.ValidValues.Add(selector);
|
---|
| 377 |
|
---|
| 378 | foreach (IReplacer replacer in ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name))
|
---|
| 379 | ImmigrationReplacerParameter.ValidValues.Add(replacer);
|
---|
| 380 |
|
---|
| 381 | ParameterizeSelectors();
|
---|
| 382 |
|
---|
| 383 | foreach (IMigrator migrator in ApplicationManager.Manager.GetInstances<IMigrator>().OrderBy(x => x.Name))
|
---|
| 384 | MigratorParameter.ValidValues.Add(migrator);
|
---|
| 385 |
|
---|
| 386 | foreach (IDiscreteDoubleValueModifier modifier in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name))
|
---|
| 387 | ComparisonFactorModifierParameter.ValidValues.Add(modifier);
|
---|
| 388 | IDiscreteDoubleValueModifier linearModifier = ComparisonFactorModifierParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("LinearDiscreteDoubleValueModifier"));
|
---|
| 389 | if (linearModifier != null) ComparisonFactorModifierParameter.Value = linearModifier;
|
---|
| 390 | ParameterizeComparisonFactorModifiers();
|
---|
| 391 |
|
---|
| 392 | qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
|
---|
| 393 | islandQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
|
---|
| 394 | selectionPressureAnalyzer = new ValueAnalyzer();
|
---|
| 395 | islandSelectionPressureAnalyzer = new ValueAnalyzer();
|
---|
[5683] | 396 | successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();
|
---|
[3689] | 397 | ParameterizeAnalyzers();
|
---|
| 398 | UpdateAnalyzers();
|
---|
| 399 |
|
---|
[3429] | 400 | Initialize();
|
---|
| 401 | }
|
---|
| 402 | public override void Prepare() {
|
---|
| 403 | if (Problem != null) base.Prepare();
|
---|
| 404 | }
|
---|
| 405 |
|
---|
| 406 | #region Events
|
---|
| 407 | protected override void OnProblemChanged() {
|
---|
| 408 | ParameterizeStochasticOperator(Problem.SolutionCreator);
|
---|
| 409 | ParameterizeStochasticOperator(Problem.Evaluator);
|
---|
| 410 | foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
|
---|
| 411 | ParameterizeSolutionsCreator();
|
---|
| 412 | ParameterizeMainLoop();
|
---|
| 413 | ParameterizeSelectors();
|
---|
[3654] | 414 | ParameterizeAnalyzers();
|
---|
[3750] | 415 | ParameterizeIterationBasedOperators();
|
---|
[3429] | 416 | UpdateCrossovers();
|
---|
| 417 | UpdateMutators();
|
---|
[3654] | 418 | UpdateAnalyzers();
|
---|
[3429] | 419 | Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
| 420 | base.OnProblemChanged();
|
---|
| 421 | }
|
---|
| 422 |
|
---|
| 423 | protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
|
---|
| 424 | ParameterizeStochasticOperator(Problem.SolutionCreator);
|
---|
| 425 | ParameterizeSolutionsCreator();
|
---|
| 426 | base.Problem_SolutionCreatorChanged(sender, e);
|
---|
| 427 | }
|
---|
| 428 | protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
|
---|
| 429 | ParameterizeStochasticOperator(Problem.Evaluator);
|
---|
| 430 | ParameterizeSolutionsCreator();
|
---|
| 431 | ParameterizeMainLoop();
|
---|
| 432 | ParameterizeSelectors();
|
---|
[3654] | 433 | ParameterizeAnalyzers();
|
---|
[3429] | 434 | Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
| 435 | base.Problem_EvaluatorChanged(sender, e);
|
---|
| 436 | }
|
---|
| 437 | protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
|
---|
| 438 | foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
|
---|
[3750] | 439 | ParameterizeIterationBasedOperators();
|
---|
[3429] | 440 | UpdateCrossovers();
|
---|
| 441 | UpdateMutators();
|
---|
[3654] | 442 | UpdateAnalyzers();
|
---|
[3429] | 443 | base.Problem_OperatorsChanged(sender, e);
|
---|
| 444 | }
|
---|
| 445 | private void ElitesParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 446 | Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
|
---|
| 447 | ParameterizeSelectors();
|
---|
| 448 | }
|
---|
| 449 | private void Elites_ValueChanged(object sender, EventArgs e) {
|
---|
| 450 | ParameterizeSelectors();
|
---|
| 451 | }
|
---|
| 452 | private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 453 | NumberOfIslands.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
|
---|
| 454 | ParameterizeSelectors();
|
---|
| 455 | }
|
---|
| 456 | private void PopulationSize_ValueChanged(object sender, EventArgs e) {
|
---|
| 457 | ParameterizeSelectors();
|
---|
| 458 | }
|
---|
| 459 | private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
|
---|
| 460 | ParameterizeMainLoop();
|
---|
| 461 | ParameterizeSelectors();
|
---|
[3654] | 462 | ParameterizeAnalyzers();
|
---|
[3429] | 463 | }
|
---|
| 464 | private void MigrationRateParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 465 | MigrationRate.ValueChanged += new EventHandler(MigrationRate_ValueChanged);
|
---|
| 466 | ParameterizeSelectors();
|
---|
| 467 | }
|
---|
| 468 | private void MigrationRate_ValueChanged(object sender, EventArgs e) {
|
---|
| 469 | ParameterizeSelectors();
|
---|
| 470 | }
|
---|
| 471 | private void MaximumMigrationsParameter_ValueChanged(object sender, EventArgs e) {
|
---|
[3611] | 472 | MaximumGenerations.ValueChanged += new EventHandler(MaximumMigrations_ValueChanged);
|
---|
[3429] | 473 | ParameterizeComparisonFactorModifiers();
|
---|
| 474 | }
|
---|
| 475 | private void MaximumMigrations_ValueChanged(object sender, EventArgs e) {
|
---|
| 476 | ParameterizeComparisonFactorModifiers();
|
---|
| 477 | }
|
---|
| 478 | private void MigrationIntervalParameter_ValueChanged(object sender, EventArgs e) {
|
---|
| 479 | MigrationInterval.ValueChanged += new EventHandler(MigrationInterval_ValueChanged);
|
---|
| 480 | ParameterizeComparisonFactorModifiers();
|
---|
| 481 | }
|
---|
| 482 | private void MigrationInterval_ValueChanged(object sender, EventArgs e) {
|
---|
| 483 | ParameterizeComparisonFactorModifiers();
|
---|
| 484 | }
|
---|
| 485 | #endregion
|
---|
| 486 |
|
---|
| 487 | #region Helpers
|
---|
| 488 | private void Initialize() {
|
---|
| 489 | PopulationSizeParameter.ValueChanged += new EventHandler(PopulationSizeParameter_ValueChanged);
|
---|
| 490 | PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
|
---|
| 491 | MigrationRateParameter.ValueChanged += new EventHandler(MigrationRateParameter_ValueChanged);
|
---|
| 492 | MigrationRate.ValueChanged += new EventHandler(MigrationRate_ValueChanged);
|
---|
| 493 | ElitesParameter.ValueChanged += new EventHandler(ElitesParameter_ValueChanged);
|
---|
| 494 | Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
|
---|
| 495 | MigrationIntervalParameter.ValueChanged += new EventHandler(MigrationIntervalParameter_ValueChanged);
|
---|
| 496 | MigrationInterval.ValueChanged += new EventHandler(MigrationInterval_ValueChanged);
|
---|
[3611] | 497 | MaximumGenerationsParameter.ValueChanged += new EventHandler(MaximumMigrationsParameter_ValueChanged);
|
---|
| 498 | MaximumGenerations.ValueChanged += new EventHandler(MaximumMigrations_ValueChanged);
|
---|
[3429] | 499 | if (Problem != null) {
|
---|
| 500 | Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
|
---|
| 501 | }
|
---|
| 502 | }
|
---|
| 503 | private void ParameterizeSolutionsCreator() {
|
---|
| 504 | SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
|
---|
| 505 | SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
|
---|
| 506 | }
|
---|
| 507 | private void ParameterizeMainLoop() {
|
---|
| 508 | MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
|
---|
| 509 | MainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
|
---|
| 510 | MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
| 511 | MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
| 512 | }
|
---|
| 513 | private void ParameterizeStochasticOperator(IOperator op) {
|
---|
| 514 | if (op is IStochasticOperator)
|
---|
| 515 | ((IStochasticOperator)op).RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
|
---|
| 516 | }
|
---|
| 517 | private void ParameterizeSelectors() {
|
---|
[3689] | 518 | foreach (ISelector selector in SelectorParameter.ValidValues) {
|
---|
[3429] | 519 | selector.CopySelected = new BoolValue(true);
|
---|
[3700] | 520 | selector.NumberOfSelectedSubScopesParameter.Value = null;
|
---|
| 521 | selector.NumberOfSelectedSubScopesParameter.ActualName = SelectedParentsParameter.Name;
|
---|
[3429] | 522 | ParameterizeStochasticOperator(selector);
|
---|
| 523 | }
|
---|
[3689] | 524 | foreach (ISelector selector in EmigrantsSelectorParameter.ValidValues) {
|
---|
[3429] | 525 | selector.CopySelected = new BoolValue(true);
|
---|
| 526 | selector.NumberOfSelectedSubScopesParameter.Value = new IntValue((int)Math.Ceiling(PopulationSize.Value * MigrationRate.Value));
|
---|
| 527 | ParameterizeStochasticOperator(selector);
|
---|
| 528 | }
|
---|
[3689] | 529 | foreach (IReplacer selector in ImmigrationReplacerParameter.ValidValues) {
|
---|
[3429] | 530 | ParameterizeStochasticOperator(selector);
|
---|
| 531 | }
|
---|
| 532 | if (Problem != null) {
|
---|
[3689] | 533 | foreach (ISingleObjectiveSelector selector in SelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
|
---|
[3429] | 534 | selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
| 535 | selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
| 536 | }
|
---|
[3689] | 537 | foreach (ISingleObjectiveSelector selector in EmigrantsSelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
|
---|
[3429] | 538 | selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
| 539 | selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
| 540 | }
|
---|
[3689] | 541 | foreach (ISingleObjectiveReplacer replacer in ImmigrationReplacerParameter.ValidValues.OfType<ISingleObjectiveReplacer>()) {
|
---|
[3611] | 542 | replacer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
| 543 | replacer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
[3429] | 544 | }
|
---|
| 545 | }
|
---|
| 546 | }
|
---|
[3654] | 547 | private void ParameterizeAnalyzers() {
|
---|
| 548 | islandQualityAnalyzer.ResultsParameter.ActualName = "Results";
|
---|
[3673] | 549 | islandQualityAnalyzer.QualityParameter.Depth = 1;
|
---|
| 550 | qualityAnalyzer.ResultsParameter.ActualName = "Results";
|
---|
| 551 | qualityAnalyzer.QualityParameter.Depth = 2;
|
---|
| 552 |
|
---|
| 553 | islandSelectionPressureAnalyzer.ResultsParameter.ActualName = "Results";
|
---|
| 554 | islandSelectionPressureAnalyzer.Name = "SelectionPressure Analyzer";
|
---|
| 555 | islandSelectionPressureAnalyzer.ValueParameter.Depth = 0;
|
---|
| 556 | islandSelectionPressureAnalyzer.ValueParameter.ActualName = "SelectionPressure";
|
---|
| 557 | islandSelectionPressureAnalyzer.ValuesParameter.ActualName = "Selection Pressure History";
|
---|
| 558 |
|
---|
| 559 | selectionPressureAnalyzer.ResultsParameter.ActualName = "Results";
|
---|
| 560 | selectionPressureAnalyzer.Name = "SelectionPressure Analyzer";
|
---|
| 561 | selectionPressureAnalyzer.ValueParameter.Depth = 1;
|
---|
| 562 | selectionPressureAnalyzer.ValueParameter.ActualName = "SelectionPressure";
|
---|
| 563 | selectionPressureAnalyzer.ValuesParameter.ActualName = "Selection Pressure History";
|
---|
| 564 |
|
---|
[5683] | 565 | successfulOffspringAnalyzer.ResultsParameter.ActualName = "Results";
|
---|
| 566 | successfulOffspringAnalyzer.GenerationsParameter.ActualName = "Generations";
|
---|
[5725] | 567 | successfulOffspringAnalyzer.SuccessfulOffspringFlagParameter.Value.Value = "SuccessfulOffspring";
|
---|
[5683] | 568 | successfulOffspringAnalyzer.DepthParameter.Value = new IntValue(2);
|
---|
| 569 |
|
---|
[3654] | 570 | if (Problem != null) {
|
---|
| 571 | islandQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
| 572 | islandQualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
| 573 | islandQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
|
---|
[3673] | 574 |
|
---|
| 575 | qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
|
---|
| 576 | qualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
|
---|
| 577 | qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
|
---|
[3654] | 578 | }
|
---|
| 579 | }
|
---|
[3429] | 580 | private void ParameterizeComparisonFactorModifiers() {
|
---|
[3689] | 581 | foreach (IDiscreteDoubleValueModifier modifier in ComparisonFactorModifierParameter.ValidValues) {
|
---|
[3429] | 582 | modifier.IndexParameter.ActualName = "Generations";
|
---|
[3611] | 583 | modifier.EndIndexParameter.Value = new IntValue(MigrationInterval.Value * MaximumGenerations.Value);
|
---|
[3429] | 584 | modifier.EndValueParameter.ActualName = ComparisonFactorUpperBoundParameter.Name;
|
---|
| 585 | modifier.StartIndexParameter.Value = new IntValue(0);
|
---|
| 586 | modifier.StartValueParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
|
---|
| 587 | modifier.ValueParameter.ActualName = "ComparisonFactor";
|
---|
| 588 | }
|
---|
| 589 | }
|
---|
[3750] | 590 | private void ParameterizeIterationBasedOperators() {
|
---|
| 591 | if (Problem != null) {
|
---|
| 592 | foreach (IIterationBasedOperator op in Problem.Operators.OfType<IIterationBasedOperator>()) {
|
---|
| 593 | op.IterationsParameter.ActualName = "Generations";
|
---|
| 594 | op.MaximumIterationsParameter.ActualName = MaximumGenerationsParameter.Name;
|
---|
| 595 | }
|
---|
| 596 | }
|
---|
| 597 | }
|
---|
[3429] | 598 | private void UpdateCrossovers() {
|
---|
| 599 | ICrossover oldCrossover = CrossoverParameter.Value;
|
---|
[7511] | 600 | ICrossover defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault();
|
---|
[3429] | 601 | CrossoverParameter.ValidValues.Clear();
|
---|
| 602 | foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name))
|
---|
| 603 | CrossoverParameter.ValidValues.Add(crossover);
|
---|
| 604 | if (oldCrossover != null) {
|
---|
| 605 | ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
|
---|
| 606 | if (crossover != null) CrossoverParameter.Value = crossover;
|
---|
[7511] | 607 | else oldCrossover = null;
|
---|
[3429] | 608 | }
|
---|
[7511] | 609 | if (oldCrossover == null && defaultCrossover != null)
|
---|
| 610 | CrossoverParameter.Value = defaultCrossover;
|
---|
[3429] | 611 | }
|
---|
| 612 | private void UpdateMutators() {
|
---|
| 613 | IManipulator oldMutator = MutatorParameter.Value;
|
---|
| 614 | MutatorParameter.ValidValues.Clear();
|
---|
| 615 | foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name))
|
---|
| 616 | MutatorParameter.ValidValues.Add(mutator);
|
---|
| 617 | if (oldMutator != null) {
|
---|
| 618 | IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
|
---|
| 619 | if (mutator != null) MutatorParameter.Value = mutator;
|
---|
| 620 | }
|
---|
| 621 | }
|
---|
[3654] | 622 | private void UpdateAnalyzers() {
|
---|
| 623 | IslandAnalyzer.Operators.Clear();
|
---|
| 624 | Analyzer.Operators.Clear();
|
---|
[7172] | 625 | IslandAnalyzer.Operators.Add(islandQualityAnalyzer, islandQualityAnalyzer.EnabledByDefault);
|
---|
| 626 | IslandAnalyzer.Operators.Add(islandSelectionPressureAnalyzer, islandSelectionPressureAnalyzer.EnabledByDefault);
|
---|
[3654] | 627 | if (Problem != null) {
|
---|
[3816] | 628 | foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) {
|
---|
[3673] | 629 | foreach (IScopeTreeLookupParameter param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>())
|
---|
| 630 | param.Depth = 2;
|
---|
[7172] | 631 | Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault);
|
---|
[3654] | 632 | }
|
---|
| 633 | }
|
---|
[7172] | 634 | Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault);
|
---|
| 635 | Analyzer.Operators.Add(selectionPressureAnalyzer, selectionPressureAnalyzer.EnabledByDefault);
|
---|
| 636 | Analyzer.Operators.Add(successfulOffspringAnalyzer, successfulOffspringAnalyzer.EnabledByDefault);
|
---|
[3654] | 637 | }
|
---|
[5366] | 638 | private IslandOffspringSelectionGeneticAlgorithmMainLoop FindMainLoop(IOperator start) {
|
---|
| 639 | IOperator mainLoop = start;
|
---|
| 640 | while (mainLoop != null && !(mainLoop is IslandOffspringSelectionGeneticAlgorithmMainLoop))
|
---|
| 641 | mainLoop = ((SingleSuccessorOperator)mainLoop).Successor;
|
---|
| 642 | if (mainLoop == null) return null;
|
---|
| 643 | else return (IslandOffspringSelectionGeneticAlgorithmMainLoop)mainLoop;
|
---|
| 644 | }
|
---|
[3429] | 645 | #endregion
|
---|
| 646 | }
|
---|
| 647 | }
|
---|