Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 3731 was 3704, checked in by abeham, 14 years ago

#839

  • removed parallel parameter from multipopulation algorithms
File size: 23.3 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.Collections.Generic;
24using System.Linq;
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;
35using HeuristicLab.Selection;
36using HeuristicLab.Analysis;
37
38namespace HeuristicLab.Algorithms.GeneticAlgorithm {
39  /// <summary>
40  /// An island genetic algorithm.
41  /// </summary>
42  [Item("Island Genetic Algorithm", "An island genetic algorithm.")]
43  [Creatable("Algorithms")]
44  [StorableClass]
45  public sealed class IslandGeneticAlgorithm : EngineAlgorithm {
46
47    #region Problem Properties
48    public override Type ProblemType {
49      get { return typeof(ISingleObjectiveProblem); }
50    }
51    public new ISingleObjectiveProblem Problem {
52      get { return (ISingleObjectiveProblem)base.Problem; }
53      set { base.Problem = value; }
54    }
55    #endregion
56
57    #region Parameter Properties
58    private ValueParameter<IntValue> SeedParameter {
59      get { return (ValueParameter<IntValue>)Parameters["Seed"]; }
60    }
61    private ValueParameter<BoolValue> SetSeedRandomlyParameter {
62      get { return (ValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
63    }
64    private ValueParameter<IntValue> NumberOfIslandsParameter {
65      get { return (ValueParameter<IntValue>)Parameters["NumberOfIslands"]; }
66    }
67    private ValueParameter<IntValue> MigrationIntervalParameter {
68      get { return (ValueParameter<IntValue>)Parameters["MigrationInterval"]; }
69    }
70    private ValueParameter<PercentValue> MigrationRateParameter {
71      get { return (ValueParameter<PercentValue>)Parameters["MigrationRate"]; }
72    }
73    private ConstrainedValueParameter<IMigrator> MigratorParameter {
74      get { return (ConstrainedValueParameter<IMigrator>)Parameters["Migrator"]; }
75    }
76    private ConstrainedValueParameter<ISelector> EmigrantsSelectorParameter {
77      get { return (ConstrainedValueParameter<ISelector>)Parameters["EmigrantsSelector"]; }
78    }
79    private ConstrainedValueParameter<IReplacer> ImmigrationReplacerParameter {
80      get { return (ConstrainedValueParameter<IReplacer>)Parameters["ImmigrationReplacer"]; }
81    }
82    private ValueParameter<IntValue> PopulationSizeParameter {
83      get { return (ValueParameter<IntValue>)Parameters["PopulationSize"]; }
84    }
85    private ValueParameter<IntValue> MaximumGenerationsParameter {
86      get { return (ValueParameter<IntValue>)Parameters["MaximumGenerations"]; }
87    }
88    private ConstrainedValueParameter<ISelector> SelectorParameter {
89      get { return (ConstrainedValueParameter<ISelector>)Parameters["Selector"]; }
90    }
91    private ConstrainedValueParameter<ICrossover> CrossoverParameter {
92      get { return (ConstrainedValueParameter<ICrossover>)Parameters["Crossover"]; }
93    }
94    private ValueParameter<PercentValue> MutationProbabilityParameter {
95      get { return (ValueParameter<PercentValue>)Parameters["MutationProbability"]; }
96    }
97    private OptionalConstrainedValueParameter<IManipulator> MutatorParameter {
98      get { return (OptionalConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }
99    }
100    private ValueParameter<IntValue> ElitesParameter {
101      get { return (ValueParameter<IntValue>)Parameters["Elites"]; }
102    }
103    private ValueParameter<MultiAnalyzer> AnalyzerParameter {
104      get { return (ValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
105    }
106    private ValueParameter<MultiAnalyzer> IslandAnalyzerParameter {
107      get { return (ValueParameter<MultiAnalyzer>)Parameters["IslandAnalyzer"]; }
108    }
109    #endregion
110
111    #region Properties
112    public IntValue Seed {
113      get { return SeedParameter.Value; }
114      set { SeedParameter.Value = value; }
115    }
116    public BoolValue SetSeedRandomly {
117      get { return SetSeedRandomlyParameter.Value; }
118      set { SetSeedRandomlyParameter.Value = value; }
119    }
120    public IntValue NumberOfIslands {
121      get { return NumberOfIslandsParameter.Value; }
122      set { NumberOfIslandsParameter.Value = value; }
123    }
124    public IntValue MigrationInterval {
125      get { return MigrationIntervalParameter.Value; }
126      set { MigrationIntervalParameter.Value = value; }
127    }
128    public PercentValue MigrationRate {
129      get { return MigrationRateParameter.Value; }
130      set { MigrationRateParameter.Value = value; }
131    }
132    public IMigrator Migrator {
133      get { return MigratorParameter.Value; }
134      set { MigratorParameter.Value = value; }
135    }
136    public ISelector EmigrantsSelector {
137      get { return EmigrantsSelectorParameter.Value; }
138      set { EmigrantsSelectorParameter.Value = value; }
139    }
140    public IReplacer ImmigrationReplacer {
141      get { return ImmigrationReplacerParameter.Value; }
142      set { ImmigrationReplacerParameter.Value = value; }
143    }
144    public IntValue PopulationSize {
145      get { return PopulationSizeParameter.Value; }
146      set { PopulationSizeParameter.Value = value; }
147    }
148    public IntValue MaximumGenerations {
149      get { return MaximumGenerationsParameter.Value; }
150      set { MaximumGenerationsParameter.Value = value; }
151    }
152    public ISelector Selector {
153      get { return SelectorParameter.Value; }
154      set { SelectorParameter.Value = value; }
155    }
156    public ICrossover Crossover {
157      get { return CrossoverParameter.Value; }
158      set { CrossoverParameter.Value = value; }
159    }
160    public PercentValue MutationProbability {
161      get { return MutationProbabilityParameter.Value; }
162      set { MutationProbabilityParameter.Value = value; }
163    }
164    public IManipulator Mutator {
165      get { return MutatorParameter.Value; }
166      set { MutatorParameter.Value = value; }
167    }
168    public IntValue Elites {
169      get { return ElitesParameter.Value; }
170      set { ElitesParameter.Value = value; }
171    }
172    public MultiAnalyzer Analyzer {
173      get { return AnalyzerParameter.Value; }
174      set { AnalyzerParameter.Value = value; }
175    }
176    public MultiAnalyzer IslandAnalyzer {
177      get { return IslandAnalyzerParameter.Value; }
178      set { IslandAnalyzerParameter.Value = value; }
179    }
180    private RandomCreator RandomCreator {
181      get { return (RandomCreator)OperatorGraph.InitialOperator; }
182    }
183    private UniformSubScopesProcessor IslandProcessor {
184      get { return ((RandomCreator.Successor as SubScopesCreator).Successor as UniformSubScopesProcessor); }
185    }
186    private SolutionsCreator SolutionsCreator {
187      get { return (SolutionsCreator)IslandProcessor.Operator; }
188    }
189    private IslandGeneticAlgorithmMainLoop MainLoop {
190      get { return (IslandGeneticAlgorithmMainLoop)IslandProcessor.Successor; }
191    }
192    [Storable]
193    private BestAverageWorstQualityAnalyzer islandQualityAnalyzer;
194    [Storable]
195    private BestAverageWorstQualityAnalyzer qualityAnalyzer;
196    #endregion
197
198    [StorableConstructor]
199    private IslandGeneticAlgorithm(bool deserializing) : base(deserializing) { }
200    public IslandGeneticAlgorithm()
201      : base() {
202      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
203      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
204      Parameters.Add(new ValueParameter<IntValue>("NumberOfIslands", "The number of islands.", new IntValue(5)));
205      Parameters.Add(new ValueParameter<IntValue>("MigrationInterval", "The number of generations that should pass between migration phases.", new IntValue(20)));
206      Parameters.Add(new ValueParameter<PercentValue>("MigrationRate", "The proportion of individuals that should migrate between the islands.", new PercentValue(0.15)));
207      Parameters.Add(new ConstrainedValueParameter<IMigrator>("Migrator", "The migration strategy."));
208      Parameters.Add(new ConstrainedValueParameter<ISelector>("EmigrantsSelector", "Selects the individuals that will be migrated."));
209      Parameters.Add(new ConstrainedValueParameter<IReplacer>("ImmigrationReplacer", "Selects the population from the unification of the original population and the immigrants."));
210      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100)));
211      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations that should be processed.", new IntValue(1000)));
212      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
213      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
214      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
215      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
216      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
217      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the islands.", new MultiAnalyzer()));
218      Parameters.Add(new ValueParameter<MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer()));
219     
220      RandomCreator randomCreator = new RandomCreator();
221      SubScopesCreator populationCreator = new SubScopesCreator();
222      UniformSubScopesProcessor ussp1 = new UniformSubScopesProcessor();
223      SolutionsCreator solutionsCreator = new SolutionsCreator();
224      IslandGeneticAlgorithmMainLoop mainLoop = new IslandGeneticAlgorithmMainLoop();
225      OperatorGraph.InitialOperator = randomCreator;
226
227      randomCreator.RandomParameter.ActualName = "Random";
228      randomCreator.SeedParameter.ActualName = SeedParameter.Name;
229      randomCreator.SeedParameter.Value = null;
230      randomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
231      randomCreator.SetSeedRandomlyParameter.Value = null;
232      randomCreator.Successor = populationCreator;
233
234      populationCreator.NumberOfSubScopesParameter.ActualName = NumberOfIslandsParameter.Name;
235      populationCreator.Successor = ussp1;
236
237      ussp1.Operator = solutionsCreator;
238      ussp1.Successor = mainLoop;
239
240      solutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
241      solutionsCreator.Successor = null;
242
243      mainLoop.EmigrantsSelectorParameter.ActualName = EmigrantsSelectorParameter.Name;
244      mainLoop.ImmigrationReplacerParameter.ActualName = ImmigrationReplacerParameter.Name;
245      mainLoop.MaximumGenerationsParameter.ActualName = MaximumGenerationsParameter.Name;
246      mainLoop.MigrationIntervalParameter.ActualName = MigrationIntervalParameter.Name;
247      mainLoop.MigrationRateParameter.ActualName = MigrationRateParameter.Name;
248      mainLoop.MigratorParameter.ActualName = MigratorParameter.Name;
249      mainLoop.NumberOfIslandsParameter.ActualName = NumberOfIslandsParameter.Name;
250      mainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
251      mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
252      mainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
253      mainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
254      mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
255      mainLoop.RandomParameter.ActualName = randomCreator.RandomParameter.ActualName;
256      mainLoop.ResultsParameter.ActualName = "Results";
257      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
258      mainLoop.IslandAnalyzerParameter.ActualName = IslandAnalyzerParameter.Name;
259      mainLoop.Successor = null;
260
261      foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name))
262        SelectorParameter.ValidValues.Add(selector);
263      ISelector proportionalSelector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("ProportionalSelector"));
264      if (proportionalSelector != null) SelectorParameter.Value = proportionalSelector;
265
266      foreach (ISelector selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name))
267        EmigrantsSelectorParameter.ValidValues.Add(selector);
268
269      foreach (IReplacer replacer in ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name))
270        ImmigrationReplacerParameter.ValidValues.Add(replacer);
271
272      ParameterizeSelectors();
273
274      foreach (IMigrator migrator in ApplicationManager.Manager.GetInstances<IMigrator>().OrderBy(x => x.Name))
275        MigratorParameter.ValidValues.Add(migrator);
276
277      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
278      islandQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
279      ParameterizeAnalyzers();
280      UpdateAnalyzers();
281
282      Initialize();
283    }
284
285    public override IDeepCloneable Clone(Cloner cloner) {
286      IslandGeneticAlgorithm clone = (IslandGeneticAlgorithm)base.Clone(cloner);
287      clone.islandQualityAnalyzer = (BestAverageWorstQualityAnalyzer)cloner.Clone(islandQualityAnalyzer);
288      clone.qualityAnalyzer = (BestAverageWorstQualityAnalyzer)cloner.Clone(qualityAnalyzer);
289      clone.Initialize();
290      return clone;
291    }
292
293    public override void Prepare() {
294      if (Problem != null) base.Prepare();
295    }
296
297    #region Events
298    protected override void OnProblemChanged() {
299      ParameterizeStochasticOperator(Problem.SolutionCreator);
300      ParameterizeStochasticOperator(Problem.Evaluator);
301      foreach (IOperator op in Problem.Operators) ParameterizeStochasticOperator(op);
302      ParameterizeSolutionsCreator();
303      ParameterizeMainLoop();
304      ParameterizeSelectors();
305      ParameterizeAnalyzers();
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      UpdateCrossovers();
330      UpdateMutators();
331      UpdateAnalyzers();
332      base.Problem_OperatorsChanged(sender, e);
333    }
334    private void ElitesParameter_ValueChanged(object sender, EventArgs e) {
335      Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
336      ParameterizeSelectors();
337    }
338    private void Elites_ValueChanged(object sender, EventArgs e) {
339      ParameterizeSelectors();
340    }
341    private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
342      NumberOfIslands.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
343      ParameterizeSelectors();
344    }
345    private void PopulationSize_ValueChanged(object sender, EventArgs e) {
346      ParameterizeSelectors();
347    }
348    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
349      ParameterizeMainLoop();
350      ParameterizeSelectors();
351      ParameterizeAnalyzers();
352    }
353    private void MigrationRateParameter_ValueChanged(object sender, EventArgs e) {
354      MigrationRate.ValueChanged += new EventHandler(MigrationRate_ValueChanged);
355      ParameterizeSelectors();
356    }
357    private void MigrationRate_ValueChanged(object sender, EventArgs e) {
358      ParameterizeSelectors();
359    }
360    #endregion
361
362    #region Helpers
363    [StorableHook(HookType.AfterDeserialization)]
364    private void Initialize() {
365      PopulationSizeParameter.ValueChanged += new EventHandler(PopulationSizeParameter_ValueChanged);
366      PopulationSize.ValueChanged += new EventHandler(PopulationSize_ValueChanged);
367      MigrationRateParameter.ValueChanged += new EventHandler(MigrationRateParameter_ValueChanged);
368      MigrationRate.ValueChanged += new EventHandler(MigrationRate_ValueChanged);
369      ElitesParameter.ValueChanged += new EventHandler(ElitesParameter_ValueChanged);
370      Elites.ValueChanged += new EventHandler(Elites_ValueChanged);
371      if (Problem != null) {
372        Problem.Evaluator.QualityParameter.ActualNameChanged += new EventHandler(Evaluator_QualityParameter_ActualNameChanged);
373      }
374    }
375    private void ParameterizeSolutionsCreator() {
376      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
377      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
378    }
379    private void ParameterizeMainLoop() {
380      MainLoop.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
381      MainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
382      MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
383      MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
384    }
385    private void ParameterizeStochasticOperator(IOperator op) {
386      if (op is IStochasticOperator)
387        ((IStochasticOperator)op).RandomParameter.ActualName = RandomCreator.RandomParameter.ActualName;
388    }
389    private void ParameterizeSelectors() {
390      foreach (ISelector selector in SelectorParameter.ValidValues) {
391        selector.CopySelected = new BoolValue(true);
392        selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(2 * (PopulationSize.Value - Elites.Value));
393        ParameterizeStochasticOperator(selector);
394      }
395      foreach (ISelector selector in EmigrantsSelectorParameter.ValidValues) {
396        selector.CopySelected = new BoolValue(true);
397        selector.NumberOfSelectedSubScopesParameter.Value = new IntValue((int)Math.Ceiling(PopulationSize.Value * MigrationRate.Value));
398        ParameterizeStochasticOperator(selector);
399      }
400      foreach (IReplacer replacer in ImmigrationReplacerParameter.ValidValues) {
401        ParameterizeStochasticOperator(replacer);
402      }
403      if (Problem != null) {
404        foreach (ISingleObjectiveSelector selector in SelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
405          selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
406          selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
407        }
408        foreach (ISingleObjectiveSelector selector in EmigrantsSelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
409          selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
410          selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
411        }
412        foreach (ISingleObjectiveReplacer selector in ImmigrationReplacerParameter.ValidValues.OfType<ISingleObjectiveReplacer>()) {
413          selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
414          selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
415        }
416      }
417    }
418    private void ParameterizeAnalyzers() {
419      islandQualityAnalyzer.ResultsParameter.ActualName = "Results";
420      islandQualityAnalyzer.QualityParameter.Depth = 1;
421      qualityAnalyzer.ResultsParameter.ActualName = "Results";
422      qualityAnalyzer.QualityParameter.Depth = 2;
423
424      if (Problem != null) {
425        islandQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
426        islandQualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
427        islandQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
428        qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
429        qualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
430        qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
431      }
432    }
433    private void UpdateCrossovers() {
434      ICrossover oldCrossover = CrossoverParameter.Value;
435      CrossoverParameter.ValidValues.Clear();
436      foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name))
437        CrossoverParameter.ValidValues.Add(crossover);
438      if (oldCrossover != null) {
439        ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
440        if (crossover != null) CrossoverParameter.Value = crossover;
441      }
442    }
443    private void UpdateMutators() {
444      IManipulator oldMutator = MutatorParameter.Value;
445      MutatorParameter.ValidValues.Clear();
446      foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name))
447        MutatorParameter.ValidValues.Add(mutator);
448      if (oldMutator != null) {
449        IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
450        if (mutator != null) MutatorParameter.Value = mutator;
451      }
452    }
453    private void UpdateAnalyzers() {
454      IslandAnalyzer.Operators.Clear();
455      Analyzer.Operators.Clear();
456      IslandAnalyzer.Operators.Add(islandQualityAnalyzer);
457      Analyzer.Operators.Add(qualityAnalyzer);
458      if (Problem != null) {
459        foreach (IAnalyzer analyzer in Problem.Operators.OfType<IAnalyzer>().OrderBy(x => x.Name)) {
460          foreach (IScopeTreeLookupParameter param in analyzer.Parameters.OfType<IScopeTreeLookupParameter>())
461            param.Depth = 2;
462          Analyzer.Operators.Add(analyzer);
463        }
464      }
465    }
466    #endregion
467  }
468}
Note: See TracBrowser for help on using the repository browser.