Changeset 11292


Ignore:
Timestamp:
08/20/14 12:12:40 (5 years ago)
Author:
pfleck
Message:

#2226
Split the CordeauInstanceProvider into 2 InstanceProvider which separates the MDCVRP and MDCVRPTW instances.

Location:
trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/CordeauFormat/CordeauFormatInstanceProvider.cs

    r11286 r11292  
    2323
    2424namespace HeuristicLab.Problems.Instances.VehicleRouting {
    25   public abstract class CordeauFormatInstanceProvider : VRPInstanceProvider<MDCVRPTWData> {
    26     protected override MDCVRPTWData LoadData(Stream stream) {
     25  public abstract class CordeauFormatInstanceProvider<T> : VRPInstanceProvider<T> where T : MDCVRPData {
     26    protected override T LoadData(Stream stream) {
    2727      return LoadInstance(new CordeauParser(stream));
    2828    }
     
    3131      get { return true; }
    3232    }
    33     public override MDCVRPTWData ImportData(string path) {
     33    public override T ImportData(string path) {
    3434      return LoadInstance(new CordeauParser(path));
    3535    }
    3636
    37     private MDCVRPTWData LoadInstance(CordeauParser parser) {
    38       parser.Parse();
    39 
    40       var instance = new MDCVRPTWData();
    41       instance.Dimension = parser.Cities + 1;
    42       instance.Depots = parser.Depots;
    43       instance.Coordinates = parser.Coordinates;
    44       instance.Capacity = parser.Capacity;
    45       instance.Demands = parser.Demands;
    46       instance.DistanceMeasure = DistanceMeasure.Euclidean;
    47       instance.ReadyTimes = parser.Readytimes;
    48       instance.ServiceTimes = parser.Servicetimes;
    49       instance.DueTimes = parser.Duetimes;
    50       instance.MaximumVehicles = parser.Vehicles;
    51 
    52       int depots = parser.Depots;
    53       int vehicles = parser.Vehicles / parser.Depots;
    54       instance.VehicleDepotAssignment = new int[depots * vehicles];
    55       int index = 0;
    56 
    57       for (int i = 0; i < depots; i++)
    58         for (int j = 0; j < vehicles; j++) {
    59           instance.VehicleDepotAssignment[index] = i;
    60           index++;
    61         }
    62 
    63       instance.Name = parser.ProblemName;
    64 
    65       return instance;
    66     }
     37    internal abstract T LoadInstance(CordeauParser parser);
    6738  }
    6839}
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/CordeauFormat/CordeauInstanceProvider.cs

    r11282 r11292  
    2121
    2222using System;
    23 using System.Collections.Generic;
    24 using System.IO;
    25 using System.Linq;
    26 using System.Reflection;
    27 using System.Text.RegularExpressions;
    28 using ICSharpCode.SharpZipLib.Zip;
    2923
    3024namespace HeuristicLab.Problems.Instances.VehicleRouting {
    31   public class CordeauInstanceProvider : CordeauFormatInstanceProvider {
     25  public class CordeauInstanceProvider : CordeauFormatInstanceProvider<MDCVRPData> {
    3226    public override string Name {
    33       get { return "Cordeau (MDCVRPTW)"; }
     27      get { return "Cordeau (MDCVRP)"; }
    3428    }
    3529
     
    3933
    4034    public override Uri WebLink {
    41       get { return new Uri(@"http://neo.lcc.uma.es/vrp/vrp-instances/"); }
     35      get { return new Uri(@"http://neo.lcc.uma.es/vrp/vrp-instances/multiple-depot-vrp-instances/"); }
    4236    }
    4337
    4438    public override string ReferencePublication {
    45       get { return @"J.-F. Cordeau, M. Gendreau, G. Laporte. 1997.
     39      get {
     40        return @"J.-F. Cordeau, M. Gendreau, G. Laporte. 1997.
    4641A tabu search heuristic for periodic and multi-depot vehicle routing problems.
    47 Networks, 30, pp. 105–119."; }
     42Networks, 30, pp. 105–119.";
     43      }
    4844    }
    4945
     
    5147      get { return "Cordeau"; }
    5248    }
     49
     50    internal override MDCVRPData LoadInstance(CordeauParser parser) {
     51      parser.Parse();
     52
     53      var instance = new MDCVRPData();
     54      instance.Dimension = parser.Cities + 1;
     55      instance.Depots = parser.Depots;
     56      instance.Coordinates = parser.Coordinates;
     57      instance.Capacity = parser.Capacity;
     58      instance.Demands = parser.Demands;
     59      instance.DistanceMeasure = DistanceMeasure.Euclidean;
     60      instance.MaximumVehicles = parser.Vehicles;
     61
     62      int depots = parser.Depots;
     63      int vehicles = parser.Vehicles / parser.Depots;
     64      instance.VehicleDepotAssignment = new int[depots * vehicles];
     65      int index = 0;
     66
     67      for (int i = 0; i < depots; i++)
     68        for (int j = 0; j < vehicles; j++) {
     69          instance.VehicleDepotAssignment[index] = i;
     70          index++;
     71        }
     72
     73      instance.Name = parser.ProblemName;
     74
     75      return instance;
     76    }
    5377  }
    5478}
  • trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/HeuristicLab.Problems.Instances.VehicleRouting-3.4.csproj

    r8624 r11292  
    103103  <ItemGroup>
    104104    <Reference Include="ICSharpCode.SharpZipLib">
    105     <HintPath>..\..\HeuristicLab.PluginInfrastructure\3.3\ICSharpCode.SharpZipLib.dll</HintPath>
    106     <Private>False</Private>
    107   </Reference>
     105      <HintPath>..\..\HeuristicLab.PluginInfrastructure\3.3\ICSharpCode.SharpZipLib.dll</HintPath>
     106      <Private>False</Private>
     107    </Reference>
    108108    <Reference Include="System" />
    109109    <Reference Include="System.Core" />
     
    111111  </ItemGroup>
    112112  <ItemGroup>
     113    <Compile Include="CordeauFormat\CordeauTWInstanceProvider.cs" />
    113114    <Compile Include="GoldenFormat\ChristofidesInstanceProvider.cs" />
    114115    <Compile Include="GoldenFormat\KytojokiInstanceProvider.cs" />
     
    148149    <EmbeddedResource Include="Data\Taillard.opt.zip" />
    149150    <EmbeddedResource Include="Data\Taillard.zip" />
     151    <EmbeddedResource Include="Data\CordeauTW.zip" />
    150152    <None Include="Plugin.cs.frame" />
    151153    <Compile Include="Plugin.cs" />
     
    180182  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    181183  <PropertyGroup>
    182    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     184    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    183185set ProjectDir=$(ProjectDir)
    184186set SolutionDir=$(SolutionDir)
     
    186188
    187189call PreBuildEvent.cmd</PreBuildEvent>
    188 <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     190    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
    189191export ProjectDir=$(ProjectDir)
    190192export SolutionDir=$(SolutionDir)
Note: See TracChangeset for help on using the changeset viewer.