- Timestamp:
- 06/19/20 17:53:36 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2521_ProblemRefactoring/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/GeneticAlgorithm.cs
r17226 r17614 381 381 } 382 382 private void UpdateCrossovers() { 383 ICrossover oldCrossover = CrossoverParameter.Value; 384 CrossoverParameter.ValidValues.Clear(); 385 ICrossover defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault(); 386 387 foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name)) 388 CrossoverParameter.ValidValues.Add(crossover); 389 390 if (oldCrossover != null) { 391 ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType()); 392 if (crossover != null) CrossoverParameter.Value = crossover; 393 else oldCrossover = null; 394 } 395 if (oldCrossover == null && defaultCrossover != null) 396 CrossoverParameter.Value = defaultCrossover; 397 } 383 CrossoverParameter.Repopulate(Problem.Operators); 384 } 385 398 386 private void UpdateMutators() { 399 IManipulator oldMutator = MutatorParameter.Value; 400 MutatorParameter.ValidValues.Clear(); 401 IManipulator defaultMutator = Problem.Operators.OfType<IManipulator>().FirstOrDefault(); 402 403 foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name)) 404 MutatorParameter.ValidValues.Add(mutator); 405 406 if (oldMutator != null) { 407 IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType()); 408 if (mutator != null) MutatorParameter.Value = mutator; 409 else oldMutator = null; 410 } 411 412 if (oldMutator == null && defaultMutator != null) 413 MutatorParameter.Value = defaultMutator; 387 MutatorParameter.Repopulate(Problem.Operators); 414 388 } 415 389 private void UpdateAnalyzers() {
Note: See TracChangeset
for help on using the changeset viewer.