- Timestamp:
- 06/21/12 18:02:33 (12 years ago)
- Location:
- branches/GP-MoveOperators
- Files:
-
- 2 deleted
- 8 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/GP-MoveOperators
- Property svn:ignore
-
old new 20 20 bin 21 21 protoc.exe 22 _ReSharper.HeuristicLab 3.3 Tests
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/GP-MoveOperators/HeuristicLab.Problems.Instances
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/trunk/sources/HeuristicLab.Problems.Instances merged eligible /branches/Benchmarking/sources/HeuristicLab.Problems.Instances 6917-7005 /branches/CloningRefactoring/HeuristicLab.Problems.Instances 4656-4721 /branches/DataAnalysis Refactoring/HeuristicLab.Problems.Instances 5471-5808 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Problems.Instances 5815-6180 /branches/DataAnalysis/HeuristicLab.Problems.Instances 4458-4459,4462,4464 /branches/GP.Grammar.Editor/HeuristicLab.Problems.Instances 6284-6795 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Problems.Instances 5060 /branches/NET40/sources/HeuristicLab.Problems.Instances 5138-5162 /branches/ParallelEngine/HeuristicLab.Problems.Instances 5175-5192 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances 7568-7810 /branches/QAPAlgorithms/HeuristicLab.Problems.Instances 6350-6627 /branches/Restructure trunk solution/HeuristicLab.Problems.Instances 6828 /branches/SuccessProgressAnalysis/HeuristicLab.Problems.Instances 5370-5682 /branches/Trunk/HeuristicLab.Problems.Instances 6829-6865 /branches/VNS/HeuristicLab.Problems.Instances 5594-5752 /branches/histogram/HeuristicLab.Problems.Instances 5959-6341
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/GP-MoveOperators/HeuristicLab.Problems.Instances/3.3
- Property svn:ignore
-
old new 2 2 bin 3 3 Plugin.cs 4 *.user
-
- Property svn:ignore
-
branches/GP-MoveOperators/HeuristicLab.Problems.Instances/3.3/HeuristicLab.Problems.Instances-3.3.csproj
r7648 r8085 105 105 </PropertyGroup> 106 106 <ItemGroup> 107 <Reference Include="Microsoft.CSharp" /> 107 108 <Reference Include="System" /> 108 109 <Reference Include="System.Core" /> … … 111 112 <ItemGroup> 112 113 <None Include="Plugin.cs.frame" /> 113 <Compile Include="IExportable.cs" /> 114 <Compile Include="ProblemInstanceManager.cs" /> 115 <Compile Include="IProblemInstanceExporter.cs" /> 114 116 <Compile Include="Types\ATSPData.cs" /> 115 117 <Compile Include="Types\CTAPData.cs" /> 116 118 <Compile Include="IDataDescriptor.cs" /> 117 <Compile Include="Types\CVRPData.cs" /> 119 <Compile Include="Types\DistanceHelper.cs" /> 120 <Compile Include="Types\VRP\MDCVRPTWData.cs" /> 121 <Compile Include="Types\VRP\MDCVRPData.cs" /> 122 <Compile Include="Types\VRP\PDPTWData.cs" /> 123 <Compile Include="Types\VRP\CVRPTWData.cs" /> 124 <Compile Include="Types\VRP\VRPData.cs" /> 125 <Compile Include="Types\VRP\CVRPData.cs" /> 118 126 <Compile Include="Types\GQAPData.cs" /> 127 <Compile Include="Types\VRP\IVRPData.cs" /> 119 128 <Compile Include="Types\QAPData.cs" /> 120 129 <Compile Include="Types\TSPData.cs" /> -
branches/GP-MoveOperators/HeuristicLab.Problems.Instances/3.3/IProblemInstanceConsumer.cs
r7548 r8085 20 20 #endregion 21 21 22 using HeuristicLab.Common; 23 22 24 namespace HeuristicLab.Problems.Instances { 23 public interface IProblemInstanceConsumer<TData> { 25 public interface IProblemInstanceConsumer : IContent { } 26 27 public interface IProblemInstanceConsumer<in TData> : IProblemInstanceConsumer { 24 28 /// <summary> 25 29 /// Loads the given instance data. -
branches/GP-MoveOperators/HeuristicLab.Problems.Instances/3.3/IProblemInstanceProvider.cs
r7548 r8085 33 33 34 34 public interface IProblemInstanceProvider<TData> : IProblemInstanceProvider { 35 IProblemInstanceConsumer<TData> Consumer { get; set; }36 37 35 IEnumerable<IDataDescriptor> GetDataDescriptors(); 38 36 TData LoadData(IDataDescriptor descriptor); 39 37 TData LoadData(string path); 40 38 41 39 void SaveData(TData instance, string path); 42 40 } -
branches/GP-MoveOperators/HeuristicLab.Problems.Instances/3.3/ProblemInstanceProvider.cs
r7548 r8085 25 25 namespace HeuristicLab.Problems.Instances { 26 26 public abstract class ProblemInstanceProvider<TData> : IProblemInstanceProvider<TData> { 27 public virtual IProblemInstanceConsumer<TData> Consumer { get; set; }28 29 27 public abstract string Name { get; } 30 28 public abstract string Description { get; } -
branches/GP-MoveOperators/HeuristicLab.Problems.Instances/3.3/Types/TSPData.cs
r7548 r8085 23 23 24 24 namespace HeuristicLab.Problems.Instances { 25 public enum TSPDistanceMeasure { Direct, Euclidean, RoundedEuclidean, UpperEuclidean, Geo, Manhattan, Maximum, Att };26 27 25 /// <summary> 28 26 /// Describes instances of the Traveling Salesman Problem (TSP). … … 45 43 /// Specifies the distance measure that is to be used. 46 44 /// </summary> 47 public TSPDistanceMeasure DistanceMeasure { get; set; }45 public DistanceMeasure DistanceMeasure { get; set; } 48 46 /// <summary> 49 47 /// Optional! The distances are given in form of a distance matrix. … … 81 79 /// <returns>A full distance matrix between all cities.</returns> 82 80 public double[,] GetDistanceMatrix() { 83 if (Distances != null) return Distances; 84 Distances = new double[Dimension, Dimension]; 85 for (int i = 0; i < Dimension - 1; i++) 86 for (int j = i + 1; j < Dimension; j++) { 87 Distances[i, j] = GetDistance(i, j); 88 Distances[j, i] = Distances[i, j]; 89 } 90 return Distances; 81 return DistanceHelper.GetDistanceMatrix(DistanceMeasure, Coordinates, Distances, Dimension); 91 82 } 92 93 #region Private Helpers94 private double GetDistance(int i, int j) {95 switch (DistanceMeasure) {96 case TSPDistanceMeasure.Att:97 return AttDistance(Coordinates[i, 0], Coordinates[i, 1], Coordinates[j, 0], Coordinates[j, 1]);98 case TSPDistanceMeasure.Direct:99 return Distances[i, j];100 case TSPDistanceMeasure.Euclidean:101 return EuclideanDistance(Coordinates[i, 0], Coordinates[i, 1], Coordinates[j, 0], Coordinates[j, 1]);102 case TSPDistanceMeasure.Geo:103 return GeoDistance(Coordinates[i, 0], Coordinates[i, 1], Coordinates[j, 0], Coordinates[j, 1]);104 case TSPDistanceMeasure.Manhattan:105 return ManhattanDistance(Coordinates[i, 0], Coordinates[i, 1], Coordinates[j, 0], Coordinates[j, 1]);106 case TSPDistanceMeasure.Maximum:107 return MaximumDistance(Coordinates[i, 0], Coordinates[i, 1], Coordinates[j, 0], Coordinates[j, 1]);108 case TSPDistanceMeasure.RoundedEuclidean:109 return Math.Round(EuclideanDistance(Coordinates[i, 0], Coordinates[i, 1], Coordinates[j, 0], Coordinates[j, 1]));110 case TSPDistanceMeasure.UpperEuclidean:111 return Math.Ceiling(EuclideanDistance(Coordinates[i, 0], Coordinates[i, 1], Coordinates[j, 0], Coordinates[j, 1]));112 default:113 throw new InvalidOperationException("Distance measure is not known.");114 }115 }116 117 private double AttDistance(double x1, double y1, double x2, double y2) {118 return Math.Ceiling(Math.Sqrt(((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) / 10.0));119 }120 121 private double EuclideanDistance(double x1, double y1, double x2, double y2) {122 return Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));123 }124 125 private const double PI = 3.141592;126 private const double RADIUS = 6378.388;127 private double GeoDistance(double x1, double y1, double x2, double y2) {128 double latitude1, longitude1, latitude2, longitude2;129 double q1, q2, q3;130 double length;131 132 latitude1 = ConvertToRadian(x1);133 longitude1 = ConvertToRadian(y1);134 latitude2 = ConvertToRadian(x2);135 longitude2 = ConvertToRadian(y2);136 137 q1 = Math.Cos(longitude1 - longitude2);138 q2 = Math.Cos(latitude1 - latitude2);139 q3 = Math.Cos(latitude1 + latitude2);140 141 length = (int)(RADIUS * Math.Acos(0.5 * ((1.0 + q1) * q2 - (1.0 - q1) * q3)) + 1.0);142 return (length);143 }144 145 private double ConvertToRadian(double x) {146 return PI * (Math.Truncate(x) + 5.0 * (x - Math.Truncate(x)) / 3.0) / 180.0;147 }148 149 private double ManhattanDistance(double x1, double y1, double x2, double y2) {150 return Math.Round(Math.Abs(x1 - x2) + Math.Abs(y1 - y2), MidpointRounding.AwayFromZero);151 }152 153 private double MaximumDistance(double x1, double y1, double x2, double y2) {154 return Math.Max(Math.Round(Math.Abs(x1 - x2), MidpointRounding.AwayFromZero), Math.Round(Math.Abs(y1 - y2), MidpointRounding.AwayFromZero));155 }156 #endregion157 83 } 158 84 }
Note: See TracChangeset
for help on using the changeset viewer.