Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/27/12 16:58:22 (12 years ago)
Author:
sforsten
Message:

#1784:

  • updated the Plugin.cs.frame files
  • added other real world problem instances
  • put some methods from TrentMcConaghyInstanceProvider to the super class ResourceRegressionInstanceProvider
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Problems.Instances.Regression/3.4/ResourceRegressionInstanceProvider.cs

    r7666 r7667  
    2020#endregion
    2121
     22using System;
     23using System.Collections.Generic;
    2224using System.IO;
    2325using System.Linq;
     
    3032
    3133    protected abstract string FileExtension { get; }
     34
     35    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
     36      var solutionsArchiveName = GetResourceName(FileExtension + @"\.zip");
     37      if (!String.IsNullOrEmpty(solutionsArchiveName)) {
     38        using (var solutionsZipFile = new ZipInputStream(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName))) {
     39          foreach (var entry in GetZipContents(solutionsZipFile).OrderBy(x => x))
     40            yield return new ResourceRegressionDataDescriptor(Path.GetFileNameWithoutExtension(entry), Description, entry);
     41        }
     42      }
     43    }
    3244
    3345    public override RegressionData LoadData(IDataDescriptor id) {
     
    4456      return Assembly.GetExecutingAssembly().GetManifestResourceNames()
    4557              .Where(x => Regex.Match(x, @".*\.Data\." + fileName).Success).SingleOrDefault();
     58    }
     59
     60    protected IEnumerable<string> GetZipContents(ZipInputStream zipFile) {
     61      ZipEntry entry;
     62      while ((entry = zipFile.GetNextEntry()) != null) {
     63        yield return entry.Name;
     64      }
    4665    }
    4766
Note: See TracChangeset for help on using the changeset viewer.