Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7658 for trunk


Ignore:
Timestamp:
03/23/12 11:03:20 (13 years ago)
Author:
mkommend
Message:

#1691: Corrected GetHashCode in TypeEqualityComparer and updated operator discovery in TSP.

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Common/3.3/TypeEqualityComparer.cs

    r7626 r7658  
    3131    int IEqualityComparer<T>.GetHashCode(T obj) {
    3232      if (obj == null) return 0;
    33       return obj.GetHashCode();
     33      return obj.GetType().GetHashCode();
    3434    }
    3535  }
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/TravelingSalesmanProblem.cs

    r7626 r7658  
    226226      Operators.Add(new TSPPopulationDiversityAnalyzer());
    227227      ParameterizeAnalyzers();
    228       var defaultOperators = new HashSet<IPermutationOperator>(new IPermutationOperator[] {
     228      var operators = new HashSet<IPermutationOperator>(new IPermutationOperator[] {
    229229        new OrderCrossover2(),
    230230        new InversionManipulator(),
    231231        new StochasticInversionMultiMoveGenerator()
    232       });
    233       Operators.AddRange(defaultOperators);
    234       Operators.AddRange(ApplicationManager.Manager.GetInstances<IPermutationOperator>().Except(defaultOperators, new TypeEqualityComparer<IPermutationOperator>()));
     232      }, new TypeEqualityComparer<IPermutationOperator>());
     233      foreach (var op in ApplicationManager.Manager.GetInstances<IPermutationOperator>())
     234        operators.Add(op);
     235      Operators.AddRange(operators);
    235236      ParameterizeOperators();
    236237      UpdateMoveEvaluators();
     
    399400        try {
    400401          EvaluateAndLoadTour(data.BestKnownTour);
    401         } catch (InvalidOperationException) {
     402        }
     403        catch (InvalidOperationException) {
    402404          if (data.BestKnownQuality.HasValue)
    403405            BestKnownQuality = new DoubleValue(data.BestKnownQuality.Value);
Note: See TracChangeset for help on using the changeset viewer.