[4323] | 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 |
|
---|
| 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 |
|
---|
| 29 | namespace HeuristicLab.Problems.DataAnalysis.Classification {
|
---|
| 30 | [Item("Classification Problem", "Represents a classfication problem.")]
|
---|
| 31 | [StorableClass]
|
---|
[4563] | 32 | public abstract class SingleObjectiveClassificationProblem<T, U> : SingleObjectiveProblem<T, U>, ISingleObjectiveDataAnalysisProblem
|
---|
[4323] | 33 | where T : class, ISingleObjectiveEvaluator
|
---|
| 34 | where U : class, ISolutionCreator {
|
---|
| 35 | private const string ClassificationProblemDataParameterName = "ClassificationProblemData";
|
---|
| 36 |
|
---|
[4366] | 37 | public IValueParameter<ClassificationProblemData> ClassificationProblemDataParameter {
|
---|
| 38 | get { return (IValueParameter<ClassificationProblemData>)Parameters[ClassificationProblemDataParameterName]; }
|
---|
[4323] | 39 | }
|
---|
[4366] | 40 | public ClassificationProblemData ClassificationProblemData {
|
---|
[4323] | 41 | get { return ClassificationProblemDataParameter.Value; }
|
---|
| 42 | set { ClassificationProblemDataParameter.Value = value; }
|
---|
| 43 | }
|
---|
| 44 |
|
---|
[4536] | 45 | DataAnalysisProblemData IDataAnalysisProblem.DataAnalysisProblemData {
|
---|
| 46 | get { return ClassificationProblemData; }
|
---|
| 47 | }
|
---|
| 48 |
|
---|
[4323] | 49 | [StorableConstructor]
|
---|
| 50 | protected SingleObjectiveClassificationProblem(bool deserializing) : base(deserializing) { }
|
---|
| 51 | public SingleObjectiveClassificationProblem()
|
---|
| 52 | : base() {
|
---|
[4366] | 53 | Parameters.Add(new ValueParameter<ClassificationProblemData>(ClassificationProblemDataParameterName, "The data set, target variable and input variables of the data analysis problem."));
|
---|
| 54 | ClassificationProblemData = new ClassificationProblemData();
|
---|
[4323] | 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 | } |
---|