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