Changeset 15238 for stable/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/IslandOffspringSelectionGeneticAlgorithm.cs
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 15006-15008,15047,15049,15070,15107
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/IslandOffspringSelectionGeneticAlgorithm.cs
r14186 r15238 280 280 if (!Parameters.ContainsKey("FillPopulationWithParents")) 281 281 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 }); 282 283 var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>; 284 if (optionalMutatorParameter != null) { 285 Parameters.Remove(optionalMutatorParameter); 286 Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 287 foreach (var m in optionalMutatorParameter.ValidValues) 288 MutatorParameter.ValidValues.Add(m); 289 if (optionalMutatorParameter.Value == null) MutationProbability.Value = 0; // to guarantee that the old configuration results in the same behavior 290 else Mutator = optionalMutatorParameter.Value; 291 optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared 292 } 282 293 #endregion 283 294 … … 311 322 Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); 312 323 Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05))); 313 Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));324 Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 314 325 Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1))); 315 326 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 }); … … 642 653 IManipulator oldMutator = MutatorParameter.Value; 643 654 MutatorParameter.ValidValues.Clear(); 655 IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault(); 656 644 657 foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) 645 658 MutatorParameter.ValidValues.Add(mutator); 659 646 660 if (oldMutator != null) { 647 661 IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType()); 648 662 if (mutator != null) MutatorParameter.Value = mutator; 649 } 663 else oldMutator = null; 664 } 665 666 if (oldMutator == null && defaultMutator != null) 667 MutatorParameter.Value = defaultMutator; 650 668 } 651 669 private void UpdateAnalyzers() {
Note: See TracChangeset
for help on using the changeset viewer.