Changeset 15259


Ignore:
Timestamp:
07/16/17 10:07:19 (2 months ago)
Author:
gkronber
Message:

#2737: merged r14697 from trunk to stable

Location:
stable
Files:
10 edited
2 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.Instances.TSPLIB/3.3/HeuristicLab.Problems.Instances.TSPLIB-3.3.csproj

    r13486 r15259  
    130130    <EmbeddedResource Include="Data\tsp.opt.tour.zip" />
    131131    <EmbeddedResource Include="Data\vrp.zip" />
     132    <EmbeddedResource Include="Data\tsp.qual" />
     133    <EmbeddedResource Include="Data\atsp.qual" />
    132134    <None Include="Plugin.cs.frame" />
    133135    <Compile Include="Plugin.cs" />
  • stable/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBATSPInstanceProvider.cs

    r14186 r15259  
    5656      instance.BestKnownTour = parser.Tour.FirstOrDefault();
    5757    }
     58
     59    protected override void LoadQuality(double? bestQuality, ATSPData instance) {
     60      instance.BestKnownQuality = bestQuality;
     61    }
    5862  }
    5963}
  • stable/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBCVRPInstanceProvider.cs

    r14186 r15259  
    7878      instance.BestKnownTour = parser.Tour;
    7979    }
     80
     81    protected override void LoadQuality(double? bestQuality, CVRPData instance) {
     82      instance.BestKnownQuality = bestQuality;
     83    }
    8084  }
    8185}
  • stable/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBDataDescriptor.cs

    r14186 r15259  
    2727    internal string InstanceIdentifier { get; set; }
    2828    internal string SolutionIdentifier { get; set; }
     29    internal double? BestQuality { get; set; }
    2930
    30     internal TSPLIBDataDescriptor(string name, string description, string instanceIdentifier, string solutionIdentifier) {
     31    internal TSPLIBDataDescriptor(string name, string description, string instanceIdentifier, string solutionIdentifier, double? bestQuality) {
    3132      this.Name = name;
    3233      this.Description = description;
    3334      this.InstanceIdentifier = instanceIdentifier;
    3435      this.SolutionIdentifier = solutionIdentifier;
     36      this.BestQuality = bestQuality;
    3537    }
    3638  }
  • stable/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBHeterogeneousPTSPDataDescriptor.cs

    r14186 r15259  
    2626
    2727    internal TSPLIBHeterogeneousPTSPDataDescriptor(string name, string description, string instanceIdentifier, string solutionIdentifier, int seed)
    28       : base(name, description, instanceIdentifier, solutionIdentifier) {
     28      : base(name, description, instanceIdentifier, solutionIdentifier, null) {
    2929      this.Name = name;
    3030      this.Description = description;
  • stable/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBHomogeneousPTSPDataDescriptor.cs

    r14186 r15259  
    2525
    2626    internal TSPLIBHomogeneousPTSPDataDescriptor(string name, string description, string instanceIdentifier, string solutionIdentifier, double probability)
    27       : base(name, description, instanceIdentifier, solutionIdentifier) {
     27      : base(name, description, instanceIdentifier, solutionIdentifier, null) {
    2828      this.Name = name;
    2929      this.Description = description;
  • stable/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBInstanceProvider.cs

    r14186 r15259  
    4747    protected abstract T LoadInstance(TSPLIBParser parser, IDataDescriptor descriptor = null);
    4848    protected abstract void LoadSolution(TSPLIBParser parser, T instance);
     49    protected abstract void LoadQuality(double? bestQuality, T instance);
    4950
    5051    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
     
    5758        }
    5859      }
     60
     61      Dictionary<string, double> qualities = new Dictionary<string, double>();
     62      var qualitiesArchiveName = GetResourceName(FileExtension + @"\.qual");
     63      if (!String.IsNullOrEmpty(qualitiesArchiveName)) {
     64        using (var qualitiesReader = new StreamReader(GetType().Assembly.GetManifestResourceStream(qualitiesArchiveName))) {
     65          while (!qualitiesReader.EndOfStream) {
     66            var line = qualitiesReader.ReadLine().Split(';');
     67            qualities.Add(line[0] + "." + FileExtension, double.Parse(line[1]));
     68          }
     69        }
     70      }
     71
    5972      var instanceArchiveName = GetResourceName(FileExtension + @"\.zip");
    6073      if (String.IsNullOrEmpty(instanceArchiveName)) yield break;
     
    6275      using (var instanceStream = new ZipArchive(GetType().Assembly.GetManifestResourceStream(instanceArchiveName), ZipArchiveMode.Read)) {
    6376        foreach (var entry in instanceStream.Entries.Select(x => x.Name).OrderBy(x => x)) {
    64           yield return new TSPLIBDataDescriptor(Path.GetFileNameWithoutExtension(entry), GetInstanceDescription(), entry, solutions.ContainsKey(entry) ? solutions[entry] : String.Empty);
     77          yield return new TSPLIBDataDescriptor(Path.GetFileNameWithoutExtension(entry),
     78                                                GetInstanceDescription(),
     79                                                entry,
     80                                                solutions.ContainsKey(entry) ? solutions[entry] : String.Empty,
     81                                                qualities.ContainsKey(entry) ? (double?)qualities[entry] : null);
    6582        }
    6683      }
     
    7592        var parser = new TSPLIBParser(stream);
    7693        var instance = LoadInstance(parser, id);
     94        LoadQuality(descriptor.BestQuality, instance);
    7795
    7896        if (!String.IsNullOrEmpty(descriptor.SolutionIdentifier)) {
  • stable/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBPTSPInstanceProvider.cs

    r14186 r15259  
    8181    }
    8282
     83    protected override void LoadQuality(double? bestQuality, PTSPData instance) {
     84      instance.BestKnownQuality = bestQuality;
     85    }
     86
    8387    public PTSPData LoadData(string tspFile, string tourFile, double? bestQuality) {
    8488      var data = LoadInstance(new TSPLIBParser(tspFile));
  • stable/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBTSPInstanceProvider.cs

    r14186 r15259  
    8181    }
    8282
     83    protected override void LoadQuality(double? bestQuality, TSPData instance) {
     84      instance.BestKnownQuality = bestQuality;
     85    }
     86
    8387    public TSPData LoadData(string tspFile, string tourFile, double? bestQuality) {
    8488      var data = LoadInstance(new TSPLIBParser(tspFile));
Note: See TracChangeset for help on using the changeset viewer.