Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataAnalysis/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblem.cs @ 4193

Last change on this file since 4193 was 4118, checked in by abeham, 14 years ago

#1090

  • Fixed problem plugins reloading their operators on deserialization in following problems (forgot on them in the first commit)
    • SupportVectorRegressionProblem
    • SymbolicTimeSeriesPrognosisProblem
  • Fixed a bug in the FeatureSelectionProblem introduced in r4098
  • Fixed the issues mentioned in the code review of mkommend
File size: 4.9 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 System.Collections.Generic;
24using System.Drawing;
25using HeuristicLab.Common;
26using HeuristicLab.Core;
27using HeuristicLab.Optimization;
28using HeuristicLab.Parameters;
29using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
30
31namespace HeuristicLab.Problems.DataAnalysis {
32  [Item("Data Analysis Problem", "Represents a data analysis problem.")]
33  [Creatable("Problems")]
34  [StorableClass]
35  public class DataAnalysisProblem : ParameterizedNamedItem, IDataAnalysisProblem {
36    private const string DataAnalysisProblemDataParameterName = "DataAnalysisProblemData";
37    public override Image ItemImage {
38      get { return HeuristicLab.Common.Resources.VS2008ImageLibrary.Type; }
39    }
40
41    #region Parameter Properties
42    public ValueParameter<DataAnalysisProblemData> DataAnalysisProblemDataParameter {
43      get { return (ValueParameter<DataAnalysisProblemData>)Parameters[DataAnalysisProblemDataParameterName]; }
44    }
45    #endregion
46    #region properties
47    public DataAnalysisProblemData DataAnalysisProblemData {
48      get { return DataAnalysisProblemDataParameter.Value; }
49    }
50    #endregion
51
52    [StorableConstructor]
53    protected DataAnalysisProblem(bool deserializing) : base(deserializing) { }
54    public DataAnalysisProblem()
55      : base() {
56      Parameters.Add(new ValueParameter<DataAnalysisProblemData>(DataAnalysisProblemDataParameterName, "The data set, target variable and input variables of the data analysis problem.", new DataAnalysisProblemData()));
57      RegisterParameterEvents();
58      RegisterParameterValueEvents();
59    }
60
61    [StorableHook(HookType.AfterDeserialization)]
62    private void AfterDeserializationHook() {
63      RegisterParameterEvents();
64      RegisterParameterValueEvents();
65    }
66
67    #region events
68    protected virtual void OnDataAnalysisProblemChanged(EventArgs e) {
69      RaiseReset(e);
70    }
71
72    private void RegisterParameterEvents() {
73      DataAnalysisProblemDataParameter.ValueChanged += new EventHandler(DataAnalysisProblemDataParameter_ValueChanged);
74    }
75
76    private void RegisterParameterValueEvents() {
77      DataAnalysisProblemData.ProblemDataChanged += new EventHandler(DataAnalysisProblemData_ProblemDataChanged);
78    }
79
80    private void DataAnalysisProblemDataParameter_ValueChanged(object sender, EventArgs e) {
81      OnDataAnalysisProblemChanged(e);
82    }
83
84    private void DataAnalysisProblemData_ProblemDataChanged(object sender, EventArgs e) {
85      OnDataAnalysisProblemChanged(e);
86    }
87    #endregion
88
89    public override IDeepCloneable Clone(Cloner cloner) {
90      DataAnalysisProblem clone = (DataAnalysisProblem)base.Clone(cloner);
91      clone.RegisterParameterEvents();
92      clone.RegisterParameterValueEvents();
93      return clone;
94    }
95
96    #region IProblem Members
97
98    public virtual IParameter SolutionCreatorParameter {
99      get { return null; }
100    }
101
102    public virtual ISolutionCreator SolutionCreator {
103      get { return null; }
104    }
105
106    public virtual IParameter EvaluatorParameter {
107      get { return null; }
108    }
109
110    public virtual IEvaluator Evaluator {
111      get { return null; }
112    }
113
114    public virtual IEnumerable<IOperator> Operators {
115      get { return new IOperator[0]; }
116    }
117
118    public event EventHandler SolutionCreatorChanged;
119    protected void RaiseSolutionCreatorChanged(EventArgs e) {
120      var changed = SolutionCreatorChanged;
121      if (changed != null)
122        changed(this, e);
123    }
124
125    public event EventHandler EvaluatorChanged;
126    protected void RaiseEvaluatorChanged(EventArgs e) {
127      var changed = EvaluatorChanged;
128      if (changed != null)
129        changed(this, e);
130    }
131
132    public event EventHandler OperatorsChanged;
133    protected void RaiseOperatorsChanged(EventArgs e) {
134      var changed = OperatorsChanged;
135      if (changed != null)
136        changed(this, e);
137    }
138
139    public event EventHandler Reset;
140    protected void RaiseReset(EventArgs e) {
141      var changed = Reset;
142      if (changed != null)
143        changed(this, e);
144    }
145    #endregion
146  }
147}
Note: See TracBrowser for help on using the repository browser.