Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ParameterBinding/HeuristicLab.Problems.DataAnalysis.Classification/3.3/SingleObjectiveClassificationProblem.cs @ 6090

Last change on this file since 6090 was 4722, checked in by swagner, 14 years ago

Merged cloning refactoring branch back into trunk (#922)

File size: 3.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 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.Classification {
30  [Item("Classification Problem", "Represents a classfication problem.")]
31  [StorableClass]
32  public abstract class SingleObjectiveClassificationProblem<T, U> : SingleObjectiveProblem<T, U>, ISingleObjectiveDataAnalysisProblem
33    where T : class, ISingleObjectiveEvaluator
34    where U : class, ISolutionCreator {
35    private const string ClassificationProblemDataParameterName = "ClassificationProblemData";
36
37    public IValueParameter<ClassificationProblemData> ClassificationProblemDataParameter {
38      get { return (IValueParameter<ClassificationProblemData>)Parameters[ClassificationProblemDataParameterName]; }
39    }
40    public ClassificationProblemData ClassificationProblemData {
41      get { return ClassificationProblemDataParameter.Value; }
42      set { ClassificationProblemDataParameter.Value = value; }
43    }
44
45    DataAnalysisProblemData IDataAnalysisProblem.DataAnalysisProblemData {
46      get { return ClassificationProblemData; }
47    }
48
49    [StorableConstructor]
50    protected SingleObjectiveClassificationProblem(bool deserializing) : base(deserializing) { }
51    protected SingleObjectiveClassificationProblem(SingleObjectiveClassificationProblem<T, U> original, Cloner cloner)
52      : base(original, cloner) {
53      Initialize();
54    }
55    public SingleObjectiveClassificationProblem()
56      : base() {
57      Parameters.Add(new ValueParameter<ClassificationProblemData>(ClassificationProblemDataParameterName, "The data set, target variable and input variables of the data analysis problem."));
58      ClassificationProblemData = new ClassificationProblemData();
59      Initialize();
60    }
61
62    [StorableHook(HookType.AfterDeserialization)]
63    private void AfterDeserialization() {
64      Initialize();
65    }
66    private void Initialize() {
67      RegisterParameterEvents();
68      RegisterParameterValueEvents();
69    }
70
71    private void RegisterParameterEvents() {
72      ClassificationProblemDataParameter.ValueChanged += new EventHandler(ClassificationProblemDataParameter_ValueChanged);
73    }
74    private void RegisterParameterValueEvents() {
75      ClassificationProblemData.ProblemDataChanged += new EventHandler(ClassificationProblemData_ProblemDataChanged);
76    }
77
78    protected virtual void OnClassificationProblemDataChanged() {
79      OnReset();
80    }
81    private void ClassificationProblemDataParameter_ValueChanged(object sender, System.EventArgs e) {
82      RegisterParameterValueEvents();
83      OnClassificationProblemDataChanged();
84    }
85    private void ClassificationProblemData_ProblemDataChanged(object sender, System.EventArgs e) {
86      OnClassificationProblemDataChanged();
87    }
88  }
89}
Note: See TracBrowser for help on using the repository browser.