Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs @ 4437

Last change on this file since 4437 was 4437, checked in by swagner, 13 years ago

Implemented !IStorableContent separately for each algorithm (#1193)

File size: 23.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Linq;
24using HeuristicLab.Analysis;
25using HeuristicLab.Common;
26using HeuristicLab.Core;
27using HeuristicLab.Data;
28using HeuristicLab.Operators;
29using HeuristicLab.Optimization;
30using HeuristicLab.Optimization.Operators;
31using HeuristicLab.Parameters;
32using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
33using HeuristicLab.PluginInfrastructure;
34using HeuristicLab.Random;
35
36namespace HeuristicLab.Algorithms.GeneticAlgorithm {
37  /// <summary>
38  /// An island genetic algorithm.
39  /// </summary>
40  [Item("Island Genetic Algorithm", "An island genetic algorithm.")]
41  [Creatable("Algorithms")]
42  [StorableClass]
43  public sealed class IslandGeneticAlgorithm : EngineAlgorithm, IStorableContent {
44    public string Filename { get; set; }
45
46    #region Problem Properties
47    public override Type ProblemType {
48      get { return typeof(ISingleObjectiveProblem); }
49    }
50    public new ISingleObjectiveProblem Problem {
51      get { return (ISingleObjectiveProblem)base.Problem; }
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    }
78    private ConstrainedValueParameter<IReplacer> ImmigrationReplacerParameter {
79      get { return (ConstrainedValueParameter<IReplacer>)Parameters["ImmigrationReplacer"]; }
80    }
81    private ValueParameter<IntValue> PopulationSizeParameter {
82      get { return (ValueParameter<IntValue>)Parameters["PopulationSize"]; }
83    }
84    private ValueParameter<IntValue> MaximumGenerationsParameter {
85      get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; }
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 ValueParameter<MultiAnalyzer> AnalyzerParameter {
103      get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
104    }
105    private ValueParameter<MultiAnalyzer> IslandAnalyzerParameter {
106      get { return (ValueParameter<MultiAnalyzer>)Parameters["IslandAnalyzer"]; }
107    }
108    #endregion
109
110    #region Properties
111    public IntValue Seed {
112      get { return SeedParameter.Value; }
113      set { SeedParameter.Value = value; }
114    }
115    public BoolValue SetSeedRandomly {
116      get { return SetSeedRandomlyParameter.Value; }
117      set { SetSeedRandomlyParameter.Value = value; }
118    }
119    public IntValue NumberOfIslands {
120      get { return NumberOfIslandsParameter.Value; }
121      set { NumberOfIslandsParameter.Value = value; }
122    }
123    public IntValue MigrationInterval {
124      get { return MigrationIntervalParameter.Value; }
125      set { MigrationIntervalParameter.Value = value; }
126    }
127    public PercentValue MigrationRate {
128      get { return MigrationRateParameter.Value; }
129      set { MigrationRateParameter.Value = value; }
130    }
131    public IMigrator Migrator {
132      get { return MigratorParameter.Value; }
133      set { MigratorParameter.Value = value; }
134    }
135    public ISelector EmigrantsSelector {
136      get { return EmigrantsSelectorParameter.Value; }
137      set { EmigrantsSelectorParameter.Value = value; }
138    }
139    public IReplacer ImmigrationReplacer {
140      get { return ImmigrationReplacerParameter.Value; }
141      set { ImmigrationReplacerParameter.Value = value; }
142    }
143    public IntValue PopulationSize {
144      get { return PopulationSizeParameter.Value; }
145      set { PopulationSizeParameter.Value = value; }
146    }
147    public IntValue MaximumGenerations {
148      get { return MaximumGenerationsParameter.Value; }
149      set { MaximumGenerationsParameter.Value = value; }
150    }
151    public ISelector Selector {
152      get { return SelectorParameter.Value; }
153      set { SelectorParameter.Value = value; }
154    }
155    public ICrossover Crossover {
156      get { return CrossoverParameter.Value; }
157      set { CrossoverParameter.Value = value; }
158    }
159    public PercentValue MutationProbability {
160      get { return MutationProbabilityParameter.Value; }
161      set { MutationProbabilityParameter.Value = value; }
162    }
163    public IManipulator Mutator {
164      get { return MutatorParameter.Value; }
165      set { MutatorParameter.Value = value; }
166    }
167    public IntValue Elites {
168      get { return ElitesParameter.Value; }
169      set { ElitesParameter.Value = value; }
170    }
171    public MultiAnalyzer Analyzer {
172      get { return AnalyzerParameter.Value; }
173      set { AnalyzerParameter.Value = value; }
174    }
175    public MultiAnalyzer IslandAnalyzer {
176      get { return IslandAnalyzerParameter.Value; }
177      set { IslandAnalyzerParameter.Value = value; }
178    }
179    private RandomCreator RandomCreator {
180      get { return (RandomCreator)OperatorGraph.InitialOperator; }
181    }
182    private UniformSubScopesProcessor IslandProcessor {
183      get { return ((RandomCreator.Successor as SubScopesCreator).Successor as UniformSubScopesProcessor); }
184    }
185    private SolutionsCreator SolutionsCreator {
186      get { return (SolutionsCreator)IslandProcessor.Operator; }
187    }
188    private IslandGeneticAlgorithmMainLoop MainLoop {
189      get { return (IslandGeneticAlgorithmMainLoop)IslandProcessor.Successor; }
190    }
191    [Storable]
192    private BestAverageWorstQualityAnalyzer islandQualityAnalyzer;
193    [Storable]
194    private BestAverageWorstQualityAnalyzer qualityAnalyzer;
195    #endregion
196
197    [StorableConstructor]
198    private IslandGeneticAlgorithm(bool deserializing) : base(deserializing) { }
199    public IslandGeneticAlgorithm()
200      : base() {
201      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
202      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
203      Parameters.Add(new ValueParameter<IntValue>("NumberOfIslands", "The number of islands.", new IntValue(5)));
204      Parameters.Add(new ValueParameter<IntValue>("MigrationInterval", "The number of generations that should pass between migration phases.", new IntValue(20)));
205      Parameters.Add(new ValueParameter<PercentValue>("MigrationRate", "The proportion of individuals that should migrate between the islands.", new PercentValue(0.15)));
206      Parameters.Add(new ConstrainedValueParameter<IMigrator>("Migrator", "The migration strategy."));
207      Parameters.Add(new ConstrainedValueParameter<ISelector>("EmigrantsSelector", "Selects the individuals that will be migrated."));
208      Parameters.Add(new ConstrainedValueParameter<IReplacer>("ImmigrationReplacer", "Selects the population from the unification of the original population and the immigrants."));
209      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100)));
210      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations that should be processed.", new IntValue(1000)));
211      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
212      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
213      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
214      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
215      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
216      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the islands.", new MultiAnalyzer()));
217      Parameters.Add(new ValueParameter<MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer()));
218
219      RandomCreator randomCreator = new RandomCreator();
220      SubScopesCreator populationCreator = new SubScopesCreator();
221      UniformSubScopesProcessor ussp1 = new UniformSubScopesProcessor();
222      SolutionsCreator solutionsCreator = new SolutionsCreator();
223      IslandGeneticAlgorithmMainLoop mainLoop = new IslandGeneticAlgorithmMainLoop();
224      OperatorGraph.InitialOperator = randomCreator;
225
226      randomCreator.RandomParameter.ActualName = "Random";
227      randomCreator.SeedParameter.ActualName = SeedParameter.Name;
228      randomCreator.SeedParameter.Value = null;
229      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
230      randomCreator.SetSeedRandomlyParameter.Value = null;
231      randomCreator.Successor = populationCreator;
232
233      populationCreator.NumberOfSubScopesParameter.ActualName = NumberOfIslandsParameter.Name;
234      populationCreator.Successor = ussp1;
235
236      ussp1.Operator = solutionsCreator;
237      ussp1.Successor = mainLoop;
238
239      solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
240      solutionsCreator.Successor = null;
241
242      mainLoop.EmigrantsSelectorParameter.ActualName = EmigrantsSelectorParameter.Name;
243      mainLoop.ImmigrationReplacerParameter.ActualName = ImmigrationReplacerParameter.Name;
244      mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
245      mainLoop.MigrationIntervalParameter.ActualName = MigrationIntervalParameter.Name;
246      mainLoop.MigrationRateParameter.ActualName = MigrationRateParameter.Name;
247      mainLoop.MigratorParameter.ActualName = MigratorParameter.Name;
248      mainLoop.NumberOfIslandsParameter.ActualName = NumberOfIslandsParameter.Name;
249      mainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
250      mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
251      mainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
252      mainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
253      mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
254      mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName;
255      mainLoop.ResultsParameter.ActualName = "Results";
256      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
257      mainLoop.IslandAnalyzerParameter.ActualName = IslandAnalyzerParameter.Name;
258      mainLoop.Successor = null;
259
260      foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name))
261        SelectorParameter.ValidValues.Add(selector);
262      ISelector proportionalSelector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("ProportionalSelector"));
263      if (proportionalSelector != null) SelectorParameter.Value = proportionalSelector;
264
265      foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name))
266        EmigrantsSelectorParameter.ValidValues.Add(selector);
267
268      foreach (IReplacer replacer in ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name))
269        ImmigrationReplacerParameter.ValidValues.Add(replacer);
270
271      ParameterizeSelectors();
272
273      foreach (IMigrator migrator in ApplicationManager.Manager.GetInstances<IMigrator>().OrderBy(x => x.Name))
274        MigratorParameter.ValidValues.Add(migrator);
275
276      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
277      islandQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
278      ParameterizeAnalyzers();
279      UpdateAnalyzers();
280
281      Initialize();
282    }
283
284    public override IDeepCloneable Clone(Cloner cloner) {
285      IslandGeneticAlgorithm clone = (IslandGeneticAlgorithm)base.Clone(cloner);
286      clone.islandQualityAnalyzer = (BestAverageWorstQualityAnalyzer)cloner.Clone(islandQualityAnalyzer);
287      clone.qualityAnalyzer = (BestAverageWorstQualityAnalyzer)cloner.Clone(qualityAnalyzer);
288      clone.Initialize();
289      return clone;
290    }
291
292    public override void Prepare() {
293      if (Problem != null) base.Prepare();
294    }
295
296    #region Events
297    protected override void OnProblemChanged() {
298      ParameterizeStochasticOperator(Problem.SolutionCreator);
299      ParameterizeStochasticOperator(Problem.Evaluator);
300      foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
301      ParameterizeSolutionsCreator();
302      ParameterizeMainLoop();
303      ParameterizeSelectors();
304      ParameterizeAnalyzers();
305      ParameterizeIterationBasedOperators();
306      UpdateCrossovers();
307      UpdateMutators();
308      UpdateAnalyzers();
309      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
310      base.OnProblemChanged();
311    }
312
313    protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
314      ParameterizeStochasticOperator(Problem.SolutionCreator);
315      ParameterizeSolutionsCreator();
316      base.Problem_SolutionCreatorChanged(sender, e);
317    }
318    protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
319      ParameterizeStochasticOperator(Problem.Evaluator);
320      ParameterizeSolutionsCreator();
321      ParameterizeMainLoop();
322      ParameterizeSelectors();
323      ParameterizeAnalyzers();
324      Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
325      base.Problem_EvaluatorChanged(sender, e);
326    }
327    protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
328      foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
329      ParameterizeIterationBasedOperators();
330      UpdateCrossovers();
331      UpdateMutators();
332      UpdateAnalyzers();
333      base.Problem_OperatorsChanged(sender, e);
334    }
335    private void ElitesParameter_ValueChanged(object sender, EventArgs e) {
336      Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
337      ParameterizeSelectors();
338    }
339    private void Elites_ValueChanged(object sender, EventArgs e) {
340      ParameterizeSelectors();
341    }
342    private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
343      NumberOfIslands.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
344      ParameterizeSelectors();
345    }
346    private void PopulationSize_ValueChanged(object sender, EventArgs e) {
347      ParameterizeSelectors();
348    }
349    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
350      ParameterizeMainLoop();
351      ParameterizeSelectors();
352      ParameterizeAnalyzers();
353    }
354    private void MigrationRateParameter_ValueChanged(object sender, EventArgs e) {
355      MigrationRate.ValueChanged += new EventHandler(MigrationRate_ValueChanged);
356      ParameterizeSelectors();
357    }
358    private void MigrationRate_ValueChanged(object sender, EventArgs e) {
359      ParameterizeSelectors();
360    }
361    #endregion
362
363    #region Helpers
364    [StorableHook(HookType.AfterDeserialization)]
365    private void Initialize() {
366      PopulationSizeParameter.ValueChanged += new EventHandler(PopulationSizeParameter_ValueChanged);
367      PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
368      MigrationRateParameter.ValueChanged += new EventHandler(MigrationRateParameter_ValueChanged);
369      MigrationRate.ValueChanged += new EventHandler(MigrationRate_ValueChanged);
370      ElitesParameter.ValueChanged += new EventHandler(ElitesParameter_ValueChanged);
371      Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
372      if (Problem != null) {
373        Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
374      }
375    }
376    private void ParameterizeSolutionsCreator() {
377      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
378      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
379    }
380    private void ParameterizeMainLoop() {
381      MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
382      MainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
383      MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
384      MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
385    }
386    private void ParameterizeStochasticOperator(IOperator op) {
387      if (op is IStochasticOperator)
388        ((IStochasticOperator)op).RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
389    }
390    private void ParameterizeSelectors() {
391      foreach (ISelector selector in SelectorParameter.ValidValues) {
392        selector.CopySelected = new BoolValue(true);
393        selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(2 * (PopulationSize.Value - Elites.Value));
394        ParameterizeStochasticOperator(selector);
395      }
396      foreach (ISelector selector in EmigrantsSelectorParameter.ValidValues) {
397        selector.CopySelected = new BoolValue(true);
398        selector.NumberOfSelectedSubScopesParameter.Value = new IntValue((int)Math.Ceiling(PopulationSize.Value * MigrationRate.Value));
399        ParameterizeStochasticOperator(selector);
400      }
401      foreach (IReplacer replacer in ImmigrationReplacerParameter.ValidValues) {
402        ParameterizeStochasticOperator(replacer);
403      }
404      if (Problem != null) {
405        foreach (ISingleObjectiveSelector selector in SelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
406          selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
407          selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
408        }
409        foreach (ISingleObjectiveSelector selector in EmigrantsSelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
410          selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
411          selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
412        }
413        foreach (ISingleObjectiveReplacer selector in ImmigrationReplacerParameter.ValidValues.OfType<ISingleObjectiveReplacer>()) {
414          selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
415          selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
416        }
417      }
418    }
419    private void ParameterizeAnalyzers() {
420      islandQualityAnalyzer.ResultsParameter.ActualName = "Results";
421      islandQualityAnalyzer.QualityParameter.Depth = 1;
422      qualityAnalyzer.ResultsParameter.ActualName = "Results";
423      qualityAnalyzer.QualityParameter.Depth = 2;
424
425      if (Problem != null) {
426        islandQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
427        islandQualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
428        islandQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
429        qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
430        qualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
431        qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
432      }
433    }
434    private void ParameterizeIterationBasedOperators() {
435      if (Problem != null) {
436        foreach (IIterationBasedOperator op in Problem.Operators.OfType<IIterationBasedOperator>()) {
437          op.IterationsParameter.ActualName = "Generations";
438          op.MaximumIterationsParameter.ActualName = "MaximumGenerations";
439        }
440      }
441    }
442    private void UpdateCrossovers() {
443      ICrossover oldCrossover = CrossoverParameter.Value;
444      CrossoverParameter.ValidValues.Clear();
445      foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name))
446        CrossoverParameter.ValidValues.Add(crossover);
447      if (oldCrossover != null) {
448        ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
449        if (crossover != null) CrossoverParameter.Value = crossover;
450      }
451    }
452    private void UpdateMutators() {
453      IManipulator oldMutator = MutatorParameter.Value;
454      MutatorParameter.ValidValues.Clear();
455      foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name))
456        MutatorParameter.ValidValues.Add(mutator);
457      if (oldMutator != null) {
458        IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
459        if (mutator != null) MutatorParameter.Value = mutator;
460      }
461    }
462    private void UpdateAnalyzers() {
463      IslandAnalyzer.Operators.Clear();
464      Analyzer.Operators.Clear();
465      IslandAnalyzer.Operators.Add(islandQualityAnalyzer);
466      if (Problem != null) {
467        foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>()) {
468          foreach (IScopeTreeLookupParameter param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>())
469            param.Depth = 2;
470          Analyzer.Operators.Add(analyzer);
471        }
472      }
473      Analyzer.Operators.Add(qualityAnalyzer);
474    }
475    #endregion
476  }
477}
Note: See TracBrowser for help on using the repository browser.