Free cookie consent management tool by TermsFeed Policy Generator

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

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

added draft version of classification (ticket #939)

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