Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/06/15 09:24:18 (9 years ago)
Author:
abeham
Message:

#2229: merged to stable

Location:
stable
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.Instances.VehicleRouting/3.4/SolomonFormat/SolomonFormatInstanceProvider.cs

    r11333 r11931  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
    2224using System.IO;
     25using System.Linq;
    2326
    2427namespace HeuristicLab.Problems.Instances.VehicleRouting {
     
    5457      return instance;
    5558    }
     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    }
    5684  }
    5785}
Note: See TracChangeset for help on using the changeset viewer.