Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis.Classification/3.3/SingleObjectiveClassificationProblem.cs @ 4657

Last change on this file since 4657 was 4565, checked in by mkommend, 14 years ago

Moved DataAnalysis.Classification from branch to trunk (ticket #939).

File size: 3.8 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    public SingleObjectiveClassificationProblem()
52      : base() {
53      Parameters.Add(new ValueParameter<ClassificationProblemData>(ClassificationProblemDataParameterName, "The data set, target variable and input variables of the data analysis problem."));
54      ClassificationProblemData = new ClassificationProblemData();
55      RegisterParameterEvents();
56      RegisterParameterValueEvents();
57    }
58
59    [StorableHook(HookType.AfterDeserialization)]
60    private void AfterDeserializationHook() {
61      RegisterParameterEvents();
62      RegisterParameterValueEvents();
63    }
64
65    public override IDeepCloneable Clone(Cloner cloner) {
66      SingleObjectiveClassificationProblem<T, U> clone = (SingleObjectiveClassificationProblem<T, U>)base.Clone(cloner);
67      clone.RegisterParameterEvents();
68      clone.RegisterParameterValueEvents();
69      return clone;
70    }
71
72    private void RegisterParameterEvents() {
73      ClassificationProblemDataParameter.ValueChanged += new EventHandler(ClassificationProblemDataParameter_ValueChanged);
74    }
75    private void RegisterParameterValueEvents() {
76      ClassificationProblemData.ProblemDataChanged += new EventHandler(ClassificationProblemData_ProblemDataChanged);
77    }
78
79    protected virtual void OnClassificationProblemDataChanged() {
80      OnReset();
81    }
82    private void ClassificationProblemDataParameter_ValueChanged(object sender, System.EventArgs e) {
83      RegisterParameterValueEvents();
84      OnClassificationProblemDataChanged();
85    }
86    private void ClassificationProblemData_ProblemDataChanged(object sender, System.EventArgs e) {
87      OnClassificationProblemDataChanged();
88    }
89  }
90}
Note: See TracBrowser for help on using the repository browser.