Changeset 15049 for trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm
- Timestamp:
- 06/23/17 15:39:35 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs ¶
r14185 r15049 211 211 Parameters.Add(new FixedValueParameter<BoolValue>("ReevaluateElites", "Flag to determine if elite individuals should be reevaluated (i.e., if stochastic fitness functions are used.)", (BoolValue)new BoolValue(false).AsReadOnly()) { Hidden = true }); 212 212 } 213 var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>; 214 if (optionalMutatorParameter != null) { 215 Parameters.Remove(optionalMutatorParameter); 216 Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 217 foreach (var m in optionalMutatorParameter.ValidValues) 218 MutatorParameter.ValidValues.Add(m); 219 if (optionalMutatorParameter.Value == null) MutationProbability.Value = 0; // to guarantee that the old configuration results in the same behavior 220 else Mutator = optionalMutatorParameter.Value; 221 optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared 222 } 213 223 #endregion 214 224 … … 240 250 Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); 241 251 Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05))); 242 Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));252 Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 243 253 Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1))); 244 254 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 }); … … 551 561 IManipulator oldMutator = MutatorParameter.Value; 552 562 MutatorParameter.ValidValues.Clear(); 563 IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault(); 564 553 565 foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) { 554 566 ParameterizeStochasticOperatorForIsland(mutator); … … 558 570 IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType()); 559 571 if (mutator != null) MutatorParameter.Value = mutator; 560 } 572 else oldMutator = null; 573 } 574 575 if (oldMutator == null && defaultMutator != null) 576 MutatorParameter.Value = defaultMutator; 561 577 } 562 578 private void UpdateAnalyzers() {
Note: See TracChangeset
for help on using the changeset viewer.