Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/03/12 13:41:36 (12 years ago)
Author:
sforsten
Message:

#1782:

  • renamed CanSave to CanExportData and SaveData to ExportData
  • added the same functionality for importing problem instance as we implemented for exporting
  • some special changes had to be made in Problems.Instances.VehicleRouting
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.Instances.DataAnalysis/3.3/Clustering/CSV/ClusteringCSVInstanceProvider.cs

    r8180 r8192  
    4747    }
    4848
    49     public override bool CanSaveData {
     49    public override IClusteringProblemData LoadData(IDataDescriptor descriptor) {
     50      throw new NotImplementedException();
     51    }
     52
     53    public override bool CanImportData {
    5054      get { return true; }
    5155    }
     56    public override IClusteringProblemData ImportData(string path) {
     57      var csvFileParser = new TableFileParser();
    5258
    53     public override void SaveData(IClusteringProblemData instance, string path) {
     59      csvFileParser.Parse(path);
     60
     61      var dataset = new Dataset(csvFileParser.VariableNames, csvFileParser.Values);
     62      var claData = new ClusteringProblemData(dataset, dataset.DoubleVariables);
     63
     64      int trainingPartEnd = csvFileParser.Rows * 2 / 3;
     65      claData.TrainingPartition.Start = 0;
     66      claData.TrainingPartition.End = trainingPartEnd;
     67      claData.TestPartition.Start = trainingPartEnd;
     68      claData.TestPartition.End = csvFileParser.Rows;
     69      int pos = path.LastIndexOf('\\');
     70      if (pos < 0)
     71        claData.Name = path;
     72      else {
     73        pos++;
     74        claData.Name = path.Substring(pos, path.Length - pos);
     75      }
     76
     77      return claData;
     78    }
     79
     80    public override bool CanExportData {
     81      get { return true; }
     82    }
     83    public override void ExportData(IClusteringProblemData instance, string path) {
    5484      var strBuilder = new StringBuilder();
    5585
     
    74104      }
    75105    }
    76 
    77     public override IClusteringProblemData LoadData(IDataDescriptor descriptor) {
    78       throw new NotImplementedException();
    79     }
    80106  }
    81107}
Note: See TracChangeset for help on using the changeset viewer.