Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/06/14 15:46:32 (10 years ago)
Author:
gkronber
Message:

#2189 reviewed r11088 and tried to add comments to explain the code.

File:
1 edited

Legend:

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

    r11088 r11096  
    351351      MoveGeneratorParameter.ValidValues.Clear();
    352352      if (Problem != null) {
     353        // only add move generators that also have a corresponding tabu-checker and tabu-maker
     354        //
     355        // 1. assumption: all tabu checkers and tabu makers also implement the IMoveOperator interface
     356        // 2. assumption: all move generators also implement the IMoveOperator interface
     357        // 3. assumption: if compatible all three operators implement the same (most specific) IMoveOperator interface
    353358        foreach (IMoveGenerator generator in Problem.Operators.OfType<IMoveGenerator>().OrderBy(x => x.Name)) {
     359          // get all interfaces equal to or derived from IMoveOperator that this move generator implements
    354360          var moveTypes = generator.GetType().GetInterfaces().Where(x => typeof(IMoveOperator).IsAssignableFrom(x)).ToList();
     361          // keep only the most specific interfaces (e.g. IPermutationTranslocationMoveOperator);
     362          // by removing all interfaces for which a derived interface is also contained in the moveTypes set
    355363          foreach (var type in moveTypes.ToList()) {
    356364            if (moveTypes.Any(t => t != type && type.IsAssignableFrom(t))) moveTypes.Remove(type);
    357365          }
     366          // keep move generator only if there is a tabu checker and a tabu maker that is derived from
     367          // one of the most specific interfaces in moveTypes (e.g. IPermutationTranslocationMoveOperator)
    358368          if (Problem.Operators.OfType<ITabuChecker>().Any(op => moveTypes.Any(m => m.IsInstanceOfType(op)))
    359369            && Problem.Operators.OfType<ITabuMaker>().Any(op => moveTypes.Any(m => m.IsInstanceOfType(op))))
Note: See TracChangeset for help on using the changeset viewer.