Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/16/12 16:28:49 (12 years ago)
Author:
gkronber
Message:

merged r7609:7840 from trunk into time series branch

Location:
branches/HeuristicLab.TimeSeries
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries

  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/ThreeOpt/TSPTranslocationMovePathEvaluator.cs

    r7268 r7842  
    4646    }
    4747
    48     protected override double EvaluateByCoordinates(Permutation permutation, DoubleMatrix coordinates) {
    49       TranslocationMove move = TranslocationMoveParameter.ActualValue;
     48    public static double EvaluateByCoordinates(Permutation permutation, TranslocationMove move, DoubleMatrix coordinates, TSPTranslocationMovePathEvaluator evaluator) {
     49      if (move.Index1 == move.Index3
     50        || move.Index2 == permutation.Length - 1 && move.Index3 == 0
     51        || move.Index1 == 0 && move.Index3 == permutation.Length - 1 - move.Index2) return 0;
     52
    5053      int edge1source = permutation.GetCircular(move.Index1 - 1);
    5154      int edge1target = permutation[move.Index1];
     
    6063        edge3target = permutation[move.Index3];
    6164      }
    62       if (move.Index1 == move.Index3
    63         || move.Index2 - move.Index1 >= permutation.Length - 2
    64         || move.Index1 == permutation.Length - 1 && move.Index3 == 0
    65         || move.Index1 == 0 && move.Index3 == permutation.Length - 1) return 0;
    6665      double moveQuality = 0;
    6766      // remove three edges
    68       moveQuality -= CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],
     67      moveQuality -= evaluator.CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],
    6968        coordinates[edge1target, 0], coordinates[edge1target, 1]);
    70       moveQuality -= CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1],
     69      moveQuality -= evaluator.CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1],
    7170        coordinates[edge2target, 0], coordinates[edge2target, 1]);
    72       moveQuality -= CalculateDistance(coordinates[edge3source, 0], coordinates[edge3source, 1],
     71      moveQuality -= evaluator.CalculateDistance(coordinates[edge3source, 0], coordinates[edge3source, 1],
    7372        coordinates[edge3target, 0], coordinates[edge3target, 1]);
    7473      // add three edges
    75       moveQuality += CalculateDistance(coordinates[edge3source, 0], coordinates[edge3source, 1],
     74      moveQuality += evaluator.CalculateDistance(coordinates[edge3source, 0], coordinates[edge3source, 1],
    7675        coordinates[edge1target, 0], coordinates[edge1target, 1]);
    77       moveQuality += CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1],
     76      moveQuality += evaluator.CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1],
    7877        coordinates[edge3target, 0], coordinates[edge3target, 1]);
    79       moveQuality += CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],
     78      moveQuality += evaluator.CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],
    8079        coordinates[edge2target, 0], coordinates[edge2target, 1]);
    8180      return moveQuality;
    8281    }
    8382
    84     protected override double EvaluateByDistanceMatrix(Permutation permutation, DistanceMatrix distanceMatrix) {
    85       TranslocationMove move = TranslocationMoveParameter.ActualValue;
     83    public static double EvaluateByDistanceMatrix(Permutation permutation, TranslocationMove move, DistanceMatrix distanceMatrix) {
     84      if (move.Index1 == move.Index3
     85        || move.Index2 == permutation.Length - 1 && move.Index3 == 0
     86        || move.Index1 == 0 && move.Index3 == permutation.Length - 1 - move.Index2) return 0;
     87
    8688      int edge1source = permutation.GetCircular(move.Index1 - 1);
    8789      int edge1target = permutation[move.Index1];
     
    9698        edge3target = permutation[move.Index3];
    9799      }
    98       if (move.Index1 == move.Index3
    99         || move.Index2 - move.Index1 >= permutation.Length - 2
    100         || move.Index1 == permutation.Length - 1 && move.Index3 == 0
    101         || move.Index1 == 0 && move.Index3 == permutation.Length - 1) return 0;
    102100      double moveQuality = 0;
    103101      // remove three edges
     
    111109      return moveQuality;
    112110    }
     111
     112    protected override double EvaluateByCoordinates(Permutation permutation, DoubleMatrix coordinates) {
     113      return EvaluateByCoordinates(permutation, TranslocationMoveParameter.ActualValue, coordinates, this);
     114    }
     115
     116    protected override double EvaluateByDistanceMatrix(Permutation permutation, DistanceMatrix distanceMatrix) {
     117      return EvaluateByDistanceMatrix(permutation, TranslocationMoveParameter.ActualValue, distanceMatrix);
     118    }
    113119  }
    114120}
Note: See TracChangeset for help on using the changeset viewer.