Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10990


Ignore:
Timestamp:
06/11/14 14:47:42 (10 years ago)
Author:
pfleck
Message:
  • Simplified export in PreprocessingContext
  • Implemented export of DataAnalysisProblemData
Location:
branches/DataPreprocessing
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.cs

    r10987 r10990  
    9898      viewShortcutListView.Enabled = Content != null;
    9999      applyInNewTabButton.Enabled = Content != null;
    100       exportProblemButton.Enabled = Content != null;
     100      exportProblemButton.Enabled = Content != null && Content.Problem != null;
    101101      undoButton.Enabled = Content != null;
    102102    }
     
    120120
    121121    private void applyInNewTabButton_Click(object sender, EventArgs e) {
    122       var item = Content.ExportAlgorithmOrProblem();
     122      var item = Content.Export();
    123123
    124124      MainFormManager.MainForm.ShowContent(item);
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingContext.cs

    r10978 r10990  
    3333    : Item, IPreprocessingContext {
    3434
     35
    3536    public IFilteredPreprocessingData Data { get; private set; }
     37
    3638    public IAlgorithm Algorithm { get; private set; }
    3739    public IDataAnalysisProblem Problem { get; private set; }
     40    public IDataAnalysisProblemData ProblemData { get; private set; }
     41
     42    private readonly ProblemDataCreator creator;
    3843
    3944    public PreprocessingContext(IDataAnalysisProblemData dataAnalysisProblemData, IAlgorithm algorithm, IDataAnalysisProblem problem) {
    40       TransactionalPreprocessingData transactionalPreprocessingData = new TransactionalPreprocessingData(dataAnalysisProblemData);
     45      var transactionalPreprocessingData = new TransactionalPreprocessingData(dataAnalysisProblemData);
     46      Data = new FilteredPreprocessingData(transactionalPreprocessingData);
    4147
    42       Data = new FilteredPreprocessingData(transactionalPreprocessingData);
     48      ProblemData = dataAnalysisProblemData;
    4349      Algorithm = algorithm;
    4450      Problem = problem;
     51
     52      creator = new ProblemDataCreator(this);
    4553    }
    4654
     
    5664    }
    5765
    58     public IItem ExportAlgorithmOrProblem() {
    59       if (Algorithm != null) {
     66    public IItem Export() {
     67      if (Algorithm != null)
    6068        return ExportAlgorithm();
    61       }
    62       return ExportProblem();
     69      else if (Problem != null)
     70        return ExportProblem();
     71      return ExportProblemData();
     72    }
     73    public IAlgorithm ExportAlgorithm() {
     74      var preprocessedAlgorithm = (IAlgorithm)Algorithm.Clone(new Cloner());
     75      preprocessedAlgorithm.Name = preprocessedAlgorithm.Name + "(Preprocessed)";
     76      Algorithm.Runs.Clear();
     77      var problem = (IDataAnalysisProblem)preprocessedAlgorithm.Problem;
     78      SetNewProblemData(problem);
     79      return preprocessedAlgorithm;
     80    }
     81    public IDataAnalysisProblem ExportProblem() {
     82      var preprocessedProblem = (IDataAnalysisProblem)Problem.Clone(new Cloner());
     83      SetNewProblemData(preprocessedProblem);
     84      return preprocessedProblem;
    6385    }
    6486
    65     public IProblem ExportProblem() {
    66       return Export(Problem, SetupProblem);
    67     }
    68     public IAlgorithm ExportAlgorithm() {
    69       return Export(Algorithm, SetupAlgorithm);
     87    public IDataAnalysisProblemData ExportProblemData() {
     88      return creator.CreateProblemData();
    7089    }
    7190
    72     private IDataAnalysisProblem SetupProblem(IProblem problem) {
    73       return (IDataAnalysisProblem)problem;
    74     }
    75     private IDataAnalysisProblem SetupAlgorithm(IAlgorithm algorithm) {
    76       algorithm.Name = algorithm.Name + "(Preprocessed)";
    77       algorithm.Runs.Clear();
    78       return (IDataAnalysisProblem)algorithm.Problem;
    79     }
    80     private T Export<T>(T original, Func<T, IDataAnalysisProblem> setup)
    81         where T : IItem {
    82       var creator = new ProblemDataCreator(this);
     91    private void SetNewProblemData(IDataAnalysisProblem problem) {
    8392      var data = creator.CreateProblemData();
    84 
    85       var clone = (T)original.Clone(new Cloner());
    86 
    87       var problem = setup(clone);
    8893      problem.ProblemDataParameter.ActualValue = data;
    8994      problem.Name = "Preprocessed " + problem.Name;
    90       return clone;
    9195    }
    9296  }
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Interfaces/IPreprocessingContext.cs

    r10978 r10990  
    2828namespace HeuristicLab.DataPreprocessing {
    2929  public interface IPreprocessingContext : IItem {
     30    IFilteredPreprocessingData Data { get; }
    3031
    31     IFilteredPreprocessingData Data { get; }
    3232    IAlgorithm Algorithm { get; }
    3333    IDataAnalysisProblem Problem { get; }
     34    IDataAnalysisProblemData ProblemData { get; }
    3435
    35     IItem ExportAlgorithmOrProblem();
     36    IItem Export();
    3637    IAlgorithm ExportAlgorithm();
    37     IProblem ExportProblem();
     38    IDataAnalysisProblem ExportProblem();
     39    IDataAnalysisProblemData ExportProblemData();
    3840  }
    3941}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/ProblemDataCreator.cs

    r10982 r10990  
    4343
    4444    public IDataAnalysisProblemData CreateProblemData() {
    45       var oldProblemData = context.Problem.ProblemData;
     45      var oldProblemData = context.ProblemData;
    4646
    47       IDataAnalysisProblemData problemData = null;
     47      IDataAnalysisProblemData problemData;
    4848
    4949      if (oldProblemData is RegressionProblemData) {
Note: See TracChangeset for help on using the changeset viewer.