Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
08/16/10 17:05:23 (14 years ago)
Author:
svonolfe
Message:

Added TSPLIBParser (#1039)

Location:
branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/HeuristicLab.Problems.VehicleRouting-3.3.csproj

    r4230 r4232  
    156156    <Compile Include="Encodings\Potvin\Manipulators\PotvinManipulator.cs" />
    157157    <Compile Include="Interfaces\IVRPMoveMaker.cs" />
     158    <Compile Include="TSPLIBParser.cs" />
    158159    <Compile Include="VRPUtilities.cs" />
    159160    <Compile Include="VRPOperator.cs" />
  • branches/VRP/HeuristicLab.Problems.VehicleRouting/3.3/VehicleRoutingProblem.cs

    r4179 r4232  
    431431    }
    432432
     433    public void ImportFromTSPLib(string tspFileName) {
     434      TSPLIBParser parser = new TSPLIBParser(tspFileName);
     435      parser.Parse();
     436
     437      this.Name = parser.Name;
     438
     439      int problemSize = parser.Demands.Length;
     440
     441      Coordinates = new DoubleMatrix(parser.Vertices);
     442      Vehicles.Value = problemSize - 1;
     443      Capacity.Value = parser.Capacity;
     444      Demand = new DoubleArray(parser.Demands);
     445      ReadyTime = new DoubleArray(problemSize);
     446      DueTime = new DoubleArray(problemSize);
     447      ServiceTime = new DoubleArray(problemSize);
     448
     449      for (int i = 0; i < problemSize; i++) {
     450        ReadyTime[i] = 0;
     451        DueTime[i] = int.MaxValue;
     452        ServiceTime[i] = 0;
     453      }
     454
     455      if (parser.Depot != 1)
     456        throw new Exception("Invalid depot specification");
     457
     458      if (parser.WeightType != TSPLIBParser.TSPLIBEdgeWeightType.EUC_2D)
     459        throw new Exception("Invalid weight type");
     460
     461      OnReset();
     462    }
     463
    433464    private void InitializeRandomVRPInstance() {
    434465      System.Random rand = new System.Random();
Note: See TracChangeset for help on using the changeset viewer.