Changeset 11931 for stable/HeuristicLab.Problems.Instances.VehicleRouting/3.4/SolomonFormat/SolomonFormatInstanceProvider.cs
- Timestamp:
- 02/06/15 09:24:18 (9 years ago)
- Location:
- stable
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
stable
- Property svn:mergeinfo changed
/trunk/sources merged: 11420,11428-11429,11432,11442,11455-11456,11478,11930
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Problems.Instances.VehicleRouting/3.4/SolomonFormat/SolomonFormatInstanceProvider.cs
r11333 r11931 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 22 24 using System.IO; 25 using System.Linq; 23 26 24 27 namespace HeuristicLab.Problems.Instances.VehicleRouting { … … 54 57 return instance; 55 58 } 59 60 protected override void LoadSolution(Stream stream, CVRPTWData instance) { 61 using (var reader = new StreamReader(stream)) { 62 string instanceName = ExtractValue(reader.ReadLine()); 63 string authors = ExtractValue(reader.ReadLine()); 64 string date = ExtractValue(reader.ReadLine()); 65 string reference = ExtractValue(reader.ReadLine()); 66 reader.ReadLine(); // Solution 67 68 var routesQuery = 69 from line in reader.ReadAllLines() 70 where !string.IsNullOrEmpty(line) 71 let tokens = ExtractValue(line).Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) 72 let stops = tokens.Select(int.Parse).Select(s => s - 1) 73 select stops; 74 75 var routes = routesQuery.Select(s => s.ToArray()).ToArray(); 76 77 instance.BestKnownTour = routes; 78 } 79 } 80 81 private static string ExtractValue(string line) { 82 return line.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries).Last().Trim(); 83 } 56 84 } 57 85 }
Note: See TracChangeset
for help on using the changeset viewer.