Changeset 13486 for stable/HeuristicLab.Problems.Instances
- Timestamp:
- 12/21/15 21:07:12 (9 years ago)
- Location:
- stable
- Files:
-
- 4 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 13484
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.Instances
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.Instances merged: 13484
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.Instances/3.3/HeuristicLab.Problems.Instances-3.3.csproj
r12742 r13486 121 121 <Compile Include="ProblemInstanceManager.cs" /> 122 122 <Compile Include="IProblemInstanceExporter.cs" /> 123 <Compile Include="Types\PTSPData.cs" /> 123 124 <Compile Include="Types\ATSPData.cs" /> 124 125 <Compile Include="Types\JSSPData.cs" /> -
stable/HeuristicLab.Problems.Instances/3.3/Types/DistanceHelper.cs
r12009 r13486 21 21 22 22 using System; 23 using System.Collections.Generic;24 using System.Linq;25 using System.Text;26 23 27 24 namespace HeuristicLab.Problems.Instances { 28 25 public enum DistanceMeasure { Direct, Euclidean, RoundedEuclidean, UpperEuclidean, Geo, Manhattan, Maximum, Att }; 29 26 30 27 public static class DistanceHelper { 31 28 /// <summary> … … 35 32 public static double[,] GetDistanceMatrix(DistanceMeasure distanceMeasure, double[,] coordinates, double[,] distances, int dimension) { 36 33 if (distances != null) return distances; 37 34 38 35 distances = new double[dimension, dimension]; 39 36 for (int i = 0; i < dimension - 1; i++) … … 44 41 45 42 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 } 46 66 } 47 67
Note: See TracChangeset
for help on using the changeset viewer.