Free cookie consent management tool by TermsFeed Policy Generator

Changeset 3076 for trunk/sources


Ignore:
Timestamp:
03/17/10 00:38:34 (15 years ago)
Author:
swagner
Message:

Fixed bug when reselecting a previously selected operator in UpdateSelectors, UpdateCrossovers and UpdateMutators in SGA (#898)

File:
1 edited

Legend:

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

    r3048 r3076  
    283283        foreach (ISelector selector in Selectors.OrderBy(x => x.Name))
    284284          SelectorParameter.ValidValues.Add(selector);
    285         if (oldSelector != null)
    286           SelectorParameter.Value = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSelector.GetType());
     285        if (oldSelector != null) {
     286          ISelector selector = SelectorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldSelector.GetType());
     287          if (selector != null) SelectorParameter.Value = selector;
     288        }
    287289      }
    288290    }
     
    292294      foreach (ICrossover crossover in Problem.Operators.OfType<ICrossover>().OrderBy(x => x.Name))
    293295        CrossoverParameter.ValidValues.Add(crossover);
    294       if (oldCrossover != null)
    295         CrossoverParameter.Value = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
     296      if (oldCrossover != null) {
     297        ICrossover crossover = CrossoverParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldCrossover.GetType());
     298        if (crossover != null) CrossoverParameter.Value = crossover;
     299      }
    296300    }
    297301    private void UpdateMutators() {
     
    300304      foreach (IManipulator mutator in Problem.Operators.OfType<IManipulator>().OrderBy(x => x.Name))
    301305        MutatorParameter.ValidValues.Add(mutator);
    302       if (oldMutator != null)
    303         MutatorParameter.Value = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
     306      if (oldMutator != null) {
     307        IManipulator mutator = MutatorParameter.ValidValues.FirstOrDefault(x => x.GetType() == oldMutator.GetType());
     308        if (mutator != null) MutatorParameter.Value = mutator;
     309      }
    304310    }
    305311    #endregion
Note: See TracChangeset for help on using the changeset viewer.