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

Location:
trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression
Files:
2 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  }
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Regression/RealWorld/RealWorldRegressionInstanceProvider.cs

    r14185 r15016  
    4747    public override IEnumerable<IDataDescriptor> GetDataDescriptors() {
    4848      List<ResourceRegressionDataDescriptor> descriptorList = new List<ResourceRegressionDataDescriptor>();
    49       descriptorList.Add(new ChemicalOne());
    50       descriptorList.Add(new Housing());
    51       descriptorList.Add(new Tower());
    52       descriptorList.Add(new Powermeter());
    53       descriptorList.Add(new SARCOS());
    54       var solutionsArchiveName = GetResourceName(FileName + @"\.zip");
    55       if (!String.IsNullOrEmpty(solutionsArchiveName)) {
    56         using (var solutionsZipFile = new ZipArchive(GetType().Assembly.GetManifestResourceStream(solutionsArchiveName), ZipArchiveMode.Read)) {
    57           IList<string> entries = new List<string>();
    58           foreach (var curEntry in solutionsZipFile.Entries) {
    59             entries.Add(curEntry.Name);
    60           }
    61           foreach (var entry in entries.OrderBy(x => x)) {
    62             string prettyName = Path.GetFileNameWithoutExtension(entry);
    63             ResourceRegressionDataDescriptor desc = descriptorList.Where(x => x.Name.Equals(prettyName)).FirstOrDefault();
    64             if (desc != null) {
    65               desc.ResourceName = entry;
    66               yield return desc;
    67             } else
    68               throw new ArgumentNullException("No Descriptor could be found for this entry.");
    69           }
    70         }
    71       }
     49      descriptorList.Add(new ChemicalOne() { ResourceName = "Chemical-I.csv" });
     50      descriptorList.Add(new Housing() { ResourceName = "Housing.csv" });
     51      descriptorList.Add(new Tower() { ResourceName = "Tower.txt" });
     52      descriptorList.Add(new Powermeter() { ResourceName = "Powermeter.txt" });
     53      descriptorList.Add(new SARCOS() { ResourceName = "SARCOS - Inverse Dynamics.txt" });
     54      return descriptorList;
    7255    }
    7356  }
Note: See TracChangeset for help on using the changeset viewer.