- Timestamp:
- 03/01/12 15:15:22 (13 years ago)
- Location:
- branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3
- Files:
-
- 3 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/HeuristicLab.Problems.Instances.TSPLIB-3.3.csproj
r7470 r7538 45 45 </ItemGroup> 46 46 <ItemGroup> 47 <Compile Include="TSPLIBATSPInstance.cs" />48 47 <Compile Include="TSPLIBATSPInstanceProvider.cs" /> 49 <Compile Include="TSPLIBCVRPInstance.cs" />50 48 <Compile Include="TSPLIBCVRPInstanceProvider.cs" /> 51 <Compile Include="TSPLIBTSPInstance.cs" />52 49 <Compile Include="TSPLIBInstanceDescriptor.cs" /> 53 50 <Compile Include="TSPLIBTSPInstanceProvider.cs" /> -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/Plugin.cs.frame
r7465 r7538 25 25 [Plugin("HeuristicLab.Problems.Instances.TSPLIB", "3.3.6.$WCREV$")] 26 26 [PluginFile("HeuristicLab.Problems.Instances.TSPLIB-3.3.dll", PluginFileType.Assembly)] 27 [PluginDependency("HeuristicLab.Common", "3.3")] 28 [PluginDependency("HeuristicLab.Problems.Instances", "3.3")] 27 29 public class HeuristicLabProblemsInstancesTSPLIBPlugin : PluginBase { 28 30 } -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBATSPInstanceProvider.cs
r7482 r7538 28 28 29 29 namespace HeuristicLab.Problems.Instances.TSPLIB { 30 public class TSPLIBATSPInstanceProvider : ProblemInstanceProvider< IATSPInstance> {30 public class TSPLIBATSPInstanceProvider : ProblemInstanceProvider<ATSPInstance> { 31 31 32 32 public override string Name { … … 65 65 } 66 66 67 public override IATSPInstance GetInstance(IInstanceDescriptor id) {67 public override ATSPInstance LoadInstance(IInstanceDescriptor id) { 68 68 var descriptor = (TSPLIBInstanceDescriptor)id; 69 var instance = new TSPLIBATSPInstance();70 69 using (var stream = Assembly.GetExecutingAssembly() 71 70 .GetManifestResourceStream(descriptor.InstanceIdentifier)) { 72 var parser = new TSPLIBParser(stream); 73 parser.Parse(); 74 instance.Dimension = parser.Dimension; 75 instance.Coordinates = parser.DisplayVertices != null ? parser.DisplayVertices : parser.Vertices; 76 instance.Distances = parser.Distances; 77 78 instance.Name = parser.Name; 79 instance.Description = parser.Comment 80 + Environment.NewLine + Environment.NewLine 81 + GetDescription(); 71 var instance = Load(new TSPLIBParser(stream)); 82 72 83 73 if (!String.IsNullOrEmpty(descriptor.SolutionIdentifier)) { … … 89 79 } 90 80 } 81 return instance; 91 82 } 83 } 84 85 public override ATSPInstance LoadInstance(string path) { 86 return Load(new TSPLIBParser(path)); 87 } 88 89 public override void SaveInstance(ATSPInstance instance, string path) { 90 throw new NotSupportedException(); 91 } 92 93 private ATSPInstance Load(TSPLIBParser parser) { 94 var instance = new ATSPInstance(); 95 96 parser.Parse(); 97 instance.Dimension = parser.Dimension; 98 instance.Coordinates = parser.DisplayVertices != null ? parser.DisplayVertices : parser.Vertices; 99 instance.Distances = parser.Distances; 100 101 instance.Name = parser.Name; 102 instance.Description = parser.Comment 103 + Environment.NewLine + Environment.NewLine 104 + GetDescription(); 105 92 106 return instance; 93 107 } -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBCVRPInstanceProvider.cs
r7482 r7538 28 28 29 29 namespace HeuristicLab.Problems.Instances.TSPLIB { 30 public class TSPLIBCVRPInstanceProvider : ProblemInstanceProvider< ICVRPInstance> {30 public class TSPLIBCVRPInstanceProvider : ProblemInstanceProvider<CVRPInstance> { 31 31 32 32 public override string Name { … … 64 64 } 65 65 66 public override ICVRPInstance GetInstance(IInstanceDescriptor id) {66 public override CVRPInstance LoadInstance(IInstanceDescriptor id) { 67 67 var descriptor = (TSPLIBInstanceDescriptor)id; 68 var instance = new TSPLIBCVRPInstance();69 68 using (var stream = Assembly.GetExecutingAssembly() 70 69 .GetManifestResourceStream(descriptor.InstanceIdentifier)) { 71 var parser = new TSPLIBParser(stream); 72 parser.Parse(); 73 instance.Dimension = parser.Dimension; 74 instance.Coordinates = parser.Vertices != null ? parser.Vertices : parser.DisplayVertices; 75 instance.Distances = parser.Distances; 76 instance.Capacity = parser.Capacity.Value; 77 instance.Demands = parser.Demands; 78 switch (parser.EdgeWeightType) { 79 case TSPLIBEdgeWeightTypes.ATT: 80 instance.DistanceMeasure = CVRPDistanceMeasure.Att; break; 81 case TSPLIBEdgeWeightTypes.CEIL_2D: 82 instance.DistanceMeasure = CVRPDistanceMeasure.UpperEuclidean; break; 83 case TSPLIBEdgeWeightTypes.EUC_2D: 84 case TSPLIBEdgeWeightTypes.EUC_3D: 85 instance.DistanceMeasure = CVRPDistanceMeasure.RoundedEuclidean; break; 86 case TSPLIBEdgeWeightTypes.EXPLICIT: 87 instance.DistanceMeasure = CVRPDistanceMeasure.Direct; break; 88 case TSPLIBEdgeWeightTypes.GEO: 89 instance.DistanceMeasure = CVRPDistanceMeasure.Geo; break; 90 case TSPLIBEdgeWeightTypes.MAN_2D: 91 case TSPLIBEdgeWeightTypes.MAN_3D: 92 instance.DistanceMeasure = CVRPDistanceMeasure.Manhattan; break; 93 case TSPLIBEdgeWeightTypes.MAX_2D: 94 case TSPLIBEdgeWeightTypes.MAX_3D: 95 instance.DistanceMeasure = CVRPDistanceMeasure.Maximum; break; 96 default: 97 throw new InvalidDataException("The given edge weight is not supported by HeuristicLab."); 98 } 99 100 instance.Name = parser.Name; 101 instance.Description = parser.Comment 102 + Environment.NewLine + Environment.NewLine 103 + GetDescription(); 70 var instance = Load(new TSPLIBParser(stream)); 104 71 105 72 if (!String.IsNullOrEmpty(descriptor.SolutionIdentifier)) { … … 111 78 } 112 79 } 80 return instance; 113 81 } 82 } 83 84 public override CVRPInstance LoadInstance(string path) { 85 return Load(new TSPLIBParser(path)); 86 } 87 88 public override void SaveInstance(CVRPInstance instance, string path) { 89 throw new NotSupportedException(); 90 } 91 92 private CVRPInstance Load(TSPLIBParser parser) { 93 parser.Parse(); 94 var instance = new CVRPInstance(); 95 instance.Dimension = parser.Dimension; 96 instance.Coordinates = parser.Vertices != null ? parser.Vertices : parser.DisplayVertices; 97 instance.Distances = parser.Distances; 98 instance.Capacity = parser.Capacity.Value; 99 instance.Demands = parser.Demands; 100 switch (parser.EdgeWeightType) { 101 case TSPLIBEdgeWeightTypes.ATT: 102 instance.DistanceMeasure = CVRPDistanceMeasure.Att; break; 103 case TSPLIBEdgeWeightTypes.CEIL_2D: 104 instance.DistanceMeasure = CVRPDistanceMeasure.UpperEuclidean; break; 105 case TSPLIBEdgeWeightTypes.EUC_2D: 106 case TSPLIBEdgeWeightTypes.EUC_3D: 107 instance.DistanceMeasure = CVRPDistanceMeasure.RoundedEuclidean; break; 108 case TSPLIBEdgeWeightTypes.EXPLICIT: 109 instance.DistanceMeasure = CVRPDistanceMeasure.Direct; break; 110 case TSPLIBEdgeWeightTypes.GEO: 111 instance.DistanceMeasure = CVRPDistanceMeasure.Geo; break; 112 case TSPLIBEdgeWeightTypes.MAN_2D: 113 case TSPLIBEdgeWeightTypes.MAN_3D: 114 instance.DistanceMeasure = CVRPDistanceMeasure.Manhattan; break; 115 case TSPLIBEdgeWeightTypes.MAX_2D: 116 case TSPLIBEdgeWeightTypes.MAX_3D: 117 instance.DistanceMeasure = CVRPDistanceMeasure.Maximum; break; 118 default: 119 throw new InvalidDataException("The given edge weight is not supported by HeuristicLab."); 120 } 121 122 instance.Name = parser.Name; 123 instance.Description = parser.Comment 124 + Environment.NewLine + Environment.NewLine 125 + GetDescription(); 126 114 127 return instance; 115 128 } -
branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBTSPInstanceProvider.cs
r7482 r7538 28 28 29 29 namespace HeuristicLab.Problems.Instances.TSPLIB { 30 public class TSPLIBTSPInstanceProvider : ProblemInstanceProvider< ITSPInstance> {30 public class TSPLIBTSPInstanceProvider : ProblemInstanceProvider<TSPInstance> { 31 31 32 32 public override string Name { … … 65 65 } 66 66 67 public override ITSPInstance GetInstance(IInstanceDescriptor id) {67 public override TSPInstance LoadInstance(IInstanceDescriptor id) { 68 68 var descriptor = (TSPLIBInstanceDescriptor)id; 69 var instance = new TSPLIBTSPInstance();70 69 using (var stream = Assembly.GetExecutingAssembly() 71 70 .GetManifestResourceStream(descriptor.InstanceIdentifier)) { 72 71 var parser = new TSPLIBParser(stream); 73 parser.Parse(); 74 if (parser.FixedEdges != null) throw new InvalidDataException("TSP instance " + parser.Name + " contains fixed edges which are not supported by HeuristicLab."); 75 76 instance.Dimension = parser.Dimension; 77 instance.Coordinates = parser.Vertices != null ? parser.Vertices : parser.DisplayVertices; 78 instance.Distances = parser.Distances; 79 switch (parser.EdgeWeightType) { 80 case TSPLIBEdgeWeightTypes.ATT: 81 instance.DistanceMeasure = TSPDistanceMeasure.Att; break; 82 case TSPLIBEdgeWeightTypes.CEIL_2D: 83 instance.DistanceMeasure = TSPDistanceMeasure.UpperEuclidean; break; 84 case TSPLIBEdgeWeightTypes.EUC_2D: 85 instance.DistanceMeasure = TSPDistanceMeasure.RoundedEuclidean; break; 86 case TSPLIBEdgeWeightTypes.EUC_3D: 87 throw new InvalidDataException("3D coordinates are not supported."); 88 case TSPLIBEdgeWeightTypes.EXPLICIT: 89 instance.DistanceMeasure = TSPDistanceMeasure.Direct; break; 90 case TSPLIBEdgeWeightTypes.GEO: 91 instance.DistanceMeasure = TSPDistanceMeasure.Geo; break; 92 case TSPLIBEdgeWeightTypes.MAN_2D: 93 instance.DistanceMeasure = TSPDistanceMeasure.Manhattan; break; 94 case TSPLIBEdgeWeightTypes.MAN_3D: 95 throw new InvalidDataException("3D coordinates are not supported."); 96 case TSPLIBEdgeWeightTypes.MAX_2D: 97 instance.DistanceMeasure = TSPDistanceMeasure.Maximum; break; 98 case TSPLIBEdgeWeightTypes.MAX_3D: 99 throw new InvalidDataException("3D coordinates are not supported."); 100 default: 101 throw new InvalidDataException("The given edge weight is not supported by HeuristicLab."); 102 } 103 104 instance.Name = parser.Name; 105 instance.Description = parser.Comment 106 + Environment.NewLine + Environment.NewLine 107 + GetDescription(); 72 var instance = Load(parser); 108 73 109 74 if (!String.IsNullOrEmpty(descriptor.SolutionIdentifier)) { … … 115 80 } 116 81 } 82 return instance; 117 83 } 84 } 85 86 public override TSPInstance LoadInstance(string path) { 87 return Load(new TSPLIBParser(path)); 88 } 89 90 public override void SaveInstance(TSPInstance instance, string path) { 91 throw new NotSupportedException(); 92 } 93 94 private TSPInstance Load(TSPLIBParser parser) { 95 parser.Parse(); 96 if (parser.FixedEdges != null) throw new InvalidDataException("TSP instance " + parser.Name + " contains fixed edges which are not supported by HeuristicLab."); 97 var instance = new TSPInstance(); 98 instance.Dimension = parser.Dimension; 99 instance.Coordinates = parser.Vertices != null ? parser.Vertices : parser.DisplayVertices; 100 instance.Distances = parser.Distances; 101 switch (parser.EdgeWeightType) { 102 case TSPLIBEdgeWeightTypes.ATT: 103 instance.DistanceMeasure = TSPDistanceMeasure.Att; break; 104 case TSPLIBEdgeWeightTypes.CEIL_2D: 105 instance.DistanceMeasure = TSPDistanceMeasure.UpperEuclidean; break; 106 case TSPLIBEdgeWeightTypes.EUC_2D: 107 instance.DistanceMeasure = TSPDistanceMeasure.RoundedEuclidean; break; 108 case TSPLIBEdgeWeightTypes.EUC_3D: 109 throw new InvalidDataException("3D coordinates are not supported."); 110 case TSPLIBEdgeWeightTypes.EXPLICIT: 111 instance.DistanceMeasure = TSPDistanceMeasure.Direct; break; 112 case TSPLIBEdgeWeightTypes.GEO: 113 instance.DistanceMeasure = TSPDistanceMeasure.Geo; break; 114 case TSPLIBEdgeWeightTypes.MAN_2D: 115 instance.DistanceMeasure = TSPDistanceMeasure.Manhattan; break; 116 case TSPLIBEdgeWeightTypes.MAN_3D: 117 throw new InvalidDataException("3D coordinates are not supported."); 118 case TSPLIBEdgeWeightTypes.MAX_2D: 119 instance.DistanceMeasure = TSPDistanceMeasure.Maximum; break; 120 case TSPLIBEdgeWeightTypes.MAX_3D: 121 throw new InvalidDataException("3D coordinates are not supported."); 122 default: 123 throw new InvalidDataException("The given edge weight is not supported by HeuristicLab."); 124 } 125 126 instance.Name = parser.Name; 127 instance.Description = parser.Comment 128 + Environment.NewLine + Environment.NewLine 129 + GetDescription(); 118 130 return instance; 119 131 }
Note: See TracChangeset
for help on using the changeset viewer.