Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/01/17 08:58:33 (7 years ago)
Author:
gkronber
Message:

#2757: simplified code for regression instance providers which load data from a ZIP file

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/MibaFriction/MibaFrictionRegressionInstanceProvider.cs

    r14790 r15016  
    4747    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    4848      List<ResourceRegressionDataDescriptor> descriptorList = new List<ResourceRegressionDataDescriptor>();
    49       descriptorList.Add(new CF1());
    50       descriptorList.Add(new CF2());
    51       descriptorList.Add(new CF3());
    52       descriptorList.Add(new CF4());
    53       descriptorList.Add(new NvhRating());
    54       descriptorList.Add(new Temp1());
    55       descriptorList.Add(new Temp2());
    56       descriptorList.Add(new Wear1());
    57       descriptorList.Add(new Wear2());
    58       var solutionsArchiveName = GetResourceName(FileName + @"\.zip");
    59       if (!String.IsNullOrEmpty(solutionsArchiveName)) {
    60         using (var solutionsZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName), ZipArchiveMode.Read)) {
    61           IList<string> entries = new List<string>();
    62           foreach (var curEntry in solutionsZipFile.Entries) {
    63             entries.Add(curEntry.Name);
    64           }
    65           foreach (var entry in entries.OrderBy(x => x)) {
    66             string prettyName = Path.GetFileNameWithoutExtension(entry);
    67             ResourceRegressionDataDescriptor desc = descriptorList.Where(x => x.Name.Equals(prettyName)).FirstOrDefault();
    68             if (desc != null) {
    69               desc.ResourceName = entry;
    70               yield return desc;
    71             } else
    72               throw new ArgumentNullException("No descriptor could be found for this entry.");
    73           }
    74         }
    75       }
     49      descriptorList.Add(new CF1() { ResourceName = "CF1.csv" });
     50      descriptorList.Add(new CF2() { ResourceName = "CF2.csv" });
     51      descriptorList.Add(new CF3() { ResourceName = "CF3.csv" });
     52      descriptorList.Add(new CF4() { ResourceName = "CF4.csv" });
     53      descriptorList.Add(new NvhRating() { ResourceName = "NvhRating.csv" });
     54      descriptorList.Add(new Temp1() { ResourceName = "Temp1.csv" });
     55      descriptorList.Add(new Temp2() { ResourceName = "Temp2.csv" });
     56      descriptorList.Add(new Wear1() { ResourceName = "Wear1.csv" });
     57      descriptorList.Add(new Wear2() { ResourceName = "Wear2.csv" });
     58
     59      return descriptorList;
    7660    }
    7761  }
Note: See TracChangeset for help on using the changeset viewer.