Changeset 8839 for branches/DynamicVehicleRouting
- Timestamp:
- 10/23/12 13:27:08 (12 years ago)
- Location:
- branches/DynamicVehicleRouting/HeuristicLab.PDPSimulation/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DynamicVehicleRouting/HeuristicLab.PDPSimulation/3.3/Parsers/DynPDPParser.cs
r8670 r8839 50 50 } 51 51 52 public struct DistanceMatrixInformation { 53 public bool useDistanceMatrix; 54 public int[,] coordinates; 55 public double[,] matrix; 56 } 57 52 58 protected string file; 53 59 protected string problemName; 54 60 protected List<Vehicle> vehicles; 55 61 protected List<Order> orders; 62 protected DistanceMatrixInformation distanceMatrix; 56 63 57 64 public string ProblemName { … … 73 80 } 74 81 82 public DistanceMatrixInformation DistanceMatrix { 83 get { 84 return distanceMatrix; 85 } 86 } 87 75 88 public DynPDPParser(string file) { 76 89 this.file = file; 77 90 vehicles = new List<Vehicle>(); 78 91 orders = new List<Order>(); 92 distanceMatrix = new DistanceMatrixInformation(); 93 distanceMatrix.useDistanceMatrix = false; 94 distanceMatrix.coordinates = null; 95 distanceMatrix.matrix = null; 79 96 } 80 97 -
branches/DynamicVehicleRouting/HeuristicLab.PDPSimulation/3.3/Parsers/TSPLibDynPDPParser.cs
r8795 r8839 23 23 using System.IO; 24 24 using System.Text.RegularExpressions; 25 using System; 25 26 26 27 namespace HeuristicLab.PDPSimulation { … … 52 53 int dueTime = int.Parse(dueTimeLine); 53 54 54 List< double> xCoord = new List<double>();55 List< double> yCoord = new List<double>();55 List<int> xCoord = new List<int>(); 56 List<int> yCoord = new List<int>(); 56 57 57 58 line = reader.ReadLine(); … … 59 60 m = reg.Matches(line); 60 61 while (m.Count == 3) { 61 xCoord.Add( double.Parse(m[1].Value, System.Globalization.CultureInfo.InvariantCulture));62 yCoord.Add( double.Parse(m[2].Value, System.Globalization.CultureInfo.InvariantCulture));62 xCoord.Add(int.Parse(m[1].Value, System.Globalization.CultureInfo.InvariantCulture)); 63 yCoord.Add(int.Parse(m[2].Value, System.Globalization.CultureInfo.InvariantCulture)); 63 64 64 65 line = reader.ReadLine(); … … 76 77 77 78 vehicles.Add(v); 79 } 80 81 if (line.Contains("EDGE_WEIGHT_TYPE: EXPLICIT")) { 82 line = reader.ReadLine(); 83 84 int count = xCoord.Count; 85 86 distanceMatrix.useDistanceMatrix = true; 87 distanceMatrix.coordinates = new int[count, 2]; 88 for (int i = 0; i < count; i++) { 89 distanceMatrix.coordinates[i, 0] = xCoord[i]; 90 distanceMatrix.coordinates[i, 1] = yCoord[i]; 91 } 92 93 distanceMatrix.matrix = new double[count, count]; 94 95 line = reader.ReadLine(); 96 m = reg.Matches(line); 97 98 int j = 0; 99 while (m.Count == count) { 100 for (int i = 0; i < count; i++) { 101 distanceMatrix.matrix[i, j] = double.Parse(m[i].Value, System.Globalization.CultureInfo.InvariantCulture); 102 } 103 104 line = reader.ReadLine(); 105 m = reg.Matches(line); 106 j++; 107 } 108 109 if (j != count) 110 throw new Exception("Invalid distance matrix definition"); 78 111 } 79 112 -
branches/DynamicVehicleRouting/HeuristicLab.PDPSimulation/3.3/PickupDeliveryScenario.cs
r8714 r8839 212 212 VehicleDueTimesParameter.Value = vehicleDueTimes; 213 213 214 if (parser.DistanceMatrix.useDistanceMatrix) { 215 DistanceMatrixMeasure dm = new DistanceMatrixMeasure(); 216 217 dm.PointMapping = new IntMatrix(parser.DistanceMatrix.coordinates); 218 dm.DistanceMatrix = new DoubleMatrix(parser.DistanceMatrix.matrix); 219 220 DistanceMeasure = dm; 221 } 222 214 223 PickupDeliveryPredefinedOrderGenerator orderGen = new PickupDeliveryPredefinedOrderGenerator(); 215 224 int orders = parser.Orders.Length;
Note: See TracChangeset
for help on using the changeset viewer.