Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/24/12 09:25:32 (13 years ago)
Author:
mkommend
Message:

#1691: Updated IslandGA, NSGA2 and IslandOSGA to use default operators.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Algorithms.GeneticAlgorithm/3.3/IslandGeneticAlgorithm.cs

    r7395 r7511  
    497497    private void UpdateCrossovers() {
    498498      ICrossover oldCrossover = CrossoverParameter.Value;
     499      ICrossover defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault();
    499500      CrossoverParameter.ValidValues.Clear();
    500       foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name)) {
    501         ParameterizeStochasticOperatorForIsland(crossover);
     501      foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name))
    502502        CrossoverParameter.ValidValues.Add(crossover);
    503       }
    504503      if (oldCrossover != null) {
    505504        ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
    506505        if (crossover != null) CrossoverParameter.Value = crossover;
    507       }
     506        else oldCrossover = null;
     507      }
     508      if (oldCrossover == null && defaultCrossover != null)
     509        CrossoverParameter.Value = defaultCrossover;
    508510    }
    509511    private void UpdateMutators() {
Note: See TracChangeset for help on using the changeset viewer.