Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3057_DynamicALPS/TestProblems/oesr-alps-master/HeuristicLab.Algorithms.OESRALPS/AlpsOffspringSelectionGeneticAlgorithm.cs @ 17479

Last change on this file since 17479 was 17479, checked in by kyang, 4 years ago

#3057

  1. upload the latest version of ALPS with SMS-EMOA
  2. upload the related dynamic test problems (dynamic, single-objective symbolic regression), written by David Daninel.
File size: 44.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 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 HEAL.Attic;
26using HeuristicLab.Algorithms.OESRALPS.Analyzers;
27using HeuristicLab.Algorithms.OESRALPS.Analyzers.Regression;
28using HeuristicLab.Algorithms.OESRALPS.SlidingWindow.Operator;
29using HeuristicLab.Analysis;
30using HeuristicLab.Collections;
31using HeuristicLab.Common;
32using HeuristicLab.Core;
33using HeuristicLab.Data;
34using HeuristicLab.Operators;
35using HeuristicLab.Optimization;
36using HeuristicLab.Optimization.Operators;
37using HeuristicLab.Parameters;
38using HeuristicLab.PluginInfrastructure;
39using HeuristicLab.Random;
40using HeuristicLab.Selection;
41
42namespace HeuristicLab.Algorithms.OESRALPS {
43  [Item("OERSALPS OffspringSelection Genetic Algorithm", "An offspring selection genetic algorithm within an open ended age-layered population structure.")]
44  [Creatable(CreatableAttribute.Categories.PopulationBasedAlgorithms, Priority = 162)]
45  [StorableType("6ECED646-9DDE-4172-839F-696EF93948A8")]
46    public sealed class AlpsOffspringSelectionGeneticAlgorithm : HeuristicOptimizationEngineAlgorithm, IStorableContent {
47    public string Filename { get; set; }
48
49    private const string TerminateSlidingWindowParameterName = "TerminateSlidingWindow";
50
51    #region Problem Properties
52    public override Type ProblemType {
53      get { return typeof(ISingleObjectiveHeuristicOptimizationProblem); }
54    }
55    public new ISingleObjectiveHeuristicOptimizationProblem Problem {
56      get { return (ISingleObjectiveHeuristicOptimizationProblem)base.Problem; }
57      set { base.Problem = value; }
58    }
59    #endregion
60
61    #region Parameter Properties
62    private IFixedValueParameter<IntValue> SeedParameter {
63      get { return (IFixedValueParameter<IntValue>)Parameters["Seed"]; }
64    }
65    private IFixedValueParameter<BoolValue> SetSeedRandomlyParameter {
66      get { return (IFixedValueParameter<BoolValue>)Parameters["SetSeedRandomly"]; }
67    }
68
69    private IFixedValueParameter<MultiAnalyzer> AnalyzerParameter {
70      get { return (IFixedValueParameter<MultiAnalyzer>)Parameters["Analyzer"]; }
71    }
72    private IFixedValueParameter<MultiAnalyzer> LayerAnalyzerParameter {
73      get { return (IFixedValueParameter<MultiAnalyzer>)Parameters["LayerAnalyzer"]; }
74    }
75
76    private IFixedValueParameter<IntValue> NumberOfLayersParameter {
77      get { return (IFixedValueParameter<IntValue>)Parameters["NumberOfLayers"]; }
78    }
79    private IFixedValueParameter<IntValue> PopulationSizeParameter {
80      get { return (IFixedValueParameter<IntValue>)Parameters["PopulationSize"]; }
81    }
82
83    public IConstrainedValueParameter<ISelector> SelectorParameter {
84      get { return (IConstrainedValueParameter<ISelector>)Parameters["Selector"]; }
85    }
86    public IConstrainedValueParameter<ICrossover> CrossoverParameter {
87      get { return (IConstrainedValueParameter<ICrossover>)Parameters["Crossover"]; }
88    }
89    public IConstrainedValueParameter<IManipulator> MutatorParameter {
90      get { return (IConstrainedValueParameter<IManipulator>)Parameters["Mutator"]; }
91    }
92    private IFixedValueParameter<PercentValue> MutationProbabilityParameter {
93      get { return (IFixedValueParameter<PercentValue>)Parameters["MutationProbability"]; }
94    }
95    private IFixedValueParameter<IntValue> ElitesParameter {
96      get { return (IFixedValueParameter<IntValue>)Parameters["Elites"]; }
97    }
98    private IFixedValueParameter<BoolValue> ReevaluateElitesParameter {
99      get { return (IFixedValueParameter<BoolValue>)Parameters["ReevaluateElites"]; }
100    }
101
102    private IFixedValueParameter<DoubleValue> SuccessRatioParameter {
103      get { return (IFixedValueParameter<DoubleValue>)Parameters["SuccessRatio"]; }
104    }
105    private IFixedValueParameter<DoubleValue> ComparisonFactorParameter {
106      get { return (IFixedValueParameter<DoubleValue>)Parameters["ComparisonFactor"]; }
107    }
108    private IFixedValueParameter<DoubleValue> MaximumSelectionPressureParameter {
109      get { return (IFixedValueParameter<DoubleValue>)Parameters["MaximumSelectionPressure"]; }
110    }
111    private IFixedValueParameter<BoolValue> OffspringSelectionBeforeMutationParameter {
112      get { return (IFixedValueParameter<BoolValue>)Parameters["OffspringSelectionBeforeMutation"]; }
113    }
114    private IFixedValueParameter<IntValue> SelectedParentsParameter {
115      get { return (IFixedValueParameter<IntValue>)Parameters["SelectedParents"]; }
116    }
117    private IFixedValueParameter<BoolValue> FillPopulationWithParentsParameter {
118      get { return (IFixedValueParameter<BoolValue>)Parameters["FillPopulationWithParents"]; }
119    }
120
121    private IFixedValueParameter<EnumValue<AgingScheme>> AgingSchemeParameter {
122      get { return (IFixedValueParameter<EnumValue<AgingScheme>>)Parameters["AgingScheme"]; }
123    }
124    private IFixedValueParameter<IntValue> AgeGapParameter {
125      get { return (IFixedValueParameter<IntValue>)Parameters["AgeGap"]; }
126    }
127    private IFixedValueParameter<DoubleValue> AgeInheritanceParameter {
128      get { return (IFixedValueParameter<DoubleValue>)Parameters["AgeInheritance"]; }
129    }
130    private IFixedValueParameter<IntArray> AgeLimitsParameter {
131      get { return (IFixedValueParameter<IntArray>)Parameters["AgeLimits"]; }
132    }
133
134    private IFixedValueParameter<IntValue> MatingPoolRangeParameter {
135      get { return (IFixedValueParameter<IntValue>)Parameters["MatingPoolRange"]; }
136    }
137    private IFixedValueParameter<BoolValue> ReduceToPopulationSizeParameter {
138      get { return (IFixedValueParameter<BoolValue>)Parameters["ReduceToPopulationSize"]; }
139    }
140
141    private IFixedValueParameter<MultiTerminator> TerminatorParameter {
142      get { return (IFixedValueParameter<MultiTerminator>)Parameters["Terminator"]; }
143    }
144    public IFixedValueParameter<MultiAnalyzer> SlidingWindowParameter {
145      get { return (IFixedValueParameter<MultiAnalyzer>)Parameters["SlidingWindow"]; }
146    }
147    public ILookupParameter<BoolValue> TerminateSlidingWindowParameter {
148      get { return (ILookupParameter<BoolValue>)Parameters[TerminateSlidingWindowParameterName]; }
149    }
150    #endregion
151
152    #region Properties
153    public int Seed {
154      get { return SeedParameter.Value.Value; }
155      set { SeedParameter.Value.Value = value; }
156    }
157    public bool SetSeedRandomly {
158      get { return SetSeedRandomlyParameter.Value.Value; }
159      set { SetSeedRandomlyParameter.Value.Value = value; }
160    }
161
162    public MultiAnalyzer Analyzer {
163      get { return AnalyzerParameter.Value; }
164    }
165    public MultiAnalyzer LayerAnalyzer {
166      get { return LayerAnalyzerParameter.Value; }
167    }
168
169    public int NumberOfLayers {
170      get { return NumberOfLayersParameter.Value.Value; }
171      set { NumberOfLayersParameter.Value.Value = value; }
172    }
173    public int PopulationSize {
174      get { return PopulationSizeParameter.Value.Value; }
175      set { PopulationSizeParameter.Value.Value = value; }
176    }
177
178    public ISelector Selector {
179      get { return SelectorParameter.Value; }
180      set { SelectorParameter.Value = value; }
181    }
182    public ICrossover Crossover {
183      get { return CrossoverParameter.Value; }
184      set { CrossoverParameter.Value = value; }
185    }
186    public IManipulator Mutator {
187      get { return MutatorParameter.Value; }
188      set { MutatorParameter.Value = value; }
189    }
190    public double MutationProbability {
191      get { return MutationProbabilityParameter.Value.Value; }
192      set { MutationProbabilityParameter.Value.Value = value; }
193    }
194    public int Elites {
195      get { return ElitesParameter.Value.Value; }
196      set { ElitesParameter.Value.Value = value; }
197    }
198    public bool ReevaluteElites {
199      get { return ReevaluateElitesParameter.Value.Value; }
200      set { ReevaluateElitesParameter.Value.Value = value; }
201    }
202
203    public double SuccessRatio {
204      get { return SuccessRatioParameter.Value.Value; }
205      set { SuccessRatioParameter.Value.Value = value; }
206    }
207    public double ComparisonFactor {
208      get { return ComparisonFactorParameter.Value.Value; }
209      set { ComparisonFactorParameter.Value.Value = value; }
210    }
211    public double MaximumSelectionPressure {
212      get { return MaximumSelectionPressureParameter.Value.Value; }
213      set { MaximumSelectionPressureParameter.Value.Value = value; }
214    }
215    public bool OffspringSelectionBeforeMutation {
216      get { return OffspringSelectionBeforeMutationParameter.Value.Value; }
217      set { OffspringSelectionBeforeMutationParameter.Value.Value = value; }
218    }
219    public int SelectedParents {
220      get { return SelectedParentsParameter.Value.Value; }
221      set { SelectedParentsParameter.Value.Value = value; }
222    }
223    public bool FillPopulationWithParents {
224      get { return FillPopulationWithParentsParameter.Value.Value; }
225      set { FillPopulationWithParentsParameter.Value.Value = value; }
226    }
227
228    public AgingScheme AgingScheme {
229      get { return AgingSchemeParameter.Value.Value; }
230      set { AgingSchemeParameter.Value.Value = value; }
231    }
232    public int AgeGap {
233      get { return AgeGapParameter.Value.Value; }
234      set { AgeGapParameter.Value.Value = value; }
235    }
236    public double AgeInheritance {
237      get { return AgeInheritanceParameter.Value.Value; }
238      set { AgeInheritanceParameter.Value.Value = value; }
239    }
240    public IntArray AgeLimits {
241      get { return AgeLimitsParameter.Value; }
242      set {
243        AgeLimits.Length = value.Length;
244        for (int i = 0; i < value.Length; i++)
245          AgeLimits[i] = value[i];
246      }
247    }
248
249    public int MatingPoolRange {
250      get { return MatingPoolRangeParameter.Value.Value; }
251      set { MatingPoolRangeParameter.Value.Value = value; }
252    }
253
254    public MultiTerminator Terminators {
255      get { return TerminatorParameter.Value; }
256    }
257
258    public int MaximumGenerations {
259      get { return generationsTerminator.Threshold.Value; }
260      set { generationsTerminator.Threshold.Value = value; }
261    }
262
263    public MultiAnalyzer SlidingWindow {
264        get { return SlidingWindowParameter.Value; }
265    }
266    #endregion
267
268    #region Helper Properties
269    private SolutionsCreator SolutionsCreator {
270      get { return OperatorGraph.Iterate().OfType<SolutionsCreator>().First(); }
271    }
272    private AlpsOffspringSelectionGeneticAlgorithmMainLoop MainLoop {
273      get { return OperatorGraph.Iterate().OfType<AlpsOffspringSelectionGeneticAlgorithmMainLoop>().First(); }
274    }
275    #endregion
276
277    #region Preconfigured Analyzers
278    [Storable]
279    private BestAverageWorstQualityAnalyzer qualityAnalyzer;
280    [Storable]
281    private BestAverageWorstQualityAnalyzer layerQualityAnalyzer;
282    [Storable]
283    private OldestAverageYoungestAgeAnalyzer ageAnalyzer;
284    [Storable]
285    private OldestAverageYoungestAgeAnalyzer layerAgeAnalyzer;
286    [Storable]
287    private AgeDistributionAnalyzer ageDistributionAnalyzer;
288    [Storable]
289    private AgeDistributionAnalyzer layerAgeDistributionAnalyzer;
290    [Storable]
291    private ValueAnalyzer selectionPressureAnalyzer;
292    [Storable]
293    private ValueAnalyzer layerSelectionPressureAnalyzer;
294    [Storable]
295    private ValueAnalyzer currentSuccessRatioAnalyzer;
296
297    [Storable]
298    private SymbolicRegressionGenerationalSlidingWindowAnalyzer generationalSlidingWindowAnalyzer;
299    [Storable]
300    private SymbolicRegressionOffspringSelectionSlidingWindowAnalyzer offspringSelectionSlidingWindowAnalyze;
301    [Storable]
302    private SymbolicRegressionOverfittingSelectionSlidingWindowAnalyzer overfittingSelectionSlidingWindowAnalyzer;
303    [Storable]
304    private SymbolicRegressionAdaptiveSlidingWindowAnalyzer generationalAdaptiveSlidingWindowAnalyzer;
305    #endregion
306
307    #region Preconfigured Terminators
308    [Storable]
309    private ComparisonTerminator<IntValue> generationsTerminator;
310    [Storable]
311    private ComparisonTerminator<IntValue> evaluationsTerminator;
312    [Storable]
313    private SingleObjectiveQualityTerminator qualityTerminator;
314    [Storable]
315    private ExecutionTimeTerminator executionTimeTerminator;
316    [Storable]
317    private ComparisonTerminator<BoolValue> slidingWindowTerminator;
318    #endregion
319
320    #region Constructors
321    [StorableConstructor]
322    private AlpsOffspringSelectionGeneticAlgorithm(StorableConstructorFlag _) : base(_) { }
323    [StorableHook(HookType.AfterDeserialization)]
324    private void AfterDeserialization() {
325      // BackwardsCompatibility3.3
326      #region Backwards compatible code, remove with 3.4
327      var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>;
328      if (optionalMutatorParameter != null) {
329        Parameters.Remove(optionalMutatorParameter);
330        Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
331        foreach (var m in optionalMutatorParameter.ValidValues)
332          MutatorParameter.ValidValues.Add(m);
333        if (optionalMutatorParameter.Value == null) MutationProbability = 0; // to guarantee that the old configuration results in the same behavior
334        else Mutator = optionalMutatorParameter.Value;
335        optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared
336      }
337      #endregion
338      Initialize();
339    }
340    private AlpsOffspringSelectionGeneticAlgorithm(AlpsOffspringSelectionGeneticAlgorithm original, Cloner cloner)
341      : base(original, cloner) {
342      qualityAnalyzer = cloner.Clone(original.qualityAnalyzer);
343      layerQualityAnalyzer = cloner.Clone(original.layerQualityAnalyzer);
344      ageAnalyzer = cloner.Clone(original.ageAnalyzer);
345      layerAgeAnalyzer = cloner.Clone(original.layerAgeAnalyzer);
346      ageDistributionAnalyzer = cloner.Clone(original.ageDistributionAnalyzer);
347      layerAgeDistributionAnalyzer = cloner.Clone(original.layerAgeDistributionAnalyzer);
348      selectionPressureAnalyzer = cloner.Clone(original.selectionPressureAnalyzer);
349      layerSelectionPressureAnalyzer = cloner.Clone(original.layerSelectionPressureAnalyzer);
350      currentSuccessRatioAnalyzer = cloner.Clone(original.currentSuccessRatioAnalyzer);
351      generationsTerminator = cloner.Clone(original.generationsTerminator);
352      evaluationsTerminator = cloner.Clone(original.evaluationsTerminator);
353      qualityTerminator = cloner.Clone(original.qualityTerminator);
354      executionTimeTerminator = cloner.Clone(original.executionTimeTerminator);
355      slidingWindowTerminator = cloner.Clone(original.slidingWindowTerminator);
356      generationalSlidingWindowAnalyzer = cloner.Clone(original.generationalSlidingWindowAnalyzer);
357      offspringSelectionSlidingWindowAnalyze = cloner.Clone(original.offspringSelectionSlidingWindowAnalyze);
358      overfittingSelectionSlidingWindowAnalyzer = cloner.Clone(original.overfittingSelectionSlidingWindowAnalyzer);
359      generationalAdaptiveSlidingWindowAnalyzer = cloner.Clone(original.generationalAdaptiveSlidingWindowAnalyzer);
360      Initialize();
361    }
362    public override IDeepCloneable Clone(Cloner cloner) {
363      return new AlpsOffspringSelectionGeneticAlgorithm(this, cloner);
364    }
365    public AlpsOffspringSelectionGeneticAlgorithm()
366      : base() {
367      #region Add parameters
368      Parameters.Add(new FixedValueParameter<IntValue>("Seed", "The random seed used to initialize the new pseudo random number generator.", new IntValue(0)));
369      Parameters.Add(new FixedValueParameter<BoolValue>("SetSeedRandomly", "True if the random seed should be set to a random value, otherwise false.", new BoolValue(true)));
370
371      Parameters.Add(new FixedValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze all individuals from all layers combined.", new MultiAnalyzer()));
372      Parameters.Add(new FixedValueParameter<MultiAnalyzer>("LayerAnalyzer", "The operator used to analyze each layer.", new MultiAnalyzer()));
373
374      Parameters.Add(new FixedValueParameter<IntValue>("NumberOfLayers", "The number of layers.", new IntValue(10)));
375      Parameters.Add(new FixedValueParameter<IntValue>("PopulationSize", "The size of the population of solutions in each layer.", new IntValue(100)));
376
377      Parameters.Add(new ConstrainedValueParameter<ISelector>("Selector", "The operator used to select solutions for reproduction."));
378      Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions."));
379      Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));
380      Parameters.Add(new FixedValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05)));
381      Parameters.Add(new FixedValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1)));
382      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 });
383
384      Parameters.Add(new FixedValueParameter<DoubleValue>("SuccessRatio", "The ratio of successful to total children that should be achieved.", new DoubleValue(1)));
385      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)));
386      Parameters.Add(new FixedValueParameter<DoubleValue>("MaximumSelectionPressure", "The maximum selection pressure that terminates the algorithm.", new DoubleValue(100)));
387      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)));
388      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)));
389      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 });
390
391      Parameters.Add(new FixedValueParameter<EnumValue<AgingScheme>>("AgingScheme", "The aging scheme for setting the age-limits for the layers.", new EnumValue<AgingScheme>(OESRALPS.AgingScheme.Polynomial)));
392      Parameters.Add(new FixedValueParameter<IntValue>("AgeGap", "The frequency of reseeding the lowest layer and scaling factor for the age-limits for the layers.", new IntValue(20)));
393      Parameters.Add(new FixedValueParameter<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.0)) { Hidden = true });
394      Parameters.Add(new FixedValueParameter<IntArray>("AgeLimits", "The maximum age an individual is allowed to reach in a certain layer.", new IntArray(new int[0])) { Hidden = true });
395
396      Parameters.Add(new FixedValueParameter<IntValue>("MatingPoolRange", "The range of layers used for creating a mating pool. (1 = current + previous layer)", new IntValue(1)) { Hidden = true });
397      Parameters.Add(new FixedValueParameter<BoolValue>("ReduceToPopulationSize", "Reduce the CurrentPopulationSize after elder migration to PopulationSize", new BoolValue(true)) { Hidden = true });
398
399      Parameters.Add(new FixedValueParameter<MultiTerminator>("Terminator", "The termination criteria that defines if the algorithm should continue or stop.", new MultiTerminator()));
400     
401      Parameters.Add(new FixedValueParameter<MultiAnalyzer>("SlidingWindow", "Operator which moves a sliding window over the training data."));   
402     
403      Parameters.Add(new ValueParameter<BoolValue>(TerminateSlidingWindowParameterName, "Indicates if the sliding window has reached the end of the training data set", new BoolValue(false)) { Hidden = true });
404      #endregion
405
406      #region Create operators
407      var globalRandomCreator = new RandomCreator();
408      var layer0Creator = new SubScopesCreator() { Name = "Create Layer Zero" };
409      var layer0Processor = new SubScopesProcessor();
410      var localRandomCreator = new LocalRandomCreator();
411      var layerSolutionsCreator = new SolutionsCreator();
412      var initializeAgeProcessor = new UniformSubScopesProcessor();
413      var initializeAge = new VariableCreator() { Name = "Initialize Age" };
414      var initializeCurrentPopulationSize = new SubScopesCounter() { Name = "Initialize CurrentPopulationCounter" };
415      var initializeLocalEvaluatedSolutions = new Assigner() { Name = "Initialize LayerEvaluatedSolutions" };
416      var initializeGlobalEvaluatedSolutions = new DataReducer() { Name = "Initialize EvaluatedSolutions" };
417      var resultsCollector = new ResultsCollector();
418      var mainLoop = new AlpsOffspringSelectionGeneticAlgorithmMainLoop();
419      #endregion
420
421      #region Create and parameterize operator graph
422      OperatorGraph.InitialOperator = globalRandomCreator;
423
424      globalRandomCreator.RandomParameter.ActualName = "GlobalRandom";
425      globalRandomCreator.SeedParameter.Value = null;
426      globalRandomCreator.SeedParameter.ActualName = SeedParameter.Name;
427      globalRandomCreator.SetSeedRandomlyParameter.Value = null;
428      globalRandomCreator.SetSeedRandomlyParameter.ActualName = SetSeedRandomlyParameter.Name;
429      globalRandomCreator.Successor = layer0Creator;
430
431      layer0Creator.NumberOfSubScopesParameter.Value = new IntValue(1);
432      layer0Creator.Successor = layer0Processor;
433
434      layer0Processor.Operators.Add(localRandomCreator);
435      layer0Processor.Successor = initializeGlobalEvaluatedSolutions;
436
437      localRandomCreator.Successor = layerSolutionsCreator;
438
439      layerSolutionsCreator.NumberOfSolutionsParameter.ActualName = PopulationSizeParameter.Name;
440      layerSolutionsCreator.Successor = initializeAgeProcessor;
441
442      initializeAgeProcessor.Operator = initializeAge;
443      initializeAgeProcessor.Successor = initializeCurrentPopulationSize;
444
445      initializeCurrentPopulationSize.ValueParameter.ActualName = "CurrentPopulationSize";
446      initializeCurrentPopulationSize.Successor = initializeLocalEvaluatedSolutions;
447
448      initializeAge.CollectedValues.Add(new ValueParameter<DoubleValue>("Age", new DoubleValue(0)));
449      initializeAge.Successor = null;
450
451      initializeLocalEvaluatedSolutions.LeftSideParameter.ActualName = "LayerEvaluatedSolutions";
452      initializeLocalEvaluatedSolutions.RightSideParameter.ActualName = "CurrentPopulationSize";
453      initializeLocalEvaluatedSolutions.Successor = null;
454
455      initializeGlobalEvaluatedSolutions.ReductionOperation.Value.Value = ReductionOperations.Sum;
456      initializeGlobalEvaluatedSolutions.TargetOperation.Value.Value = ReductionOperations.Assign;
457      initializeGlobalEvaluatedSolutions.ParameterToReduce.ActualName = "LayerEvaluatedSolutions";
458      initializeGlobalEvaluatedSolutions.TargetParameter.ActualName = "EvaluatedSolutions";
459      initializeGlobalEvaluatedSolutions.Successor = resultsCollector;
460
461      resultsCollector.CollectedValues.Add(new LookupParameter<IntValue>("Evaluated Solutions", null, "EvaluatedSolutions"));
462      resultsCollector.Successor = mainLoop;
463
464      mainLoop.GlobalRandomParameter.ActualName = "GlobalRandom";
465      mainLoop.LocalRandomParameter.ActualName = localRandomCreator.LocalRandomParameter.Name;
466      mainLoop.EvaluatedSolutionsParameter.ActualName = "EvaluatedSolutions";
467      mainLoop.AnalyzerParameter.ActualName = AnalyzerParameter.Name;
468      mainLoop.LayerAnalyzerParameter.ActualName = LayerAnalyzerParameter.Name;
469      mainLoop.NumberOfLayersParameter.ActualName = NumberOfLayersParameter.Name;
470      mainLoop.PopulationSizeParameter.ActualName = PopulationSizeParameter.Name;
471      mainLoop.CurrentPopulationSizeParameter.ActualName = "CurrentPopulationSize";
472      mainLoop.SelectorParameter.ActualName = SelectorParameter.Name;
473      mainLoop.CrossoverParameter.ActualName = CrossoverParameter.Name;
474      mainLoop.MutatorParameter.ActualName = MutatorParameter.Name;
475      mainLoop.MutationProbabilityParameter.ActualName = MutationProbabilityParameter.Name;
476      mainLoop.ElitesParameter.ActualName = ElitesParameter.Name;
477      mainLoop.ReevaluateElitesParameter.ActualName = ReevaluateElitesParameter.Name;
478      mainLoop.SuccessRatioParameter.ActualName = SuccessRatioParameter.Name;
479      mainLoop.ComparisonFactorParameter.ActualName = ComparisonFactorParameter.Name;
480      mainLoop.MaximumSelectionPressureParameter.ActualName = MaximumSelectionPressureParameter.Name;
481      mainLoop.OffspringSelectionBeforeMutationParameter.ActualName = OffspringSelectionBeforeMutationParameter.Name;
482      mainLoop.FillPopulationWithParentsParameter.ActualName = FillPopulationWithParentsParameter.Name;
483      mainLoop.AgeParameter.ActualName = "Age";
484      mainLoop.AgeGapParameter.ActualName = AgeGapParameter.Name;
485      mainLoop.AgeInheritanceParameter.ActualName = AgeInheritanceParameter.Name;
486      mainLoop.AgeLimitsParameter.ActualName = AgeLimitsParameter.Name;
487      mainLoop.MatingPoolRangeParameter.ActualName = MatingPoolRangeParameter.Name;
488      mainLoop.ReduceToPopulationSizeParameter.ActualName = ReduceToPopulationSizeParameter.Name;
489      mainLoop.TerminatorParameter.ActualName = TerminatorParameter.Name;
490      mainLoop.SlidingWindowParameter.ActualName = SlidingWindowParameter.Name;
491      #endregion
492
493      #region Set operators
494      foreach (var selector in ApplicationManager.Manager.GetInstances<ISelector>().Where(s => !(s is IMultiObjectiveSelector)).OrderBy(s => Name))
495        SelectorParameter.ValidValues.Add(selector);
496      var defaultSelector = SelectorParameter.ValidValues.OfType<GeneralizedRankSelector>().FirstOrDefault();
497      if (defaultSelector != null) {
498        defaultSelector.PressureParameter.Value = new DoubleValue(4.0);
499        SelectorParameter.Value = defaultSelector;
500      }
501      #endregion
502
503      #region Create analyzers
504      qualityAnalyzer = new BestAverageWorstQualityAnalyzer();
505      layerQualityAnalyzer = new BestAverageWorstQualityAnalyzer();
506      ageAnalyzer = new OldestAverageYoungestAgeAnalyzer();
507      layerAgeAnalyzer = new OldestAverageYoungestAgeAnalyzer();
508      ageDistributionAnalyzer = new AgeDistributionAnalyzer();
509      layerAgeDistributionAnalyzer = new AgeDistributionAnalyzer();
510      selectionPressureAnalyzer = new ValueAnalyzer();
511      layerSelectionPressureAnalyzer = new ValueAnalyzer();
512      currentSuccessRatioAnalyzer = new ValueAnalyzer();
513      generationalSlidingWindowAnalyzer = new SymbolicRegressionGenerationalSlidingWindowAnalyzer();
514      offspringSelectionSlidingWindowAnalyze = new SymbolicRegressionOffspringSelectionSlidingWindowAnalyzer();
515      overfittingSelectionSlidingWindowAnalyzer = new SymbolicRegressionOverfittingSelectionSlidingWindowAnalyzer();
516      generationalAdaptiveSlidingWindowAnalyzer = new SymbolicRegressionAdaptiveSlidingWindowAnalyzer();
517      #endregion
518
519      #region Create terminators
520      generationsTerminator = new ComparisonTerminator<IntValue>("Generations", ComparisonType.Less, new IntValue(1000)) { Name = "Generations" };
521      evaluationsTerminator = new ComparisonTerminator<IntValue>("EvaluatedSolutions", ComparisonType.Less, new IntValue(int.MaxValue)) { Name = "Evaluations" };
522      qualityTerminator = new SingleObjectiveQualityTerminator() { Name = "Quality" };
523      executionTimeTerminator = new ExecutionTimeTerminator(this, new TimeSpanValue(TimeSpan.FromMinutes(5)));
524      slidingWindowTerminator = new ComparisonTerminator<BoolValue>(TerminateSlidingWindowParameterName, ComparisonType.NotEqual, new BoolValue(true)) { Name = "Terminate sliding window" };
525      #endregion
526
527      #region Parameterize
528      UpdateAnalyzers();
529      ParameterizeAnalyzers();
530
531      ParameterizeSelectors();
532
533      UpdateTerminators();
534
535      ParameterizeAgeLimits();
536      #endregion
537
538      Initialize();
539    }
540    #endregion
541
542    #region Events
543    public override void Prepare() {
544      if (Problem != null)
545        base.Prepare();
546    }
547    protected override void OnProblemChanged() {
548      base.OnProblemChanged();
549      ParameterizeStochasticOperator(Problem.SolutionCreator);
550      foreach (var @operator in Problem.Operators.OfType<IOperator>())
551        ParameterizeStochasticOperator(@operator);
552      ParameterizeStochasticOperatorForLayer(Problem.Evaluator);
553
554      ParameterizeIterationBasedOperators();
555
556      ParameterizeSolutionsCreator();
557      ParameterizeMainLoop();
558      ParameterizeAnalyzers();
559      ParameterizeSelectors();
560      ParameterizeTerminators();
561
562      Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
563
564      UpdateAnalyzers();
565      UpdateCrossovers();
566      UpdateMutators();
567      UpdateTerminators();
568    }
569
570    protected override void RegisterProblemEvents() {
571      base.RegisterProblemEvents();
572      var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter;
573      if (maximizationParameter != null) maximizationParameter.ValueChanged += new EventHandler(MaximizationParameter_ValueChanged);
574    }
575    protected override void DeregisterProblemEvents() {
576      var maximizationParameter = (IValueParameter<BoolValue>)Problem.MaximizationParameter;
577      if (maximizationParameter != null) maximizationParameter.ValueChanged -= new EventHandler(MaximizationParameter_ValueChanged);
578      base.DeregisterProblemEvents();
579    }
580
581    protected override void Problem_SolutionCreatorChanged(object sender, EventArgs e) {
582      base.Problem_SolutionCreatorChanged(sender, e);
583      ParameterizeStochasticOperator(Problem.SolutionCreator);
584
585      Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
586
587      ParameterizeSolutionsCreator();
588      ParameterizeAnalyzers();
589    }
590    protected override void Problem_EvaluatorChanged(object sender, EventArgs e) {
591      base.Problem_EvaluatorChanged(sender, e);
592      ParameterizeStochasticOperatorForLayer(Problem.Evaluator);
593
594      UpdateAnalyzers();
595
596      ParameterizeSolutionsCreator();
597      ParameterizeMainLoop();
598      ParameterizeSelectors();
599    }
600    protected override void Problem_OperatorsChanged(object sender, EventArgs e) {
601      base.Problem_OperatorsChanged(sender, e);
602      foreach (IOperator op in Problem.Operators.OfType<IOperator>()) ParameterizeStochasticOperator(op);
603      ParameterizeStochasticOperatorForLayer(Problem.Evaluator);
604      ParameterizeIterationBasedOperators();
605      UpdateCrossovers();
606      UpdateMutators();
607      UpdateTerminators();
608    }
609    private void Evaluator_QualityParameter_ActualNameChanged(object sender, EventArgs e) {
610      ParameterizeMainLoop();
611      ParameterizeAnalyzers();
612      ParameterizeSelectors();
613    }
614    private void MaximizationParameter_ValueChanged(object sender, EventArgs e) {
615      ParameterizeTerminators();
616    }
617    private void QualityAnalyzer_CurrentBestQualityParameter_NameChanged(object sender, EventArgs e) {
618      ParameterizeTerminators();
619    }
620
621    private void AgeGap_ValueChanged(object sender, EventArgs e) {
622      ParameterizeAgeLimits();
623    }
624    private void AgingScheme_ValueChanged(object sender, EventArgs e) {
625      ParameterizeAgeLimits();
626    }
627    private void NumberOfLayers_ValueChanged(object sender, EventArgs e) {
628      ParameterizeAgeLimits();
629    }
630
631    private void AnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
632      foreach (var analyzer in e.Items) {
633        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
634          parameter.Depth = 2;
635        }
636      }
637    }
638    private void LayerAnalyzerOperators_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<IAnalyzer>> e) {
639      foreach (var analyzer in e.Items) {
640        IParameter resultParameter;
641        if (analyzer.Value.Parameters.TryGetValue("Results", out resultParameter)) {
642          var lookupParameter = resultParameter as ILookupParameter;
643          if (lookupParameter != null)
644            lookupParameter.ActualName = "LayerResults";
645        }
646        foreach (var parameter in analyzer.Value.Parameters.OfType<IScopeTreeLookupParameter>()) {
647          parameter.Depth = 1;
648        }
649      }
650    }
651    #endregion
652
653    #region Parameterization
654    private void Initialize() {
655      if (Problem != null)
656        Problem.Evaluator.QualityParameter.ActualNameChanged += Evaluator_QualityParameter_ActualNameChanged;
657
658      NumberOfLayersParameter.Value.ValueChanged += NumberOfLayers_ValueChanged;
659
660      Analyzer.Operators.ItemsAdded += AnalyzerOperators_ItemsAdded;
661      LayerAnalyzer.Operators.ItemsAdded += LayerAnalyzerOperators_ItemsAdded;
662
663      AgeGapParameter.Value.ValueChanged += AgeGap_ValueChanged;
664      AgingSchemeParameter.Value.ValueChanged += AgingScheme_ValueChanged;
665
666      qualityAnalyzer.CurrentBestQualityParameter.NameChanged += QualityAnalyzer_CurrentBestQualityParameter_NameChanged;
667    }
668    private void ParameterizeSolutionsCreator() {
669      SolutionsCreator.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
670      SolutionsCreator.SolutionCreatorParameter.ActualName = Problem.SolutionCreatorParameter.Name;
671    }
672    private void ParameterizeMainLoop() {
673      MainLoop.EvaluatorParameter.ActualName = Problem.EvaluatorParameter.Name;
674      MainLoop.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
675      MainLoop.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
676    }
677    private void ParameterizeAnalyzers() {
678      qualityAnalyzer.ResultsParameter.ActualName = "Results";
679      qualityAnalyzer.ResultsParameter.Hidden = true;
680      qualityAnalyzer.QualityParameter.Depth = 2;
681      layerQualityAnalyzer.ResultsParameter.ActualName = "LayerResults";
682      layerQualityAnalyzer.ResultsParameter.Hidden = true;
683      layerQualityAnalyzer.QualityParameter.Depth = 1;
684      selectionPressureAnalyzer.Name = "SelectionPressure Analyzer";
685      selectionPressureAnalyzer.ResultsParameter.ActualName = "Results";
686      selectionPressureAnalyzer.ValueParameter.ActualName = "SelectionPressure";
687      selectionPressureAnalyzer.ValueParameter.Depth = 1;
688      selectionPressureAnalyzer.ValuesParameter.ActualName = "Selection Pressure History";
689      layerSelectionPressureAnalyzer.Name = "SelectionPressure Analyzer";
690      layerSelectionPressureAnalyzer.ResultsParameter.ActualName = "LayerResults";
691      layerSelectionPressureAnalyzer.ValueParameter.ActualName = "SelectionPressure";
692      layerSelectionPressureAnalyzer.ValueParameter.Depth = 0;
693      layerSelectionPressureAnalyzer.ValuesParameter.ActualName = "Selection Pressure History";
694      currentSuccessRatioAnalyzer.Name = "CurrentSuccessRatio Analyzer";
695      currentSuccessRatioAnalyzer.ResultsParameter.ActualName = "Results";
696      currentSuccessRatioAnalyzer.ValueParameter.ActualName = "CurrentSuccessRatio";
697      currentSuccessRatioAnalyzer.ValueParameter.Depth = 1;
698      currentSuccessRatioAnalyzer.ValuesParameter.ActualName = "Success Ratio History";
699      if (Problem != null) {
700        qualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
701        qualityAnalyzer.MaximizationParameter.Hidden = true;
702        qualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
703        qualityAnalyzer.QualityParameter.Hidden = true;
704        qualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
705        qualityAnalyzer.BestKnownQualityParameter.Hidden = true;
706        layerQualityAnalyzer.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
707        layerQualityAnalyzer.MaximizationParameter.Hidden = true;
708        layerQualityAnalyzer.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
709        layerQualityAnalyzer.QualityParameter.Hidden = true;
710        layerQualityAnalyzer.BestKnownQualityParameter.ActualName = Problem.BestKnownQualityParameter.Name;
711        layerQualityAnalyzer.BestKnownQualityParameter.Hidden = true;
712      }
713    }
714    private void ParameterizeSelectors() {
715      foreach (var selector in SelectorParameter.ValidValues) {
716        selector.CopySelected = new BoolValue(true);
717        selector.NumberOfSelectedSubScopesParameter.Hidden = true;
718        selector.NumberOfSelectedSubScopesParameter.ActualName = SelectedParentsParameter.Name;
719        ParameterizeStochasticOperatorForLayer(selector);
720      }
721      if (Problem != null) {
722        foreach (var selector in SelectorParameter.ValidValues.OfType<ISingleObjectiveSelector>()) {
723          selector.MaximizationParameter.ActualName = Problem.MaximizationParameter.Name;
724          selector.MaximizationParameter.Hidden = true;
725          selector.QualityParameter.ActualName = Problem.Evaluator.QualityParameter.ActualName;
726          selector.QualityParameter.Hidden = true;
727        }
728      }
729    }
730    private void ParameterizeTerminators() {
731      qualityTerminator.Parameterize(qualityAnalyzer.CurrentBestQualityParameter, Problem);
732    }
733    private void ParameterizeIterationBasedOperators() {
734      if (Problem != null) {
735        foreach (var @operator in Problem.Operators.OfType<IIterationBasedOperator>()) {
736          @operator.IterationsParameter.ActualName = "Generations";
737          @operator.IterationsParameter.Hidden = true;
738          @operator.MaximumIterationsParameter.ActualName = generationsTerminator.ThresholdParameter.Name;
739          @operator.MaximumIterationsParameter.Hidden = true;
740        }
741      }
742    }
743    private void ParameterizeAgeLimits() {
744      AgeLimits = AgingScheme.CalculateAgeLimits(AgeGap, NumberOfLayers);
745    }
746
747    private void ParameterizeStochasticOperator(IOperator @operator) {
748      var stochasticOperator = @operator as IStochasticOperator;
749      if (stochasticOperator != null) {
750        stochasticOperator.RandomParameter.ActualName = "GlobalRandom";
751        stochasticOperator.RandomParameter.Hidden = true;
752      }
753    }
754
755    private void ParameterizeStochasticOperatorForLayer(IOperator @operator) {
756      var stochasticOperator = @operator as IStochasticOperator;
757      if (stochasticOperator != null) {
758        stochasticOperator.RandomParameter.ActualName = "LocalRandom";
759        stochasticOperator.RandomParameter.Hidden = true;
760      }
761    }
762
763    #endregion
764
765    #region Updates
766    private void UpdateAnalyzers() {
767      Analyzer.Operators.Clear();
768      LayerAnalyzer.Operators.Clear();
769      SlidingWindow.Operators.Clear();
770
771      Analyzer.Operators.Add(qualityAnalyzer, qualityAnalyzer.EnabledByDefault);
772      Analyzer.Operators.Add(ageAnalyzer, ageAnalyzer.EnabledByDefault);
773      Analyzer.Operators.Add(ageDistributionAnalyzer, ageDistributionAnalyzer.EnabledByDefault);
774      Analyzer.Operators.Add(selectionPressureAnalyzer, false);
775      selectionPressureAnalyzer.ValueParameter.Depth = 1; // Adding analyzer sets depth to 2
776      Analyzer.Operators.Add(currentSuccessRatioAnalyzer, false);
777      currentSuccessRatioAnalyzer.ValueParameter.Depth = 1; // Adding analyzer sets depth to 2
778      LayerAnalyzer.Operators.Add(layerQualityAnalyzer, false);
779      LayerAnalyzer.Operators.Add(layerAgeAnalyzer, false);
780      LayerAnalyzer.Operators.Add(layerAgeDistributionAnalyzer, false);
781      LayerAnalyzer.Operators.Add(layerSelectionPressureAnalyzer, false);
782      layerSelectionPressureAnalyzer.ValueParameter.Depth = 0; // Adding layer-analyzer sets depth to 1
783      LayerAnalyzer.Operators.Add(new SymbolicRegressionSingleObjectiveTrainingBestSolutionSlidingWindowAnalyzer() { UpdateAlways = true }, true);
784      LayerAnalyzer.Operators.Add(new SymbolicRregressionSingleObjectiveLayerQualityAnalyzer(), true);
785      LayerAnalyzer.Operators.Add(new SymbolicRegressionSingleObjectiveOverfittingSlidingWindowAnalyzer(), false);
786      LayerAnalyzer.Operators.Add(new SymbolicRegressionSingleObjectiveValidationBestSolutionSlidingWindowAnalyzer(), true);
787     
788      SlidingWindow.Operators.Add(generationalSlidingWindowAnalyzer);
789      SlidingWindow.Operators.Add(offspringSelectionSlidingWindowAnalyze, false);
790      SlidingWindow.Operators.Add(overfittingSelectionSlidingWindowAnalyzer, false);
791      SlidingWindow.Operators.Add(generationalAdaptiveSlidingWindowAnalyzer, false);
792
793      if (Problem != null) {
794        foreach (var analyzer in Problem.Operators.OfType<IAnalyzer>()) {
795          Analyzer.Operators.Add(analyzer, analyzer.EnabledByDefault);
796          LayerAnalyzer.Operators.Add((IAnalyzer)analyzer.Clone(), false);
797        }
798      }
799    }
800    private void UpdateCrossovers() {
801      var oldCrossover = CrossoverParameter.Value;
802      var defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault();
803      CrossoverParameter.ValidValues.Clear();
804      foreach (var crossover in Problem.Operators.OfType<ICrossover>().OrderBy(c => c.Name)) {
805        ParameterizeStochasticOperatorForLayer(crossover);
806        CrossoverParameter.ValidValues.Add(crossover);
807      }
808      if (oldCrossover != null) {
809        var crossover = CrossoverParameter.ValidValues.FirstOrDefault(c => c.GetType() == oldCrossover.GetType());
810        if (crossover != null)
811          CrossoverParameter.Value = crossover;
812        else
813          oldCrossover = null;
814      }
815      if (oldCrossover == null && defaultCrossover != null)
816        CrossoverParameter.Value = defaultCrossover;
817    }
818    private void UpdateMutators() {
819      IManipulator oldMutator = MutatorParameter.Value;
820      MutatorParameter.ValidValues.Clear();
821      IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault();
822
823      foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) {
824        ParameterizeStochasticOperatorForLayer(mutator);
825        MutatorParameter.ValidValues.Add(mutator);
826      }
827
828      if (oldMutator != null) {
829        IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
830        if (mutator != null) MutatorParameter.Value = mutator;
831        else oldMutator = null;
832      }
833
834      if (oldMutator == null && defaultMutator != null)
835        MutatorParameter.Value = defaultMutator;
836    }
837    private void UpdateTerminators() {
838      var newTerminators = new Dictionary<ITerminator, bool> {
839       {generationsTerminator, Terminators.Operators.Contains(generationsTerminator) && Terminators.Operators.ItemChecked(generationsTerminator)},
840        {evaluationsTerminator, Terminators.Operators.Contains(evaluationsTerminator) && Terminators.Operators.ItemChecked(evaluationsTerminator)},
841        {qualityTerminator, Terminators.Operators.Contains(qualityTerminator) && Terminators.Operators.ItemChecked(qualityTerminator) },
842        {executionTimeTerminator, Terminators.Operators.Contains(executionTimeTerminator) && Terminators.Operators.ItemChecked(executionTimeTerminator)},
843        {slidingWindowTerminator, !Terminators.Operators.Contains(slidingWindowTerminator) || Terminators.Operators.ItemChecked(slidingWindowTerminator)}
844      };
845      if (Problem != null) {
846        foreach (var terminator in Problem.Operators.OfType<ITerminator>())
847          newTerminators.Add(terminator, !Terminators.Operators.Contains(terminator) || Terminators.Operators.ItemChecked(terminator));
848      }
849
850      Terminators.Operators.Clear();
851
852      foreach (var newTerminator in newTerminators)
853        Terminators.Operators.Add(newTerminator.Key, newTerminator.Value);
854    }
855    #endregion
856  }
857}
Note: See TracBrowser for help on using the repository browser.