Changeset 14454 for branches/MemPRAlgorithm/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TwoOpt
- Timestamp:
- 12/05/16 16:06:18 (8 years ago)
- Location:
- branches/MemPRAlgorithm/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TwoOpt
- Files:
-
- 4 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/MemPRAlgorithm/HeuristicLab.Problems.TravelingSalesman/3.3/MoveEvaluators/TwoOpt/TSPInversionMovePathEvaluator.cs
r14185 r14454 33 33 [Item("TSPInversionMovePathEvaluator", "Evaluates an inversion move (2-opt) by summing up the length of all added edges and subtracting the length of all deleted edges.")] 34 34 [StorableClass] 35 public abstractclass TSPInversionMovePathEvaluator : TSPPathMoveEvaluator, IPermutationInversionMoveOperator {35 public class TSPInversionMovePathEvaluator : TSPPathMoveEvaluator, IPermutationInversionMoveOperator { 36 36 public ILookupParameter<InversionMove> InversionMoveParameter { 37 37 get { return (ILookupParameter<InversionMove>)Parameters["InversionMove"]; } … … 46 46 } 47 47 48 public static double EvaluateByCoordinates(Permutation permutation, InversionMove move, DoubleMatrix coordinates, TSPInversionMovePathEvaluator evaluator) { 48 public override IDeepCloneable Clone(Cloner cloner) { 49 return new TSPInversionMovePathEvaluator(this, cloner); 50 } 51 52 public static double EvaluateByCoordinates(Permutation permutation, InversionMove move, DoubleMatrix coordinates, TSPDistanceFunction distanceFunction) { 49 53 int edge1source = permutation.GetCircular(move.Index1 - 1); 50 54 int edge1target = permutation[move.Index1]; … … 54 58 double moveQuality = 0; 55 59 // remove two edges 56 moveQuality -= evaluator.CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],60 moveQuality -= TravelingSalesmanProblem.CalculateDistance(distanceFunction, coordinates[edge1source, 0], coordinates[edge1source, 1], 57 61 coordinates[edge1target, 0], coordinates[edge1target, 1]); 58 moveQuality -= evaluator.CalculateDistance(coordinates[edge2source, 0], coordinates[edge2source, 1],62 moveQuality -= TravelingSalesmanProblem.CalculateDistance(distanceFunction, coordinates[edge2source, 0], coordinates[edge2source, 1], 59 63 coordinates[edge2target, 0], coordinates[edge2target, 1]); 60 64 // add two edges 61 moveQuality += evaluator.CalculateDistance(coordinates[edge1source, 0], coordinates[edge1source, 1],65 moveQuality += TravelingSalesmanProblem.CalculateDistance(distanceFunction, coordinates[edge1source, 0], coordinates[edge1source, 1], 62 66 coordinates[edge2source, 0], coordinates[edge2source, 1]); 63 moveQuality += evaluator.CalculateDistance(coordinates[edge1target, 0], coordinates[edge1target, 1],67 moveQuality += TravelingSalesmanProblem.CalculateDistance(distanceFunction, coordinates[edge1target, 0], coordinates[edge1target, 1], 64 68 coordinates[edge2target, 0], coordinates[edge2target, 1]); 65 69 return moveQuality; … … 82 86 } 83 87 84 protected override double EvaluateByCoordinates(Permutation permutation, DoubleMatrix coordinates ) {85 return EvaluateByCoordinates(permutation, InversionMoveParameter.ActualValue, coordinates, this);88 protected override double EvaluateByCoordinates(Permutation permutation, DoubleMatrix coordinates, TSPDistanceFunction distanceFunction) { 89 return EvaluateByCoordinates(permutation, InversionMoveParameter.ActualValue, coordinates, distanceFunction); 86 90 } 87 91
Note: See TracChangeset
for help on using the changeset viewer.