Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/DataAnalysisProblem.cs @ 6560

Last change on this file since 6560 was 5809, checked in by mkommend, 14 years ago

#1418: Reintegrated branch into trunk.

File size: 3.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using HeuristicLab.Common;
24using HeuristicLab.Core;
25using HeuristicLab.Optimization;
26using HeuristicLab.Parameters;
27using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
28
29namespace HeuristicLab.Problems.DataAnalysis {
30  [StorableClass]
31  public abstract class DataAnalysisProblem<T> : Problem,
32    IDataAnalysisProblem<T>
33    where T : class, IDataAnalysisProblemData {
34    private const string ProblemDataParameterName = "ProblemData";
35    private const string ProblemDataParameterDescription = "The data set, target variable and input variables of the data analysis problem.";
36    #region parameter properties
37    IParameter IDataAnalysisProblem.ProblemDataParameter {
38      get { return ProblemDataParameter; }
39    }
40    public IValueParameter<T> ProblemDataParameter {
41      get { return (IValueParameter<T>)Parameters[ProblemDataParameterName]; }
42    }
43    #endregion
44    #region properties
45    IDataAnalysisProblemData IDataAnalysisProblem.ProblemData {
46      get { return ProblemData; }
47    }
48    public T ProblemData {
49      get { return ProblemDataParameter.Value; }
50      protected set { ProblemDataParameter.Value = value; }
51    }
52    #endregion
53    protected DataAnalysisProblem(DataAnalysisProblem<T> original, Cloner cloner)
54      : base(original, cloner) {
55    }
56    [StorableConstructor]
57    protected DataAnalysisProblem(bool deserializing) : base(deserializing) { }
58    public DataAnalysisProblem()
59      : base() {
60      Parameters.Add(new ValueParameter<T>(ProblemDataParameterName, ProblemDataParameterDescription));
61    }
62
63    private void RegisterEventHandlers() {
64      ProblemDataParameter.Value.Changed += new EventHandler(ProblemDataParameter_ValueChanged);
65    }
66    private void ProblemDataParameter_ValueChanged(object sender, EventArgs e) {
67      OnProblemDataChanged();
68      OnReset();
69    }
70
71    public event EventHandler ProblemDataChanged;
72    protected virtual void OnProblemDataChanged() {
73      var handler = ProblemDataChanged;
74      if (handler != null) handler(this, EventArgs.Empty);
75    }
76
77    public abstract void ImportProblemDataFromFile(string fileName);
78  }
79}
Note: See TracBrowser for help on using the repository browser.