Changeset 15973 for branches/2522_RefactorPluginInfrastructure/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2.cs
- Timestamp:
- 06/28/18 11:13:37 (6 years ago)
- Location:
- branches/2522_RefactorPluginInfrastructure
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2522_RefactorPluginInfrastructure
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2522_RefactorPluginInfrastructure/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2.cs
r12504 r15973 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 39 39 /// </summary> 40 40 [Item("NSGA-II", "The Nondominated Sorting Genetic Algorithm II was introduced in Deb et al. 2002. A Fast and Elitist Multiobjective Genetic Algorithm: NSGA-II. IEEE Transactions on Evolutionary Computation, 6(2), pp. 182-197.")] 41 [Creatable(CreatableAttribute.Categories. Algorithms, Priority = 100)]41 [Creatable(CreatableAttribute.Categories.PopulationBasedAlgorithms, Priority = 135)] 42 42 [StorableClass] 43 43 public class NSGA2 : HeuristicOptimizationEngineAlgorithm, IStorableContent { … … 176 176 Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); 177 177 Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05))); 178 Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));178 Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 179 179 Parameters.Add(new ValueParameter<MultiAnalyzer>("Analyzer", "The operator used to analyze each generation.", new MultiAnalyzer())); 180 180 Parameters.Add(new ValueParameter<IntValue>("MaximumGenerations", "The maximum number of generations which should be processed.", new IntValue(1000))); … … 326 326 if (!Parameters.ContainsKey("DominateOnEqualQualities")) 327 327 Parameters.Add(new FixedValueParameter<BoolValue>("DominateOnEqualQualities", "Flag which determines wether solutions with equal quality values should be treated as dominated.", new BoolValue(false))); 328 var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>; 329 if (optionalMutatorParameter != null) { 330 Parameters.Remove(optionalMutatorParameter); 331 Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 332 foreach (var m in optionalMutatorParameter.ValidValues) 333 MutatorParameter.ValidValues.Add(m); 334 if (optionalMutatorParameter.Value == null) MutationProbability.Value = 0; // to guarantee that the old configuration results in the same behavior 335 else Mutator = optionalMutatorParameter.Value; 336 optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared 337 } 328 338 #endregion 329 339 … … 397 407 IManipulator oldMutator = MutatorParameter.Value; 398 408 MutatorParameter.ValidValues.Clear(); 409 IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault(); 399 410 foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) 400 411 MutatorParameter.ValidValues.Add(mutator); … … 402 413 IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType()); 403 414 if (mutator != null) MutatorParameter.Value = mutator; 404 } 415 else oldMutator = null; 416 } 417 if (oldMutator == null && defaultMutator != null) 418 MutatorParameter.Value = defaultMutator; 405 419 } 406 420 private void UpdateAnalyzers() {
Note: See TracChangeset
for help on using the changeset viewer.