Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/07/14 14:21:54 (10 years ago)
Author:
abeham
Message:

#2189: merged to stable

Location:
stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Algorithms.TabuSearch/3.3/TabuSearch.cs

    r9456 r11110  
    351351      MoveGeneratorParameter.ValidValues.Clear();
    352352      if (Problem != null) {
     353        // only add move generators that also have a corresponding tabu-checker and tabu-maker
    353354        foreach (IMoveGenerator generator in Problem.Operators.OfType<IMoveGenerator>().OrderBy(x => x.Name)) {
    354           MoveGeneratorParameter.ValidValues.Add(generator);
     355          // get all interfaces equal to or derived from IMoveOperator that this move generator implements
     356          var moveTypes = generator.GetType().GetInterfaces().Where(x => typeof(IMoveOperator).IsAssignableFrom(x)).ToList();
     357          // keep only the most specific interfaces (e.g. IPermutationTranslocationMoveOperator);
     358          // by removing all interfaces for which a derived interface is also contained in the moveTypes set
     359          foreach (var type in moveTypes.ToList()) {
     360            if (moveTypes.Any(t => t != type && type.IsAssignableFrom(t))) moveTypes.Remove(type);
     361          }
     362          // keep move generator only if there is a tabu checker and a tabu maker that is derived from the same move interface
     363          if (Problem.Operators.OfType<ITabuChecker>().Any(op => moveTypes.Any(m => m.IsInstanceOfType(op)))
     364            && Problem.Operators.OfType<ITabuMaker>().Any(op => moveTypes.Any(m => m.IsInstanceOfType(op))))
     365            MoveGeneratorParameter.ValidValues.Add(generator);
    355366        }
    356367      }
Note: See TracChangeset for help on using the changeset viewer.