Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/28/15 23:38:51 (8 years ago)
Author:
abeham
Message:

#2221:

  • Completely refactored PTSP branch
    • Added two sets of problem instances based on TSPLIB: homogeneous and heterogeneous
    • Implemented missing EvaluateByCoordinates for 1-shift moves
    • Made it clear that move evaluators are for estimated PTSP only
    • Changed parameter realization from a rather strange list of list of ints to a list of bool arrays
    • Reusing code of the 2-opt and 1-shift move evaluators in 2.5 move evaluator
    • Introducing distance calculators to properly handle the case when no distance matrix is given (previous code only worked with distance matrix and without only with euclidean distance in some settings)
    • Fixed several smaller code issues: protected, static, method parameters, copy & paste, interfaces, naming, parameters, serialization hooks, license headers, doc comments, data types
Location:
branches/PTSP/HeuristicLab.Problems.Instances
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/PTSP/HeuristicLab.Problems.Instances/3.3

    • Property svn:ignore
      •  

        old new  
        33Plugin.cs
        44*.user
         5*.DotSettings
  • branches/PTSP/HeuristicLab.Problems.Instances/3.3/Types/DistanceHelper.cs

    r12012 r13412  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.Linq;
    25 using System.Text;
    2623
    2724namespace HeuristicLab.Problems.Instances {
    2825  public enum DistanceMeasure { Direct, Euclidean, RoundedEuclidean, UpperEuclidean, Geo, Manhattan, Maximum, Att };
    29  
     26
    3027  public static class DistanceHelper {
    3128    /// <summary>
     
    3532    public static double[,] GetDistanceMatrix(DistanceMeasure distanceMeasure, double[,] coordinates, double[,] distances, int dimension) {
    3633      if (distances != null) return distances;
    37      
     34
    3835      distances = new double[dimension, dimension];
    3936      for (int i = 0; i < dimension - 1; i++)
     
    4441
    4542      return distances;
     43    }
     44
     45    public static double GetDistance(DistanceMeasure distanceMeasure, double x1, double y1, double x2, double y2) {
     46      switch (distanceMeasure) {
     47        case DistanceMeasure.Att:
     48          return AttDistance(x1, y1, x2, y2);
     49        case DistanceMeasure.Direct:
     50          throw new ArgumentException("Direct distance measure requires distance matrix for distance calculation.");
     51        case DistanceMeasure.Euclidean:
     52          return EuclideanDistance(x1, y1, x2, y2);
     53        case DistanceMeasure.Geo:
     54          return GeoDistance(x1, y1, x2, y2);
     55        case DistanceMeasure.Manhattan:
     56          return ManhattanDistance(x1, y1, x2, y2);
     57        case DistanceMeasure.Maximum:
     58          return MaximumDistance(x1, y1, x2, y2);
     59        case DistanceMeasure.RoundedEuclidean:
     60          return Math.Round(EuclideanDistance(x1, y1, x2, y2));
     61        case DistanceMeasure.UpperEuclidean:
     62          return Math.Ceiling(EuclideanDistance(x1, y1, x2, y2));
     63        default:
     64          throw new InvalidOperationException("Distance measure is not known.");
     65      }
    4666    }
    4767
Note: See TracChangeset for help on using the changeset viewer.