Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Problems.DataAnalysis/3.3/DataAnalysisProblem.cs @ 4102

Last change on this file since 4102 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

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    public DataAnalysisProblem()
53      : base() {
54      Parameters.Add(new ValueParameter<DataAnalysisProblemData>(DataAnalysisProblemDataParameterName, "The data set, target variable and input variables of the data analysis problem.", new DataAnalysisProblemData()));
55      RegisterParameterEvents();
56      RegisterParameterValueEvents();
57    }
58
59    [StorableConstructor]
60    private DataAnalysisProblem(bool deserializing) : base() { }
61
62    [StorableHook(HookType.AfterDeserialization)]
63    private void AfterDeserializationHook() {
64      RegisterParameterEvents();
65      RegisterParameterValueEvents();
66    }
67
68    #region events
69    protected virtual void OnDataAnalysisProblemChanged(EventArgs e) {
70      RaiseReset(e);
71    }
72
73    private void RegisterParameterEvents() {
74      DataAnalysisProblemDataParameter.ValueChanged += new EventHandler(DataAnalysisProblemDataParameter_ValueChanged);
75    }
76
77    private void RegisterParameterValueEvents() {
78      DataAnalysisProblemData.ProblemDataChanged += new EventHandler(DataAnalysisProblemData_ProblemDataChanged);
79    }
80
81    private void DataAnalysisProblemDataParameter_ValueChanged(object sender, EventArgs e) {
82      OnDataAnalysisProblemChanged(e);
83    }
84
85    private void DataAnalysisProblemData_ProblemDataChanged(object sender, EventArgs e) {
86      OnDataAnalysisProblemChanged(e);
87    }
88    #endregion
89
90    public override IDeepCloneable Clone(Cloner cloner) {
91      DataAnalysisProblem clone = (DataAnalysisProblem)base.Clone(cloner);
92      clone.RegisterParameterEvents();
93      clone.RegisterParameterValueEvents();
94      return clone;
95    }
96
97    #region IProblem Members
98
99    public virtual IParameter SolutionCreatorParameter {
100      get { return null; }
101    }
102
103    public virtual ISolutionCreator SolutionCreator {
104      get { return null; }
105    }
106
107    public virtual IParameter EvaluatorParameter {
108      get { return null; }
109    }
110
111    public virtual IEvaluator Evaluator {
112      get { return null; }
113    }
114
115    public virtual IEnumerable<IOperator> Operators {
116      get { return new IOperator[0]; }
117    }
118
119    public event EventHandler SolutionCreatorChanged;
120    protected void RaiseSolutionCreatorChanged(EventArgs e) {
121      var changed = SolutionCreatorChanged;
122      if (changed != null)
123        changed(this, e);
124    }
125
126    public event EventHandler EvaluatorChanged;
127    protected void RaiseEvaluatorChanged(EventArgs e) {
128      var changed = EvaluatorChanged;
129      if (changed != null)
130        changed(this, e);
131    }
132
133    public event EventHandler OperatorsChanged;
134    protected void RaiseOperatorsChanged(EventArgs e) {
135      var changed = OperatorsChanged;
136      if (changed != null)
137        changed(this, e);
138    }
139
140    public event EventHandler Reset;
141    protected void RaiseReset(EventArgs e) {
142      var changed = Reset;
143      if (changed != null)
144        changed(this, e);
145    }
146    #endregion
147  }
148}
Note: See TracBrowser for help on using the repository browser.