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 |
|
---|
22 | using System;
|
---|
23 | using HeuristicLab.Common;
|
---|
24 | using HeuristicLab.Core;
|
---|
25 | using HeuristicLab.Optimization;
|
---|
26 | using HeuristicLab.Parameters;
|
---|
27 | using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
|
---|
28 | using HeuristicLab.PluginInfrastructure;
|
---|
29 |
|
---|
30 | namespace HeuristicLab.Problems.DataAnalysis.Classification {
|
---|
31 | [Item("Classification Problem", "Represents a classfication problem.")]
|
---|
32 | [StorableClass]
|
---|
33 | [NonDiscoverableType]
|
---|
34 | public abstract class SingleObjectiveClassificationProblem<T, U> : SingleObjectiveHeuristicOptimizationProblem<T, U>, ISingleObjectiveDataAnalysisProblem
|
---|
35 | where T : class, ISingleObjectiveEvaluator
|
---|
36 | where U : class, ISolutionCreator {
|
---|
37 | private const string ClassificationProblemDataParameterName = "ClassificationProblemData";
|
---|
38 |
|
---|
39 | public IValueParameter<ClassificationProblemData> ClassificationProblemDataParameter {
|
---|
40 | get { return (IValueParameter<ClassificationProblemData>)Parameters[ClassificationProblemDataParameterName]; }
|
---|
41 | }
|
---|
42 | public ClassificationProblemData ClassificationProblemData {
|
---|
43 | get { return ClassificationProblemDataParameter.Value; }
|
---|
44 | set { ClassificationProblemDataParameter.Value = value; }
|
---|
45 | }
|
---|
46 |
|
---|
47 | DataAnalysisProblemData IDataAnalysisProblem.DataAnalysisProblemData {
|
---|
48 | get { return ClassificationProblemData; }
|
---|
49 | }
|
---|
50 |
|
---|
51 | [StorableConstructor]
|
---|
52 | protected SingleObjectiveClassificationProblem(bool deserializing) : base(deserializing) { }
|
---|
53 | protected SingleObjectiveClassificationProblem(SingleObjectiveClassificationProblem<T, U> original, Cloner cloner)
|
---|
54 | : base(original, cloner) {
|
---|
55 | Initialize();
|
---|
56 | }
|
---|
57 | public SingleObjectiveClassificationProblem()
|
---|
58 | : base() {
|
---|
59 | Parameters.Add(new ValueParameter<ClassificationProblemData>(ClassificationProblemDataParameterName, "The data set, target variable and input variables of the data analysis problem."));
|
---|
60 | ClassificationProblemData = new ClassificationProblemData();
|
---|
61 | Initialize();
|
---|
62 | }
|
---|
63 |
|
---|
64 | [StorableHook(HookType.AfterDeserialization)]
|
---|
65 | private void AfterDeserialization() {
|
---|
66 | Initialize();
|
---|
67 | }
|
---|
68 | private void Initialize() {
|
---|
69 | RegisterParameterEvents();
|
---|
70 | RegisterParameterValueEvents();
|
---|
71 | }
|
---|
72 |
|
---|
73 | private void RegisterParameterEvents() {
|
---|
74 | ClassificationProblemDataParameter.ValueChanged += new EventHandler(ClassificationProblemDataParameter_ValueChanged);
|
---|
75 | }
|
---|
76 | private void RegisterParameterValueEvents() {
|
---|
77 | ClassificationProblemData.ProblemDataChanged += new EventHandler(ClassificationProblemData_ProblemDataChanged);
|
---|
78 | }
|
---|
79 |
|
---|
80 | protected virtual void OnClassificationProblemDataChanged() {
|
---|
81 | OnReset();
|
---|
82 | }
|
---|
83 | private void ClassificationProblemDataParameter_ValueChanged(object sender, System.EventArgs e) {
|
---|
84 | RegisterParameterValueEvents();
|
---|
85 | OnClassificationProblemDataChanged();
|
---|
86 | }
|
---|
87 | private void ClassificationProblemData_ProblemDataChanged(object sender, System.EventArgs e) {
|
---|
88 | OnClassificationProblemDataChanged();
|
---|
89 | }
|
---|
90 | }
|
---|
91 | } |
---|