Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/25/12 10:14:58 (12 years ago)
Author:
jkarder
Message:

#1331:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ScatterSearch (trunk integration)/HeuristicLab.Problems.TravelingSalesman/3.3/SimilarityCalculators/TSPSimilarityCalculator.cs

    r8319 r8322  
    6767    private static double CalculateAbsolute(Permutation left, Permutation right) {
    6868      double similarity = 0.0;
    69       for (int i = 0; i < left.Length && left[i] == right[i]; similarity = ++i) ;
     69      for (int i = 0; i < left.Length; i++)
     70        if (left[i] == right[i]) similarity++;
     71
    7072      return similarity / left.Length;
    7173    }
    7274
    7375    private static double CalculateRelativeDirected(Permutation left, Permutation right) {
    74       throw new NotImplementedException();
     76      int[] edges = new int[right.Length];
     77      for (int i = 0; i < right.Length; i++)
     78        edges[right[i]] = right[(i + 1) % right.Length];
     79
     80      double similarity = 0.0;
     81      for (int i = 0; i < left.Length; i++)
     82        if (left[(i + 1) % left.Length] == edges[left[i]]) similarity++;
     83
     84      return similarity / left.Length;
    7585    }
    7686
Note: See TracChangeset for help on using the changeset viewer.