Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ALPS/HeuristicLab.Algorithms.ALPS.OffspringSelection/3.3/AlpsOffspringSelectionGeneticAlgorithm.cs @ 12417

Last change on this file since 12417 was 12331, checked in by pfleck, 10 years ago

#2375 Added first draft of ALPS-OSGA which simply uses a OSGA inside ALPS.

File size: 23.2 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.Algorithms.OffspringSelectionGeneticAlgorithm;
25using HeuristicLab.Analysis;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Data;
29using HeuristicLab.Operators;
30using HeuristicLab.Optimization;
31using HeuristicLab.Optimization.Operators;
32using HeuristicLab.Parameters;
33using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
34using HeuristicLab.PluginInfrastructure;
35using HeuristicLab.Random;
36using HeuristicLab.Selection;
37
38namespace HeuristicLab.Algorithms.ALPS.OffspringSelection {
39  [Item("ALPS Offspring Selection Genetic Algorithm", "A genetic algorithm with an age-layered population structure and Offspring Selection.")]
40  [Creatable("Algorithms")]
41  [StorableClass]
42  public sealed class AlpsOffspringSelectionGeneticAlgorithm : Alps {
43    #region Parameter Properties
44    private IValueParameter<IntArray> PopulationSizeParameter {
45      get { return (IValueParameter<IntArray>)Parameters["PopulationSize"]; }
46    }
47    public IConstrainedValueParameter<ISelector> SelectorParameter {
48      get { return (IConstrainedValueParameter<ISelector>)Parameters["Selector"]; }
49    }
50    public IConstrainedValueParameter<ICrossover> CrossoverParameter {
51      get { return (IConstrainedValueParameter<ICrossover>)Parameters["Crossover"]; }
52    }
53    private IValueParameter<PercentValue> MutationProbabilityParameter {
54      get { return (IValueParameter<PercentValue>)Parameters["MutationProbability"]; }
55    }
56    public IConstrainedValueParameter<IManipulator> MutatorParameter {
57      get { return (IConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }
58    }
59    private IValueParameter<IntValue> ElitesParameter {
60      get { return (IValueParameter<IntValue>)Parameters["Elites"]; }
61    }
62    private IFixedValueParameter<BoolValue> ReevaluateElitesParameter {
63      get { return (IFixedValueParameter<BoolValue>)Parameters["ReevaluateElites"]; }
64    }
65    private IValueParameter<IntValue> MaximumGenerationsParameter {
66      get { return (IValueParameter<IntValue>)Parameters["MaximumGenerations"]; }
67    }
68    private ValueLookupParameter<DoubleValue> SuccessRatioParameter {
69      get { return (ValueLookupParameter<DoubleValue>)Parameters["SuccessRatio"]; }
70    }
71    private ValueLookupParameter<DoubleValue> ComparisonFactorLowerBoundParameter {
72      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorLowerBound"]; }
73    }
74    private ValueLookupParameter<DoubleValue> ComparisonFactorUpperBoundParameter {
75      get { return (ValueLookupParameter<DoubleValue>)Parameters["ComparisonFactorUpperBound"]; }
76    }
77    public IConstrainedValueParameter<IDiscreteDoubleValueModifier> ComparisonFactorModifierParameter {
78      get { return (IConstrainedValueParameter<IDiscreteDoubleValueModifier>)Parameters["ComparisonFactorModifier"]; }
79    }
80    private ValueLookupParameter<DoubleValue> MaximumSelectionPressureParameter {
81      get { return (ValueLookupParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
82    }
83    private ValueLookupParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
84      get { return (ValueLookupParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
85    }
86    private ValueLookupParameter<IntValue> SelectedParentsParameter {
87      get { return (ValueLookupParameter<IntValue>)Parameters["SelectedParents"]; }
88    }
89    private ValueParameter<IntValue> MaximumEvaluatedSolutionsParameter {
90      get { return (ValueParameter<IntValue>)Parameters["MaximumEvaluatedSolutions"]; }
91    }
92    private IFixedValueParameter<BoolValue> FillPopulationWithParentsParameter {
93      get { return (IFixedValueParameter<BoolValue>)Parameters["FillPopulationWithParents"]; }
94    }
95    #endregion
96
97    #region Properties
98    public IntArray PopulationSize {
99      get { return PopulationSizeParameter.Value; }
100      set { PopulationSizeParameter.Value = value; }
101    }
102    public ISelector Selector {
103      get { return SelectorParameter.Value; }
104      set { SelectorParameter.Value = value; }
105    }
106    public ICrossover Crossover {
107      get { return CrossoverParameter.Value; }
108      set { CrossoverParameter.Value = value; }
109    }
110    public PercentValue MutationProbability {
111      get { return MutationProbabilityParameter.Value; }
112      set { MutationProbabilityParameter.Value = value; }
113    }
114    public IManipulator Mutator {
115      get { return MutatorParameter.Value; }
116      set { MutatorParameter.Value = value; }
117    }
118    public IntValue Elites {
119      get { return ElitesParameter.Value; }
120      set { ElitesParameter.Value = value; }
121    }
122    public bool ReevaluteElites {
123      get { return ReevaluateElitesParameter.Value.Value; }
124      set { ReevaluateElitesParameter.Value.Value = value; }
125    }
126    public IntValue MaximumGenerations {
127      get { return MaximumGenerationsParameter.Value; }
128      set { MaximumGenerationsParameter.Value = value; }
129    }
130    public DoubleValue SuccessRatio {
131      get { return SuccessRatioParameter.Value; }
132      set { SuccessRatioParameter.Value = value; }
133    }
134    public DoubleValue ComparisonFactorLowerBound {
135      get { return ComparisonFactorLowerBoundParameter.Value; }
136      set { ComparisonFactorLowerBoundParameter.Value = value; }
137    }
138    public DoubleValue ComparisonFactorUpperBound {
139      get { return ComparisonFactorUpperBoundParameter.Value; }
140      set { ComparisonFactorUpperBoundParameter.Value = value; }
141    }
142    public IDiscreteDoubleValueModifier ComparisonFactorModifier {
143      get { return ComparisonFactorModifierParameter.Value; }
144      set { ComparisonFactorModifierParameter.Value = value; }
145    }
146    public DoubleValue MaximumSelectionPressure {
147      get { return MaximumSelectionPressureParameter.Value; }
148      set { MaximumSelectionPressureParameter.Value = value; }
149    }
150    public BoolValue OffspringSelectionBeforeMutation {
151      get { return OffspringSelectionBeforeMutationParameter.Value; }
152      set { OffspringSelectionBeforeMutationParameter.Value = value; }
153    }
154    public IntValue SelectedParents {
155      get { return SelectedParentsParameter.Value; }
156      set { SelectedParentsParameter.Value = value; }
157    }
158    public IntValue MaximumEvaluatedSolutions {
159      get { return MaximumEvaluatedSolutionsParameter.Value; }
160      set { MaximumEvaluatedSolutionsParameter.Value = value; }
161    }
162    public bool FillPopulationWithParents {
163      get { return FillPopulationWithParentsParameter.Value.Value; }
164      set { FillPopulationWithParentsParameter.Value.Value = value; }
165    }
166
167    private AlpsOffspringSelectionGeneticAlgorithmMainLoop MainLoop {
168      get { return OperatorGraph.Iterate().OfType<AlpsOffspringSelectionGeneticAlgorithmMainLoop>().First(); }
169    }
170    #endregion
171
172    [Storable]
173    private ValueAnalyzer selectionPressureAnalyzer;
174    [Storable]
175    private SuccessfulOffspringAnalyzer successfulOffspringAnalyzer;
176
177    [StorableConstructor]
178    private AlpsOffspringSelectionGeneticAlgorithm(bool deserializing)
179      : base(deserializing) { }
180    private AlpsOffspringSelectionGeneticAlgorithm(AlpsOffspringSelectionGeneticAlgorithm original, Cloner cloner)
181      : base(original, cloner) {
182      selectionPressureAnalyzer = cloner.Clone(original.selectionPressureAnalyzer);
183      successfulOffspringAnalyzer = cloner.Clone(original.successfulOffspringAnalyzer);
184      Initialize();
185    }
186    public override IDeepCloneable Clone(Cloner cloner) {
187      return new AlpsOffspringSelectionGeneticAlgorithm(this, cloner);
188    }
189
190    public AlpsOffspringSelectionGeneticAlgorithm()
191      : base() {
192      Parameters.Add(new ValueParameter<IntArray>("PopulationSize", "The size of the population of solutions each layer.", new IntArray(new[] { 100 })));
193      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
194      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
195      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
196      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
197      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
198      Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", new BoolValue(false)) { Hidden = true });
199      Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000)));
200      Parameters.Add(new ValueLookupParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1)));
201      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorLowerBound", "The lower bound of the comparison factor (start).", new DoubleValue(0)));
202      Parameters.Add(new ValueLookupParameter<DoubleValue>("ComparisonFactorUpperBound", "The upper bound of the comparison factor (end).", new DoubleValue(1)));
203      Parameters.Add(new OptionalConstrainedValueParameter<IDiscreteDoubleValueModifier>("ComparisonFactorModifier", "The operator used to modify the comparison factor.", new ItemSet<IDiscreteDoubleValueModifier>(new IDiscreteDoubleValueModifier[] { new LinearDiscreteDoubleValueModifier() }), new LinearDiscreteDoubleValueModifier()));
204      Parameters.Add(new ValueLookupParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100)));
205      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)));
206      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)));
207      Parameters.Add(new ValueParameter<IntValue>("MaximumEvaluatedSolutions", "The maximum number of evaluated solutions (approximately).", new IntValue(int.MaxValue)));
208      Parameters.Add(new FixedValueParameter<BoolValue>("FillPopulationWithParents", "True if the population should be filled with parent individual or false if worse children should be used when the maximum selection pressure is exceeded.", new BoolValue(false)) { Hidden = true });
209
210      var globalRandomCreator = new RandomCreator();
211      var layer0Creator = new SubScopesCreator() { Name = "Create Layer Zero" };
212      var layer0Processor = new LayerUniformSubScopesProcessor();
213      var localRandomCreator = new LocalRandomCreator();
214      var layerVariableCreator = new VariableCreator();
215      var layerSolutionsCreator = new SolutionsCreator();
216      var initializeAgeProcessor = new UniformSubScopesProcessor();
217      var initializeAge = new VariableCreator() { Name = "Initialize Age" };
218      var initializeLayerPopulationSize = new SubScopesCounter() { Name = "Init LayerPopulationCounter" };
219      var initializeLocalEvaluatedSolutions = new Assigner() { Name = "Initialize LayerEvaluatedSolutions" };
220      var initializeGlobalEvaluatedSolutions = new DataReducer() { Name = "Initialize EvaluatedSolutions" };
221      var resultsCollector = new ResultsCollector();
222      var mainLoop = new AlpsOffspringSelectionGeneticAlgorithmMainLoop();
223
224      OperatorGraph.InitialOperator = globalRandomCreator;
225
226      globalRandomCreator.RandomParameter.ActualName = "GlobalRandom";
227      globalRandomCreator.SeedParameter.Value = null;
228      globalRandomCreator.SetSeedRandomlyParameter.Value = null;
229      globalRandomCreator.Successor = layer0Creator;
230
231      layer0Creator.NumberOfSubScopesParameter.Value = new IntValue(1);
232      layer0Creator.Successor = layer0Processor;
233
234      layer0Processor.Operator = localRandomCreator;
235      layer0Processor.Successor = initializeGlobalEvaluatedSolutions;
236
237      localRandomCreator.Successor = layerVariableCreator;
238
239      layerVariableCreator.CollectedValues.Add(new ValueParameter<IntValue>("Layer", new IntValue(0)));
240      layerVariableCreator.Successor = layerSolutionsCreator;
241
242      layerSolutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
243      layerSolutionsCreator.Successor = initializeAgeProcessor;
244
245      initializeAgeProcessor.Operator = initializeAge;
246      initializeAgeProcessor.Successor = initializeLayerPopulationSize;
247
248      initializeLayerPopulationSize.ValueParameter.ActualName = "LayerPopulationSize";
249      initializeLayerPopulationSize.Successor = initializeLocalEvaluatedSolutions;
250
251      initializeAge.CollectedValues.Add(new ValueParameter<IntValue>("Age", new IntValue(0)));
252      initializeAge.Successor = null;
253
254      initializeLocalEvaluatedSolutions.LeftSideParameter.ActualName = "LayerEvaluatedSolutions";
255      initializeLocalEvaluatedSolutions.RightSideParameter.ActualName = "LayerPopulationSize";
256      initializeLocalEvaluatedSolutions.Successor = null;
257
258      initializeGlobalEvaluatedSolutions.ReductionOperation.Value.Value = ReductionOperations.Sum;
259      initializeGlobalEvaluatedSolutions.TargetOperation.Value.Value = ReductionOperations.Assign;
260      initializeGlobalEvaluatedSolutions.ParameterToReduce.ActualName = "LayerEvaluatedSolutions";
261      initializeGlobalEvaluatedSolutions.TargetParameter.ActualName = "EvaluatedSolutions";
262      initializeGlobalEvaluatedSolutions.Successor = resultsCollector;
263
264      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
265      resultsCollector.Successor = mainLoop;
266
267      mainLoop.ComparisonFactorModifierParameter.ActualName = ComparisonFactorModifierParameter.Name;
268      mainLoop.ComparisonFactorParameter.ActualName = "ComparisonFactor";
269      mainLoop.ComparisonFactorStartParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
270
271
272      foreach (var selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(s => !(s is IMultiObjectiveSelector)).OrderBy(s => Name))
273        SelectorParameter.ValidValues.Add(selector);
274      var tournamentSelector = SelectorParameter.ValidValues.OfType<TournamentSelector>().FirstOrDefault();
275      if (tournamentSelector != null) {
276        tournamentSelector.GroupSizeParameter.Value = new IntValue(4);
277        SelectorParameter.Value = tournamentSelector;
278      }
279      ParameterizeSelectors();
280
281      foreach (IDiscreteDoubleValueModifier modifier in ApplicationManager.Manager.GetInstances<IDiscreteDoubleValueModifier>().OrderBy(x => x.Name))
282        ComparisonFactorModifierParameter.ValidValues.Add(modifier);
283      IDiscreteDoubleValueModifier linearModifier = ComparisonFactorModifierParameter.ValidValues.FirstOrDefault(x => x.GetType().Name.Equals("LinearDiscreteDoubleValueModifier"));
284      if (linearModifier != null) ComparisonFactorModifierParameter.Value = linearModifier;
285      ParameterizeComparisonFactorModifiers();
286
287      selectionPressureAnalyzer = new ValueAnalyzer();
288      successfulOffspringAnalyzer = new SuccessfulOffspringAnalyzer();
289      selectionPressureAnalyzer.Name = "SelectionPressure Analyzer";
290      selectionPressureAnalyzer.ResultsParameter.ActualName = "Results";
291      selectionPressureAnalyzer.ValueParameter.ActualName = "SelectionPressure";
292      selectionPressureAnalyzer.ValueParameter.Depth = 0;
293      selectionPressureAnalyzer.ValuesParameter.ActualName = "Selection Pressure History";
294      successfulOffspringAnalyzer.ResultsParameter.ActualName = "Results";
295      successfulOffspringAnalyzer.GenerationsParameter.ActualName = "Generations";
296      successfulOffspringAnalyzer.SuccessfulOffspringFlagParameter.Value.Value = "SuccessfulOffspring";
297      successfulOffspringAnalyzer.DepthParameter.Value = new IntValue(1);
298
299      Initialize();
300    }
301
302    #region Events
303    protected override void OnProblemChanged() {
304      base.OnProblemChanged();
305      ParameterizeSolutionsCreator();
306      ParameterizeMainLoop();
307      ParameterizeSelectors();
308      ParameterizeIterationBasedOperators();
309      UpdateCrossovers();
310      UpdateMutators();
311    }
312    protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
313      base.Problem_SolutionCreatorChanged(sender, e);
314      ParameterizeSolutionsCreator();
315    }
316    protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
317      base.Problem_EvaluatorChanged(sender, e);
318      ParameterizeSolutionsCreator();
319      ParameterizeMainLoop();
320      ParameterizeSelectors();
321    }
322    protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
323      base.Problem_OperatorsChanged(sender, e);
324      ParameterizeIterationBasedOperators();
325      UpdateCrossovers();
326      UpdateMutators();
327    }
328    protected override void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
329      base.Evaluator_QualityParameter_ActualNameChanged(sender, e);
330      ParameterizeMainLoop();
331      ParameterizeSelectors();
332    }
333    #endregion
334    #region Parameterization
335    private void Initialize() {
336    }
337    private void ParameterizeSolutionsCreator() {
338      MainLoop.LayerUpdator.SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
339      MainLoop.LayerUpdator.SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
340    }
341    private void ParameterizeMainLoop() {
342      MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
343      MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
344      MainLoop.MainOperator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
345      MainLoop.MainOperator.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
346      MainLoop.MainOperator.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
347      MainLoop.LayerUpdator.SolutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
348    }
349    private void ParameterizeSelectors() {
350      foreach (var selector in SelectorParameter.ValidValues) {
351        selector.CopySelected = new BoolValue(true);
352        selector.NumberOfSelectedSubScopesParameter.Value = null;
353        selector.NumberOfSelectedSubScopesParameter.ActualName = SelectedParentsParameter.Name;
354        selector.NumberOfSelectedSubScopesParameter.Hidden = true;
355        ParameterizeStochasticOperatorForLayer(selector);
356      }
357      if (Problem != null) {
358        foreach (var selector in SelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
359          selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
360          selector.MaximizationParameter.Hidden = true;
361          selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
362          selector.QualityParameter.Hidden = true;
363        }
364      }
365    }
366    private void ParameterizeComparisonFactorModifiers() {
367      foreach (IDiscreteDoubleValueModifier modifier in ComparisonFactorModifierParameter.ValidValues) {
368        modifier.IndexParameter.ActualName = "Generations";
369        modifier.EndIndexParameter.ActualName = MaximumGenerationsParameter.Name;
370        modifier.EndValueParameter.ActualName = ComparisonFactorUpperBoundParameter.Name;
371        modifier.StartIndexParameter.Value = new IntValue(0);
372        modifier.StartValueParameter.ActualName = ComparisonFactorLowerBoundParameter.Name;
373        modifier.ValueParameter.ActualName = "ComparisonFactor";
374      }
375    }
376    private void ParameterizeIterationBasedOperators() {
377      if (Problem != null) {
378        foreach (var @operator in Problem.Operators.OfType<IIterationBasedOperator>()) {
379          @operator.IterationsParameter.ActualName = "Generations";
380          @operator.IterationsParameter.Hidden = true;
381          @operator.MaximumIterationsParameter.ActualName = MaximumGenerationsParameter.Name;
382          @operator.MaximumIterationsParameter.Hidden = true;
383        }
384      }
385    }
386
387    protected override ReductionOperations GetAgeInheritanceReduction(AgeInheritance ageInheritance) {
388      switch (ageInheritance) {
389        case ALPS.AgeInheritance.Older: return ReductionOperations.Max;
390        case ALPS.AgeInheritance.Agerage: return ReductionOperations.Avg;
391        case ALPS.AgeInheritance.Younger: return ReductionOperations.Min;
392        default: throw new NotSupportedException("AgeInheritance " + ageInheritance + " is not supported.");
393      }
394    }
395    #endregion
396
397    #region Updates
398    private void UpdateCrossovers() {
399      var oldCrossover = CrossoverParameter.Value;
400      var defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault();
401      CrossoverParameter.ValidValues.Clear();
402      foreach (var crossover in Problem.Operators.OfType<ICrossover>().OrderBy(c => c.Name)) {
403        ParameterizeStochasticOperatorForLayer(crossover);
404        CrossoverParameter.ValidValues.Add(crossover);
405      }
406      if (oldCrossover != null) {
407        var crossover = CrossoverParameter.ValidValues.FirstOrDefault(c => c.GetType() == oldCrossover.GetType());
408        if (crossover != null)
409          CrossoverParameter.Value = crossover;
410        else
411          oldCrossover = null;
412      }
413      if (oldCrossover == null && defaultCrossover != null)
414        CrossoverParameter.Value = defaultCrossover;
415    }
416    private void UpdateMutators() {
417      var oldMutator = MutatorParameter.Value;
418      MutatorParameter.ValidValues.Clear();
419      foreach (var mutator in Problem.Operators.OfType<IManipulator>().OrderBy(m => m.Name)) {
420        ParameterizeStochasticOperatorForLayer(mutator);
421        MutatorParameter.ValidValues.Add(mutator);
422      }
423      if (oldMutator != null) {
424        var mutator = MutatorParameter.ValidValues.FirstOrDefault(m => m.GetType() == oldMutator.GetType());
425        if (mutator != null)
426          MutatorParameter.Value = mutator;
427      }
428    }
429    #endregion
430  }
431}
Note: See TracBrowser for help on using the repository browser.