Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/26/10 00:04:24 (15 years ago)
Author:
abeham
Message:

updated permutation moves, fixed 3-opt #889

Location:
trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/ThreeOpt/TSPThreeOptPathMoveEvaluator.cs

    r3209 r3221  
    5858        edge3target = permutation[move.Index3];
    5959      }
     60      if (move.Index1 == move.Index3
     61        || move.Index2 - move.Index1 >= permutation.Length - 2
     62        || move.Index1 == permutation.Length - 1 && move.Index3 == 0
     63        || move.Index1 == 0 && move.Index3 == permutation.Length - 1) return 0;
    6064      double moveQuality = 0;
    6165      // remove three edges
     
    9195      }
    9296      if (move.Index1 == move.Index3
    93         || move.Index2 - move.Index1 >= permutation.Length - 2) return 0;
     97        || move.Index2 - move.Index1 >= permutation.Length - 2
     98        || move.Index1 == permutation.Length - 1 && move.Index3 == 0
     99        || move.Index1 == 0 && move.Index3 == permutation.Length - 1) return 0;
    94100      double moveQuality = 0;
    95101      // remove three edges
  • trunk/sources/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TwoOpt/TSPTwoOptPathMoveEvaluator.cs

    r3209 r3221  
    4545
    4646    protected override double EvaluateByCoordinates(Permutation permutation, DoubleMatrix coordinates) {
    47       TwoOptMove m = TwoOptMoveParameter.ActualValue;
    48       int edge1source = permutation.GetCircular(m.Index1 - 1);
    49       int edge1target = permutation[m.Index1];
    50       int edge2source = permutation[m.Index2];
    51       int edge2target = permutation.GetCircular(m.Index2 + 1);
     47      TwoOptMove move = TwoOptMoveParameter.ActualValue;
     48      int edge1source = permutation.GetCircular(move.Index1 - 1);
     49      int edge1target = permutation[move.Index1];
     50      int edge2source = permutation[move.Index2];
     51      int edge2target = permutation.GetCircular(move.Index2 + 1);
     52      if (move.Index2 - move.Index1 >= permutation.Length - 2) return 0;
    5253      double moveQuality = 0;
    5354      // remove two edges
     
    6566
    6667    protected override double EvaluateByDistanceMatrix(Permutation permutation, DoubleMatrix distanceMatrix) {
    67       TwoOptMove m = TwoOptMoveParameter.ActualValue;
    68       int edge1source = permutation.GetCircular(m.Index1 - 1);
    69       int edge1target = permutation[m.Index1];
    70       int edge2source = permutation[m.Index2];
    71       int edge2target = permutation.GetCircular(m.Index2 + 1);
     68      TwoOptMove move = TwoOptMoveParameter.ActualValue;
     69      int edge1source = permutation.GetCircular(move.Index1 - 1);
     70      int edge1target = permutation[move.Index1];
     71      int edge2source = permutation[move.Index2];
     72      int edge2target = permutation.GetCircular(move.Index2 + 1);
     73      if (move.Index2 - move.Index1 >= permutation.Length - 2) return 0;
    7274      double moveQuality = 0;
    7375      // remove two edges
Note: See TracChangeset for help on using the changeset viewer.