- Timestamp:
- 10/17/14 11:43:40 (10 years ago)
- Location:
- trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/CordeauFormat/CordeauFormatInstanceProvider.cs
r11442 r11478 43 43 protected override void LoadSolution(Stream stream, TData instance) { 44 44 using (var reader = new StreamReader(stream)) { 45 double costs = double.Parse(reader.ReadLine(), new CultureInfo("en-US"));45 double costs = double.Parse(reader.ReadLine(), CultureInfo.InvariantCulture); 46 46 47 47 var toursPerDepotQuery = 48 from line in ReadAllLines(reader)48 from line in reader.ReadAllLines() 49 49 where !string.IsNullOrEmpty(line) 50 50 let tokens = line.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) 51 51 let depot = int.Parse(tokens[0]) 52 52 //let vehicle = int.Parse(tokens[1]) 53 //let duration = double.Parse(tokens[2], new CultureInfo("en-US"))54 //let load = double.Parse(tokens[3], new CultureInfo ("en-US"))53 //let duration = double.Parse(tokens[2], CultureInfo.InvariantCulture) 54 //let load = double.Parse(tokens[3], new CultureInfo.InvariantCulture) 55 55 let customers = tokens.Skip(4).Where(t => !t.StartsWith("(")).Select(int.Parse) 56 56 let numberOfCustomers = customers.Count() 57 //let serviceTimes = tokens.Skip(5).Where(t => t.StartsWith("(")).Select(t => double.Parse(t.Trim('(', ')'), new CultureInfo("en-US")))57 //let serviceTimes = tokens.Skip(5).Where(t => t.StartsWith("(")).Select(t => double.Parse(t.Trim('(', ')'), CultureInfo.InvariantCulture)) 58 58 let stops = customers.Skip(1).Take(numberOfCustomers - 2).Select(s => s - 1) 59 59 select new { depot, /*vehicle,*/ stops } into assignment … … 89 89 return tourToVehicle.ToArray(); 90 90 } 91 92 private IEnumerable<string> ReadAllLines(StreamReader reader) {93 while (!reader.EndOfStream)94 yield return reader.ReadLine();95 }96 91 } 97 92 } -
trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/HeuristicLab.Problems.Instances.VehicleRouting-3.4.csproj
r11455 r11478 118 118 <Compile Include="GoldenFormat\GoldenFormatInstanceProvider.cs" /> 119 119 <Compile Include="IVRPInstanceProvider.cs" /> 120 <Compile Include="StreamReaderHelper.cs" /> 120 121 <Compile Include="TaillardFormat\TaillardInstanceProvider.cs" /> 121 122 <Compile Include="TaillardFormat\TaillardParser.cs" /> -
trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/SolomonFormat/SolomonFormatInstanceProvider.cs
r11455 r11478 67 67 68 68 var routesQuery = 69 from line in ReadAllLines(reader)69 from line in reader.ReadAllLines() 70 70 where !string.IsNullOrEmpty(line) 71 71 let tokens = ExtractValue(line).Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) … … 82 82 return line.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Last().Trim(); 83 83 } 84 private IEnumerable<string> ReadAllLines(StreamReader reader) {85 while (!reader.EndOfStream)86 yield return reader.ReadLine();87 }88 84 } 89 85 } -
trunk/sources/HeuristicLab.Problems.Instances.VehicleRouting/3.4/VRPInstanceProvider.cs
r11455 r11478 92 92 93 93 protected virtual void LoadSolution(Stream stream, TData instance) { 94 LoadOptFile(stream, instance); 95 } 96 97 private void LoadOptFile(Stream stream, TData instance) { 94 98 List<List<int>> routes = new List<List<int>>(); 95 99 … … 122 126 123 127 public void LoadSolution(string path, TData instance) { 124 using (FileStream stream = new FileStream(path, FileMode.Open)) { 125 LoadSolution(stream, instance); 128 try { 129 using (var stream = new FileStream(path, FileMode.Open)) { 130 LoadSolution(stream, instance); 131 } 132 } catch (Exception) { 133 // new stream necessary because first try already read from stream 134 using (var stream = new FileStream(path, FileMode.Open)) { 135 LoadOptFile(stream, instance); // Fallback to .opt-Format 136 } 126 137 } 127 138 }
Note: See TracChangeset
for help on using the changeset viewer.