Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2258_IslandALPS/IslandALPS/3.3/Offspring Selection/IslandAlpsOffspringSelectionAlgorithm.cs @ 17800

Last change on this file since 17800 was 13962, checked in by pkuelzer, 8 years ago

#2558 cloning constructor to public

File size: 44.9 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using HeuristicLab.Algorithms.ALPS;
5using HeuristicLab.Analysis;
6using HeuristicLab.Collections;
7using HeuristicLab.Common;
8using HeuristicLab.Core;
9using HeuristicLab.Data;
10using HeuristicLab.Operators;
11using HeuristicLab.Optimization;
12using HeuristicLab.Optimization.Operators;
13using HeuristicLab.Parameters;
14using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
15using HeuristicLab.PluginInfrastructure;
16using HeuristicLab.Random;
17using HeuristicLab.Selection;
18
19namespace HeuristicLab.Algorithms.IslandALPS {
20  [Item("IslandAlpsOffspringSelectionAlgorithm", "An island version of ALPS with offspring selection")]
21  [StorableClass]
22  [Creatable(CreatableAttribute.Categories.PopulationBasedAlgorithms, Priority = 100)]
23  public class IslandAlpsOffspringSelectionAlgorithm : HeuristicOptimizationEngineAlgorithm, IStorableContent {
24    public string Filename { get; set; }
25
26    #region Problem Properties
27
28    public override Type ProblemType {
29      get { return typeof (ISingleObjectiveHeuristicOptimizationProblem); }
30    }
31
32    public new ISingleObjectiveHeuristicOptimizationProblem Problem {
33      get { return (ISingleObjectiveHeuristicOptimizationProblem) base.Problem; }
34      set { base.Problem = value; }
35    }
36
37    #endregion
38
39    #region Parameter Properties
40
41    #region ALPSParameter
42
43    public IValueParameter<IntValue> AgeGapParameter { get { return (IValueParameter<IntValue>) Parameters["AgeGap"]; } }
44
45    public IValueParameter<EnumValue<AgingScheme>> AgingSchemeParameter { get { return (IValueParameter<EnumValue<AgingScheme>>) Parameters["AgingScheme"]; } }
46    public IValueParameter<DoubleValue> AgeInheritanceParameter {   get { return (IValueParameter<DoubleValue>) Parameters["AgeInheritance"]; } }
47    public IValueParameter<IntArray> AgeLimitsParameter {   get { return (IValueParameter<IntArray>) Parameters["AgeLimits"]; }   }
48    public IValueParameter<BoolValue> ReduceToPopulationSizeParameter {   get { return (IValueParameter<BoolValue>) Parameters["ReduceToPopulationSize"]; }   }
49    public IValueParameter<IntValue> NumberOfLayersParameter {   get { return (IValueParameter<IntValue>) Parameters["NumberOfLayers"]; } }
50    public IValueParameter<MultiAnalyzer> LayerAnalyzerParameter {   get { return (IValueParameter<MultiAnalyzer>) Parameters["LayerAnalyzer"]; } }
51    public IValueParameter<MultiAnalyzer> GroupAnalyzerParameter {   get { return (IValueParameter<MultiAnalyzer>) Parameters["GroupAnalyzer"]; } }
52    #endregion
53    #region OSParameter
54
55    public IFixedValueParameter<DoubleValue> SuccessRatioParameter { get { return (IFixedValueParameter<DoubleValue>) Parameters["SuccessRatio"]; } }
56    public IFixedValueParameter<DoubleValue> ComparisonFactorParameter { get { return (IFixedValueParameter<DoubleValue>) Parameters["ComparisonFactor"]; } }
57    public IFixedValueParameter<DoubleValue> MaximumSelectionPressureParameter { get { return (IFixedValueParameter<DoubleValue>) Parameters["MaximumSelectionPressure"]; } }
58    public IFixedValueParameter<BoolValue> OffspringSelectionBeforeMutationParameter { get { return (IFixedValueParameter<BoolValue>) Parameters["OffspringSelectionBeforeMutation"]; } }
59    public IFixedValueParameter<IntValue> SelectedParentsParameter { get { return (IFixedValueParameter<IntValue>) Parameters["SelectedParents"]; } }
60    #endregion
61
62    #region IslandParameter
63
64    public IValueParameter<MultiAnalyzer> IslandAnalyzerParameter {   get { return (IValueParameter<MultiAnalyzer>) Parameters["IslandAnalyzer"]; } }
65    public IValueParameter<IntValue> NumberOfIslandsParameter {   get { return (IValueParameter<IntValue>) Parameters["NumberOfIslands"]; } }
66    public IValueParameter<PercentValue> MigrationRateParameter {   get { return (IValueParameter<PercentValue>) Parameters["MigrationRate"]; } }
67    public IValueParameter<IntValue> MigrationIntervalParameter {   get { return (IValueParameter<IntValue>) Parameters["MigrationInterval"]; } }
68    public IConstrainedValueParameter<IMigrator> MigratorParameter {   get { return (IConstrainedValueParameter<IMigrator>) Parameters["Migrator"]; } }
69    public IConstrainedValueParameter<ISelector> EmigrantsSelectorParameter {   get { return (IConstrainedValueParameter<ISelector>) Parameters["EmigrantsSelector"]; } }
70    public IConstrainedValueParameter<IReplacer> ImmigrationReplacerParameter {   get { return (IConstrainedValueParameter<IReplacer>) Parameters["ImmigrationReplacer"]; } }
71    #endregion
72
73    #region GeneralParameter
74
75    public IValueParameter<IntValue> SeedParameter {   get { return (IValueParameter<IntValue>) Parameters["Seed"]; } }
76    public IValueParameter<BoolValue> SetSeedRandomlyParameter {   get { return (IValueParameter<BoolValue>) Parameters["SetSeedRandomly"]; } }
77    public IValueParameter<IntValue> PopulationSizeParameter {   get { return (IValueParameter<IntValue>) Parameters["PopulationSize"]; } }
78    public IValueParameter<MultiAnalyzer> AnalyzerParameter {   get { return (IValueParameter<MultiAnalyzer>) Parameters["Analyzer"]; } }
79    public IConstrainedValueParameter<ISelector> SelectorParameter {   get { return (IConstrainedValueParameter<ISelector>) Parameters["Selector"]; } }
80    public IConstrainedValueParameter<ICrossover> CrossoverParameter {   get { return (IConstrainedValueParameter<ICrossover>) Parameters["Crossover"]; } }
81    public IValueParameter<PercentValue> MutationProbabilityParameter {   get { return (IValueParameter<PercentValue>) Parameters["MutationProbability"]; } }
82    public IConstrainedValueParameter<IManipulator> MutatorParameter {   get { return (IConstrainedValueParameter<IManipulator>) Parameters["Mutator"]; } }
83    public IValueParameter<IntValue> ElitesParameter {   get { return (IValueParameter<IntValue>) Parameters["Elites"]; } }
84    public IFixedValueParameter<BoolValue> ReevaluateElitesParameter {   get { return (IFixedValueParameter<BoolValue>) Parameters["ReevaluateElites"]; } }
85    public IValueParameter<MultiTerminator> TerminatorParameter {   get { return (IValueParameter<MultiTerminator>) Parameters["Terminator"]; } }
86    #endregion
87
88    #endregion
89
90    #region Properties
91
92    public IntValue Seed {
93      get { return SeedParameter.Value; }
94      set { SeedParameter.Value = value; }
95    }
96
97    public BoolValue SetSeedRandomly {
98      get { return SetSeedRandomlyParameter.Value; }
99      set { SetSeedRandomlyParameter.Value = value; }
100    }
101
102    public IntValue PopulationSize {
103      get { return PopulationSizeParameter.Value; }
104      set { PopulationSizeParameter.Value = value; }
105    }
106
107    public IntValue NumberOfIslands {
108      get { return NumberOfIslandsParameter.Value; }
109      set { NumberOfIslandsParameter.Value = value; }
110    }
111
112    public MultiAnalyzer Analyzer {
113      get { return AnalyzerParameter.Value; }
114      set { AnalyzerParameter.Value = value; }
115    }
116
117    public MultiAnalyzer IslandAnalyzer {
118      get { return IslandAnalyzerParameter.Value; }
119      set { IslandAnalyzerParameter.Value = value; }
120    }
121
122    public MultiAnalyzer LayerAnalyzer {
123      get { return LayerAnalyzerParameter.Value; }
124      set { LayerAnalyzerParameter.Value = value; }
125    }
126
127    public MultiAnalyzer GroupAnalyzer {
128      get { return GroupAnalyzerParameter.Value; }
129      set { GroupAnalyzerParameter.Value = value; }
130    }
131
132    public ISelector Selector {
133      get { return SelectorParameter.Value; }
134      set { SelectorParameter.Value = value; }
135    }
136
137    public ICrossover Crossover {
138      get { return CrossoverParameter.Value; }
139      set { CrossoverParameter.Value = value; }
140    }
141
142    public PercentValue MutationProbability {
143      get { return MutationProbabilityParameter.Value; }
144      set { MutationProbabilityParameter.Value = value; }
145    }
146
147    public IManipulator Mutator {
148      get { return MutatorParameter.Value; }
149      set { MutatorParameter.Value = value; }
150    }
151
152    public IntValue Elites {
153      get { return ElitesParameter.Value; }
154      set { ElitesParameter.Value = value; }
155    }
156
157    public bool ReevaluteElites {
158      get { return ReevaluateElitesParameter.Value.Value; }
159      set { ReevaluateElitesParameter.Value.Value = value; }
160    }
161
162    public MultiTerminator Terminators {
163      get { return TerminatorParameter.Value; }
164    }
165
166    public EnumValue<AgingScheme> AgingScheme {
167      get { return AgingSchemeParameter.Value; }
168      set { AgingSchemeParameter.Value = value; }
169    }
170
171    public IntValue AgeGap {
172      get { return AgeGapParameter.Value; }
173      set { AgeGapParameter.Value = value; }
174    }
175
176    public DoubleValue AgeInheritance {
177      get { return AgeInheritanceParameter.Value; }
178      set { AgeInheritanceParameter.Value = value; }
179    }
180
181    public IntArray AgeLimits {
182      get { return AgeLimitsParameter.Value; }
183      set { AgeLimitsParameter.Value = value; }
184    }
185
186    public IntValue NumberOfLayers {
187      get { return NumberOfLayersParameter.Value; }
188      set { NumberOfLayersParameter.Value = value; }
189    }
190
191    #endregion
192
193    #region Helper Properties
194
195    private IslandAlpsOffspringSelectionAlgorithmMainLoop MainLoop {
196      get { return OperatorGraph.Iterate().OfType<IslandAlpsOffspringSelectionAlgorithmMainLoop>().First(); }
197    }
198
199    private SolutionsCreator SolutionsCreator {
200      get { return OperatorGraph.Iterate().OfType<SolutionsCreator>().First(); }
201    }
202
203    #endregion
204
205    #region Preconfigured Terminators
206
207    [Storable] private readonly ComparisonTerminator<IntValue> generationsTerminator;
208    [Storable] private readonly ComparisonTerminator<IntValue> evaluationsTerminator;
209    [Storable] private readonly SingleObjectiveQualityTerminator qualityTerminator;
210    [Storable] private readonly ExecutionTimeTerminator executionTimeTerminator;
211
212    #endregion
213
214    #region Preconfigured Analyzers
215
216    [Storable] private readonly BestAverageWorstQualityAnalyzer qualityAnalyzer;
217    [Storable] private readonly BestAverageWorstQualityAnalyzer islandQualityAnalyzer;
218    [Storable] private readonly BestAverageWorstQualityAnalyzer layerQualityAnalyzer;
219    [Storable] private readonly BestAverageWorstQualityAnalyzer groupQualityAnalyzer;
220    [Storable] private readonly ValueAnalyzer layerSelectionPressureAnalyzer;
221    [Storable] private readonly ValueAnalyzer currentSucessRatioAnalyzer;
222
223    #endregion
224
225    #region Constructors
226
227    [StorableConstructor]
228    public IslandAlpsOffspringSelectionAlgorithm(bool deserializing) : base(deserializing) {}
229
230    [StorableHook(HookType.AfterDeserialization)]
231    public void AfterDeserialization() {
232      InitializeEventHandler();
233    }
234
235    public IslandAlpsOffspringSelectionAlgorithm(IslandAlpsOffspringSelectionAlgorithm original, Cloner cloner)
236      : base(original, cloner) {
237      //clone Properties
238
239      //analyzer
240      qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
241      islandQualityAnalyzer = cloner.Clone(original.islandQualityAnalyzer);
242      layerQualityAnalyzer = cloner.Clone(original.layerQualityAnalyzer);
243      groupQualityAnalyzer = cloner.Clone(original.groupQualityAnalyzer);
244      layerSelectionPressureAnalyzer = cloner.Clone(original.layerSelectionPressureAnalyzer);
245      currentSucessRatioAnalyzer = cloner.Clone(currentSucessRatioAnalyzer);
246      //terminator
247      generationsTerminator = cloner.Clone(original.generationsTerminator);
248      evaluationsTerminator = cloner.Clone(original.evaluationsTerminator);
249      qualityTerminator = cloner.Clone(original.qualityTerminator);
250      executionTimeTerminator = cloner.Clone(original.executionTimeTerminator);
251
252      InitializeEventHandler();
253    }
254
255    public IslandAlpsOffspringSelectionAlgorithm() {
256   
257      AddParameters();
258
259      #region create Operators
260
261      var globalRandomCreator = new RandomCreator();
262      var islandLayerCreator = new SubScopesCreator {Name = "Create Islands"};
263      var islandUssp = new UniformSubScopesProcessor();
264      var islandRandomCreator = new LocalRandomCreator();
265      var layerZeroCreator = new SubScopesCreator {Name = "Create Layer 0"};
266      var layerZeroUssp = new UniformSubScopesProcessor();
267      var layerRandomCreator = new LocalRandomCreator();
268      var islandSolutionsCounter = new DataReducer {Name = "Count IslandSolutions"};
269      var layerSolutionCreator = new SolutionsCreator();
270      var ageInitializerUssp = new UniformSubScopesProcessor();
271      var ageInitializerVc = new VariableCreator {Name = "Initialize Age"};
272      var evaluatedSolutionsVc = new VariableCreator {Name = "Create LayerEvaluatedSolutions"};
273      var evaluatedSolutionsCounter = new SubScopesCounter {Name = "Count LayerEvaluatedSolutions"};
274      var globalEvaluatedSolutionsCounter = new DataReducer {Name = "Count GlobalSolutions"};
275      var resultsCollector = new ResultsCollector();
276      var mainLoop = new IslandAlpsOffspringSelectionAlgorithmMainLoop();
277
278      #endregion
279
280      #region Set selectors
281
282      var selectors = ApplicationManager.Manager.GetInstances<ISelector>()
283                                        .Where(s => !(s is IMultiObjectiveSelector))
284                                        .OrderBy(s => Name);
285      foreach (var selector in selectors)
286        SelectorParameter.ValidValues.Add(selector);
287
288      var defaultSelector = SelectorParameter.ValidValues.OfType<GeneralizedRankSelector>().FirstOrDefault();
289      if (defaultSelector != null) {
290        defaultSelector.PressureParameter.Value = new DoubleValue(4.0);
291        SelectorParameter.Value = defaultSelector;
292      }
293
294      #endregion
295
296      #region Create Analyzers
297      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
298      islandQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
299      layerQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
300      groupQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
301      layerSelectionPressureAnalyzer = new ValueAnalyzer();
302      currentSucessRatioAnalyzer = new ValueAnalyzer();
303      #endregion
304
305      #region Create terminators
306
307      generationsTerminator = new ComparisonTerminator<IntValue>("Generations", ComparisonType.Less, new IntValue(1000)) { Name = "Generations" };
308      evaluationsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.Less, new IntValue(int.MaxValue)) {Name = "Evaluations"};
309      qualityTerminator = new SingleObjectiveQualityTerminator {Name = "Quality"};
310      executionTimeTerminator = new ExecutionTimeTerminator(this, new TimeSpanValue(TimeSpan.FromMinutes(5)));
311
312      #endregion
313
314      #region Operator Graph
315
316      globalRandomCreator.RandomParameter.ActualName = "GlobalRandom";
317      globalRandomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
318      globalRandomCreator.SetSeedRandomlyParameter.Value = null;
319      globalRandomCreator.SeedParameter.ActualName = SeedParameter.Name;
320      globalRandomCreator.SeedParameter.Value = null;
321
322      //create islands
323      islandLayerCreator.NumberOfSubScopesParameter.ActualName = NumberOfIslandsParameter.Name;
324
325      islandRandomCreator.GlobalRandomParameter.ActualName = globalRandomCreator.RandomParameter.ActualName;
326      islandRandomCreator.LocalRandomParameter.ActualName = "IslandRandom";
327
328      layerZeroCreator.NumberOfSubScopesParameter.Value = new IntValue(1);
329
330      islandSolutionsCounter.ParameterToReduce.Depth = 1;
331      islandSolutionsCounter.ParameterToReduce.ActualName = "LayerEvaluatedSolutions";
332      islandSolutionsCounter.TargetParameter.ActualName = "IslandEvaluatedSolutions";
333      islandSolutionsCounter.ReductionOperation.Value.Value = ReductionOperations.Sum;
334      islandSolutionsCounter.TargetOperation.Value.Value = ReductionOperations.Assign;
335
336      layerRandomCreator.GlobalRandomParameter.ActualName = globalRandomCreator.RandomParameter.ActualName;
337      layerRandomCreator.LocalRandomParameter.ActualName = "LayerRandom";
338
339      layerSolutionCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
340      layerSolutionCreator.ParallelParameter.Value = new BoolValue(true);
341
342      ageInitializerVc.CollectedValues.Add(new ValueParameter<DoubleValue>("Age", new DoubleValue(0)));
343
344      evaluatedSolutionsVc.CollectedValues.Add(new ValueParameter<IntValue>("LayerEvaluatedSolutions", new IntValue(0)));
345
346      evaluatedSolutionsCounter.ValueParameter.ActualName = "LayerEvaluatedSolutions";
347
348      globalEvaluatedSolutionsCounter.ParameterToReduce.Depth = 1;
349      globalEvaluatedSolutionsCounter.ParameterToReduce.ActualName = "IslandEvaluatedSolutions";
350      globalEvaluatedSolutionsCounter.TargetParameter.ActualName = "EvaluatedSolutions";
351      globalEvaluatedSolutionsCounter.ReductionOperation.Value.Value = ReductionOperations.Sum;
352      globalEvaluatedSolutionsCounter.TargetOperation.Value.Value = ReductionOperations.Assign;
353
354      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("EvaluatedSolutions"));
355
356      //flow
357      OperatorGraph.InitialOperator = globalRandomCreator;
358      globalRandomCreator.Successor = islandLayerCreator;
359      islandLayerCreator.Successor = islandUssp;
360      islandUssp.Operator = islandRandomCreator;
361      islandRandomCreator.Successor = layerZeroCreator;
362      layerZeroCreator.Successor = layerZeroUssp;
363      layerZeroUssp.Operator = layerRandomCreator;
364      layerRandomCreator.Successor = layerSolutionCreator;
365      layerSolutionCreator.Successor = ageInitializerUssp;
366      ageInitializerUssp.Operator = ageInitializerVc;
367      ageInitializerVc.Successor = null;
368      ageInitializerUssp.Successor = evaluatedSolutionsVc;
369      evaluatedSolutionsVc.Successor = evaluatedSolutionsCounter;
370      evaluatedSolutionsCounter.Successor = null;
371      layerZeroUssp.Successor = islandSolutionsCounter;
372      islandSolutionsCounter.Successor = null;
373      islandUssp.Successor = globalEvaluatedSolutionsCounter;
374      globalEvaluatedSolutionsCounter.Successor = resultsCollector;
375      resultsCollector.Successor = mainLoop;
376
377      #endregion
378
379      #region parametrize
380      UpdateAnalyzers();
381      ParameterizeAnalyzers();
382      ParameterizeSelectors();
383      UpdateTerminators();
384      ParameterizeAgeLimits();
385      ParametrizeMigration();
386
387      #endregion
388
389      InitializeEventHandler();
390    }
391
392    private void AddParameters() {
393      #region ALPSParameter
394
395      Parameters.Add(new ValueParameter<IntValue>("AgeGap", "The frequency of reseeding the lowest layer and scaling factor for the age-limits for the layers.", new IntValue(20)));
396      Parameters.Add(new ValueParameter<DoubleValue>("AgeInheritance", "A weight that determines the age of a child after crossover based on the older (1.0) and younger (0.0) parent.", new DoubleValue(1)));
397      Parameters.Add(new ValueParameter<IntArray>("AgeLimits", "The maximum age an individual is allowed to reach in a certain layer.", new IntArray(new int[0])) {Hidden = true});
398      Parameters.Add(new ValueParameter<EnumValue<AgingScheme>>("AgingScheme", "The aging scheme for setting the age-limits for the layers.", new EnumValue<AgingScheme>(ALPS.AgingScheme.Polynomial)));
399      Parameters.Add(new ValueParameter<BoolValue>("ReduceToPopulationSize", ".", new BoolValue(true)));
400
401      Parameters.Add(new ValueParameter<IntValue>("NumberOfLayers", "", new IntValue(10000)));
402      Parameters.Add(new ValueParameter<MultiAnalyzer>("LayerAnalyzer", "The operator used to analyze each layer.", new MultiAnalyzer()));
403      Parameters.Add(new ValueParameter<MultiAnalyzer>("GroupAnalyzer", "The operator used to analyze each layergroup.", new MultiAnalyzer()));
404
405      #endregion
406      #region OS
407
408      Parameters.Add(new FixedValueParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1)));
409      Parameters.Add(new FixedValueParameter<DoubleValue>("ComparisonFactor", "The comparison factor is used to determine whether the offspring should be compared to the better parent, the worse parent or a quality value linearly interpolated between them. It is in the range [0;1].", new DoubleValue(1)));
410      Parameters.Add(new FixedValueParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100)));
411      Parameters.Add(new FixedValueParameter<BoolValue>("OffspringSelectionBeforeMutation", "True if the offspring selection step should be applied before mutation, false if it should be applied after mutation.", new BoolValue(false)));
412      Parameters.Add(new FixedValueParameter<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)));
413
414      #endregion
415
416      #region IslandParameter
417
418      Parameters.Add(new ValueParameter<IntValue>("NumberOfIslands", "The number of islands.", new IntValue(5)));
419      Parameters.Add(new ValueParameter<PercentValue>("MigrationRate", "How many individuals should migrate.", new PercentValue(0.15)));
420      Parameters.Add(new ValueParameter<IntValue>("MigrationInterval", "The number Generations before a migration occurs.", new IntValue(20)));
421      Parameters.Add(new ValueParameter<MultiAnalyzer>("IslandAnalyzer", "The operator used to analyze each island.", new MultiAnalyzer()));
422      Parameters.Add(new ConstrainedValueParameter<IMigrator>("Migrator", "The migration strategy."));
423      Parameters.Add(new ConstrainedValueParameter<ISelector>("EmigrantsSelector", "Selects the individuals that will be migrated."));
424      Parameters.Add(new ConstrainedValueParameter<IReplacer>("ImmigrationReplacer", "Selects the population from the unification of the original population and the immigrants."));
425
426      #endregion
427
428      #region GeneralParameter   
429
430      Parameters.Add(new ValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
431      Parameters.Add(new ValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
432      Parameters.Add(new ValueParameter<IntValue>("PopulationSize", "The size of the population of solutions.", new IntValue(100)));
433      Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze the islands.", new MultiAnalyzer()));
434      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
435      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
436      Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
437      Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
438      Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
439      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});
440      Parameters.Add(new ValueParameter<MultiTerminator>("Terminator", "The termination criteria that defines if the algorithm should continue or stop.", new MultiTerminator()));
441
442      #endregion
443    }
444
445
446    public override IDeepCloneable Clone(Cloner cloner) {
447      return new IslandAlpsOffspringSelectionAlgorithm(this, cloner);
448    }
449
450    #endregion
451
452    #region events
453
454    protected override void RegisterProblemEvents() {
455      base.RegisterProblemEvents();
456      var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter;
457      if (maximizationParameter != null) maximizationParameter.ValueChanged += MaximizationParameter_ValueChanged;
458    }
459    protected override void DeregisterProblemEvents() {
460      var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter;
461      if (maximizationParameter != null) maximizationParameter.ValueChanged -= MaximizationParameter_ValueChanged;
462      base.DeregisterProblemEvents();
463    }
464
465    protected override void OnProblemChanged() {
466      base.OnProblemChanged();
467      ParameterizeStochasticOperator(Problem.SolutionCreator);
468      ParameterizeStochasticOperatorForLayer(Problem.Evaluator);
469      foreach (var op in Problem.Operators.OfType<IOperator>()) {
470        ParameterizeStochasticOperator(op);
471      }
472
473      ParameterizeSolutionsCreator();
474      ParameterizeMainLoop();
475      ParameterizeSelectors();
476      ParameterizeAnalyzers();
477      ParameterizeTerminators();
478      ParameterizeIterationBasedOperators();
479
480      Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
481
482      UpdateAnalyzers();
483      UpdateCrossovers();
484      UpdateMutators();
485      UpdateTerminators();
486    }
487
488    protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
489      base.Problem_SolutionCreatorChanged(sender, e);
490      ParameterizeStochasticOperator(Problem.SolutionCreator);
491      ParameterizeStochasticOperatorForLayer(Problem.Evaluator);
492
493      Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
494
495      ParameterizeSolutionsCreator();
496      ParameterizeAnalyzers();
497    }
498
499    protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
500      base.Problem_EvaluatorChanged(sender, e);
501
502      ParameterizeStochasticOperatorForLayer(Problem.Evaluator);
503      ParameterizeSolutionsCreator();
504      ParameterizeMainLoop();
505      ParameterizeSelectors();
506      ParameterizeAnalyzers();
507      ParameterizeTerminators();
508
509      Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
510
511      UpdateAnalyzers();
512      UpdateCrossovers();
513      UpdateMutators();
514      UpdateTerminators();
515    }
516
517    protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
518      base.Problem_OperatorsChanged(sender, e);
519      ParameterizeIterationBasedOperators();
520      UpdateCrossovers();
521      UpdateMutators();
522      UpdateAnalyzers();
523      UpdateTerminators();
524    }
525
526    private void InitializeEventHandler() {
527      PopulationSizeParameter.ValueChanged += PopulationSizeParameter_ValueChanged;
528      PopulationSize.ValueChanged += PopulationSize_ValueChanged;
529      ElitesParameter.ValueChanged += ElitesParameter_ValueChanged;
530      Elites.ValueChanged += Elites_ValueChanged;
531      MigrationRateParameter.Value.ValueChanged += MigrationRate_ValueChanged;
532      MigrationRateParameter.ValueChanged += MigrationRate_ValueChanged;
533
534      Analyzer.Operators.ItemsAdded += AnalyzerOperators_ItemsAdded;
535      IslandAnalyzer.Operators.ItemsAdded += IslandAnalyzerOperators_ItemsAdded;
536      LayerAnalyzer.Operators.ItemsAdded += LayerAnalyzerOperators_ItemsAdded;
537      GroupAnalyzer.Operators.ItemsAdded += GroupAnalyzerOperators_ItemsAdded;
538
539      if (Problem != null) {
540        Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
541      }
542
543      AgeGapParameter.ValueChanged += AgeGapParameter_ValueChanged;
544      AgeGap.ValueChanged += AgeGap_ValueChanged;
545      AgingSchemeParameter.ValueChanged += AgingSchemeParameter_ValueChanged;
546      AgingScheme.ValueChanged += AgingScheme_ValueChanged;
547
548      NumberOfLayersParameter.ValueChanged += NumberOfLayersParameter_ValueChanged;
549      NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged;
550      qualityAnalyzer.CurrentBestQualityParameter.NameChanged += QualityAnalyzer_CurrentBestQualityParameter_NameChanged;
551    }
552
553    private void MigrationRate_ValueChanged(object sender, EventArgs e) {
554      ParametrizeMigration();
555    }
556
557    private void GroupAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
558      foreach (var analyzer in e.Items) {
559        IParameter resultParameter;
560        if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
561          var lookupParameter = resultParameter as ILookupParameter;
562          if (lookupParameter != null)
563            lookupParameter.ActualName = "GroupResults";
564        }
565        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
566          parameter.Depth = 1;
567        }
568      }
569    }
570    private void IslandAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
571      foreach (var analyzer in e.Items) {
572        IParameter resultParameter;
573        if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
574          var lookupParameter = resultParameter as ILookupParameter;
575          if (lookupParameter != null)
576            lookupParameter.ActualName = "IslandResults";
577        }
578        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
579          parameter.Depth = 2;
580        }
581      }
582    }
583    private void LayerAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
584      foreach (var analyzer in e.Items) {
585        IParameter resultParameter;
586        if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
587          var lookupParameter = resultParameter as ILookupParameter;
588          if (lookupParameter != null)
589            lookupParameter.ActualName = "LayerResults";
590        }
591        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
592          parameter.Depth = 1;
593        }
594      }
595    }
596
597    private void AnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
598      foreach (var analyzer in e.Items) {
599        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
600          parameter.Depth = 3;
601        }
602      }
603    }
604
605    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
606      ParameterizeMainLoop();
607      ParameterizeSelectors();
608      ParameterizeAnalyzers();
609    }
610
611    private void MaximizationParameter_ValueChanged(object sender, EventArgs e) {
612      ParameterizeTerminators();
613    }
614    private void QualityAnalyzer_CurrentBestQualityParameter_NameChanged(object sender, EventArgs e) {
615      ParameterizeTerminators();
616    }
617    private void ElitesParameter_ValueChanged(object sender, EventArgs e) {
618      ParameterizeSelectors();
619    }
620
621    private void Elites_ValueChanged(object sender, EventArgs e) {
622      ParameterizeSelectors();
623    }
624
625    private void PopulationSizeParameter_ValueChanged(object sender, EventArgs e) {
626      ParameterizeSelectors();
627    }
628
629    private void PopulationSize_ValueChanged(object sender, EventArgs e) {
630      ParameterizeSelectors();
631      ParametrizeMigration();
632    }
633
634    private void NumberOfLayersParameter_ValueChanged(object sender, EventArgs e) {
635      NumberOfLayers.ValueChanged += NumberOfLayers_ValueChanged;
636      ParameterizeAgeLimits();
637    }
638
639    private void NumberOfLayers_ValueChanged(object sender, EventArgs e) {
640      ParameterizeAgeLimits();
641    }
642
643    private void AgeGapParameter_ValueChanged(object sender, EventArgs e) {
644      AgeGap.ValueChanged += AgeGap_ValueChanged;
645      ParameterizeAgeLimits();
646    }
647
648    private void AgeGap_ValueChanged(object sender, EventArgs e) {
649      ParameterizeAgeLimits();
650    }
651
652    private void AgingSchemeParameter_ValueChanged(object sender, EventArgs e) {
653      AgingScheme.ValueChanged += AgingScheme_ValueChanged;
654      ParameterizeAgeLimits();
655    }
656
657    private void AgingScheme_ValueChanged(object sender, EventArgs e) {
658      ParameterizeAgeLimits();
659    }
660
661    #endregion
662
663    #region Update Functions
664
665    private void UpdateCrossovers() {
666      var oldCrossover = CrossoverParameter.Value;
667      var defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault();
668      CrossoverParameter.ValidValues.Clear();
669      foreach (var crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name)) {
670        ParameterizeStochasticOperatorForLayer(crossover);
671        CrossoverParameter.ValidValues.Add(crossover);
672      }
673      if (oldCrossover != null) {
674        var crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
675        if (crossover != null) CrossoverParameter.Value = crossover;
676        else oldCrossover = null;
677      }
678      if (oldCrossover == null && defaultCrossover != null)
679        CrossoverParameter.Value = defaultCrossover;
680    }
681
682    private void UpdateMutators() {
683      var oldMutator = MutatorParameter.Value;
684      MutatorParameter.ValidValues.Clear();
685      foreach (var mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) {
686        ParameterizeStochasticOperatorForLayer(mutator);
687        MutatorParameter.ValidValues.Add(mutator);
688      }
689      if (oldMutator != null) {
690        var mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
691        if (mutator != null) MutatorParameter.Value = mutator;
692      }
693    }
694
695    private void UpdateAnalyzers() {
696      LayerAnalyzer.Operators.Clear();
697      IslandAnalyzer.Operators.Clear();
698      GroupAnalyzer.Operators.Clear();
699      Analyzer.Operators.Clear();
700
701      //add analyzer
702      GroupAnalyzer.Operators.Add(groupQualityAnalyzer, false);
703      LayerAnalyzer.Operators.Add(layerQualityAnalyzer, false);
704      LayerAnalyzer.Operators.Add(layerSelectionPressureAnalyzer, false);
705      LayerAnalyzer.Operators.Add(currentSucessRatioAnalyzer, false);
706      IslandAnalyzer.Operators.Add(islandQualityAnalyzer, false);
707
708      Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault);
709
710      //depth for each analyzer gets set when added
711      if (Problem != null) {
712        foreach (var analyzer in Problem.Operators.OfType<IAnalyzer>()) {
713          Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault);
714          IslandAnalyzer.Operators.Add((IAnalyzer) analyzer.Clone(), false);
715          LayerAnalyzer.Operators.Add((IAnalyzer) analyzer.Clone(), false);
716          GroupAnalyzer.Operators.Add((IAnalyzer) analyzer.Clone(), false);
717        }
718      }
719      //setting the right depth because adding analyzer sets the depth
720      layerSelectionPressureAnalyzer.ValueParameter.Depth = 0;
721      currentSucessRatioAnalyzer.ValueParameter.Depth = 0;
722
723    }
724
725    private void UpdateTerminators() {
726      var newTerminators = new Dictionary<ITerminator, bool> {
727        {
728          generationsTerminator,
729          !Terminators.Operators.Contains(generationsTerminator) ||
730          Terminators.Operators.ItemChecked(generationsTerminator)
731        }, {
732          evaluationsTerminator,
733          Terminators.Operators.Contains(evaluationsTerminator) &&
734          Terminators.Operators.ItemChecked(evaluationsTerminator)
735        }, {
736          qualityTerminator,
737          Terminators.Operators.Contains(qualityTerminator) && Terminators.Operators.ItemChecked(qualityTerminator)
738        }, {
739          executionTimeTerminator,
740          Terminators.Operators.Contains(executionTimeTerminator) &&
741          Terminators.Operators.ItemChecked(executionTimeTerminator)
742        }
743      };
744      if (Problem != null) {
745        foreach (var terminator in Problem.Operators.OfType<ITerminator>())
746          newTerminators.Add(terminator,
747                             !Terminators.Operators.Contains(terminator) || Terminators.Operators.ItemChecked(terminator));
748      }
749
750      Terminators.Operators.Clear();
751
752      foreach (var newTerminator in newTerminators)
753        Terminators.Operators.Add(newTerminator.Key, newTerminator.Value);
754    }
755
756    private void ParameterizeAgeLimits() {
757      var scheme = AgingScheme.Value;
758      var ageGap = AgeGap.Value;
759      var numberOfLayers = NumberOfLayers.Value;
760      AgeLimits = scheme.CalculateAgeLimits(ageGap, numberOfLayers);
761    }
762
763    private void ParameterizeMainLoop() {
764      MainLoop.AgeGapParameter.ActualName = AgeGapParameter.Name;
765      MainLoop.AgeInheritanceParameter.ActualName = AgeInheritanceParameter.Name;
766      MainLoop.AgeLimitsParameter.ActualName = AgeLimitsParameter.Name;
767      MainLoop.ReduceToPopulationSizeParameter.ActualName = ReduceToPopulationSizeParameter.Name;
768      MainLoop.AgeParameter.ActualName = "Age";
769      MainLoop.GlobalRandomParameter.ActualName = "GlobalRandom";
770      MainLoop.IslandRandomParameter.ActualName = "IslandRandom";
771      MainLoop.LayerRandomParameter.ActualName = "LayerRandom";
772
773      MainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
774      MainLoop.LayerEvaluatedSolutionsParameter.ActualName = "LayerEvaluatedSolutions";
775
776      MainLoop.NumberOfIslandsParameter.ActualName = NumberOfIslandsParameter.Name;
777      MainLoop.NumberOfLayersParameter.ActualName = NumberOfLayersParameter.Name;
778      MainLoop.MigrationIntervalParameter.ActualName = MigrationIntervalParameter.Name;
779      MainLoop.MigratorParameter.ActualName = MigratorParameter.Name;
780      MainLoop.EmigrantsSelectorParameter.ActualName = EmigrantsSelectorParameter.Name;
781      MainLoop.ImmigrationReplacerParameter.ActualName = ImmigrationReplacerParameter.Name;
782
783      MainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
784      MainLoop.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
785      MainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
786      MainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
787      MainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
788      MainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
789      MainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
790      MainLoop.TerminatorParameter.ActualName = TerminatorParameter.Name;
791
792      MainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
793      MainLoop.LayerAnalyzerParameter.ActualName = LayerAnalyzerParameter.Name;
794      MainLoop.IslandAnalyzerParameter.ActualName = IslandAnalyzerParameter.Name;
795      MainLoop.GroupAnalyzerParameter.ActualName = GroupAnalyzerParameter.Name;
796
797      MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
798      MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
799
800      MainLoop.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
801      MainLoop.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
802      MainLoop.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
803      MainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
804      //MainLoop.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name;
805    }
806
807    private void ParametrizeMigration() {
808      var migrationSize = (int) Math.Ceiling(MigrationRateParameter.Value.Value*PopulationSize.Value);
809      EmigrantsSelectorParameter.ValidValues.Clear();
810      foreach (var selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(x => !(x is IMultiObjectiveSelector)).OrderBy(x => x.Name)) {
811        selector.NumberOfSelectedSubScopesParameter.Value = new IntValue(migrationSize);
812        selector.NumberOfSelectedSubScopesParameter.Hidden = true;
813
814        ParameterizeStochasticOperatorForLayer(selector);
815
816        EmigrantsSelectorParameter.ValidValues.Add(selector);
817      }
818
819      ImmigrationReplacerParameter.ValidValues.Clear();
820      foreach (var replacer in ApplicationManager.Manager.GetInstances<IReplacer>().OrderBy(x => x.Name)) {
821        ParameterizeStochasticOperatorForLayer(replacer);
822        ImmigrationReplacerParameter.ValidValues.Add(replacer);
823      }
824
825      MigratorParameter.ValidValues.Clear();
826      MigratorParameter.ValidValues.Add(new LayerMigrator());
827    }
828
829    private void ParameterizeSolutionsCreator() {
830      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
831      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
832    }
833
834    private void ParameterizeSelectors() {
835      foreach (var selector in SelectorParameter.ValidValues) {
836        selector.CopySelected = new BoolValue(true);
837        selector.NumberOfSelectedSubScopesParameter.ActualName = SelectedParentsParameter.Name;
838        selector.NumberOfSelectedSubScopesParameter.Hidden = true;
839        ParameterizeStochasticOperatorForLayer(selector);
840      }
841
842      if (Problem != null) {
843        foreach (var selector in SelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
844          ParametrizeSingleObjectiveSelector(selector);
845        }
846        foreach (var replacer in EmigrantsSelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
847          ParametrizeSingleObjectiveSelector(replacer);
848        }
849        foreach (var selector in ImmigrationReplacerParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
850          ParametrizeSingleObjectiveSelector(selector);
851        }
852      }
853    }
854
855    private void ParametrizeSingleObjectiveSelector(ISingleObjectiveSelector selector) {
856      selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
857      selector.MaximizationParameter.Hidden = true;
858      selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
859      selector.QualityParameter.Hidden = true;
860    }
861
862    private void ParameterizeAnalyzers() {
863      layerQualityAnalyzer.ResultsParameter.ActualName = "LayerResults";
864      layerQualityAnalyzer.ResultsParameter.Hidden = true;
865
866      islandQualityAnalyzer.ResultsParameter.ActualName = "IslandResults";
867      islandQualityAnalyzer.ResultsParameter.Hidden = true;
868
869      qualityAnalyzer.ResultsParameter.ActualName = "Results";
870      qualityAnalyzer.ResultsParameter.Hidden = true;
871
872      groupQualityAnalyzer.ResultsParameter.ActualName = "GroupResults";
873      groupQualityAnalyzer.ResultsParameter.Hidden = true;
874
875      layerSelectionPressureAnalyzer.Name = "SelectionPressureAnalyzer Layer";
876      layerSelectionPressureAnalyzer.ResultsParameter.ActualName = "LayerResults";
877      layerSelectionPressureAnalyzer.ValueParameter.ActualName = "SelectionPressure";
878      layerSelectionPressureAnalyzer.ValuesParameter.ActualName = "SelectionPressure History";
879
880      currentSucessRatioAnalyzer.Name = "CurrentSuccessRatio Analyzer";
881      currentSucessRatioAnalyzer.ResultsParameter.ActualName = "Results";
882      currentSucessRatioAnalyzer.ValueParameter.ActualName = "CurrentSuccessRatio";
883      currentSucessRatioAnalyzer.ValuesParameter.ActualName = "Success Ratio History";
884
885      if (Problem != null) {
886        SetAnalyzerParameter(layerQualityAnalyzer);
887        SetAnalyzerParameter(islandQualityAnalyzer);
888        SetAnalyzerParameter(qualityAnalyzer);
889        SetAnalyzerParameter(groupQualityAnalyzer);
890      }
891    }
892
893    private void SetAnalyzerParameter(BestAverageWorstQualityAnalyzer analyzer) {
894      analyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
895      analyzer.MaximizationParameter.Hidden = true;
896      analyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
897      analyzer.QualityParameter.Hidden = true;
898      analyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
899      analyzer.BestKnownQualityParameter.Hidden = true;
900    }
901
902    private void ParameterizeTerminators() {
903      qualityTerminator.Parameterize(qualityAnalyzer.CurrentBestQualityParameter, Problem);
904    }
905
906    private void ParameterizeIterationBasedOperators() {
907      if (Problem != null) {
908        foreach (var op in Problem.Operators.OfType<IIterationBasedOperator>()) {
909          op.IterationsParameter.ActualName = "Generations";
910          op.IterationsParameter.Hidden = true;
911          op.MaximumIterationsParameter.ActualName = generationsTerminator.ThresholdParameter.Name;
912          op.MaximumIterationsParameter.Hidden = true;
913        }
914      }
915    }
916
917    private void ParameterizeStochasticOperator(IOperator op) {
918      var stochasticOp = op as IStochasticOperator;
919      if (stochasticOp != null) {
920        stochasticOp.RandomParameter.ActualName = "GlobalRandom";
921        stochasticOp.RandomParameter.Hidden = true;
922      }
923    }
924
925    private void ParameterizeStochasticOperatorForLayer(IOperator op) {
926      var stochasticOp = op as IStochasticOperator;
927      if (stochasticOp != null) {
928        stochasticOp.RandomParameter.ActualName = "LayerRandom";
929        stochasticOp.RandomParameter.Hidden = true;
930      }
931    }
932
933    #endregion
934  }
935}
Note: See TracBrowser for help on using the repository browser.