Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/21/12 10:37:49 (13 years ago)
Author:
mkommend
Message:

#1691: Reordered problem dependent operators in the GeneticAlgorithm and the OSGA.

File:
1 edited

Legend:

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

    r7259 r7493  
    353353      ICrossover oldCrossover = CrossoverParameter.Value;
    354354      CrossoverParameter.ValidValues.Clear();
     355      ICrossover defaultCrossover = Problem.Operators.OfType<ICrossover>().FirstOrDefault();
     356
    355357      foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name))
    356358        CrossoverParameter.ValidValues.Add(crossover);
     359
    357360      if (oldCrossover != null) {
    358361        ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
    359362        if (crossover != null) CrossoverParameter.Value = crossover;
    360       }
     363      } else if (defaultCrossover != null)
     364        CrossoverParameter.Value = defaultCrossover;
    361365    }
    362366    private void UpdateMutators() {
Note: See TracChangeset for help on using the changeset viewer.