Changeset 15107
- Timestamp:
- 07/01/17 22:36:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2.cs
r14227 r15107 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.