Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7887


Ignore:
Timestamp:
05/24/12 10:41:05 (13 years ago)
Author:
svonolfe
Message:

Added support for the DCVRP in the Golden format (#1177)

Location:
branches/VRP/HeuristicLab.Problems.Instances.VehicleRouting/3.4/GoldenFormat
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.Instances.VehicleRouting/3.4/GoldenFormat/ChristofidesInstanceProvider.cs

    r7883 r7887  
    3131  public class ChristofidesInstanceProvider : GoldenFormatInstanceProvider {
    3232    public override string Name {
    33       get { return "Christofides (CVRP)"; }
     33      get { return "Christofides (DCVRP)"; }
    3434    }
    3535
  • branches/VRP/HeuristicLab.Problems.Instances.VehicleRouting/3.4/GoldenFormat/GoldenFormatInstanceProvider.cs

    r7883 r7887  
    3030
    3131namespace HeuristicLab.Problems.Instances.VehicleRouting {
    32   public abstract class GoldenFormatInstanceProvider : VRPInstanceProvider<CVRPData> {
    33     protected override CVRPData LoadData(Stream stream) {
     32  public abstract class GoldenFormatInstanceProvider : VRPInstanceProvider<CVRPTWData> {
     33    protected override CVRPTWData LoadData(Stream stream) {
    3434      return LoadInstance(new GoldenParser(stream));
    3535    }
    3636
    37     public override CVRPData LoadData(string path) {
     37    public override CVRPTWData LoadData(string path) {
    3838      return LoadInstance(new GoldenParser(path));
    3939    }
    4040
    41     private CVRPData LoadInstance(GoldenParser parser) {
     41    private CVRPTWData LoadInstance(GoldenParser parser) {
    4242      parser.Parse();
    4343
    44       var instance = new CVRPData();
     44      var instance = new CVRPTWData();
    4545      instance.Dimension = parser.Vertices.GetLength(0) + 1;
    4646      instance.Coordinates = parser.Vertices;
     
    5656      }
    5757
     58      instance.ReadyTimes = new double[instance.Dimension];
     59      instance.ServiceTimes = new double[instance.Dimension];
     60      instance.DueTimes = new double[instance.Dimension];
     61
     62      for (int i = 0; i < instance.Dimension; i++) {
     63        instance.ReadyTimes[i] = 0;
     64        instance.ServiceTimes[i] = 0;
     65        instance.DueTimes[i] = double.MaxValue;
     66      }
     67
     68      if(parser.Distance > 0)
     69        instance.DueTimes[0] = parser.Distance;
     70
     71      if (parser.Vehicles > 0)
     72        instance.MaximumVehicles = parser.Vehicles;
     73
    5874      instance.Name = parser.ProblemName;
    5975      instance.Description = parser.Comment
  • branches/VRP/HeuristicLab.Problems.Instances.VehicleRouting/3.4/GoldenFormat/GoldenInstanceProvider.cs

    r7883 r7887  
    3131  public class GoldenInstanceProvider : GoldenFormatInstanceProvider {
    3232    public override string Name {
    33       get { return "Golden (CVRP)"; }
     33      get { return "Golden (DCVRP)"; }
    3434    }
    3535
  • branches/VRP/HeuristicLab.Problems.Instances.VehicleRouting/3.4/GoldenFormat/GoldenParser.cs

    r7883 r7887  
    4848    private const int NODESECTION = 7;
    4949    private const int CAPACITY = 8;
     50    private const int DISTANCE = 12;
    5051    private const int VEHICLES = 13;
    5152    private const int DEPOTSECTION = 9;
     
    8586      get {
    8687        return vehicles;
     88      }
     89    }
     90
     91    private double distance;
     92    public double Distance {
     93      get {
     94        return distance;
    8795      }
    8896    }
     
    113121      capacity = -1;
    114122      vehicles = -1;
     123      distance = -1;
    115124      demands = null;
    116125    }
     
    179188              case VEHICLES:
    180189                ReadVehicles(str);
     190                break;
     191              case DISTANCE:
     192                ReadDistance(str);
    181193                break;
    182194              case DEPOTSECTION:
     
    226238      if (token.Equals("vehicles", StringComparison.OrdinalIgnoreCase))
    227239        return VEHICLES;
     240      if (token.Equals("distance", StringComparison.OrdinalIgnoreCase))
     241        return DISTANCE;
    228242      if (token.Equals("depot_section", StringComparison.OrdinalIgnoreCase))
    229243        return DEPOTSECTION;
     
    321335    }
    322336
     337    private void ReadDistance(string str) {
     338      string[] tokens = str.Split(new string[] { ":" }, StringSplitOptions.None);
     339      distance = double.Parse(tokens[tokens.Length - 1].Trim(), System.Globalization.CultureInfo.InvariantCulture);
     340    }
     341
    323342    private void ReadDepot(StreamReader reader) {
    324343      string[] tokens;
  • branches/VRP/HeuristicLab.Problems.Instances.VehicleRouting/3.4/GoldenFormat/KytojokiInstanceProvider.cs

    r7883 r7887  
    3131  public class KytojokiInstanceProvider : GoldenFormatInstanceProvider {
    3232    public override string Name {
    33       get { return "Kytojoki (CVRP)"; }
     33      get { return "Kytojoki (DCVRP)"; }
    3434    }
    3535
Note: See TracChangeset for help on using the changeset viewer.