Changeset 7511


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

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

Location:
trunk/sources
Files:
3 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() {
  • trunk/sources/HeuristicLab.Algorithms.NSGA2/3.3/NSGA2.cs

    r7351 r7511  
    365365    private void UpdateCrossovers() {
    366366      ICrossover oldCrossover = CrossoverParameter.Value;
     367      ICrossover defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault();
    367368      CrossoverParameter.ValidValues.Clear();
    368369      foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name))
     
    371372        ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
    372373        if (crossover != null) CrossoverParameter.Value = crossover;
    373       }
     374        else oldCrossover = null;
     375      }
     376      if (oldCrossover == null && defaultCrossover != null)
     377        CrossoverParameter.Value = defaultCrossover;
    374378    }
    375379    private void UpdateMutators() {
  • trunk/sources/HeuristicLab.Algorithms.OffspringSelectionGeneticAlgorithm/3.3/IslandOffspringSelectionGeneticAlgorithm.cs

    r7259 r7511  
    598598    private void UpdateCrossovers() {
    599599      ICrossover oldCrossover = CrossoverParameter.Value;
     600      ICrossover defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault();
    600601      CrossoverParameter.ValidValues.Clear();
    601602      foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name))
     
    604605        ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
    605606        if (crossover != null) CrossoverParameter.Value = crossover;
    606       }
     607        else oldCrossover = null;
     608      }
     609      if (oldCrossover == null && defaultCrossover != null)
     610        CrossoverParameter.Value = defaultCrossover;
    607611    }
    608612    private void UpdateMutators() {
Note: See TracChangeset for help on using the changeset viewer.