Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 3884 was 3884, checked in by gkronber, 14 years ago

Worked on support vector regression operators and views. #1009

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