Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/01/12 15:15:22 (13 years ago)
Author:
abeham
Message:

#1614

  • Fixed plugin dependencies
  • Updated GQAP view
  • Changed instances infrastructure
    • Changed interface types into classes
    • Removed the library specific instance classes
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  
    4545  </ItemGroup>
    4646  <ItemGroup>
    47     <Compile Include="TSPLIBATSPInstance.cs" />
    4847    <Compile Include="TSPLIBATSPInstanceProvider.cs" />
    49     <Compile Include="TSPLIBCVRPInstance.cs" />
    5048    <Compile Include="TSPLIBCVRPInstanceProvider.cs" />
    51     <Compile Include="TSPLIBTSPInstance.cs" />
    5249    <Compile Include="TSPLIBInstanceDescriptor.cs" />
    5350    <Compile Include="TSPLIBTSPInstanceProvider.cs" />
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/Plugin.cs.frame

    r7465 r7538  
    2525  [Plugin("HeuristicLab.Problems.Instances.TSPLIB", "3.3.6.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Problems.Instances.TSPLIB-3.3.dll", PluginFileType.Assembly)]
     27  [PluginDependency("HeuristicLab.Common", "3.3")]
     28  [PluginDependency("HeuristicLab.Problems.Instances", "3.3")]
    2729  public class HeuristicLabProblemsInstancesTSPLIBPlugin : PluginBase {
    2830  }
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBATSPInstanceProvider.cs

    r7482 r7538  
    2828
    2929namespace HeuristicLab.Problems.Instances.TSPLIB {
    30   public class TSPLIBATSPInstanceProvider : ProblemInstanceProvider<IATSPInstance> {
     30  public class TSPLIBATSPInstanceProvider : ProblemInstanceProvider<ATSPInstance> {
    3131
    3232    public override string Name {
     
    6565    }
    6666
    67     public override IATSPInstance GetInstance(IInstanceDescriptor id) {
     67    public override ATSPInstance LoadInstance(IInstanceDescriptor id) {
    6868      var descriptor = (TSPLIBInstanceDescriptor)id;
    69       var instance = new TSPLIBATSPInstance();
    7069      using (var stream = Assembly.GetExecutingAssembly()
    7170        .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));
    8272
    8373        if (!String.IsNullOrEmpty(descriptor.SolutionIdentifier)) {
     
    8979          }
    9080        }
     81        return instance;
    9182      }
     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
    92106      return instance;
    93107    }
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBCVRPInstanceProvider.cs

    r7482 r7538  
    2828
    2929namespace HeuristicLab.Problems.Instances.TSPLIB {
    30   public class TSPLIBCVRPInstanceProvider : ProblemInstanceProvider<ICVRPInstance> {
     30  public class TSPLIBCVRPInstanceProvider : ProblemInstanceProvider<CVRPInstance> {
    3131
    3232    public override string Name {
     
    6464    }
    6565
    66     public override ICVRPInstance GetInstance(IInstanceDescriptor id) {
     66    public override CVRPInstance LoadInstance(IInstanceDescriptor id) {
    6767      var descriptor = (TSPLIBInstanceDescriptor)id;
    68       var instance = new TSPLIBCVRPInstance();
    6968      using (var stream = Assembly.GetExecutingAssembly()
    7069        .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));
    10471
    10572        if (!String.IsNullOrEmpty(descriptor.SolutionIdentifier)) {
     
    11178          }
    11279        }
     80        return instance;
    11381      }
     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
    114127      return instance;
    115128    }
  • branches/GeneralizedQAP/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBTSPInstanceProvider.cs

    r7482 r7538  
    2828
    2929namespace HeuristicLab.Problems.Instances.TSPLIB {
    30   public class TSPLIBTSPInstanceProvider : ProblemInstanceProvider<ITSPInstance> {
     30  public class TSPLIBTSPInstanceProvider : ProblemInstanceProvider<TSPInstance> {
    3131
    3232    public override string Name {
     
    6565    }
    6666
    67     public override ITSPInstance GetInstance(IInstanceDescriptor id) {
     67    public override TSPInstance LoadInstance(IInstanceDescriptor id) {
    6868      var descriptor = (TSPLIBInstanceDescriptor)id;
    69       var instance = new TSPLIBTSPInstance();
    7069      using (var stream = Assembly.GetExecutingAssembly()
    7170        .GetManifestResourceStream(descriptor.InstanceIdentifier)) {
    7271        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);
    10873
    10974        if (!String.IsNullOrEmpty(descriptor.SolutionIdentifier)) {
     
    11580          }
    11681        }
     82        return instance;
    11783      }
     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();
    118130      return instance;
    119131    }
Note: See TracChangeset for help on using the changeset viewer.