Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/16/12 16:28:49 (13 years ago)
Author:
gkronber
Message:

merged r7609:7840 from trunk into time series branch

Location:
branches/HeuristicLab.TimeSeries
Files:
21 deleted
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries

  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/CordeauGQAPInstanceProvider.cs

    r7548 r7842  
    2626using System.Reflection;
    2727using System.Text.RegularExpressions;
     28using ICSharpCode.SharpZipLib.Zip;
    2829
    2930namespace HeuristicLab.Problems.Instances.CordeauGQAP {
     
    4950    }
    5051
     52    private const string FileName = "CordeauGQAP";
     53   
    5154    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    52       return Assembly.GetExecutingAssembly()
    53           .GetManifestResourceNames()
    54           .Where(x => x.EndsWith(".txt"))
    55           .OrderBy(x => x)
    56           .Select(x => new CordeauGQAPDataDescriptor(GetPrettyName(x), GetDescription(), x));
     55      var instanceArchiveName = GetResourceName(FileName + @"\.zip");
     56      if (String.IsNullOrEmpty(instanceArchiveName)) yield break;
     57
     58      using (var instanceStream = new ZipInputStream(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {
     59        foreach (var entry in GetZipContents(instanceStream).OrderBy(x => x)) {
     60          yield return new CordeauGQAPDataDescriptor(Path.GetFileNameWithoutExtension(entry), GetDescription(), entry);
     61        }
     62      }
    5763    }
    5864
    5965    public override GQAPData LoadData(IDataDescriptor id) {
    6066      var descriptor = (CordeauGQAPDataDescriptor)id;
    61       using (var stream = Assembly.GetExecutingAssembly()
    62         .GetManifestResourceStream(descriptor.InstanceIdentifier)) {
    63         var parser = new CordeauGQAPParser();
    64         parser.Parse(stream);
    65         var instance = Load(parser);
     67      var instanceArchiveName = GetResourceName(FileName + @"\.zip");
     68      using (var instancesZipFile = new ZipFile(GetType().Assembly.GetManifestResourceStream(instanceArchiveName))) {
     69        var entry = instancesZipFile.GetEntry(descriptor.InstanceIdentifier);
     70        using (var stream = instancesZipFile.GetInputStream(entry)) {
     71          var parser = new CordeauGQAPParser();
     72          parser.Parse(stream);
     73          var instance = Load(parser);
    6674
    67         instance.Name = id.Name;
    68         instance.Description = id.Description;
     75          instance.Name = id.Name;
     76          instance.Description = id.Description;
    6977
    70         return instance;
     78          return instance;
     79        }
    7180      }
    7281    }
     
    100109    }
    101110
    102     private string GetPrettyName(string instanceIdentifier) {
    103       return Regex.Match(instanceIdentifier, GetType().Namespace + @"\.Data\.(.*)\.txt").Groups[1].Captures[0].Value;
    104     }
    105 
    106111    private string GetDescription() {
    107112      return "Embedded instance of plugin version " + Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyFileVersionAttribute), true).Cast<AssemblyFileVersionAttribute>().First().Version + ".";
    108113    }
     114
     115    protected virtual string GetResourceName(string fileName) {
     116      return Assembly.GetExecutingAssembly().GetManifestResourceNames()
     117              .Where(x => Regex.Match(x, @".*\.Data\." + fileName).Success).SingleOrDefault();
     118    }
     119
     120    protected IEnumerable<string> GetZipContents(ZipInputStream zipFile) {
     121      ZipEntry entry;
     122      while ((entry = zipFile.GetNextEntry()) != null) {
     123        yield return entry.Name;
     124      }
     125    }
    109126  }
    110127}
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Problems.Instances.CordeauGQAP/3.3/HeuristicLab.Problems.Instances.CordeauGQAP-3.3.csproj

    r7600 r7842  
    102102  </PropertyGroup>
    103103  <ItemGroup>
     104    <Reference Include="ICSharpCode.SharpZipLib, Version=0.85.4.369, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
     105      <Private>False</Private>
     106    </Reference>
    104107    <Reference Include="System" />
    105108    <Reference Include="System.Core" />
     
    107110  </ItemGroup>
    108111  <ItemGroup>
     112    <EmbeddedResource Include="Data\CordeauGQAP.zip" />
    109113    <None Include="Plugin.cs.frame" />
    110114    <Compile Include="CordeauGQAPParser.cs" />
     
    122126      <Project>{A9AD58B9-3EF9-4CC1-97E5-8D909039FF5C}</Project>
    123127      <Name>HeuristicLab.Common-3.3</Name>
     128      <Private>False</Private>
    124129    </ProjectReference>
    125130    <ProjectReference Include="..\..\HeuristicLab.PluginInfrastructure\3.3\HeuristicLab.PluginInfrastructure-3.3.csproj">
    126131      <Project>{94186A6A-5176-4402-AE83-886557B53CCA}</Project>
    127132      <Name>HeuristicLab.PluginInfrastructure-3.3</Name>
     133      <Private>False</Private>
    128134    </ProjectReference>
    129135    <ProjectReference Include="..\..\HeuristicLab.Problems.Instances\3.3\HeuristicLab.Problems.Instances-3.3.csproj">
    130136      <Project>{3540E29E-4793-49E7-8EE2-FEA7F61C3994}</Project>
    131137      <Name>HeuristicLab.Problems.Instances-3.3</Name>
     138      <Private>False</Private>
    132139    </ProjectReference>
    133   </ItemGroup>
    134   <ItemGroup>
    135     <EmbeddedResource Include="Data\20-15-35.txt" />
    136     <EmbeddedResource Include="Data\20-15-55.txt" />
    137     <EmbeddedResource Include="Data\20-15-75.txt" />
    138     <EmbeddedResource Include="Data\30-06-95.txt" />
    139     <EmbeddedResource Include="Data\30-07-75.txt" />
    140     <EmbeddedResource Include="Data\30-08-55.txt" />
    141     <EmbeddedResource Include="Data\30-10-65.txt" />
    142     <EmbeddedResource Include="Data\30-20-35.txt" />
    143     <EmbeddedResource Include="Data\30-20-55.txt" />
    144     <EmbeddedResource Include="Data\30-20-75.txt" />
    145     <EmbeddedResource Include="Data\30-20-95.txt" />
    146     <EmbeddedResource Include="Data\35-15-35.txt" />
    147     <EmbeddedResource Include="Data\35-15-55.txt" />
    148     <EmbeddedResource Include="Data\35-15-75.txt" />
    149     <EmbeddedResource Include="Data\35-15-95.txt" />
    150     <EmbeddedResource Include="Data\40-07-75.txt" />
    151     <EmbeddedResource Include="Data\40-09-95.txt" />
    152     <EmbeddedResource Include="Data\40-10-65.txt" />
    153     <EmbeddedResource Include="Data\50-10-65.txt" />
    154     <EmbeddedResource Include="Data\50-10-75.txt" />
    155     <EmbeddedResource Include="Data\50-10-95.txt" />
    156140  </ItemGroup>
    157141  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Note: See TracChangeset for help on using the changeset viewer.