Changeset 16692 for branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithm.cs
- Timestamp:
- 03/18/19 17:24:30 (6 years ago)
- Location:
- branches/2521_ProblemRefactoring
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring
- Property svn:ignore
-
old new 24 24 protoc.exe 25 25 obj 26 .vs
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithm.cs
r13173 r16692 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 5Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 156 156 Parameters.Add(new ConstrainedValueParameter<ICrossover>("Crossover", "The operator used to cross solutions.")); 157 157 Parameters.Add(new ValueParameter<PercentValue>("MutationProbability", "The probability that the mutation operator is applied on a solution.", new PercentValue(0.05))); 158 Parameters.Add(new OptionalConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions."));158 Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 159 159 Parameters.Add(new ValueParameter<IntValue>("Elites", "The numer of elite solutions which are kept in each generation.", new IntValue(1))); 160 160 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 }); … … 221 221 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 }); 222 222 } 223 var optionalMutatorParameter = MutatorParameter as OptionalConstrainedValueParameter<IManipulator>; 224 if (optionalMutatorParameter != null) { 225 Parameters.Remove(optionalMutatorParameter); 226 Parameters.Add(new ConstrainedValueParameter<IManipulator>("Mutator", "The operator used to mutate solutions.")); 227 foreach (var m in optionalMutatorParameter.ValidValues) 228 MutatorParameter.ValidValues.Add(m); 229 if (optionalMutatorParameter.Value == null) MutationProbability.Value = 0; // to guarantee that the old configuration results in the same behavior 230 else Mutator = optionalMutatorParameter.Value; 231 optionalMutatorParameter.ValidValues.Clear(); // to avoid dangling references to the old parameter its valid values are cleared 232 } 223 233 #endregion 224 234 … … 387 397 IManipulator oldMutator = MutatorParameter.Value; 388 398 MutatorParameter.ValidValues.Clear(); 399 IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault(); 400 389 401 foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) 390 402 MutatorParameter.ValidValues.Add(mutator); 403 391 404 if (oldMutator != null) { 392 405 IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType()); 393 406 if (mutator != null) MutatorParameter.Value = mutator; 394 } 407 else oldMutator = null; 408 } 409 410 if (oldMutator == null && defaultMutator != null) 411 MutatorParameter.Value = defaultMutator; 395 412 } 396 413 private void UpdateAnalyzers() {
Note: See TracChangeset
for help on using the changeset viewer.