Free cookie consent management tool by TermsFeed Policy Generator

Changeset 17265 for branches


Ignore:
Timestamp:
09/19/19 20:46:19 (5 years ago)
Author:
abeham
Message:

#2521: remove usage of solutions or best-known quality when converting TSPLIB instances to pTSP instances

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2521_ProblemRefactoring/HeuristicLab.Problems.Instances.TSPLIB/3.3/TSPLIBPTSPInstanceProvider.cs

    r17226 r17265  
    2222using System;
    2323using System.IO;
    24 using System.Linq;
    2524
    2625namespace HeuristicLab.Problems.Instances.TSPLIB {
     
    7675    protected abstract double[] GetProbabilities(IDataDescriptor descriptor, PTSPData instance);
    7776
     77    public override PTSPData LoadData(IDataDescriptor id) {
     78      var tsplibId = (id as TSPLIBDataDescriptor);
     79      if (tsplibId != null) tsplibId.SolutionIdentifier = null;
     80      return base.LoadData(tsplibId ?? id);
     81    }
     82
    7883    protected override void LoadSolution(TSPLIBParser parser, PTSPData instance) {
    79       parser.Parse();
    80       instance.BestKnownTour = parser.Tour.FirstOrDefault();
     84      // solutions are not defined for pTSP
    8185    }
    8286
    8387    protected override void LoadQuality(double? bestQuality, PTSPData instance) {
    84       instance.BestKnownQuality = bestQuality;
     88      // best known qualities are not defined for pTSP
    8589    }
    86 
    87     public PTSPData LoadData(string tspFile, string tourFile, double? bestQuality) {
    88       var data = LoadInstance(new TSPLIBParser(tspFile));
    89       if (!String.IsNullOrEmpty(tourFile)) {
    90         var tourParser = new TSPLIBParser(tourFile);
    91         LoadSolution(tourParser, data);
    92       }
    93       if (bestQuality.HasValue)
    94         data.BestKnownQuality = bestQuality.Value;
    95       return data;
    96     }
    97 
    9890  }
    9991}
Note: See TracChangeset for help on using the changeset viewer.