- Timestamp:
- 08/20/14 12:12:40 (10 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/CordeauFormat
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/CordeauFormat/CordeauFormatInstanceProvider.cs
r11286 r11292 23 23 24 24 namespace HeuristicLab.Problems.Instances.VehicleRouting { 25 public abstract class CordeauFormatInstanceProvider : VRPInstanceProvider<MDCVRPTWData>{26 protected override MDCVRPTWDataLoadData(Stream stream) {25 public abstract class CordeauFormatInstanceProvider<T> : VRPInstanceProvider<T> where T : MDCVRPData { 26 protected override T LoadData(Stream stream) { 27 27 return LoadInstance(new CordeauParser(stream)); 28 28 } … … 31 31 get { return true; } 32 32 } 33 public override MDCVRPTWDataImportData(string path) {33 public override T ImportData(string path) { 34 34 return LoadInstance(new CordeauParser(path)); 35 35 } 36 36 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); 67 38 } 68 39 } -
trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/CordeauFormat/CordeauInstanceProvider.cs
r11282 r11292 21 21 22 22 using 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;29 23 30 24 namespace HeuristicLab.Problems.Instances.VehicleRouting { 31 public class CordeauInstanceProvider : CordeauFormatInstanceProvider {25 public class CordeauInstanceProvider : CordeauFormatInstanceProvider<MDCVRPData> { 32 26 public override string Name { 33 get { return "Cordeau (MDCVRP TW)"; }27 get { return "Cordeau (MDCVRP)"; } 34 28 } 35 29 … … 39 33 40 34 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/"); } 42 36 } 43 37 44 38 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. 46 41 A tabu search heuristic for periodic and multi-depot vehicle routing problems. 47 Networks, 30, pp. 105–119."; } 42 Networks, 30, pp. 105–119."; 43 } 48 44 } 49 45 … … 51 47 get { return "Cordeau"; } 52 48 } 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 } 53 77 } 54 78 }
Note: See TracChangeset
for help on using the changeset viewer.