Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/04/14 17:32:52 (10 years ago)
Author:
abeham
Message:

#2189: make sure to skip move generators that do not have associated tabu operators

File:
1 edited

Legend:

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

    r9456 r11088  
    352352      if (Problem != null) {
    353353        foreach (IMoveGenerator generator in Problem.Operators.OfType<IMoveGenerator>().OrderBy(x => x.Name)) {
    354           MoveGeneratorParameter.ValidValues.Add(generator);
     354          var moveTypes = generator.GetType().GetInterfaces().Where(x => typeof(IMoveOperator).IsAssignableFrom(x)).ToList();
     355          foreach (var type in moveTypes.ToList()) {
     356            if (moveTypes.Any(t => t != type && type.IsAssignableFrom(t))) moveTypes.Remove(type);
     357          }
     358          if (Problem.Operators.OfType<ITabuChecker>().Any(op => moveTypes.Any(m => m.IsInstanceOfType(op)))
     359            && Problem.Operators.OfType<ITabuMaker>().Any(op => moveTypes.Any(m => m.IsInstanceOfType(op))))
     360            MoveGeneratorParameter.ValidValues.Add(generator);
    355361        }
    356362      }
Note: See TracChangeset for help on using the changeset viewer.