Changeset 15049 for trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SASEGASA.cs
- Timestamp:
- 06/23/17 15:39:35 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/SASEGASA.cs
r14185 r15049 256 256 if (!Parameters.ContainsKey("FillPopulationWithParents")) 257 257 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 }); 258 259 var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>; 260 if (optionalMutatorParameter != null) { 261 Parameters.Remove(optionalMutatorParameter); 262 Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 263 foreach (var m in optionalMutatorParameter.ValidValues) 264 MutatorParameter.ValidValues.Add(m); 265 if (optionalMutatorParameter.Value == null) MutationProbability.Value = 0; // to guarantee that the old configuration results in the same behavior 266 else Mutator = optionalMutatorParameter.Value; 267 optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared 268 } 258 269 #endregion 259 270 … … 282 293 Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); 283 294 Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05))); 284 Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));295 Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 285 296 Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1))); 286 297 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 }); … … 561 572 ICrossover oldCrossover = CrossoverParameter.Value; 562 573 CrossoverParameter.ValidValues.Clear(); 574 ICrossover defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault(); 575 563 576 foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name)) 564 577 CrossoverParameter.ValidValues.Add(crossover); 578 565 579 if (oldCrossover != null) { 566 580 ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType()); 567 581 if (crossover != null) CrossoverParameter.Value = crossover; 568 } 582 else oldCrossover = null; 583 } 584 if (oldCrossover == null && defaultCrossover != null) 585 CrossoverParameter.Value = defaultCrossover; 569 586 } 570 587 private void UpdateMutators() { 571 588 IManipulator oldMutator = MutatorParameter.Value; 572 589 MutatorParameter.ValidValues.Clear(); 590 IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault(); 591 573 592 foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) 574 593 MutatorParameter.ValidValues.Add(mutator); 594 575 595 if (oldMutator != null) { 576 596 IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType()); 577 597 if (mutator != null) MutatorParameter.Value = mutator; 578 } 598 else oldMutator = null; 599 } 600 601 if (oldMutator == null && defaultMutator != null) 602 MutatorParameter.Value = defaultMutator; 579 603 } 580 604 private void UpdateAnalyzers() {
Note: See TracChangeset
for help on using the changeset viewer.