Changeset 15049 for trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/OffspringSelectionGeneticAlgorithm.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/OffspringSelectionGeneticAlgorithm.cs
r14185 r15049 228 228 if (!Parameters.ContainsKey("FillPopulationWithParents")) 229 229 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 }); 230 231 var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>; 232 if (optionalMutatorParameter != null) { 233 Parameters.Remove(optionalMutatorParameter); 234 Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 235 foreach (var m in optionalMutatorParameter.ValidValues) 236 MutatorParameter.ValidValues.Add(m); 237 if (optionalMutatorParameter.Value == null) MutationProbability.Value = 0; // to guarantee that the old configuration results in the same behavior 238 else Mutator = optionalMutatorParameter.Value; 239 optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared 240 } 230 241 #endregion 231 242 … … 250 261 Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); 251 262 Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05))); 252 Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));263 Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 253 264 Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1))); 254 265 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 }); … … 487 498 IManipulator oldMutator = MutatorParameter.Value; 488 499 MutatorParameter.ValidValues.Clear(); 500 IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault(); 501 489 502 foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) 490 503 MutatorParameter.ValidValues.Add(mutator); 504 491 505 if (oldMutator != null) { 492 506 IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType()); 493 507 if (mutator != null) MutatorParameter.Value = mutator; 494 } 508 else oldMutator = null; 509 } 510 511 if (oldMutator == null && defaultMutator != null) 512 MutatorParameter.Value = defaultMutator; 495 513 } 496 514 private void UpdateAnalyzers() {
Note: See TracChangeset
for help on using the changeset viewer.